akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#define rep(i,n) for(int i=0;i<(n);++i)
 typedef long long ll;
 
using namespace std;
 
int main(){
    int N,K,Q;
    cin >>N>>K>>Q;
    int A[Q];
    rep(i,Q)cin >>A[i];
    vector<int> Man(N,K-Q);
    rep(i,Q)Man[A[i]-1]++;
    rep(i,N){
        if(0<Man[i]){
            cout <<"Yes"<<endl;
        }
        else cout <<"No"<<endl;
    }
return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  if (n == 1) cout << "Hello World" << endl;
  else {
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
}

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

typedef long long ll;

using namespace std;

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

    int n;
    cin >> n;

    int ret = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 1) continue;
        while (x % 2 == 0) {
            x >>= 1;
            ret++;
        }
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int n;
  cin>>n;
  for(int x=111;x<=999;x+=111){
    if(x>=n){
      cout<<x<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    mod = 998244353
    s, k = input().split()
    k = int(k)
    n = len(s)

    one = s.count("1")

    cnt = 0
    zero_list = []
    for i in range(n):
        if s[i] == "0":
            zero_list.append(cnt)
            cnt = 0
        else:
            cnt += 1

    z = 0
    mm = min(one, k)

    dp = [[0]*(one+1) for _ in [0]*(one+1)]
    dp[0][0] = 1

    for i in range(len(zero_list)):
        dp2 = [[0]*(mm+1) for _ in [0]*(one+1)]
        base = zero_list[i]
        # j:何個今までに入れたか
        for j in range(one+1):
            # l:何個入れるか
            for l in range(one+1-j):
                if l < z+base-j:
                    continue
                ml = max(l-base, 0)
                # p:これまでのペナルティ
                for p in range(min(one, k)+1):
                    q = p+ml
                    if q <= mm:
                        dp2[j+l][q] = (dp2[j+l][q]+dp[j][p]) % mod
                    else:
                        break
        z += base
        dp = dp2
    print(sum([sum(i) for i in dp]) % mod)


main()

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

int main(){
    int n;
    cin >> n;
    vector<long long int> a(n), b(n), c(n);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    long long int ans = 0;
    for(int i=0; i<n; i++){
        //cout << lower_bound(a.begin(),a.end(),b[i]) - a.begin() << " * " << c.end() - lower_bound(c.begin(),c.end(),b[i]+1) << endl;
        ans += (lower_bound(a.begin(),a.end(),b[i]) - a.begin()) * (c.end() - lower_bound(c.begin(),c.end(),b[i]+1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
class RMQ{
public:
  int n,dat[555555];
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    fill(dat,dat+2*n-1,MAX);
  }
  void update(int k,int a){
    k+=n-1;dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b){return query(a,b,0,0,n);}
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return MAX;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

void Main() {
  ll n;
  R n;
  ll a[n];
  RMQ t;
  t.init(n+1);
  rep(i,n) {
    R a[i];
    t.update(i+1,a[i]);
  }
  ll ans=0;
  rep(i,n) {
    ll l=0,r=i+1;
    while(l+1<r) {
      int m=(l+r)/2;
      if(t.query(m,i+2)<a[i]) l=m;
      else r=m;
    }
    ll x=i-l+1;
    l=i,r=n;
    while(l+1<r) {
      int m=(l+r)/2;
      if(t.query(i+1,m+2)<a[i]) r=m;
      else l=m;
    }
    ll y=l-i+1;
    ans+=x*y*a[i];
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    string s;
    cin >> s;
    int ans=0;
    int n = s.length();
    for(int i=0; i<n; i++){
        if(s[i]!=s[n-1-i]){
            ans++;
        }
    }
    ans /= 2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;
vector <point> pl;

double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}

vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return res;
}

double get_area(vector <point> &polygon){
  if(polygon.size()<3)return 0;
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()])/2;
  return res;
}


int main(){
  int n;
  cin>>n;
  for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));

  int m;
  cin>>m;
  for(int i=0,c,d;i<m;i++){
    cin>>c>>d;
    point a,b;
    a=point(c,d);
    cin>>c>>d;
    b=point(c,d);
    vector<point> res=ConvexCut(pl,a,b);
    printf("%.8f\n",get_area(res));
  }


  return 0;
}

Measured memory_bytes: 1248
from sys import stdin
import math

n, d = stdin.readline().rstrip().split()

n = int(n)
d = int(d)

data = [stdin.readline().rstrip().split() for _ in range(n)]

count = 0
for i in range(n):
  if math.sqrt(int(data[i][0]) * int(data[i][0]) + int(data[i][1]) * int(data[i][1])) <= d:
    count = count + 1

print(count)


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  int ans = 0;
  while (n) {
    string s = to_string(n);
    if (s.size() % 2) ans++;
    n--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int t = n, divide = 0;
  while (t) {
    divide += t % 10;
    t /= 10;
  }

  if (n % divide)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < 3; ++i)
	{
		ans += s[i] == t[i];
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll x = 0;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        x^=a[i];
    }
    rep(i,n){
        a[i] ^= x;
        cout << a[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 4800
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, 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 Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	string s;
	cin >> s;
	int jd = 0;
	for (int i = 0; i < s.size(); i++) {
		jd += (s[i] - '0');
		jd %= 9;
	}
	if (jd % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main() {
    string S;
    cin >> S;
    if ((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll k = 0;
int n;
//vector<ll> a(n);

bool bor(vector<ll> a){
    bool rtn = false;
    REP(i,n){
        if(a[i]>=n){
            rtn = true;
        }
    }
    return rtn;
}

int main(void){
    cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    while(bor(a)){
        REP(i,n){
            if(a[i]>=n){
                ll num = a[i]/n;
                k += num;
                a[i]=a[i]%n-num;
                REP(j,n){
                    a[j]+=num;
                }
            }
        }
    }
    put(k);
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7

N,M = map(int,input().split())
dp = [0]*(N+1)
dp[0] = 1
A = set(int(input()) for _ in range(M)) # 禁止地帯

for i in range(1,N+1):
  if i in A:
    continue
  x = dp[i-1]
  if i > 1:
    x += dp[i-2]
  dp[i] = x%MOD

answer = dp[N]
print(answer)


Measured memory_bytes: 12652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

int N;
int W;
int v[110];
int w[110];
int dp[110][110][310];
int dp2[110][31000];

int main(){
  cin >> N >> W;
  for(int i = 0; i < N; i++)  cin >> w[i] >> v[i];

  if(w[0] > 300){
    for(int i = 0; i < 110; i++){
      for(int j = 0; j < 110; j++)  fill(dp[i][j], dp[i][j]+310, -1e9-1);
    }

    for(int i = 0; i < 110; i++)  dp[i][0][0] = 0;
    dp[0][1][0] = v[0];

    for(int i = 1; i < N; i++){
      for(int j = 1; j <= i+1; j++){
        for(int k = 0; k < 310; k++){
          int wr = w[i] - w[0];
          if(k >= wr){
            if(dp[i-1][j-1][k-wr] < 0) dp[i][j][k] = dp[i-1][j][k];
            else dp[i][j][k] = max(dp[i-1][j-1][k-wr]+v[i], dp[i-1][j][k]);
          }
          else dp[i][j][k] = dp[i-1][j][k];
        }
      }
    }

    int ma = 0;
    for(ll i = 0; i <= N; i++){
      for(ll j = 0; j < 310; j++){
        ll x = i * w[0] + j;
        if(x <= W) ma = max(ma, dp[N-1][i][j]);
      }
    }
    cout << ma << endl;
  }
  else if(W >= 31000){
    int sum = 0;
    for(int i = 0; i < N; i++)  sum += v[i];
    cout << sum << endl;
  }
  else{
    for(int i = 0; i < 110; i++)  fill(dp2[i], dp2[i]+W, -1e9-1);
    dp2[0][w[0]] = v[0];
    for(int i = 0; i < 110; i++) dp2[i][0] = 0;
    for(int i = 1; i < N; i++){
      for(int j = 0; j <= W; j++){
        if(j - w[i] >= 0) dp2[i][j] = max(dp2[i-1][j-w[i]]+v[i], dp2[i-1][j]);
        else dp2[i][j] = dp2[i-1][j];
      }
    }
    int ma = 0;
    for(int i = 0; i <= W; i++){
      ma = max(dp2[N-1][i], ma);
    }
    cout << ma << endl;
  }

  return 0;
}


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

int main(){
  int N, K, a;
  cin >> N >> K;
  int S[N] = {0}, d;
  for(int i=0;i < N;i++) {
    cin >> d;
    for(int j=0;j<d;j++) {
      cin >> a;
      S[a-1]++;
    }
  }
  a=0;
  for(int i=0;i<N;i++) if(S[i]==0)a++;
  cout << a;
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int a = tmp[0], b = tmp[1];
        int ans = Math.Max(a - 2 * b, 0);
        WriteLine(ans);
    }
}

Measured memory_bytes: 13268
# coding: utf-8
# Your code here!
import math
while True:
    table=input().split()
    a = int(table[0])
    op = table[1]
    b = int(table[2])

    if op=="?":
        break
    
    if op=="+":
        print(math.floor(a+b))
    elif op == '-':
        print(math.floor(a-b))
    elif op == '/':
        print(math.floor(a/b))
    else:
        print(math.floor(a*b))
    


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

int main() {

    static const double pi = 3.141592653589793238462643383279502884;

    long int A,B,H,M;
    cin>>A>>B>>H>>M;

    long double a=2*pi*(60*H+M)/720;
    long double b=2*pi*M/60;

    if (a>=b&&a-b<=pi){

        cout<<fixed<<setprecision(15)<<sqrt(static_cast<long double>(A*A+B*B-2*A*B*cos(a-b)))<<endl;
    }

    else if (a>=b&&a-b>pi){

        cout<<fixed<<setprecision(15)<<sqrt(static_cast<long double>(A*A+B*B-2*A*B*cos(2*pi-a+b)))<<endl;
    }

    else if (a<=b&&b-a<=pi){

        cout<<fixed<<setprecision(15)<<sqrt(static_cast<long double>(A*A+B*B-2*A*B*cos(b-a)))<<endl;
    }

    else if (a<=b&&b-a>pi){

        cout<<fixed<<setprecision(15)<<sqrt(static_cast<long double>(A*A+B*B-2*A*B*cos(2*pi+a-b)))<<endl;
    }

}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  vll A(N);
  ll sum = 0;
  ll sum0 = 0, sum1 = 0;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
    if(i % 2 == 0) sum0 += A.at(i);
    else sum1 += A.at(i);
  }
  sum /= 2;
  vll M(N);
  ll x = 0;
  for(int i = 0; i < (N-1)/2; i++){
    x += A.at(2*i + 1);
  }
  M.at(0) = 2 * (sum - x);
  for(int i = 0; i < N-1; i++){
    M.at(i+1) = 2 * A.at(i) - M.at(i);
  }
  for(int i = 0; i < N; i++){
    cout << M.at(i);
    if(i != N-1) cout << ' ';
    else cout << endl;
  }
}

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

int max_, N;

void knapsack(int pos, int sum, vector<int> V, vector<int> C){

    if(pos == N) return;

    //入れるパターン
    sum = sum + V[pos] - C[pos];
    if(sum > max_) max_ = sum;
    knapsack(pos+1, sum, V, C);

    //入れないパターン
    sum = sum - V[pos] + C[pos];
    knapsack(pos+1, sum, V, C);
}

int main() {

    int i, j;
    max_ = 0;
    cin >> N;
    vector<int> V(N), C(N);

    for(i=0; i<N; i++)cin >> V[i];
    for(i=0; i<N; i++)cin >> C[i];

    knapsack(0, 0, V, C);

    cout << max_ << endl;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  for(int i=0;i<S.size();i=i+2){
    cout << S.at(i);
  }
}

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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}

	as.emplace_back(-1);

	int64_t fst = 0, snd = n;

	for (int64_t i = 1; i < n; i++)
	{
		if (as[fst] <= as[i])
		{
			snd = fst;
			fst = i;
		}
		else if (as[snd] <= as[i])
		{
			snd = i;
		}
	}

	for (int64_t i = 0; i < n; i++)
	{
		if (i == fst)
		{
			cout << as[snd] << endl;
		}
		else
		{
			cout << as[fst] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4864
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
// #define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// #endif
	crap;

	int a, b;
	cin >> a >> b;

 	for(int i = 1; i <= 1030; i++){
 		int a1 = i * 8/100;
 		int b1 = i * 10/100;

 		if(a1 == a and b1 == b){
 			cout << i << endl;
 			return 0;
 		}
 	}

 	cout << -1 << endl;

	return 0;
}






Measured memory_bytes: 256
W,H,N=map(int,input().split())

# 左下の座標
X=Y=0

for i in range(N):
  # 入力
  x,y,a=map(int,input().split())

  if a==1:
    X=max(X,x)
  elif a==2:
    W=min(W,x)
  elif a==3:
    Y=max(Y,y)
  else:
    H=min(H,y)

# 出力
print(max(W-X,0)*max(H-Y,0))
        


Measured memory_bytes: 9020
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
const int N = 1e5 + 10;

ll a[N];

int main() {
    //freopen("a.in", "r", stdin);
    int n;
    ll x;
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        if (a[i] <= x)
            x -= a[i];
        else {
            cout << i;
            return 0;
        }
    }
    if (x == 0)
    cout << n;
    else
        cout << n - 1;
}


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

using namespace std;

int n, d;
int t[200];
int a[200], b[200], c[200];
int dp[201][200]; // dp[i][j] = i??\?????????j???????????????????´????????????¶??????????????§???


int main()
{
    cin >> d >> n;
    for (int i = 0; i < d; ++i) cin >> t[i];
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
    
    for (int i = 1; i < d; ++i) {
        for (int j = 0; j < n; ++j) { // i??\???
            if (a[j] <= t[i] && t[i] <= b[j]) {
                for (int k = 0; k < n; ++k) { // i-1??\???
                    if (a[k] <= t[i - 1] && t[i - 1] <= b[k]) {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(c[j] - c[k]));
                    }
                }
            }
        }
    }

    int ma = 0;

    for (int i = 0; i < n; ++i) ma = max(ma, dp[d-1][i]);

    cout << ma << endl;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  int N = inputValue();

  int ans = N * N * N;
  cout << ans << endl;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
* * WRITER:kakitamasziru/OxOmisosiru * *
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1001001001001001;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
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);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % 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 * b / gcd(a, b);
}

long long A,B;
bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    vector<long long> monster(N+1);
    vector<long long> saver(N);

    for(int i = 0;i<N+1;i++)cin >> monster.at(i);
    for(int i = 0;i<N;i++)cin >> saver.at(i);
    long long ans = 0;
    for(int i = 0;i<N;i++){
        if(saver.at(i) >= monster.at(i)){
            ans += monster.at(i);
            saver.at(i) -= monster.at(i);
            ans += min(monster.at(i+1),saver.at(i));
            monster.at(i+1) -= min(monster.at(i+1),saver.at(i));
        }
        else{
            ans += saver.at(i);
        }
    }

    cout << ans << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        v.push_back(x);
    }
    make_heap(v.begin(), v.end());

    for (int i = 0; i < m; i++)
    {
        ll x;
        x = v.front();
        pop_heap(v.begin(), v.end());
        v.pop_back();
        x = x / 2;
        v.push_back(x);
        push_heap(v.begin(), v.end());
    }
    ll sum  = 0;
    for (int& x : v)
    {
        sum += x;
    }
    cout << sum;


    return 0;
}



Measured memory_bytes: 892
#include <stdio.h>
int main(void)
{
 
    int n,i,j,x[4][13]={{0}},no,k;
    char cards;
     
 
 
    scanf("%d",&n);
     
     
 
    while(n>0)
    {
         
        scanf(" %c",&cards);
        scanf("%d",&no);
         
 
        if(cards =='S')
        {
            k=0;
 
             
             
        }
     
     
        if(cards =='H')
        {
            k=1;
 
             
             
        }
     
 
        if(cards =='C')
        {
            k=2;
 
             
             
        }
     
        if(cards =='D')
        {
            k=3;
 
             
             
        }
 
        x[k][no-1] =1;
        n--;
 
    }
     
    for(i=0;i<4;i++)
    {
         
         
 
        for(j=0;j<13;j++)
        {
            if(x[i][j] == 0)
            {
             
              
                if(i==0)
                {
                    cards = 'S';
                     
                }
 
                if(i==1)
                {
                    cards = 'H';
                     
                }
 
                if(i==2)
                {
                    cards = 'C';
                     
                }
                 
                if(i==3)
                {
                    cards = 'D';
                     
                }
 
                printf("%c %d\n",cards,j+1);
                 
             
         
        }
     
    }
 
    }
    return 0;
     
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
//#include <stack>

using namespace std;

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

#define max_n 100

int N;

int main() {

	cin >> N;

	if ((double)N/1.08 - (int)(N/1.08) == 0) { cout << N / 1.08 << endl; return 0; }
	
	int ans = N / 1.08;
	ans++;

	if((int)(ans*1.08)!=N) { cout << ":(" << endl; return 0; }

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
lens = len(s)
ans = False
keyence = "keyence"


for i in range(0,8):
    if s[:i] == keyence[:i] and s[i+lens-7:] == keyence[i:]:
        ans = True
            
print("YES") if ans else print("NO")

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 520005;
const int K = 25;
int p[N], v1, v2, mx[N], cnt[N];
vector < int > g[N];
pair < int, int > dfs(int v, int pr = -1, int d = 0){
    pair < int, int > res;
    res.F = v;
    res.S = d;
    for (auto u: g[v]){
        if (u == pr) continue;
        p[u] = v;
        auto x = dfs(u, v, d + 1);
        if (x.S > res.S) res = x;
    }
    return res;
}
void dfs2 (int v, int pr = -1, int d = 0){
    cnt[d]++;
    int k = 0;
    for (auto u: g[v]){
        if (u == pr || u == v1 || u == v2) continue;
        k++;
        dfs2(u, v, d + 1);
    }
    mx[d] = max(mx[d], k);
}
int calc(int u1, int u2, int d){
    cnt[0] = 0;
    v1 = u1;
    v2 = u2;
    for (int i = 0; i <= 100; i++) cnt[i] = mx[i] = 0;
    dfs2(v1);
    if (v1 != v2){
        dfs2(v2);
    }
    int y = cnt[0];
   // cout << x.S << " " << v1 << " " << v2 << endl;
    for (int i = 0; i < d / 2; i++){
        y = y * mx[i];
    }
    return y;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    auto x = dfs(1);
    x = dfs(x.F);
    cout << (x.S + 2) / 2 << " ";
    int v1 = x.F;
    int v2;
    for (int i = 1; i <= (x.S) / 2; i++) v1 = p[v1];
    if (x.S % 2) v2 = p[v1]; else v2 = v1;
    int res = calc(v1, v2, x.S);
    if (v1 == v2){
        for (auto u: g[v1]){
            res = min(res, calc(u, v1, x.S + 1));
        }
    }
    cout << res;
}


Measured memory_bytes: 16768
#include<stdio.h>
int main(void)
{
	int i, j;
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i * j);	
		} 
	} 
	return 0;
	
	
	
	

    
}


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

int main() {
	long  h,i,m,n,k;
	string t;
	cin >> t;
	for(i=0; i<t.size(); i++){
		if(t[i]=='?'){
			t[i]='D';
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3748
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int k = scan.nextInt();
    int r = scan.nextInt();
    int s = scan.nextInt();
    int p = scan.nextInt();
    String t = scan.next();

    ArrayList<ArrayList<Character>> a = new ArrayList<ArrayList<Character>>();
    for (int i=0;i<k;i++){
      ArrayList<Character> b = new ArrayList<Character>();
      a.add(b);
    }

    for (int i=0;i<n;i++){
      int target = (int) i%k;
      ArrayList<Character> c = a.get(target);
      char g = t.charAt(i);
      if (g == 'r'){
        g = 'p';
      }
      else if (g == 's'){
        g = 'r';
      }
      else{
        g = 's';
      }
      c.add(g);
    }

    long sum = 0;
    for (int j=0;j<k;j++){
      ArrayList<Character> e = a.get(j);
      char prev = 'a';
      for (char m : e){
        if (m != prev){
          if (m == 'r'){
            sum += r;
          }
          else if (m == 's'){
            sum += s;
          }
          else{
            sum += p;
          }
          prev = m;
        }
        else{
          prev = 'a';
        }
      }
    }
    System.out.println(sum);
  }

}


Measured memory_bytes: 50624
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <queue>
#include <cmath>
#include <set>



using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

pair<ll, ll> minuss(pair<ll, ll> a,pair<ll, ll> b)
{
    ll up=a.first*b.second-a.second*b.first;
    if(up<0)
        return {-1,-1};
    ll dwon=a.second*b.second;
    ll gc=gcd(up,dwon);
    up/=gc;
    dwon/=gc;
    return {up,dwon};
}

int main () {
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    for(int i=1;i<=3500;i++)
    {
        
    
        for(int j=1;j<=3500;j++)
        {
            
            pair<ll,ll> one=minuss({4,n},{1,i});
            if(one.first<0)
                break;
            pair<ll,ll> two=minuss({one.first,one.second},{1,j});
            if(two.first<0)
                continue;
            if(two.first==1)
            {
                cout<<i<<" "<<j<<" "<<two.second;
                return 0;
            }
            
        }
    }

    
    return 0;
}


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

typedef pair<int, int>P;

int main(){

    int N;
    cin>>N;
    vector<P>vec(N);
    vector<int>ans(N);
    for(int i=0;i<N;i++){
        cin>>vec[i].first;
        vec[i].second = i;
    }
    sort(vec.begin(), vec.end());
    for(int i=0;i<N;i++){
        int p=N/2;
        if(p<=i)p--;
        ans[vec[i].second]=vec[p].first;
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            
            string s,t;
            cin >> s >> t;
            int n = s.size(), m = t.size();
            int ans = m;
            for(int i = 0; i + m <= n; i++)
            {
                int cur = 0;
                for(int j = 0; j < m; j++)
                    if(s[i+j] != t[j])
                        cur++;
                ans = min(ans, cur);
            }

            cout << ans << '\n';


           return 0;
        }
          

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

int H, W;
vector<string> vstr;

bool check(int x, int y){
    int nx, ny;
    int dx[4] ={0, 1, -1, 0};
    int dy[4] = {1, 0, 0, -1};
    for(int k=0; k<4; k++){
        nx = x + dx[k];
        ny = y + dy[k];
        if(nx >=0 && ny>=0 && nx <W && ny <H && vstr[ny][nx]=='#') return true;
    }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> H >> W;
    string tmp;
    for(int i=0; i<H; i++){
        cin >> tmp;
        vstr.push_back(tmp);
    }
    bool ok = true;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(vstr[i][j]=='#') ok = check(j, i);
            if(!ok){
                cout << "No" << endl;
                return 0;
            } 
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while(t--)
    {
        int n,m,i,x,y,z;
        cin>>n;
        if(n==1)
            cout<<"a"<<endl;
        else {
            string ans="";
            while(n>0) {
                x=n%26;
                x--;
                if(x<0)
                    x=25;
                ans.push_back((char)('a'+x));
                n--;
                n/=26;
            }
            reverse(ans.begin(),ans.end());
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k;
    cin>>n;
    int a[100000],b[100000],c[100000];
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[100000][3];
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(i=2;i<=n;i++)
    {
        dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int timePrice = scanner.nextInt() * scanner.nextInt();
        int fixedAmount = scanner.nextInt();

        System.out.println(timePrice < fixedAmount ? timePrice : fixedAmount);
    }
}


Measured memory_bytes: 22228
import java.util.*;
import java.util.Map.Entry;

public class Main {
	static HashMap<String,Integer> hm;
	static ArrayList<String> al;
	static String head;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,count;
		String[] token;
		String ans;
		
		while(true){
			n = Integer.valueOf(sc.nextLine());
			if(n == 0){
				break;
			}
			
			hm = new HashMap<String,Integer>();
			al = new ArrayList<String>();
			
			for(int i=0; i<n; i++){
				token = sc.nextLine().split(" ");
				for(int j=0; j<token.length; j++){
					if(hm.containsKey(token[j])){
						hm.put(token[j],hm.get(token[j])+1);
					}else{
						hm.put(token[j],1);
					}
				}
			}
			
			head = sc.nextLine();
			mapSort();
			
			ans = "";
			count = 0;
			if(al.size() == 0){
				System.out.println("NA");
			}else{
				for(String s:al){
					ans += s+" ";
					count++;
					if(count == 5){
						break;
					}
				}
				System.out.println(ans.trim());
			}
		}
		
	}
	
	private static void mapSort() {
		ArrayList<String> tmp = new ArrayList<String>();
		int value = -1;
		
		List<Map.Entry<String,Integer>> entries = 
				new ArrayList<Map.Entry<String,Integer>>(hm.entrySet());
		Collections.sort(entries, new Comparator<Map.Entry<String,Integer>>() { 
            @Override
            public int compare(
                  Entry<String,Integer> entry1, Entry<String,Integer> entry2) {
                return ((Integer)entry2.getValue()).compareTo((Integer)entry1.getValue());
            }
        });
		
		for (Entry<String,Integer> s : entries) {
            if(head.charAt(0) == s.getKey().charAt(0)){
            	if(value == -1){
            		value = s.getValue();
            	}
            	
            	if(value == s.getValue()){
            		tmp.add(s.getKey());
            	}else{
            		value = s.getValue();
            		Collections.sort(tmp);
            		al.addAll(tmp);
            		tmp.clear();
            		tmp.add(s.getKey());
            	}
            }
        }
		
		if(tmp.size() > 0){
			if(!al.contains(tmp.get(0))){
				Collections.sort(tmp);
				al.addAll(tmp);
			}
		}
	}
}

Measured memory_bytes: 39972
#include <iostream>
using namespace std;
 
int main(){
  int n,m;
  int a;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    n-=a;
  }
  if(n>=0){
    cout<<n<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3196
import java.util.*;

public class Main {

	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in);){
			int count = 0;
			List<Integer> list = new ArrayList<Integer>();
			int N = Integer.parseInt(scan.next());
			for(int i=0; i< N ; i++) {
				list.add(Integer.parseInt(scan.next()));
			}
			out:while(true) {
				for(int j = 0; j<N ; j++) {
					int elm = list.get(j);
					if(elm % 2 == 1) {
						System.out.print(count);
						break out;
					}else {
						list.set(j, elm/2);
					}
				}
				count++;
			}		
		}		
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Discount Fare
            var line = ReadLine();
            int x = line[0];
            int y = line[1];

            Console.WriteLine(x + y / 2);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
inline double sq(double a) { return a*a; }

int N, M, C;
int u[2000], v[2000], w[2000], next[2000], head[200];
int dp[200][1024];

int main() {
    for(;;) {
        scanf("%d%d%d", &N, &M, &C);
        if(N==0) return 0;
        memset(head, -1, sizeof(head));
        rep(i, M) {
            scanf("%d%d%d", u+i, v+i, w+i);
            u[i]--, v[i]--;
            next[i] = head[u[i]];
            head[u[i]] = i;
        }
        typedef pair<int, int> node;
        priority_queue<pair<int, node> > q;
        memset(dp, -1, sizeof(dp));
        q.push(mp(0, mp(0, 0)));
        while(!q.empty()) {
            pair<int, node> vv(q.top());
            q.pop();
            const int cw = -vv.first;
            if(cw>C) break;
            const int cat = vv.second.first;
            const int cdel = vv.second.second;
            if(dp[cat][cdel]!=-1) continue;
            dp[cat][cdel] = cw;
            for(int x=head[cat]; x!=-1; x=next[x]) {
                if(cdel<M) q.push(mp(-cw, mp(v[x], cdel+1)));
                if(dp[v[x]][cdel]==-1) q.push(mp(-cw-w[x], mp(v[x], cdel)));
            }
        }
        rep(i, M+1) if(dp[N-1][i]!=-1 && dp[N-1][i]<=C) {
            printf("%d\n", i);
            break;
        }
    }
}

Measured memory_bytes: 13000
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L, A):

    dp = [[sys.maxsize] * (L+1) for _ in range(5)]
    for i in range(5):
        dp[i][0] = 0

    def s(a, t):
        if t == 0 or t == 4:
            return a
        if t == 1 or t == 3:
            if a == 0:
                return 2
            else:
                return a % 2
        else:
            return (a+1) % 2

    for i, a in enumerate(A):
        for j in range(5):
            if j > 0:
                dp[j][i] = min(dp[j-1][i], dp[j][i])
            dp[j][i+1] = min(dp[j][i+1], dp[j][i]+s(a, j))
        # dp[0][i+1] = dp[0][i] + a
        # dp[1][i+1] = min(dp[0][i], dp[1][i]) + ((a%2) if a != 0 else 2)
        # dp[2][i+1] = min(dp[1][i], dp[2][i]) + ((a+1)%2)
        # dp[3][i+1] = min(dp[2][i], dp[3][i]) + ((a%2) if a != 0 else 2)
        # dp[4][i+1] = min(dp[3][i], dp[4][i]) + a
    

    return min([dp[i][L] for i in range(5)])

def main():
    L = read_int()
    A = [read_int() for _ in range(L)]
    print(slv(L, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 50448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');

            for (int k = 0; k < n; k++)
                Console.Write(k == 0 ? "" + str[k] : " " + str[k]);
            Console.WriteLine();

            for (int j=1;j<n;j++)
            {
                string key = str[j];
                int i = j - 1;
                for (; i >= 0 && int.Parse(str[i]) > int.Parse(key); i--)
                    str[i + 1] = str[i];
                str[i+1] = key;

                for (int k = 0; k < n; k++)
                    Console.Write(k==0?""+str[k]:" "+str[k]);
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9008
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000], B[200000];
    cin >> N;
    REP(i, N) cin >> A[i] >> B[i];
    sort(A, A + N); sort(B, B + N);
    if (N % 2 == 0) cout << B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1 << endl;
    else cout << B[N / 2] - A[N / 2] + 1 << endl;
    return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int sum=0;
	int n;
	int box1[51];
	int box2[51];
	int box[51];
	int i;
	cin>>n;
	for(i=0;i<n;i++)	cin>>box1[i];
	for(i=0;i<n;i++)	cin>>box2[i];
	for(i=0;i<n;i++){
		box[i]=box1[i]-box2[i];
		if(box[i]>=0)	sum+=box[i];
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256