akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

 //int dp[1001][1001];
 /*
vector < int > tree(400005);

void buildtree (vector < int > v,int node,int start,int fin)
  {
      if(start==fin)
      {
          tree[node]=v[start];
          return;
      }
      int mid=(start+fin)/2;
      buildtree(v,2*node,start,mid);
      buildtree(v,2*node+1,mid+1,fin);
      tree[node]=tree[2*node]+tree[2*node+1];
  }

 int sum (int node,int tl,int tr,int l , int r)
   {
       if(l>r) return 0;
       if(l==tl and r==tr) return tree[node];
       int mid=(tl+tr)/2;
       return sum(2*node,tl,mid,l,min(r,mid))+sum(2*node+1,mid+1,tr,max(l,mid+1),r);
   }

  void update(int node,int tl , int tr,int pos,int val)
    {
        if(tl==tr) {tree[node]=val; return;}
        int mid=(tl+tr)/2;
        if(pos<=mid)
              update(2*node,tl,mid,pos,val);
        else
            update(2*node+1,mid+1,tr,pos,val);
        tree[node]=tree[2*node]+tree[2*node+1];

    }
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}
*/


void solve()
{
    ll int i,j=0,r=200,p,q,k,d,y=0,h,flag=1,n,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l;
   cin>>n;
   cout<<n*n*n;

}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
     solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll n, c, k;
vector<ll> t;

int main() {
	cin >> n >> c >> k;
	t.resize(n);
	REP(i, n) {
		cin >> t[i];
	}
	sort(ALL(t));
	ll num = t[0];
	ll ans = 0, cnt = 0;
	REP(i, t.size()) {
		if (cnt == c) {
			ans++;
			num = t[i];
			cnt = 0;
			if (i == t.size() - 1)continue;
		}
		if (t[i] - num <= k) {
			cnt++;
		}
		else {
			ans++;
			num = t[i];
			cnt = 1;
		}
		//cout << t[i] << " " << ans << endl;
	}
	ans++;
	cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  C -= min(C, A - B);
  cout << C << endl;
  return 0;
}



Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 12.12.2019 13:25:11       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, tt;
  cin >> n >> tt;
  while (tt--) {
    int a, b;
    cin >> a >> b;
    if (n == 1) {
      cout << min(a, b) << '\n';
      continue;
    }
    --a; --b;
    while (a != b) {
      if (a > b) {
        a = (a - 1) / n;
      } else {
        b = (b - 1) / n;
      }
    }
    cout << a + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 1280
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
        int a[]=new int[n-1];
        int f[]=new int[n+1];
        for(int i=0;i<n-1;i++){
            a[i]=s.nextInt();
            f[a[i]]++;
        }
        int c=0;
        int prev=1;
      //  System.out.println
        for(int i=1;i<=n;i++){
            
                System.out.println(f[i]);
               
            }
        
	}
}

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

int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    for (long long i=0; i<N; i++) cin >> A.at(i);
    long long temoti = 1000;
    for (int i=0; i<N-1; i++) {
        long long stock = 0;
        if (A.at(i) < A.at(i+1)) stock = temoti/A.at(i);
        temoti += (A.at(i+1)-A.at(i)) * stock;
    }
    cout << temoti;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <stack>
#define pb push_back
// #define pop pop_back
#define ll long long int
#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, a, b) for (ll i = a; i <= b; i++)
#define repr(i, a, b) for (ll i = a; i >= b; i--)
#define I long_max
#define pii pair<int, int>
#define pll pair<long, long>
#define vpair vector<pair<int, int>>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fir first
#define sec second
#define d (int)1e9 + 7
#define INF (int)2e9 + 1
#define el "\n"
#define fs fastscan

#define vrep(vec) for (const auto &value : vec)
#define arep(arrat) for (const auto &value : array)
using namespace std;

bool sortinrev(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.first > b.first);
}
void swap(int *a, int *b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

//over

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

ll dfs(ll n, vector<vector<ll>> &adj, vector<ll> &dp)
{
    for (ll j = 0; j < adj[n].size(); j++)
    {
        if (dp[adj[n][j]] == -1)
        {
            if (dp[n] == -1)
            {
                dp[n] = 0;
            }
            dp[n] = max(dp[n], 1 + dfs(adj[n][j], adj, dp));
        }
        else
        {
            if (dp[n] == -1)
            {
                dp[n] = 0;
            }
            dp[n] = max(dp[n], 1 + dp[adj[n][j]]);
        }
    }
    if (dp[n] == -1)
    {
        return dp[n] = 0;
    }
    return dp[n];
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //use auto instead of data types
    {
        ll n, m;
        cin >> n >> m;
        vector<vector<char>> a(n, vector<char>(m, 0));
        rep(i, n)
        {
            rep(j, m)
            {
                cin >> a[i][j];
            }
        }
        vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
        dp[n-1][m-1] = 1;
        for(int i = n-1;i>=0;i--){
            for(int j = m-1;j>=0;j--){
                if(a[i][j] == '.'){
                    dp[i][j] = dp[i][j] + dp[i+1][j] + dp[i][j+1];
                    dp[i][j] = dp[i][j] % int(1e9+7);
                }
            }
        }
        // ll count = 0;
        
        cout << dp[0][0] << endl;
    }
    return 0;
}

Measured memory_bytes: 12040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;

    static int divisors[1 << 24];
    for (int i = 1; i < 1 << 24; ++i) {
        for (int j = 1; i*j <=n; ++j) {
            divisors[i*j] += 1;
        }
    }

    ll ans = 0;
    for(int i = 1; i < n+1; ++i) {
        ans += ll(i) * divisors[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 42672
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using Point = pair<double, double>;
bool compare_y(Point a, Point b) { return a.second < b.second; }

double closest_pair(vector<Point> &points, int l, int r) {
    if(r - l <= 1) return 1e100;
    int mid = (l + r) / 2;
    double x = points[mid].first;
    double d = min(closest_pair(points, l, mid), closest_pair(points, mid, r));
    auto iti = points.begin(), itl = iti + l, itm = iti + mid, itr = iti + r;
    inplace_merge(itl, itm, itr, compare_y);

    vector<Point> near_line;
    for(int i=l; i<r; i++) {
        if(abs(points[i].first - x) >= d) continue;

        int sz = near_line.size();
        for(int j=sz-1; j>=0; j--) {
            double dx = points[i].first  - near_line[j].first;
            double dy = points[i].second - near_line[j].second;
            if(dy >= d) break;
            d = min(d, sqrt(dx * dx + dy * dy));
        }
        near_line.push_back(points[i]);
    }
    return d;
}

int main() {
    int N; scanf("%d", &N);
    vector<Point> points;
    for(int i=0; i<N; i++) {
        double x, y; scanf("%lf%lf", &x, &y);
        points.emplace_back(x, y);
    }
    sort(points.begin(), points.end());
    printf("%.12f\n", closest_pair(points, 0, N));
    return 0;
}



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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
int factorial(int n)
{
    ll ans = 1;
    for (ll i = 1; i <=n; i++)
    {
        ans *= i;
        ans %= MOD;
    }
    ans %= MOD;
    return ans;
}

int main()
{
    int n,m;
    cin >> n >> m;
    ll ans;
    // 常にn>m
    if(n<m)
    {
        swap(n,m);
    }
    if(n-m>=2)
    {
        cout << 0 << endl;
        return 0;
    }
    if(n==m)
    {
        ll temp = factorial(n);
        ans = (2*temp*temp)%MOD;
    }
    if(n>m)
    {
        ll temp = factorial(m);
        ll temp2 = factorial(m)*(ll)n%MOD;
        ans = temp*temp2%MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	long long int y = 100, x;
	long int f = 0, i = 1;
	scanf("%lld", &x);
	while (f == 0) {
		y = y*1.01;
		if (y >= x) {
			f++;
		}
		else {
			i++;
		}
	}
	printf("%ld", i);
}

Measured memory_bytes: 2152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

int main() {
	cin >> n;
	if (n % 10 == 9 || n / 10 == 9)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[n-1];
		int[] s = new int[n-1];
		int[] f = new int[n-1];
		int[] t = new int[n];
		for(int i=0; i<n-1; i++){
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		for(int i=0; i<n-1; i++){
			for(int j=i; j<n-1; j++){
				if(t[i]<s[j])t[i] = s[j];
				else {
					if((t[i]-s[j])%f[j]==0)t[i] =  s[j] + ((t[i]-s[j])/f[j])*f[j];
					else t[i] = s[j] + ((t[i]-s[j])/f[j] + 1)*f[j];
				}
				t[i] += c[j];
			}
		}
		for(int i=0; i<n; i++){
			System.out.println(t[i]);
		}
	}
}

Measured memory_bytes: 25612
import heapq

def solve():
    n = int(input())
    hp = 0
    ord_l = [[] for _ in range(n)]
    ord_r = [[] for _ in range(n)]
    bd_l, bd_r = 0, 0
    for _ in range(n):
        k, l, r = map(int, input().split())
        if k == n:
            hp += l
            continue
        if l == r:
            hp += l
            continue

        hp += min(l, r)
        if l > r:
            ord_l[k-1].append(l-r)
            bd_l = max(bd_l, k)
        else:
            ord_r[k].append(r-l)
            bd_r = max(bd_r, n-k)

    ord_l = ord_l[:bd_l][::-1]
    ord_r = ord_r[-bd_r:]

    left = []
    heapq.heapify(left)
    for i in range(bd_l):
        for x in ord_l[i]:
            heapq.heappush(left, -x)
        if left:
            hp += (heapq.heappop(left)*(-1))
    
    right = []
    heapq.heapify(right)
    for i in range(bd_r):
        for x in ord_r[i]:
            heapq.heappush(right, -x)
        if right:
            hp += (heapq.heappop(right)*(-1))
    print(hp)


def main():
    t = int(input())
    for _ in range(t):
        solve()

main()

Measured memory_bytes: 49680
// Bismillahir Rahmanir Rahim
// Mr_Emrul

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

typedef long long int ll;
typedef pair <ll, ll> pll;
typedef pair <ll, pll> plp;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
const ll MX = 1000005;

#define LCM(a,b)        (a / __gcd(a,b) ) *-b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a,n,sizeof(a))
#define for1(i, n)      for(i=1; i<=n; i++)
#define for0(i, n)      for(i=0; i<n; i++)
#define rof0(i, n)      for(i=n-1; i>=0; i--)
#define rof1(i, n)      for(i=n; i>=1; i--)
#define forab(i, a, b)  for(i=a; i<=b; i++)
#define rofab(i, a, b)  for(i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)          getline(cin, s)
#define scf(a)          cin >> a
#define scf2(a, b)      cin >> a >> b
#define scf3(a, b, c)   cin >> a >> b >> c
#define scf4(a,b,c,d)   cin >> a >> b >> c >> d
#define pnf(a)          cout << (a) << endl
#define pnf2(a, b)      cout << (a) << " " << (b) << endl
#define pnf3(a, b, c)   cout << (a) << " " << (b) << " " << (c) << endl
#define pnfa(a)         cout << (a) << " "
#define pf(a)           cout << (a)
#define sp              cout << " "
#define nl              cout << endl
#define sz(n)           n.size()
#define clear(v)        v.clear()
#define bug(n)          cout << ">> " << n << " <<" << endl
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("in.txt", "r", stdin)
#define out             freopen("out.txt", "w", stdout)
#define fast            {ios_base::sync_with_stdio(false); cin.tie(0);}
#define F               first
#define S               second
#define mpp             make_pair

int main()
{
    ll n, cur, m, t, x, flg=0, sum=0, s, i;
    scf2(n, t);
    cur=-t;
    for1(i, n)
    {
        scf(x);
        sum += min(x-cur,t);
        cur = x;

    }
    pnf(sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n;
	cin>>n;
	vvl dp(n,vl(3));
	ll a,b,c;
	cin>>a>>b>>c;
	dp[0][0]=a;dp[0][1]=b;dp[0][2]=c;
	for(int i=1;i<n;i++){
		cin>>a>>b>>c;
		dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

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

using namespace std;

int f[200010],sz[200010];

int zzs(int u)
{
	return f[u]==u?u:f[u]=zzs(f[u]);
}
void sq(int u,int v)
{
	int a,b;
	a=zzs(u);
	b=zzs(v);
	if(a!=b)
		f[b]=a;
}
int main()
{
	int n,m,u,v,sn=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		f[i]=i;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		sq(u,v);
	}
	for(int i=1;i<=n;i++)
	{
		sz[zzs(i)]++;
	}
	for(int i=1;i<=n;i++)
	{
		sn=max(sn,sz[i]);
	}
	printf("%d\n",sn);	
	return 0;
}

Measured memory_bytes: 5276
s = input()
x = len(s)

ans = 0
for i in range(x):
    for j in range(i + 1, x + 1):
        t = s[i:j]
        y = len(t)
        for ss in 'ACGT':
            t = t.replace(ss, '')
        if t == '':
            ans = max(ans, y)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#define N 10005
using namespace std;

typedef long long ll;
ll n, i, a[100];
int main()
{
	cin >> n;
	a[0] = 2;
	a[1] = 1;
	for (i = 2; i <= n; i++) a[i] = a[i - 1] + a[i - 2];
	cout << a[n];
    return 0;
}


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

int main()
{
	int n, d2, d4,a;
	d2 = d4 = 0;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (a % 2 != 0)
			d2++;
		if (a % 4 == 0)
			d4++;
	}

	if (d2 + d4 == n)
	{
		if (d2 <= d4 + 1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	else
	{
		if (d4 >= d2)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    n = int(input())
    s = input()

    x = 0
    result = 0

    for si in s:
        if si == 'I':
            x += 1
            result = max(x, result)
        elif si == 'D':
            x -= 1
            result = max(x, result)

    print(result)


Measured memory_bytes: 2940
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    a = [0] * n
    MOD = 10 ** 9 + 7
    for _ in range(m):
        a[int(input())] = 1
    dp = [0] * (n+1)
    dp[0] = 1
    for i in range(n):
        dp[i] %= MOD
        if a[i]:
            dp[i] = 0
        if i + 1 <= n:
            dp[i+1] += dp[i]
        if i + 2 <= n:
            dp[i+2] += dp[i]
    print(dp[-1]%MOD)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 13428
#include<stdio.h>
int main()
{
    int n,s=0,a,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        s+=a;
    }
    s-=n;
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	lli n,k;
	cin >> n >> k;
	lli a[n+1];
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	lli dp[n+1];
	dp[0]=0;
	dp[1]=0;
	lli low,high,t;
	for(lli i=2;i<=n;i++){
		low=i-1;high=i;t=k;
		dp[i]=100000000000000;
		while(t--){
			if(low<1)	break;
			dp[i]=min(dp[i],dp[low]+abs(a[low]-a[high]));
			low--;
		}
	}
	cout<<dp[n];



	return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>


#define fs first
#define sc second

using namespace std;

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

#define MAX_V 210
#define INF LONG_LONG_MAX

// 行き先、容量、逆辺(反対側の辺)
struct edge{int to, rev; ll cap;};

vector<edge> G[MAX_V];  //グラフ
ll level[MAX_V];   //sからの距離
int iter[MAX_V];   //どこまで調べ終わったか

// fromからtoへ向かう容量capの変をグラフに追加する
void add_edge(int from, int to, ll cap){
    G[from].push_back((edge){to, G[to].size(), cap});
    G[to].push_back((edge){from, G[from].size()-1, 0});
}

// sからの最短距離をBFSで計算する
void bfs(int s){
    fill(level, level+MAX_V, -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int i = 0; i < G[v].size(); i++){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをDFSで探す
ll dfs(int v, int t, ll f){
    if(v == t)  return f;
    for(int &i = iter[v]; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            ll d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}


ll max_flow(int s, int t){
    ll flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0){
            return flow;
        }
        fill(iter, iter+MAX_V, 0);
        ll f;
        while((f = dfs(s, t, INF)) > 0){
            flow += f;
        }
    }
}




int main(){
    int N;
    cin >> N;
    int a[100], b[100], c[100], d[100];
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < N; i++){
        cin >> c[i] >> d[i];
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(a[i] < c[j] && b[i] < d[j]){
                add_edge(i, j+N, 1);
            }
        }
    }

    for(int i = 0; i < N; i++){
        add_edge(2*N, i, 1);
        add_edge(i+N, 2*N+1, 1);
    }

    cout << max_flow(2*N, 2*N+1) << endl;

    return 0;

}


Measured memory_bytes: 384
a, b, c = map(int, input().split())

i = 0
while True:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(i)
        break
    elif a == b == c:
        print(-1)
        break
    a_h = a / 2
    b_h = b / 2
    c_h = c / 2
    a = b_h + c_h
    b = a_h + c_h
    c = a_h + b_h
    i += 1

Measured memory_bytes: 3064
N = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
ans = 0

for i in range(N):
  if list_a[i] <= list_b[i]:
    ans += list_a[i]
    list_b[i] -= list_a[i]
    list_a[i] = 0
    #print(list_a, list_b)
    if list_a[i+1] <= list_b[i]:
      ans += list_a[i+1]
      list_a[i+1] = 0
    else:
      ans += list_b[i]
      list_a[i+1] -= list_b[i]
  else:
    ans += list_b[i]

print(ans)
      

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

typedef long long lint;

int main(void){
    lint arr[4];
    for(int i=0;i<4;i++)scanf("%lld",&arr[i]);
    lint n;scanf("%lld",&n);
    lint k1=4*arr[0];
    lint k2=2*arr[1];
    lint k3=arr[2];
    lint k=min(k1,min(k2,k3));
    lint ans;
    if(k*2<=arr[3])ans=k*n;
    else{
        lint N=n/2;
        lint mod=n%2;
        ans=N*arr[3]+mod*k;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000
#define inf 1000000000
#define NIL -1
#define BLACK 2
#define GRAY 1
#define WHITE 0

int n,A[N][N];

int prime(n,w)
{
  int i,v,u,mincost,d[N],pi[N],color[N],sum;

  for(i = 0;i < n;i++){
    d[i] = inf;
    pi[i] = NIL;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = inf;
    u = NIL;
    for(i = 0;i < n;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == inf) break;

    color[u] = BLACK;

    for(v = 0;v < n;v++){
      if(color[v] != BLACK && A[u][v] != inf){
	if(d[v] > A[u][v]){
	  pi[v] = u;
	  d[v] = A[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  sum = 0;
  for(i = 0;i < n;i++){
    if(pi[i] != NIL) sum += A[i][pi[i]];
  }
  return sum;
}
    
int main()
{
  int i,j,e;

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    {
      for(j = 0;j < n;j++)
	{
	  scanf("%d",&e);
	  A[i][j] = (e == NIL) ? inf : e;
	}
    }

  printf("%d\n",prime(n,A));

  return 0;
}

  



Measured memory_bytes: 2192
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct restaurant {
  int index;
  string city;
  int score;
  bool operator<(const restaurant& r) const {
    if (city == r.city) return score > r.score;
    return city < r.city;
  };
};
int main() {
    int N;
    cin >> N;
    restaurant r[100];
    for (int i = 0; i < N; i++) {
      r[i].index = i + 1;
      cin >> r[i].city >> r[i].score;
    }
    sort(r, r + N);
    for (int i = 0; i < N; i++) cout << r[i].index << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
long long n, a, b, K; vector<pair<long long, long long>>vec;
int main() {
	cin >> n >> K;
	for (int i = 0; i < n; i++) {
		cin >> a >> b; vec.push_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < vec.size(); i++) {
		K -= vec[i].second;
		if (K <= 0) { cout << vec[i].first << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 2420
function swap(items, leftIndex, rightIndex){
    var temp = items[leftIndex];
    items[leftIndex] = items[rightIndex];
    items[rightIndex] = temp;
}
function partition(items, left, right) {
    var pivot   = items[Math.floor((right + left) / 2)], //middle element
        i       = left, //left pointer
        j       = right; //right pointer
    while (i <= j) {
        while (items[i] < pivot) {
            i++;
        }
        while (items[j] > pivot) {
            j--;
        }
        if (i <= j) {
            swap(items, i, j); //sawpping two elements
            i++;
            j--;
        }
    }
    return i;
}

function quickSort(items, left, right) {
    var index;
    if (items.length > 1) {
        index = partition(items, left, right); //index returned from partition
        if (left < index - 1) { //more elements on the left side of the pivot
            quickSort(items, left, index - 1);
        }
        if (index < right) { //more elements on the right side of the pivot
            quickSort(items, index, right);
        }
    }
    return items;
}
  // inputに入力データ全体が入る
  function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");

  for(i=0; i<input.length; i++){
    tmp = input[i].split(" ");
    for(j=0; j<tmp.length; j++){
      tmp[j] = Number(tmp[j]);
    }
    input[i] = tmp;
  }

	//文字列から10進数に変換するときはparseIntを使います
  var X = input[0][0];
  var Y = input[0][1];
  var A = input[0][2];
  var B = input[0][3];
  var C = input[0][4];

  var eatR = [];
  var eatG = [];

  input[1] = quickSort(input[1], 0, input[1].length-1);
  input[2] = quickSort(input[2], 0, input[2].length-1);
  input[3] = quickSort(input[3], 0, input[3].length-1);

  input[1].reverse();
  input[2].reverse();
  input[3].reverse();
  // console.log(input[1]);
  // console.log(input[2]);

  for(i=0; i<X; i++){
    eatR[i] = input[1][i];
  }
  for(i=0; i<Y; i++){
    eatG[i] = input[2][i];
  }


  var merge = eatR.concat(eatG);
  merge = quickSort(merge, 0, merge.length-1);

  i=0;
  for(j=0; j<merge.length; j++){
    if(input[3][i] > merge[j]){
      merge[j] = input[3][i];
      i++;
      if(i>=C) break;
    }
    else break;
  }


  var sum=0;
  for(i=0; i<merge.length; i++){
    sum += merge[i];
  }

	//出力
	console.log('%d',sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35644
#include <stdio.h>

int main(void)
{
    char s[100001];
    int i, j;
    int bit;
    int count;
    int a, b;

    scanf("%s", &s);

    count = 0;
    a = 0;
    b = 0;
    while(s[count] != NULL){
        bit = s[count] - '0';

        if((count&1) == 0){
            if(bit == 0){
                a++;
            }else{
                b++;
            }
        }else{
            if(bit == 1){
                a++;
            }else{
                b++;
            }
        }
        count++;
    }

    if(a > b){
        printf("%d", b);
    }else{
        printf("%d", a);
    }

    return 0;
}


Measured memory_bytes: 256
s = input()

d = [False for _ in range(4)]

for c in s:
    if c == 'N':
        d[0] = True
    elif c == 'S':
        d[1] = True
    elif c == 'W':
        d[2] = True
    else:
        d[3] = True

if d[0] ^ d[1] or d[2] ^ d[3]:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	char str[256];

	cin >> str;

	if (str[2] == str[3] && str[4] == str[5])
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, w;
  cin >> n >> w;
  vector<pair<int, long long>> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i].first >> p[i].second;
  long long dp[n + 1][w + 1];
  for (int i = 0; i <= w; i++)
    dp[0][i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= w; j++) {
      dp[i + 1][j] = dp[i][j];
      if (j > 0) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - 1]);
      }
      if (j - p[i].first < 0)
        continue;
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - p[i].first] + p[i].second);
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}


Measured memory_bytes: 79104
#include<iostream>

using namespace std;

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

  for(int x=0;x<=N;x++){
    for(int y=0;y<=N-x;y++){
      int z = N - x - y;
      int kane = 10000*x + 5000*y + 1000*z;
      if(kane == Y){
	cout << x << " " << y << " " << z << endl;
	return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  
}

Measured memory_bytes: 256
var
	n,i,x,y:Integer;
	a,b,c,d:int64;
begin
	read(n);
	a:=1;
	b:=1;
	for i:=1 to n do begin
		read(x,y);
		c:=(a-1)div x+1;
		d:=(b-1)div y+1;
		if c<d then c:=d;
		a:=c*x;
		b:=c*y;
	end;
	writeln(a+b);
end.


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



signed main(void){
    int x; cin >> x;
    vector<int>sosuu;
    for(int i=2;i<1e5+4;i++){
        bool flag = true;
        for(int j=0;j<sosuu.size();j++){
            if (i%sosuu[j]==0){
                flag = false;
                break;
            }
        }
        if (flag == true){
            sosuu.push_back(i);
        }
    }
    for(int i=0;i<sosuu.size();i++){
        if (x <= sosuu[i]){
            cout << sosuu[i] << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<pii> lr(n);
	trav(pa, lr) cin >> pa.first >> pa.second;
	sort(all(lr));

	int mx = 0;

	auto f = [&](int piv){
		// sätt ls i [1,piv), rs i [piv, m]
		// 1 <= piv <= m+1
		int l = 0, r = 0;
		int ix = n-1;
		priority_queue<int> rs;
		rrep(pos,0,piv){
			while(ix>=0 && lr[ix].first >= pos){
				rs.push(lr[ix].second);
				--ix;
			}
			if(pos==0) continue;
			if(!rs.empty()){
				++l;
				rs.pop();
			}
		}
		rrep(pos,piv,m+1){
			while(!rs.empty() && rs.top() > pos)
				rs.pop();
			if(rs.empty()) break;
			++r;
			rs.pop();
		}
		mx = max(mx, l+r);
		return pii(l,r);
	};

	int lo = 1, hi = m+2;
	while(lo+1 < hi){
		int mi = (lo+hi)/2;
		pii pa = f(mi);
		if(pa.first != mi-1) hi = mi;
		else lo = mi;
	}
	f(lo);
	cout << n-mx << endl;
}

Measured memory_bytes: 3692
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	string str, ans = "CODEFESTIVAL2016";
	cin >> str;
	int cnt = 0;
	rep(i, str.size()) if (str[i] != ans[i]) cnt++;


	cout << cnt << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 504
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	str := ""
	if a < b {
		for i := 0; i < b; i++ {
			str += string(rune(int('0') + a))
		}
	} else {
		for i := 0; i < a; i++ {
			str += string(rune(int('0') + b))
		}
	}
	fmt.Printf("%s\n", str)
}


Measured memory_bytes: 512
def main():
    N = int(input())
    C = list(input())
    R_cnt = C.count("R")#Rの個数を数える
    #方針 RR...RWWW...Wの形になれば良いので
    #RR..WRWR/WWW...RRWW  ・・・/の位置がRの個数番目であれば, そこまでのWの個数分「/」の右側のRと交換すればよい
    cnt = 0
    for i in range(R_cnt):
        if C[i] == "R":
            cnt+=1
    print(R_cnt - cnt)

if __name__ == "__main__":
    main()

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)

int n;
const int maxN = 2005;
pii arr[maxN];
int dp[maxN][maxN];

int res(int ind = 0, int left = 0, int right = n - 1) {
	if (ind == n or left < 0 or right >= n) {
		return 0;
	}
	int &ans = dp[left][right];
	if (ans == -1) {
		ans = abs(left - arr[ind].sc) * arr[ind].fs + res(ind + 1, left + 1, right);
		ans = max(ans, abs(right - arr[ind].sc) * arr[ind].fs + res(ind + 1, left, right - 1));
	}
	return ans;
}

int32_t main() { fastio;
	cin >> n;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].fs;
		arr[i].sc = i;
	}
	sort(arr, arr + n, greater<pii>());
	cout << res() << endl;
	return 0;
}


Measured memory_bytes: 35200
n = readline.to_i
h = readline.split.map!(&:to_i)
flg = true
max_h = h[0]
(1..n-1).each do |i|
  if (max_h - h[i]) >= 2 then
    flg = false
    break
  end
  if max_h < h[i] then
    max_h = h[i]
  end
end
print(flg ? "Yes" : "No")


Measured memory_bytes: 7812
import heapq


class Job:

    def __repr__(self):
        return "%d,%d".format(self.days, self.reward)

    def __lt__(self, other):
        return self.reward < other.reward

    def __init__(self, job_id, reward, days):
        self.id = job_id
        self.reward = reward
        self.days = days

N, M = list(map(int, input().split()))
h = []
jobs = []

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.append(Job(job_id=i, reward=B, days=A))


jobs = sorted(jobs, key=lambda j: j.days)
idx = 0
c = 0

for i in range(1, M+1):
    while idx < N and jobs[idx].days <= i:
        heapq.heappush(h, -jobs[idx].reward)
        idx += 1

    if len(h) != 0:
        c += -heapq.heappop(h)

print(c)


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

using namespace std;

int N, M;
vector<int> z;
int Land[210][210];
int Sea[210][210];
long long dp[1001][210];

#define INF (1<<29)

int main() {
  
  while(cin >> N >> M && (N|M)) {
    z.clear();
    for(int i=0; i<N; i++) {
      Land[i][i] = Sea[i][i] = 0;
      for(int j=i+1; j<N; j++) {
	Land[i][j] = Land[j][i] = INF;
	Sea[i][j] = Sea[j][i] = INF;
      }
    }
    
    for(int i=0; i<M; i++) {
      int x, y, t; char sl;
      cin >> x >> y >> t >> sl; x--, y--;
      if(sl == 'L') {
	Land[x][y] = Land[y][x] = min(Land[x][y], t); // taju hen ari
      }
      else {
	Sea[x][y] = Sea[y][x] = min(Sea[x][y], t); // taju hen ari
      }
    }
    
    int R; cin >> R;
    z.resize(R);
    for(int i=0; i<R; i++) {
      cin >> z[i]; z[i] --;
    }
    
    // warshall floyd
    for(int k=0; k<N; k++)
      for(int i=0; i<N; i++)
	for(int j=0; j<N; j++) {
	  Land[i][j] = min(Land[i][j], Land[i][k]+Land[k][j]);
	  Sea[i][j] = min(Sea[i][j], Sea[i][k]+Sea[k][j]);
	}
    
    fill(dp[0], dp[0]+1001*210, INF);
    dp[0][z[0]] = 0;
    for(int i=1; i<R; i++) {
      for(int u=0; u<N; u++) {
	for(int v=0; v<N; v++) {
	  dp[i][v] = min(dp[i][v], dp[i-1][u] + Land[z[i-1]][u] + Sea[u][v] + Land[v][z[i]]);
	  dp[i][v] = min(dp[i][v], dp[i-1][v] + Land[z[i-1]][z[i]]);
	}
      }
    }
    
    cout << *min_element(dp[R-1], dp[R]) << endl;
  }
  return 0;
}

Measured memory_bytes: 3180
#include <iostream>

int main(){
 int X,Y;
 std::cin>>X>>Y;

 if(Y%2==1){
  std::cout<<"No"<<std::endl;
 }else{
  if(Y/2-X>=0 && 2*X-Y/2>=0){
   std::cout<<"Yes"<<std::endl;
  }else{
   std::cout<<"No"<<std::endl;
  }
 }

 return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int n = Integer.parseInt(sc.next());
		int taroScore = 0, hanakoScore = 0;
		for (int i=0; i < n; i++) {
			String taro = sc.next(), hanako = sc.next();
			if (taro.compareToIgnoreCase(hanako) < 0) hanakoScore += 3;
			else if (taro.compareToIgnoreCase(hanako) > 0) taroScore += 3;
			else { taroScore++; hanakoScore++; }
		}
		sc.close(); System.out.println(taroScore + " " + hanakoScore);
	}
}

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


int main() {
string s;
int q;
cin >> s >> q;
  int cnt = 0;

rep(i,q) {
  int t;
  cin >> t;
  if (t == 1) {
    cnt++;
  } else {
    int f;
    char c;
    cin >> f >> c;
    if (f == 1 && cnt % 2 == 0 || f ==2 && cnt %2 == 1) {
      string k;
      k.push_back(c);
      k += s;
      s = k;
    }else {
      s.push_back(c);
    }
  }
}
if (cnt % 2 == 1) reverse(s.begin(),s.end());
cout << s << endl;

return 0;
}



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

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmp(const pair<string, pair<int, int>> left, pair<string, pair<int, int>> right) {
if(left.first != right.first)
	return left.first < right.first;
	else return left.second.second > right.second.second;
}

int main() {
	int n;
	cin >> n;
	vector<pair<string,pair<int,int>>> str(n);
	rep0(i, n) {
		cin >> str[i].first >> str[i].second.second;
		str[i].second.first = i;
	}

	sort(all(str),cmp);
	rep0(i, n) cout <<  str[i].second.first+1 <<endl;
}


Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}




signed main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for(auto& x : a)
        cin >> x;
    sort(a.begin(), a.end());

    auto f = [&](i64 val){
        i64 cnt = 0;
        for(int i = 0; i < n; ++i){
            int dist = 0;
            if(a[i] == 0){
                dist = (val >= 0 ? (n - i - 1) : 0);
            }
            else if(a[i] > 0){
                int ok = i, ng = n;
                while(ng - ok > 1){
                    int j = (ok + ng) / 2;
                    (a[i] * a[j] <= val ? ok : ng) = j;
                }
                dist = ok - i;
            }
            else{
                int ok = n, ng = i;
                while(ok - ng > 1){
                    int j = (ok + ng) / 2;
                    (a[i] * a[j] <= val ? ok : ng) = j;
                }
                dist = (n - ok);
            }
            cnt += dist;
        }
        return cnt >= k;
    };

    i64 ng = -INF, ok = INF;
    while(abs(ok - ng) > 1){
        i64 mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit
def solve(N, W, w, v):
    dp = np.full(shape=(N + 1, np.sum(v) + 1), fill_value=(N * W), dtype=np.int64)
    dp[:, 0] = 0
    for i in range(N):
        # TODO: use out keyward
        dp[i + 1][:v[i]] = np.minimum(w[i], dp[i][:v[i]])
        dp[i + 1][v[i]:] = np.minimum(w[i] + dp[i][: - v[i]], dp[i][v[i]:])
    return np.where(dp[-1] <= W)[0][-1]


def main():
    N, W = map(int, input().split())

    w = np.empty(shape=N, dtype=np.int64)
    v = np.empty(shape=N, dtype=np.int64)
    for i in range(N):
        w[i], v[i] = map(int, input().split())

    ans = solve(N, W, w, v)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 200124
#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() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a.at(i);
  vector<ll> b(n);
  rep(i,n) cin >> b.at(i);
  ll ans = 0;
  rep(i,n) {
    if(b.at(i)<=a.at(i)) ans += b.at(i);
    else {
      if(b.at(i)-a.at(i)>=a.at(i+1)) {
        ans += (a.at(i) + a.at(i+1));
        a.at(i+1) = 0;
      }
      else {
        ans += b.at(i);
        a.at(i+1) -= (b.at(i)-a.at(i));
      }
    }
  }
  cout << ans << endl;
  return 0; 
}

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

int main() {
	int K, S;
	cin >> K >> S;
	int sum = 0;
	for (int X = 0;X <= K;X ++) {
		for (int Y = 0;Y <= K;Y ++) {
			if (S - X - Y >= 0 && S - X - Y <= K) sum ++; // X+Y+Z=Sを満たすZが存在する
		}
	}
	cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

変数が2個以上ある時は、まずいくつかを固定して考えると良い
今回の場合、XとYが確定しているときにZ=S-X-Yを満たすZが0<=Z<=Kであれば1通り存在
これを全てのXとYについて行えば良い
オーダーはO(K^2)
*/

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>

void solve(int a[310][310], int n, int m)
{
	int values[310] = { 0 }, maxRating, maxValues = 0, maxIndex = 0, ans = INT_MAX;
	bool visited[310] = { 0 };
	
	maxRating = m;
	while (maxRating--)
	{
//		std::cout << "\n";
		int values[310] = { 0 }, popularSport = 0, indexOfPopularSport = 0;
		for (int i = 0; i < n; ++i)
		{
			int chosenSport = INT_MAX, minOfChosenSport = INT_MAX;
			for (int j = 0; j < m; ++j)
			{
				if (!visited[a[i][j]])
				{
					if (j < chosenSport)
					{
						chosenSport = j;
						++values[a[i][j]];
						
						if (values[a[i][j]] > popularSport)
						{
							popularSport = values[a[i][j]];
							indexOfPopularSport = a[i][j];
						}
					}
				}
			}
		}
		
		if (popularSport < ans)
			ans = popularSport;
		
		visited[indexOfPopularSport] = true;
	}
	
	std::cout << ans;
}

int main()
{
	int n, m, a[310][310], values[310] = { 0 }, maxRating = INT_MAX, maxValues = 0, maxIndex = 0;
	bool visited[310] = { 0 };
	std::cin >> n >> m;
	
	maxRating = m;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			std::cin >> a[i][j];
			if (a[i][j] == maxRating)
				++values[i];
			if (values[i] > maxValues)
			{
				maxValues = values[i];
				maxIndex = maxValues;
			}
		}
	}
	
	solve(a, n, m);
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b)
        printf("a > b\n");
    if(a==b)
        printf("a == b\n");
    if(a<b)
        printf("a < b\n");
    return 0;
}

Measured memory_bytes: 580
n=int(input())
a_list = list(map(int,input().split()))

count = 0
for i in range(n):
    if a_list[i] % 2 == 0:
        if (a_list[i] % 3 != 0) and (a_list[i] % 5 != 0):
            count += 1

if count == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<int> A(N+1);
	for (int i = 0; i < N; ++ i) {
		A[i+1] = A[i];
		if (S[i] == 'E') ++ A[i+1];
	}
	int r = 1 << 30;
	for (int i = 0; i < N; ++ i) {
		int x = i - A[i];
		int y = A[N] - A[i+1];
		r = min(r, x+y);
	}
	cout << r << endl;
}


Measured memory_bytes: 1796