akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()
{
	int h, n, a;
	ll sum = 0;
	cin >> h >> n;
	rep(i, 0, n){
		scanf("%d", &a);
		sum += a;
	}
	if (sum >= h)	puts("Yes");
	else			puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {

    long N, tmp;
    long tm=0;
    int i=0,j=0;
    long n = 0;
   int flag = 0;
    scanf("%ld",&N);

    tm = N;
    tmp = N;
    tmp %= 10;
    if(tmp==9) {
        j++;
    }else{
       flag =1;
   }

    N = N/10;
    i++;
    if(N == 0){
        printf("%ld",tm);
        return 0;
    }
    
    while(N != 0){
        tmp = N;
        tmp %= 10;
        if(tmp==9)
            j++;
        tm = N;
        n+=9;
        N /= 10;
        i++;
    }

    if((i==j || i == j+1)&&(flag == 0)){
        n+=tm;
    }else {
        n += tm - 1;
    }



    printf("%ld", n);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep0(i, n) for (int i = 0; i <= (n); i++)
#define rep2(a, n) for (int i = a; i < (n); i++)
#define rep3(i, a, n) for (int i = a; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
// dp
ll dp[100010];
// input
ll h[100010];

int main(void) {
  int n, k;
  cin >> n >> k;
  rep(i, n) cin >> h[i];
  rep(i, 100010) dp[i] = INF;
  dp[0] = 0;
  rep(i, n) rep0(j, k) {
    dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,Q;
    cin >> N >> Q;

    vector<i64> A(N);
    rep(i,0,N) cin >> A[i];

    vector<i64> s(N),t(N);
    s[0]=A[0];
    t[0]=A[0];
    rep(i,1,N){
        s[i]=s[i-1]+A[i];
        if(i%2==0) t[i]=t[i-1]+A[i];
        else t[i]=t[i-1];
    }

    rep(i,0,N) A[i]*=4;

    function<i64(i64,i64)> f=[&](i64 n, i64 turn){
        if(n<0) return i64(0);
        if(turn==1) return f(n-1,(turn+1)%2);
        return n%2==0?t[n]:s[n]-t[n];
    };

    auto bsearch=[&](i64 r){
        return lower_bound(begin(A),end(A),r)-begin(A);
    };

    rep(_,0,Q) {
        i64 X;
        cin >> X;

        X=4*X-1;

        i64 lb=0,ub=inf64;
        while(ub-lb>1){
            auto mid=(lb+ub)/2;
            i64 l=bsearch(X-mid);
            i64 r=bsearch(X+mid+1);
            if(r-l>(N-1)-r+1) ub=mid;
            else lb=mid;
        }

        i64 l=bsearch(X-lb);
        i64 r=bsearch(X+lb+1);

        cout << s[N-1]-s[r-1]+((N-l)%2==1?f(l-1,1):f(l-1,0)) << endl;
    }
}

int main(){
    //std::cin.tie(0);
    //std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 4096
# coding: utf-8

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


def main():
    N = int(input())
    D = map(int, input().split(" "))
    ds = defaultdict(int)
    for d in D:
        ds[d] += 1
    M = int(input())
    T = map(int, input().split(" "))
    for t in T:
        ds[t] -= 1
    for i in ds.values():
        if i < 0:
            return "NO"
    return "YES"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 45028
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int gcd(int a, int b) {
  if (a < b) return gcd(b, a);
  int r;
  while ((r = (a % b))) {
    a = b;
    b = r;
  }
  return b;
}
int main(int argc, char* argv[]) {
  long long int A, B, C, D, gcdCD, lcmCD;
  cin >> A >> B >> C >> D;
  long long int minC, maxC, minD, maxD, minlcm, maxlcm;
  if (A % C == 0)
    minC = A;
  else
    minC = (A / C + 1) * C;
  if (B % C == 0)
    maxC = B;
  else
    maxC = B / C * C;

  if (A % D == 0)
    minD = A;
  else
    minD = (A / D + 1) * D;
  if (B % D == 0)
    maxD = B;
  else
    maxD = (B / D) * D;

  gcdCD = gcd(C, D);
  lcmCD = C * D / gcdCD;

  if (A % lcmCD == 0)
    minlcm = A;
  else
    minlcm = (A / lcmCD + 1) * lcmCD;
  if (B % lcmCD == 0)
    maxlcm = B;
  else
    maxlcm = B / lcmCD * lcmCD;

  long long int tot = B - A + 1;
  long long int cc = (maxC - minC) / C + 1;
  long long int dc = (maxD - minD) / D + 1;
  long long int lcmc = (maxlcm - minlcm) / lcmCD + 1;
  if (cc < 0) cc = 0;
  if (dc < 0) dc = 0;
  if (lcmc < 0) lcmc = 0;
  cout << (tot - (cc + dc - lcmc)) << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 5000 + 7;
const int K = 40;

int n;
int k;
pair<int, ll> e[K][N];
ll be[K][N];
ll so[N];

ll sum(int bg) {
  int now = bg;
  ll sol = 0, mx = -(ll) 1e18;
  for (int j = 0; (1 << j) <= k; j++) {
    if (k & (1 << j)) {
      mx = max(mx, sol + be[j][now]);
      sol += e[j][now].second;
      now = e[j][now].first;
    }
  }
  return mx;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> e[0][i].first;
  }
  for (int i = 1; i <= n; i++) {
    cin >> so[i];
  }
  for (int i = 1; i <= n; i++) {
    e[0][i].second = so[e[0][i].first];
    be[0][i] = e[0][i].second;
  }
  for (int i = 1; i < K; i++) {
    for (int j = 1; j <= n; j++) {
      pair<int, ll> p = e[i - 1][j];
      e[i][j] = {e[i - 1][p.first].first, e[i - 1][p.first].second + p.second};
      be[i][j] = max(be[i - 1][j], p.second + be[i - 1][p.first]);
    }
  }
  ll sol = -(ll) 1e18;
  for (int i = 1; i <= n; i++) {
    ll x = sum(i);
    sol = max(sol, x);
  }
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 8384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	ll x, f = 0;
	cin >> x;
	for (ll i = -1000; i <= 1000; i++)
	{
		for (ll j = -1000; j <= 1000; j++)
		{
			if (pow(i, 5) - pow(j, 5) == x)
			{
				f = 1;
				cout << i << " " << j << endl;
			}
		}
		if (f == 1)
			break;
	}



}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string s;
    cin >> s;
    if (s.size() == 1) {
        cout << "YES" << endl;
        return 0;
    }
    map<char,int> mp;
    for(const auto &it: s) {
        if(mp.count(it) == 0) mp[it] = 0;
        mp[it]++;
    }

    set<int> st;
    for(const auto &it: mp) {
        st.insert(it.second);
    }

    auto maxi = *max_element(ALL(st));
    auto mini = *min_element(ALL(st));

    cerr << "maxi: " << maxi << endl;
    cerr << "mini: " << mini << endl;
    cerr << "st: " << st.size() << endl;
    cerr << "mp: " << mp.size() << endl;
    if (mp.size() == 2) {
        if ((maxi+mini)>2) cout << "NO" << endl;
        else cout << "YES" << endl;
        return 0;
    }

    cout << ( ((st.size() < mp.size()) && ((maxi-mini) <= 1)) ? "YES":"NO" ) << endl;

    return 0;
}


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

int main() {
    
    int N;
    cin >> N;
    
    for(int i=0; i<=N; i++)
        for(int j=0; j<=N; j++)
            if(i*4+j*7==N)
            {
                cout << "Yes\n";
                return 0;
            }
    
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll ans = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    ans += a;
  }
  COUT(ans - N);
  return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int main (void) {
  int a, b, c;
  char dummy[8];
  
  while(1) {
    cin >> a >> b;
  
    if(cin.eof()) return 0;

    c = a + b;

    cout << sprintf(dummy, "%d", c) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
N, X = map(int, input().split())
x = list(map(int, input().split()))

S = [0]
for i in range(N):
    S.append(S[-1] + x[i])

ans = float('inf')
for k in range(1, N + 1):
    tmp = (S[N] - S[N - k]) * 5
    i = N - k
    t = 1
    while i - k >= 0:
        tmp += (S[i] - S[i - k]) * (2 * t + 3)
        i -= k
        t += 1
    tmp += S[i] * (2 * t + 3)
    ans = min(ans, tmp + (k + N) * X)
print(ans)






Measured memory_bytes: 98128
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    // dp[0] = false
    // true -> win, false -> lose
    vector<bool> dp(K+1);
    // vector<bool> dp(K+1, false);
    for (int i = 1; i <= K; i++) {
        for (int j = 0; j < N; j++) {
            // dpの遷移
            // 石をa[i]個とってfalseにできるならtrue
            if (i - a[j] >= 0) dp[i] = dp[i] | !dp[i - a[j]];
        }
    }

    // 1番目の人がtrue of false
    if (dp[K]) cout << "First" << '\n';
    else cout << "Second" << '\n';
}


Measured memory_bytes: 3652
while 1:
    n=int(raw_input())
    if n==0:
        break
    a,dp=[],[]
    for i in range(n):
        a.append(int(raw_input()))
    ans=a[0]
    for i in range(n):
        tmp=0
        for j in range(i,n):
            tmp+=a[j]
            ans=max(ans,tmp)
    print ans

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

int main(){
    string s; cin >> s;
    int len = s.length();
    if(len%2 != 0){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < len-1; i+=2){
        if(s[i] == 'h' && s[i+1] == 'i'){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n; ll x;
  	cin >> n >> x;
  	
  	// B[i] = レベル i バーガーの B の数
  	// P[i] = レベル i バーガーの P の数
  	// N[i] = レベル i バーガーの全体数
  
  	// レベル 0 バーガー P
  	// レベル 1 バーガー B[P]P[P]B  	
  	// レベル 2 バーガー B[BPPPB]P[BPPPB]B
  	// レベル 3 バーガー B[BBPPPBPBPPPBB]P[BBPPPBPBPPPBB]B
  
  	ll B[55], P[55], N[55];
  	N[0] = 1;
  	B[0] = 0;
  	P[0] = 1;
  	int i = 0;
  	while(i < n) {
      	N[i+1] = 3+2*N[i];
      	B[i+1] = 2+2*B[i];
      	P[i+1] = 1+2*P[i];
      	i++;
    }
  	//cout << i << ": " << B[i] << " " << P[i] << " " << N[i] << endl;
  	
  	auto f = [&](int xx){
    	if(xx<=4) return xx-1;
      	if(xx==5) return 3;
    };
  	
  	// 現在 N[i] >= x > N[i-1]
	ll ans = 0;
  	while(x>0){
      	if(i == 1){
			ans += f(x);
          	break;
        }
      	else if(x == N[i]){
        	ans += P[i];
          	break;
        }
      	else if(x>N[i-1]+1){
      		// i-1 バーガーの下 x 個問題に帰着
        	ans += P[i-1]+1;
          	x -= 2 + N[i-1];
        }else{
          	x--;
        }
        i--;
      	//cout << i << " " << x << " " << ans << endl;
    }
  
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

#define  FOR(i,s,g) for(int i=s;i<g;i++)
#define RREP(i  ,n) for(int i=n-1;i>=0;i--);
#define  REP(i,  n) for(int i=0;i<n;i++)

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

const char en = '\n';
const ull  INFL = 810000001919114514;
const ull  INF  =         1919114514;

using Q = priority_queue<int, vector<int>, greater<int>>;

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

	Q q;

	int n,buf;
	cin>>n;
	n*=2;
	REP(i,n){
		cin>>buf;
		q.push(buf);
	}
	int result=0,a,b;

	while(!q.empty()){
		a=q.top();
		q.pop();
		b=q.top();
		q.pop();
		result+=min(a,b);
	}
	cout<<result<<en;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N, K;
	cin >> N >> K;

	int ans = 1;
	while( (N /= K) > 0 ) { ans += 1; }

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


Measured memory_bytes: 256
# いったん全て正答として合計値を出しておき、
# 条件に合うまで配当の小さい問題の点数分引いていく
# -> って、条件に合うまで、つーか「10で割って0にならない最小の点数」でいいのでそれを取る
n = gets.to_i
k = []
n.times do
  k << gets.to_i
end
k.sort!
sum = k.inject(:+)

if sum%10!=0
  puts sum
else
  if k.all?{|x|x%10==0}
    puts 0
  else
    k = k.select{|x|x%10!=0}
    puts sum - k[0]
  end
end


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

using namespace std;

int main()
{
    int N,M,C;
    cin>>N>>M>>C;
    vector<int> B;
    for(int i = 0;i < M;i++){
        int b;cin >> b;
        B.push_back(b);
    }
    int ans = 0;
    for(int i = 0;i < N;i++){
        int value = 0;
        for(int j = 0;j < M;j++){
            int a;
            cin>>a;
            value += a*B.at(j);
        }
        value += C;
        if(value > 0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
//const ll INF64 = 9223372036854775807ll;
const ll INF64 = 9223372036854775ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n-1);
    std::vector<int> ans(n);
    ans[0]=a[0];
    ans[1]=a[0];
    rrep(i,1,n-1){
        chmin(ans[i],a[i]);
        ans[i+1]=a[i];
    }/*
    erep(i,ans){
        std::cout << i << ' ';
    }
    std::cout  << std::endl;
    */
    std::cout << sum(ans) << std::endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string gesture[] = {"Rock", "Fire", "Scissors", "Snake", "Human",
                        "Tree", "Wolf", "Sponge", "Paper", "Air",
                        "Water", "Dragon", "Devil", "Lightning", "Gun"};

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<string> s(n);
        for(int i=0; i<n; ++i)
            cin >> s[i];

        string ret = "Draw";
        for(int i=0; i<n; ++i){
            int a = find(gesture, gesture+15, s[i]) - gesture;
            bool win = false, lose = false;
            for(int j=0; j<n; ++j){
                int b = find(gesture, gesture+15, s[j]) - gesture;
                if((b - a + 15) % 15 > 7)
                    lose = true;
                else if((b - a + 15) % 15 > 0)
                    win = true;
            }
            if(win && !lose){
                ret = s[i];
                break;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1268
def readinput():
    n=int(input())
    b=list(map(int,input().split()))
    return n,b

def main(n,b):
    sum=b[0]
    for i in range(1,n-1):
        sum+=min(b[i-1],b[i])
    sum+=b[n-2]
    return sum

if __name__=='__main__':
    n,b=readinput()
    ans=main(n,b)
    print(ans)


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

typedef long long ll;
ll a, b, c, d;
ll common=0;

ll to(ll no){
    ll div = __gcd(c, d);
    return (no/c)+(no/d)-no/(c*d/div);
}

int main(){
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    if(c > d) swap(c, d);
    printf("%lld\n", (b-a+1)-(to(b)-to(a-1)));
    return 0;
}


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

using namespace std;

int n;
string s;

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

    cin >> n;
    cin >> s;

    cout << s.substr(0, n);

    if(s.size() > n) {
        cout << "...";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
int main() {
    int n{}, sum{};
    cin >> n;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n; j++) {
            for(int k=1; k<=n; k++) {
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
int main (void){
  long long X,Y,test;
  long long ans=0;
  scanf("%lld %lld",&X,&Y);
  test=Y/X;
  while (1) {
    if(test<1) {
      break;
    }else{
      test/=2;
      ans++;
    }
  }

  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {

  int n;
  cin >> n;

  for(int i=1; i<=n; i++){
    int tmp = i * (i+1) / 2;
    if( tmp >= n ){
      for(int j=1; j<=i; j++){
        if( j == tmp - n ) continue;
        cout << j << endl;
      }
      return 0;
    }
  }

  return 0;
}

//


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, A;

int main() {
  cin >> N >> A;
  cout << N * N - A;
}


Measured memory_bytes: 3556
N, K = map(int, input().split())
mod = 10**9+7

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

def func(N, K, mod):
    if K<0 or K>N:
        return 0
    K = min(K, N-K)
    return g1[N] * g2[K] * g2[N-K] % mod

for i in range(1, K+1):
    ans = func(N-K+1, i, mod)*func(K-1, i-1, mod)%mod
    print(ans)

Measured memory_bytes: 74548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mpi map<int,int>
#define  si set<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define reP(i,a,n) for(int i=a;i<=n;i++)
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define st string
#define sz size()
#define case(i,n) Case<<" "<<i<<": "<<n<<endl;
#define tc ll t;cin>>t;while(t--)
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    ll ans=1;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    if(a[0]==0){
        cout<<"0"<<endl;
        return 0;
    }
    rep(i,n){
        if(a[i]>1000000000000000000/ans){
            cout<<"-1"<<endl;
            return 0;
        }
        ans=ans*a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3968
sub g{($d[$x=@@[@_]]-$d[$y=$@["@_"+1]])/($H[$y]-$H[$x])-$H[$x]-$H[$y]}<>=~$";map{shift@@while@@>1&&-2*$_<g 0;$d[@d]=$X=$d[$@[0]]+$'+($H[$@[0]]-$_)**2;$#@-=2while(push@@,$#d)>2&&g(-2)>g-3}@H=glob<>;print$X-$'

Measured memory_bytes: 69668
#include <iostream>
#include <string>

using namespace std;
string solve(string s, string t){
  if(s.length()+1 == t.length()){
    for(int i = 0; i < s.length(); i++){
      if(s[i] != t[i]) return "No";
    }
    return "Yes";
  }else{
    return "No";
  }
}

int main(){
  string s, t; cin >> s >> t;
  cout << solve(s, t) << endl;
  return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  int64_t S;
  cin>>S;
  
  if(S<1e9){
  for(int i=0;i<K;++i){
    cout<<S<<" ";
  }
  for(int i=0;i<N-K;++i){
    cout<<S+1<<" ";
  }
  }
  else{
      for(int i=0;i<K;++i){
    cout<<S<<" ";
  }
  for(int i=0;i<N-K;++i){
    cout<<S-1<<" ";
  }
  }
  
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void)
{
	int n,box[10],j,y,i,b;
	char c[101];
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		box[j]=0;
		for(i=1;i<=n;i++){
			box[i]=0;
		}
		y=0;
		j=0;
		scanf("%s",c);
		for(i=0;i<100;i++){
			j++;
			if(j>n){
				j=j-n;
			}
			if(c[i]=='M'){
				box[j]=box[j]+1;
			}
			if(c[i]=='S'){
				y=y+box[j]+1;
				box[j]=0;
			}
			if(c[i]=='L'){
				box[j]=box[j]+y+1;
				y=0;
			}
		}
		for(i=1;i<n;i++){
			for(j=i+1;j<=n;j++){
				if(box[i]>box[j]){
					b=box[i];
					box[i]=box[j];
					box[j]=b;
				}
			}
		}
		for(i=1;i<=n;i++){
			if(i==1){
			printf("%d",box[i]);
			}
			else{
				printf(" %d",box[i]);
			}
		}
		printf(" %d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,A[100000],h,s=0,d=0,p=0;
    cin >> h >> n;
    for(i=0;i<n;i++)
    {
        cin >> A[i];
    }
    for(i=0;i<n;i++)
    {
        s=s+A[i];
    }
    if(h<=s)
    {
        cout << "Yes" <<endl;
    }
    else if(h>s)
    {
        cout << "No" <<endl;
    }
    return 0;
}


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

typedef long long LL;
const int N = 401, mod = 1000000007;

int p[N][N], q[N], t[N], s[N], l[N], r[N], n, m;
void reduce(int &x) { x += x >> 31 & mod; }
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 0; i < N; ++i) {
		p[i][0] = 1;
		for (int j = 1; j <= m; ++j)
			p[i][j] = (LL) p[i][j - 1] * i % mod;
	}
	for (int i = 1; i < N; ++i)
		for (int j = 0; j <= m; ++j)
			reduce(p[i][j] += p[i - 1][j] - mod);
	for (int i = 0; i < n; ++i) std::cin >> l[i], --l[i];
	for (int i = 0; i < n; ++i) std::cin >> r[i];
	q[0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= m; ++j)
			t[j] = p[r[i]][j] - p[l[i]][j] + mod, s[j] = 0;
		for (int j = 0; j <= m; ++j)
			for (int k = 0; k <= m - j; ++k)
				s[j + k] = (s[j + k] + (LL) t[j] * q[k]) % mod;
		for (int j = 0; j <= m; ++j) q[j] = s[j];
	}
	std::cout << q[m] << '\n';
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		String[] d = new String[K];
		for (int i = 0; i < K; i++) {
			d[i] = in.next();
		}
		int num = N;
		while (true) {
			String s = String.valueOf(num);
			boolean isOk = true;
			for (int i = 0; i < d.length; i++) {
				if (s.contains(d[i])) {
					num++;
					isOk = false;
					break;
				}
			}
			if (isOk) {
				System.out.println(num);
				break;
			}
		}
		in.close();
	}
}

Measured memory_bytes: 23636
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main()
{
   int n,i,j,k;
   int a[200100],b[200100];
   scanf("%d",&n);


   for(i=0;i<n;i++)
   {
       b[i]=0;
   }

   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
       b[a[i]-1] += 1;
   }

   for(i=0;i<n;i++)
   {
       printf("%d\n",b[i]);
   }

return 0;
}

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

if K == 1:
    print(A[0])
    exit()

if A[0] == 1:
    print(1)
    exit()

# (cnt, k)
visit_town = [(0, 0)]*N
history = [0]*N

visit_town[0] = (1, 0)
history[0] = 1
visit = -1
for i in range(K):
    next_town = A[history[i]-1]
    if visit_town[next_town-1][0] == 0:
        visit_town[next_town-1] = (1, i + 1)
        history[i+1] = next_town
        continue
    mod_k = (K - visit_town[next_town-1][1]) % (i + 1 - visit_town[next_town-1][1])
    visit = mod_k + visit_town[next_town-1][1]
    break
if visit == -1:
    print(history[K])
else:
    print(history[visit])

    

Measured memory_bytes: 92996
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int x;
	cin >> x;
	int y = 8 - (x - 400) / 200;
	cout << y << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	c=0;
	d=0;
	scanf("%d %d", &a, &b);
	c = a * b;
	d = c % 2;
	if(d == 0){
		printf("Even");
	}else{
		printf("Odd");
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      int D = input.nextInt();
      int T = input.nextInt();
      int S = input.nextInt();

      if(D > T*S) {
         System.out.println("No");
      }  else {
         System.out.println("Yes");
      }
      input.close();

   }
   
}

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

int main() {
  string str;
  char ch;
  int w, n, a, b;
  cin >> w >> n;
  vector<int> num(w, 0);
  for(int i = 0; i < w; i++) num.at(i) = i + 1;
  
  for(int i = 0; i < n; i++){
    cin >> a >> ch >> b;
    swap( num.at(a - 1), num.at(b - 1));
  }
  
  for(int i = 0; i < w; i++) cout << num.at(i) << endl;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1, 1);
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int b;
            cin >> b;
            if (a[b] == 1) a[b] = 0;
        }
    }
    int ans = 0;
    for (int i = 1; i < n + 1; i++){
        if(a[i] == 1) ans++;
    }
    cout << ans << endl;
}

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

int main(){
	/*input*/
	int a, b;	cin >> a >> b;
	/*calculation*/
	int ab = a*b;
	/*output*/
	switch(ab%2){
		case 0:
			cout << "No" << endl;
		break;
		case 1:
			cout << "Yes" << endl;
		break;
	}
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, m; cin >> n >> m;
	vector<ll>a(n);
	ll sum = 0;
	for (ll i = 0; i < n; i++) cin >> a[i], sum += a[i];
	sort(all(a)); reverse(all(a));
	ll x = a[m - 1];
	if (x * 4 * m >= sum) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}




	return 0;
}

/*


*/

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,mmx")

#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    long long answ = 0;

    for(long long i = 2; i <= n; i++) {
        if(a[i] == 0) {
            a[i] = i;
            for(long long j = i*i; j <= n; j+=i)
                if(!a[j])
                    a[j] = i;
        }
    }

    for(int i = 1; i <= n; i++) {
        if(i == 1)
            answ++;
        else {
            long long c = 1;
            int t = i;
            vector<int> factors;
            while(t > 1)
                factors.push_back(a[t]), t /= a[t];
            int l = 0;
            while(l < factors.size()) {
                int r = l;
                while(r < factors.size() && factors[r] == factors[l])
                    r++;
                c *= (long long)(r-l+1);
                l = r;
            }
            answ += (long long)i * c;
        }
    }

    cout << answ;

    return 0;
}


Measured memory_bytes: 42276
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<ll,int>> vec(n);
    rep(i,n) cin>>vec[i].first>>vec[i].second;//first=値段,second=上限
    sort(all(vec));
    ll buy=0,money=0;
    for(auto a:vec){
        money+=a.first*min(m,a.second);
        m=max(0,m-a.second);
        if(m==0) break;
    }
    cout<<money<<endl;
}

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

int n,m;
struct element{
  char name[101];
  int cost;
} *product;

struct recipe{
  char name[101];
  int num_of_prod;
  char zairyo[100][101];
} *menu;

void minimum_cost(int number);

int main(void){
  int i,j;
  char final[101];
  while(scanf("%d",&n) && n){
    product=(struct element *)calloc(n,sizeof(struct element));
    for(i=0;i<n;i++){
      scanf("%s %d%*c", product[i].name,&product[i].cost);
    }
    /*
    for(i=0;i<n;i++){
      printf("%s %d\n", product[i].name,product[i].cost);
      }*/

    scanf("%d",&m);
    menu=(struct recipe *)calloc(m,sizeof(struct recipe));
    for(i=0;i<m;i++){
      scanf("%s %d%*c", menu[i].name,&menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	scanf("%s%*c",menu[i].zairyo[j]);
      }
    }
    /*
    for(i=0;i<m;i++){
      printf("%s %d ", menu[i].name,menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	printf("%s ",menu[i].zairyo[j]);
      }
      putchar('\n');
      }*/
    
    scanf("%s%*c",final);
    for(i=0;i<n;i++){
      if(!strcmp(final,product[i].name)){
	minimum_cost(i);
	printf("%d\n",product[i].cost);
	break;
      }
    }
    
    free(menu);
    free(product);
  }
  return 0;
}

void minimum_cost(int number){
  int i,j,k;
  int sum=0;
  //printf("%d %d\n",m,n);
  //printf("%s recipe is searching...\n",product[number].name);
  for(i=0;i<m;i++){
    //printf("%lu %lu\n",strlen(product[number].name),strlen(menu[i].name));
    if(!strcmp(product[number].name,menu[i].name)){
      //printf("%s menu found!\n",product[number].name);
      for(j=0;j<menu[i].num_of_prod;j++){
	for(k=0;k<n;k++){
	  if(!strcmp(menu[i].zairyo[j],product[k].name)){
	    minimum_cost(k);
	    sum+=product[k].cost;
	    break;
	  }
	}	
      }
      //printf("%s cost is from %d to ",product[number].name,product[number].cost);
      if(sum<product[number].cost) product[number].cost=sum;
      //printf("%d \n",product[number].cost);
      break;
    }
  }
}

Measured memory_bytes: 820
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<4; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			switch(a){
			case 1:
				System.out.println(b*6000);
				break;
			case 2:
				System.out.println(b*4000);
				break;
			case 3:
				System.out.println(b*3000);
				break;
			case 4:
				System.out.println(b*2000);
				break;
			}
		}
	}

}

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

using namespace std;

int main(){
    char s, ans;
    cin >> s;
    switch (s){
        case 'A':
            ans = 'T';
            break;
        case 'T':
            ans = 'A';
            break;
        case 'C':
            ans = 'G';
            break;
        case 'G':
            ans = 'C';
            break;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import statistics
n=int(input())
la, lb = [], []
for _ in range(n):
  a, b =map(int, input().split())
  la.append(a)
  lb.append(b)
c=statistics.median(la)
d=statistics.median(lb)
if n%2==1:
  print(d-c+1)
else:
  print(int(2*d-2*c+1))









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

#define N 4097


typedef struct{
  double x, y;
}Point;

Point data[N], tmp[N];
int size;

void kochCurve(Point a, Point b, int n, int p){
  Point o = (Point){(b.x-a.x)/3.0, (b.y-a.y)/3.0};
  Point s = (Point){o.x+a.x, o.y+a.y};
  Point u = (Point){s.x + o.x / 2.0 - sqrt(3.0) * o.y / 2.0, s.y + sqrt(3.0) * o.x / 2.0 + o.y / 2.0};
  Point t = (Point){(b.x-a.x)*2.0/3.0+a.x, (b.y-a.y)*2.0/3.0+a.y};
  if(p == n) return;
  kochCurve(a, s, n, p+1);
  data[size++] = s;
  kochCurve(s, u, n, p+1);
  data[size++] = u;
  kochCurve(u, t, n, p+1);
  data[size++] = t;
  kochCurve(t, b, n, p+1);
}

main(){
  int i, n;
  scanf("%d", &n);
  data[size++] = (Point){0.0, 0.0};
  kochCurve(data[0], (Point){100.0, 0.0}, n, 0);
  data[size++] = (Point){100.0, 0.0};
  for(i=0;i<size;i++) printf("%.8f %.8f\n", data[i].x, data[i].y);
  return 0;
}

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

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

Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, j, H, W, K, x[2], y[2];
	char **c;
	scanf("%d %d %d", &H, &W, &K);
	scanf("%d %d %d %d", &(x[0]), &(y[0]), &(x[1]), &(y[1]));
	c = (char**)malloc(sizeof(char*) * (H + 2));
	for (i = 1; i <= H; i++) {
		c[i] = (char*)malloc(sizeof(char) * (W + 2));
		scanf("%s", &(c[i][1]));
	}
	c[0] = (char*)malloc(sizeof(char) * (W + 2));
	c[H+1] = (char*)malloc(sizeof(char) * (W + 2));
	for (i = 1; i <= H; i++) {
		c[i][0] = '@';
		c[i][W+1] = '@';
	}
	for (j = 1; j <= W; j++) {
		c[0][j] = '@';
		c[H+1][j] = '@';
	}
	
	int k, l, head, tail;
	int **dist = (int**)malloc(sizeof(int*) * (H + 2)), *q[2];
	for (i = 0; i <= H + 1; i++) {
		dist[i] = (int*)malloc(sizeof(int) * (W + 2));
		for (j = 0; j <= W + 1; j++) dist[i][j] = 1 << 30;
	}
	q[0] = (int*)malloc(sizeof(int) * (H * W * 4));
	q[1] = (int*)malloc(sizeof(int) * (H * W * 4));
	dist[x[0]][y[0]] = 0;
	q[0][0] = x[0];
	q[1][0] = y[0];
	for (head = 0, tail = 1; head < tail; head++) {
		i = q[0][head];
		j = q[1][head];
		for (k = i - 1; k >= i - K && c[k][j] == '.' && dist[k][j] > dist[i][j]; k--) {
			if (dist[k][j] == dist[i][j] + 1) continue;
			dist[k][j] = dist[i][j] + 1;
			q[0][tail] = k;
			q[1][tail++] = j;
		}
		for (k = i + 1; k <= i + K && c[k][j] == '.' && dist[k][j] > dist[i][j]; k++) {
			if (dist[k][j] == dist[i][j] + 1) continue;
			dist[k][j] = dist[i][j] + 1;
			q[0][tail] = k;
			q[1][tail++] = j;
		}
		for (l = j - 1; l >= j - K && c[i][l] == '.' && dist[i][l] > dist[i][j]; l--) {
			if (dist[i][l] == dist[i][j] + 1) continue;
			dist[i][l] = dist[i][j] + 1;
			q[0][tail] = i;
			q[1][tail++] = l;
		}
		for (l = j + 1; l <= j + K && c[i][l] == '.' && dist[i][l] > dist[i][j]; l++) {
			if (dist[i][l] == dist[i][j] + 1) continue;
			dist[i][l] = dist[i][j] + 1;
			q[0][tail] = i;
			q[1][tail++] = l;
		}
	}
	if (dist[x[1]][y[1]] < 1 << 30) printf("%d\n", dist[x[1]][y[1]]);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 20956
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
  int x, key=0,a,b;
  int stack[101];
  char s[100];
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        a = stack[key];
                b = stack[key-1];
                stack[key-1] = b + a;
                key--;
 
    } else if ( s[0] == '-' ){
                a = stack[key];
                b = stack[key-1];
                stack[key-1] = b - a;
                key--;
 
    } else if ( s[0] == '*' ){
        a = stack[key];
                b = stack[key-1];
                stack[key-1] = b * a;
                key--;
 
    } else {
      x = atoi(s);
      key++;
      stack[key] = x;
    }
  }
  printf("%d\n",stack[key]);
 
  return 0;
}

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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
    int N, Q;
    ll sum = 0;
    cin >> N;
    vector<int> L(100010);
    rep (i, N) {
        int a;
        cin >> a;
        L[a]++;
        sum += a;
    }
    cin >> Q;
    ll S[Q];
    rep (i, Q) {
        int b, c;
        cin >> b >> c;
        sum += (L[b]*(c-b));
        L[c] += L[b];
        L[b] = 0;
        S[i]  = sum;
    }
    rep (i, Q) cout << S[i] << endl;

}

Measured memory_bytes: 4576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A+B >= 10)
			System.out.println("error");
		else
			System.out.println(A+B);
	}
}

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

int main() {
  int n;
  cin >> n;
  
  switch (n) {
    case 25:
      cout << "Christmas" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
  }
  
  return 0; 
}


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

using ld = long double;

int main() {
    int N;
    ld W;
    std::cin >> N >> W;

    std::vector<std::pair<ld, ld>> vp(N);
    for (auto& p : vp) std::cin >> p.first >> p.second;

    std::sort(vp.begin(), vp.end(), [](const auto& a, const auto& b) {
        return a.first / a.second > b.first / b.second;
    });

    ld ans = 0;
    for (auto p : vp) {
        ans += p.first * std::min(W, p.second) / p.second;
        W -= std::min(W, p.second);
    }
    std::cout << std::fixed << std::setprecision(10)
              << ans << std::endl;
}


Measured memory_bytes: 6152