akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){ 
    int x;
    cin>>x;
    if(x==3||x==5||x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;    return 0;
}


/*
abcde


*/


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

int main() {
  string s;
  cin >> s;
  
  rep(i,s.length())
    cout << "x";
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
string s,t;
int a[110],b[110];
bool f=1;

int main(){
	cin>>s>>t;
	int sl=s.length(),tl=t.length();
	for(int i=1;i<=sl;i++)a[i]=s[i-1];
	for(int i=1;i<=tl;i++)b[i]=t[i-1];
	sort(a+1,a+1+sl);sort(b+1,b+1+tl);
    if(a[1]>b[tl]){
    	cout<<"No";return 0;
	}
	else if(a[1]<b[tl]){
		cout<<"Yes";return 0;
	}
	else {
		int i;
		for(i=1;i<=min(sl,tl);i++){
			if(s[i]!=t[i]){
				if(s[i]>t[i]){
					cout<<"No";return 0;
				}
				else if(t[i]<s[i]){
					cout<<"Yes";return 0;
				}
			}
		}
			
		}
	if(sl<tl){
	cout<<"Yes";return 0;}
	else {
	cout<<"No";return 0;}
}

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

using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long

ll k;
int n;
ll a[111];
int main(){
	cin>>k;
	
	n=50;
	rep(i,n)a[i]=n-1;
	
	rep(i,n){
		a[i]+=k/n;
	}

	rep(i,k%n){
		rep(j,n){
			if(i==j)a[j]+=n;
			else a[j]--;
		}
	}

	cout<<n<<endl;
	rep(i,n){
		cout<<a[i];
		if(i==n-1)cout<<endl;
		else cout<<" ";
	}
	return 0;
}


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

int main(){
int N;
  cin>>N;
  vector<string>W(N);
  for(int i=0; i<N; i++){
   cin>>W[i]; }
  
  bool ans=true;
  for(int i=0; i<N; i++){
   for(int j=i+1; j<N; j++){
    if(W[i]==W[j]){ans=false;}
   }
  }
  
  for(int i=0; i<N-1; i++){ // W[i]入力時のiの数値と合わせる必要がある
    if(W[i].back()!=W[i+1].front()){ans=false;}
  }  // .back()と.front()で末尾と先頭の指定ができる
 
 if(ans){cout<<"Yes";}
 else{cout<<"No";} 
}

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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int L;
  cin>>L;
  vector<vector<int>> dp(N,vector<int>(17));
  for(int j=0;j<17;j++){
    for(int i=0;i<N;i++){
      if(j==0){
        if(p[i]+L>=p[N-1]){
          dp[i][0]=N-1;
        }
        else{
          int b=lower_bound(p.begin(),p.end(),p[i]+L+1)-p.begin();
          dp[i][0]=b-1;
        }
      }
      else{
        dp[i][j]=dp[dp[i][j-1]][j-1];
      }
    }
  }
  int Q;
  cin>>Q;
  for(int l=0;l<Q;l++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    if(a>b){
      swap(a,b);
    }
    int Z=1;
    for(int i=16;i>=0;i--){
      if(dp[a][i]<b){
        Z+=(1<<i);
        a=dp[a][i];
      }
    }
    cout<<Z<<endl;
  }
}

Measured memory_bytes: 13752
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  string s = "";
  s += (char)(a[0]-97+65);
  s += (char)(b[0]-97+65);
  s += (char)(c[0]-97+65);
  cout << s << endl;
  return 0;
}


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

int main() {
    int a, b; cin >> a >> b;
    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (a > 0) cout << "Positive" << endl;
    else {
        int num = b - a + 1;
        if (num % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}

Measured memory_bytes: 3548
def d_11(MOD=10**9 + 7):
    from collections import Counter

    class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ["mod", "factorial", "inverse"]

        def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_n + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_n, 0, -1):
                inv_append(inv[-1] * i % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

    N = int(input())
    A = [int(i) for i in input().split()]
    # 重複した数のインデックスを求める
    c = Counter(A).most_common(n=1)[0][0]  # 重複した整数の値を取得
    index = [i for i, x in enumerate(A) if x == c]  # 重複した整数のインデックス
    left = index[0] + 1
    right = index[1] + 1

    comb = Combination(N + 1).combination
    ans = [(comb(N + 1, k) - comb(N - (right - left), k - 1)) % MOD for k in range(1, N + 2)]
    return '\n'.join(map(str, ans))

print(d_11())

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n){
  	cin >> v.at(i);
  }
  int max_e = *max_element(v.begin(), v.end());
  int min_e = *min_element(v.begin(), v.end());
  cout << max_e - min_e << endl;
  return 0;
}

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

using namespace std;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
const long double Pi=acos(-1),e=2.718;
const int N=1e2+10,W=1e5+10,mod=3e7;
ll w[N],v[N],dp[N][W],n,k;
ll solve(int i,int we){
    if(we>k)return -oo;
    if(i==n)return 0;
    ll &ret=dp[i][we];
    if(ret+1)return ret;
    ret = 0;
    ret = max(ret,solve(i+1,we+w[i])+v[i]);
    ret = max(ret,solve(i+1,we));
    return ret;
}
int main()
{
    memset(dp,-1,sizeof dp);
    FASTIO
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    cout << solve(0,0) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 86272
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> s(n);
    for(int i=0; i<n; ++i)
        cin >> s[i];
    sort(s.rbegin(), s.rend());

    vector<long long> dp(x+1, 0);
    dp[x] = 1;
    for(int i=0; i<n; ++i){
        vector<long long> nextDp(x+1, 0);
        for(int a=0; a<=x; ++a){
            int b = a % s[i];
            nextDp[b] += dp[a];
            nextDp[b] %= MOD;
            nextDp[a] += dp[a] * (n - 1 - i);
            nextDp[a] %= MOD;
        }
        dp = move(nextDp);
    }

    long long ans = 0;
    for(int a=0; a<=x; ++a){
        ans += a * dp[a];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;
ll A[200005];

int main(void) {
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A;
    ll max_A = -1;
    rep(i, 0, N) {
        ll a;
        cin >> a;
        A.pb(a);
        max_A = max(a, max_A);
    }
    
    ll l = 0, r = max_A;
    while (r-l>1) {
        ll m = (r+l)/2;
        ll sum = 0;
        rep(i, 0, N) {
            sum += A[i]/m;
            if (A[i]%m==0) sum--;
        }
        if (sum>K) l = m;
        else r = m;
    }
  
    cout << r << "\n";
    return 0;
}



Measured memory_bytes: 5368
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(G, v, visited):
    """G: graph, v: vertex"""
    visited[v] = True
    for c in G[v]:
        if visited[c]:
            continue
        dfs(G, c, visited)


def main():
    N, M = map(int, input().split())
    a = [None] * M
    b = [None] * M
    G = [[] for _ in range(N)]
    for i in range(M):
        a[i], b[i] = map(int, input().split())
        a[i] -= 1
        b[i] -= 1
        G[a[i]].append(b[i])
        G[b[i]].append(a[i])

    ans = 0
    for i in range(M):
        # remove an adge
        G[a[i]].remove(b[i])
        G[b[i]].remove(a[i])

        visited = [False] * N
        visited[0] = True
        dfs(G, 0, visited)

        if visited.count(True) != N:
            ans += 1

        # restore an edge
        G[a[i]].append(b[i])
        G[b[i]].append(a[i])

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  string str;
  cin >> str;
  for(int i = 0 ; i < str.size() ; i++){
    if(str[i] == ',')cout << ' ';
    else cout << str[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll dp[55][55][5000];

signed main(){
	//cout << fixed << setprecision(10);
	 ll n; cin>>n;
	 vl vec(205);
	 rep(i,1,201){
		 ll j=i;
		 while(j<=200){
			 vec[j]+=1;
			j+=i;
		 }
	}
	ll ans=0;
	rep(i,1,n+1)ans+=(vec[i]==8 && i%2==1);
	cout << ans << endl;
	return 0;
}

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

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void getInv(){
  for (int i = 1; i < MAX_N; i++) {
    if (i == 1) inv[i] = 1;
    else {
      inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
      if (inv[i] < 0) inv[i] += mod;
    }
  }
}
void getFactorial(){
  factorial[0] = 1; inv_factorial[0] = 1;
  for (int i = 1; i < MAX_N; i++) {
    factorial[i] = factorial[i-1] * i;
    factorial[i] %= mod;
    inv_factorial[i] = inv_factorial[i-1] * inv[i];
    inv_factorial[i] %= mod;
  }
}

long long combination(int n, int r) {
  long long ret = factorial[n] * inv_factorial[r];
  ret %= mod;
  ret *= inv_factorial[n-r];
  return ret % mod;
}

int main(){
  getInv(); getFactorial();
  int n, m; cin >> n >> m;
  long long ans = 1;
  for (int i = 2; i * i <= m; i++) {
    int cnt = 0;
    while (m % i == 0) {
      cnt++; m /= i;
    }
    if (cnt == 0) continue;
    ans *= combination(cnt+n-1, n-1); ans %= mod;
  }
  if (m != 1) {
    ans *= combination(n, n-1); ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

int main() {
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

vector<P> prime_fact(int n) {
	vector<P> res;
	int id = 0;
	if (n % 2 == 0) {
		res.push_back(P(2, 1));
		n /= 2;
		while (n % 2 == 0) {
			res[id].second++;
			n /= 2;
		}
		id++;
	}
	int p = 3;
	while (n > 1) {
		while (p*p <= n && n%p) p += 2;
		if (n%p){
			res.push_back(P(n, 1));
			break;
		}
		else res.push_back(P(p, 1));
		n /= p;
		while (n%p == 0) {
			res[id].second++;
			n /= p;
		}
		id++;
	}
	return res;
}

int pow(int a, int b) {
	if (b == 0) return 1;
	if (b % 2) return a*pow(a, b - 1);
	int tmp = pow(a, b / 2);
	return tmp*tmp;
}

int euler(int n) {
	vector<P> pf = prime_fact(n);
	int res = 1;
	for (int i = 0;i < pf.size();i++) {
		res *= (pf[i].first - 1)*pow(pf[i].first, pf[i].second - 1);
	}
	return res;
}

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

	int n;
	cin >> n;
	cout << euler(n) << "\n";
	/*
	vector<P> pf = prime_fact(n);
	cout << n << "=";
	for (int i = 0;i < pf.size();i++) {
		if (i > 0) cout << "*";
		cout << pf[i].first;
		if (pf[i].second > 1) cout << "^" << pf[i].second;
	}
	cout << "\n";
	*/
	
	return 0;
}




Measured memory_bytes: 3224
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N,Q;
    cin >> N >> Q;
    ll score[N+1];
    ll ans[N+1];
    bool check[N+1];
    vector<vector<int>> child(N+1);
    for(int i = 0; i <= N; i++){
        score[i] = 0;
        ans[i]  = 0;
        check[i] = false;
    }
    for(int i = 0; i < N - 1; i++){
        int a,b;
        cin >> a >> b;
        child[a].emplace_back(b);
        child[b].emplace_back(a);
    }
    for(int i = 0; i < Q; i++){
        int p;
        ll x;
        cin >> p >> x;
        score[p] += x;
    }
    queue<pair<int,int>> que;
    que.push({0,1});
    while(!que.empty()){
        pair<int,int> p = que.front();
        que.pop();
        int par = p.first;
        int chi = p.second;
        ans[chi] = ans[par] + score[chi];
        check[chi] = true;
        for(auto c : child[chi]){
            if(!check[c]) que.push({chi,c});
        }
    }
    for(int i = 1; i <= N ; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 19992
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

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

    int n;
    cin >> n;

    cout << (1 + n) * n / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-12-01:01:52:02
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 1e9 +  7;
int64 dp[2020][2020];
// dp[i][j] : s の i 番目と t の j 番目をペアにしたときの共通部分列の総数

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

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

  for (int i = 0; i <= n; ++i) dp[i][0] = 1;
  for (int i = 0; i <= m; ++i) dp[0][i] = 1;

  for (int i = 0; i < n; ++i){
    for (int j = 0; j < m; ++j) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
        dp[i + 1][j + 1] %= MOD;
      } else {
        dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
        if (dp[i + 1][j + 1] < 0) dp[i + 1][j + 1] += MOD;
        dp[i + 1][j + 1] %= MOD;
      }
    }
  }

  cout << dp[n][m] << endl;

  return 0;
}

Measured memory_bytes: 31872
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
char c[1000000];
int a[3];
for(int i=0;i<3;i++)a[i]=0;
for(int i=0;i<1000000;i++)c[i]='\0';
scanf("%s",c);
for(int i=0;c[i]!='\0';i++)a[c[i]-'a']++;
sort(a,a+3);
if(a[2]-a[0]<=1)printf("YES\n");
else printf("NO\n");
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    // input
    string S; cin >> S;

    // compute
    char a = S.at(0);
    size_t b = S.size() - 2; 
    char c = S.at(S.size()-1);
    
    string ans;
    ans = a + to_string(b) + c;

    // output
    cout << ans << endl;
}

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

int main()
{
    int t, x;
    string s;
    cin >> s;
    long long dp[13] = {0};
    int L = s.length();
    long MOD = (int)pow(10, 9) + 7;

    dp[0] = 1;

    int m = 1;
    for (int i = 0; i < L; i++)
    {
        long long next_dp[13] = {0};
        char c = s[i];
        int ic  = -1;
        if(c!='?') {
            ic = c-'0';
        }
        // cout << ic << endl;

        for (int j = 0; j < 13; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                if (ic >= 0 && ic != k)
                    continue;
                next_dp[(j * 10 + k) % 13] += dp[j] % MOD;
            }
        }
        for (int j = 0; j < 13; j++)
        {
            dp[j] = next_dp[j];
        }
    }

    // cout << (double(t)/x) << endl;
    cout << (dp[5] % MOD) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;
int n,a[3],k;
string t;
long long ans;
long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
vector<int> s[100001];
vector<char> d[100001];
vector<bool> f[100001],f1[100001];
map<char,int> mp;
int main(){
	mp['r']=2;
	mp['p']=1;
	mp['s']=0;
	cin>>n>>k>>a[0]>>a[1]>>a[2]>>t;
	
	for(int i=0;i<k;i++){
		for(int j=i;j<n;j+=k)
		s[i].pb(a[mp[t[j]]]),d[i].pb(t[j]);
	}
	for(int i=0;i<k;i++){
		for(int j=0;j<s[i].size()-1;j++)
		f[i].pb((d[i][j]==d[i][j+1]));
	}
	int now=0; 
	for(int i=0;i<k;i++){
		now=0;
		for(int j=0;j<s[i].size()-1;j++){
			if(!f[i][j]){
				if(now==0)
				ans+=s[i][j];
				else{
					now=now/2+1;
					ans+=(ll)(now*s[i][j]);
					now=0;
				}
			}else{
				now++;
			}
		}
		if(now==0){
			ans+=s[i][s[i].size()-1];
		}else{
			now=now/2+1;
			ans+=(ll)(now*s[i][s[i].size()-1]);
		}
	}
	cout<<ans;
	re 0;
}


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

int main() {
  int A, B, C, D, area1, area2;
  cin >> A >> B >> C >> D;
  
  area1 = A * B;
  area2 = C * D;

  if(area1 >= area2) {
    cout << area1 << endl;
  } else {
    cout << area2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int W,H;
for(;;){
H =sc.nextInt();
W =sc.nextInt();
if(H == 0) break;
for(int b=1; b<=H; b++){
if(b%2 ==0){
for(int a=1; a<=W; a++){
if(a%2 ==0) System.out.print("#");
else System.out.print(".");
}System.out.println();
}else{
for(int a=1; a<=W; a++){
if(a%2 ==0) System.out.print(".");
else System.out.print("#");
}
System.out.println();
}
}
System.out.println();
}
}
}

Measured memory_bytes: 26896
x = int(input())
S = set()
S.add(1)
for b in range(2, int(1000**0.5) + 1):
	for p in range(2, 10):
		if b**p > 1000:
			break
		S.add(b**p)
for n in range(x, 0, -1):
	if n in S:
		print(n)
		exit()

Measured memory_bytes: 38512
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-b) > abs(x-a)){
    cout<<"A"<<'\n';
  }
  else{
    cout<<"B"<<'\n';
  }
  return 0;
}



Measured memory_bytes: 3576
// C++ program to find longest path of the tree 
#include <bits/stdc++.h> 
using namespace std; 
  
// This class represents a undirected graph using adjacency list 
class Graph 
{ 
    int V;              // No. of vertices 
    list<int> *adj;     // Pointer to an array containing 
                        // adjacency lists 
public: 
    Graph(int V);              // Constructor 
    void addEdge(int v, int w);// function to add an edge to graph 
    int longestPathLength();  // prints longest path of the tree 
    pair<int, int> bfs(int u); // function returns maximum distant 
                               // node from u with its distance 
}; 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
  
void Graph::addEdge(int v, int w) 
{ 
    adj[v].push_back(w);    // Add w to v’s list. 
    adj[w].push_back(v);    // Since the graph is undirected 
} 
  
//  method returns farthest node and its distance from node u 
pair<int, int> Graph::bfs(int u) 
{ 
    //  mark all distance with -1 
    int dis[V]; 
    memset(dis, -1, sizeof(dis)); 
  
    queue<int> q; 
    q.push(u); 
  
    //  distance of u from u will be 0 
    dis[u] = 0; 
  
    while (!q.empty()) 
    { 
        int t = q.front();       q.pop(); 
  
        //  loop for all adjacent nodes of node-t 
        for (auto it = adj[t].begin(); it != adj[t].end(); it++) 
        { 
            int v = *it; 
  
            // push node into queue only if 
            // it is not visited already 
            if (dis[v] == -1) 
            { 
                q.push(v); 
  
                // make distance of v, one more 
                // than distance of t 
                dis[v] = dis[t] + 1; 
            } 
        } 
    } 
  
    int maxDis = 0; 
    int nodeIdx; 
  
    //  get farthest node distance and its index 
    for (int i = 0; i < V; i++) 
    { 
        if (dis[i] > maxDis) 
        { 
            maxDis = dis[i]; 
            nodeIdx = i; 
        } 
    } 
    return make_pair(nodeIdx, maxDis); 
} 
  
//  method prints longest path of given tree 
int Graph::longestPathLength() 
{ 
    pair<int, int> t1, t2; 
  
    // first bfs to find one end point of 
    // longest path 
    t1 = bfs(0); 
  
    //  second bfs to find actual longest path 
    t2 = bfs(t1.first); 
  
    return t2.second; 
} 

int main(void){
    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n-1; i++) {
        int a,b;
        cin >> a >> b;
        g.addEdge(a-1,b-1);
    }

    int x;
    x=g.longestPathLength();
    
    if(x%3!=1){
        cout << "First" << endl;    
    }else{
        cout << "Second" << endl;    
    }
    
    // Your code here!
    
}


Measured memory_bytes: 17480
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();

		int max = 0;
		int temp = 0;
		for(int i=0; i < str.length(); i++) {
			char c = str.charAt(i);
			if(c == 'R'){
				temp++;
			} else {
				if(max < temp){
					max = temp;
					temp = 0;
				}
			}
		}
		if(max < temp){
			max = temp;
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 35620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
string s;
int w;
int main() {
    cin>>s>>w;
    for(int i=0;i<s.length();i+=w)
        cout<<s[i];


    return 0;
}



Measured memory_bytes: 256
import java.util.*;
class Main
{
    static long cnt = 0;
    static long n;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        func(0);
        System.out.println(cnt);
    }
    public  static boolean judge(long i){
        boolean b1 = false, b2 = false, b3 = false;
        while(i > 0){
            long k = i % 10;
            if(k == 3) b1 = true;
            else if(k == 5) b2 = true;
            else if(k == 7) b3 = true;
            i /= 10;
        }
        if(b1 && b2 && b3) return true;
        else return false;
    }
    public static void func(long i){
        if(i > n) return;
        if(judge(i)) cnt++;
        func(i * 10 + 3);
        func(i * 10 + 5);
        func(i * 10 + 7);
    }
}

Measured memory_bytes: 24276
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    IOS; int a, b;
    cin >> a >> b;
    cout << a *b;
    return 0;
}


Measured memory_bytes: 3656
N=int(input())
A=list(map(int,input().split()))
B=[abs(A[0])]

for i in range(1,N):
  B.append(B[-1] + abs(A[i]-A[i-1]))
  
total=B[-1]+abs(A[-1])

for j in range(N):
  ans=total
  if 0<j<N-1:
    ans -= abs(A[j]-A[j-1])
    ans -= abs(A[j+1]-A[j])
    ans += abs(A[j+1]-A[j-1])
  elif j==0:
    ans -= abs(A[0])
    ans -= abs(A[1]-A[0])
    ans += abs(A[1])
  else:
    ans -= abs(A[-1]-A[-2])
    ans -= abs(A[-1])
    ans += abs(A[-2])
  print(ans)  

Measured memory_bytes: 14040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


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


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


int main() {
	int N; cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	int A, B;
	cin >> A >> B;
	cout << A + B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;

// a / b % MOD;
// (a % MOD) * modinv(b, MOD) % MOD
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

map<ll, ll> prime_factor(ll N)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; i++) {
        while(N % i == 0) {
            ++res[i];
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> nax;
    rep(i, N) cin >> A[i];

    rep(i, N) {
        map<ll, ll> p = prime_factor(A[i]);
        for (auto itr : p) {
            chmax(nax[itr.first], itr.second);
        }
    }

    ll ans = 0;
    ll L = 1;
    for (auto itr : nax) {
        L *= modpow(itr.first, itr.second, MOD);
        L %= MOD;
    }

    rep(i, N) {
        ans += (L % MOD) * modinv(A[i], MOD) % MOD;
        ans %= MOD;
    }

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

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

using namespace std;

typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<pair<int, int>>> G(n + 1);
    for (int i = 0; i < m; ++i) {
        int l, r, d; cin >> l >> r >> d;
        G[l].push_back({ r, d });
        G[r].push_back({ l, -d });
    }
    vector<int> pos(n + 1);
    vector<bool> reached(n + 1);
    for (int v = 1; v <= n; ++v) {
        if (reached[v]) {
            continue;
        }
        reached[v] = true;
        pos[v] = 0;
        queue<int> q;
        q.push(v);
        while (!q.empty()) {
            int f = q.front();
            q.pop();
            for (auto p : G[f]) {
                int r = p.first;
                int d = p.second;
                if (reached[r]) {
                    if (pos[f] + d != pos[r]) {
                        cout << "No";
                        return 0;
                    }
                } else {
                    reached[r] = true;
                    pos[r] = pos[f] + d;
                    q.push(r);
                }
            }
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 9344
O = list(input())
E = list(input())
password = []

while True:
    if len(O) == 0 and len(E) == 0:
        break;
    if len(O) > 0:
        password.append(O.pop(0))
    if len(E) > 0:
        password.append(E.pop(0))

print("".join(password))

Measured memory_bytes: 3060
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var HW = Console.ReadLine().SplittedStringToBigInteger();
        var H = HW[0];
        var W = HW[1];
        BigInteger minimumdiff = LONGINF;
        for (int i = 1; i <= H; i++)
        {
            var num1 = i * W;
            var num2 = (W / 2) * (H - i);
            var num3 = (W - (W / 2)) * (H - i);
            var max = BigInteger.Max(num1, BigInteger.Max(num2, num3));
            var min = BigInteger.Min(num1, BigInteger.Min(num2, num3));
            minimumdiff = BigInteger.Min(max - min, minimumdiff);
        }
        for (int i = 0; i <= W; i++)
        {
            var num1 = i * H;
            var num2 = (H / 2) * (W - i);
            var num3 = (H - (H / 2)) * (W - i);
            var max = BigInteger.Max(num1, BigInteger.Max(num2, num3));
            var min = BigInteger.Min(num1, BigInteger.Min(num2, num3));
            minimumdiff = BigInteger.Min(max - min, minimumdiff);
        }
        minimumdiff = BigInteger.Min(minimumdiff, H % 3 == 0 ? 0 : W);
        minimumdiff = BigInteger.Min(minimumdiff, W % 3 == 0 ? 0 : H);

        Console.WriteLine(minimumdiff);
        Console.ReadLine();
    }

    public static void PrintArray<T>(T[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            for (int j = 0; j < array.GetLength(1); j++)
            {
                Console.Write(array[i, j] + " ");
            }
            Console.WriteLine();
        }
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

    public static int Max(params int[] values)
    {
        var maxes = -1;
        for (int i = 0; i < values.Length; i++)
        {
            maxes = Math.Max(values[i], maxes);
        }
        return maxes;
    }

    #endregion
}



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

// 0-based numbering; O(E*V^2);
template<class Numeric> struct Dinic {
	struct edge {
		int to; Numeric cap; int rev;
		edge(int t, Numeric c, int r){
			to = t; cap = c; rev = r;
		}
		void print() {
			cout << to << "\t" << cap << "\t" << rev << endl;
		}
	};
	vector< vector<edge> > g; vector<int> iter, level;
	int N; Numeric INF;
	Dinic(int n) {
		N = n; g.resize(N); iter.resize(N); level.resize(N);
		INF = numeric_limits<Numeric>::max();
	}
	void add(int from, int to, Numeric cap) {
		g[from].push_back(edge(to, cap, (int) g[to].size()));
		g[to].push_back(edge(from, 0, (int) g[from].size()-1));
	}
	void bfs(int s){
		level.assign(N,-1);
		queue<int> q;
		level[s] = 0; q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for(int i = 0; i < (int) g[v].size(); i++){
				edge &e = g[v][i];
				if (e.cap > 0 and level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	Numeric dfs(int v, int t, Numeric f) {
		if (v == t) return f;
		for (int i = iter[v]; i < (int) g[v].size(); i++) {
			edge &e = g[v][i];
			if (e.cap > 0 && level[v] < level[e.to]){
				Numeric 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;
	}
	Numeric solve(int s, int t) {
		Numeric flow = 0;
		while(true){
			bfs(s);
			if (level[t] < 0) return flow;
			iter.assign(N, 0);
			Numeric f;
			while ((f = dfs(s, t, INF)) > 0){
				flow += f;
			}
		}
	}
};


int main(){
    int n; cin >> n;
    Dinic<long long> d(n+2);
    long long all = 0;
    for (int i = 1; i <= n; i++) {
        long long a; cin >> a;
        if (a < 0) d.add(0, i, -a);
        else {
            d.add(i, n+1, a);
            all += a;
        }
    }
    for (int i = 1; i <= n; i++) {
        int j = i;
        while (j + i <= n) {
            j += i;
            d.add(i, j, d.INF);
        }
    }
    cout << all - d.solve(0, n+1) << endl; 
	return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
#include <fstream>
#include<set>
//AtCoderC++.cpp

using namespace std;

template<typename T>
inline T ceiling(T n, T d) {
	return n % d == 0 ? n / d : n / d + 1;
}

int main() {
	int M, D; cin >> M >> D;
	auto answer = 0;
	for (size_t i = 1; i <= M; i++) {
		for (size_t j = 22; j <= D; j++) {
			if (j % 10 < 2)continue;
			if (i == (j / 10)*(j % 10))				++answer;
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    int kaisu, a;
    kaisu = N / X;
    if(N % X != 0){
        kaisu += 1;
    }
    a = kaisu * T;
    cout << a;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N>>M;
    vec a(M,0);
    rep(i,M) cin>>a[i];
    sort(a.begin(),a.end());
    //dpにおいて、大きい番号を多く確保＝同一個数ならLがUより有利
    vec m_num = {0,2,5,5,4,5,6,3,7,6};
    mat dp(M,vec(N+1,-1)),memo(M,vec(N+1,-1));//1-indexed,memo 0 = 'U',1 = 'L'
    dp[0][0] = 0;
    rep(i,M){
        A = a[i];
        ll use = m_num.at(A);
        rep(j,N+1){
            if(j - use >= 0 && dp.at(i).at(j-use) != -1){
                dp[i][j] = dp[i][j - use] + 1;
                memo[i][j] = 1;
            }
            if(i != 0 && dp.at(i-1).at(j) != -1){
                if(dp[i][j] < dp[i-1][j]){
                    dp[i][j] = dp[i-1][j];
                    memo[i][j] = 0;
                }
            }
        }
    }
    /*rep(i,M){
        rep(j,N+1){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }
    rep(i,M){
        rep(j,N+1){
            cout<<memo[i][j]<<' ';
        }
        cout<<endl;
    }*/
    ll I = M-1, J = N;
    while(I != 0 || J != 0){
        if(memo[I][J] == 0) {
            --I;
        }else {
            J -= m_num.at(a[I]);
            cout << a[I];//<< ' ' << I << ' ' << J << endl;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int mod=998244353;
inline int add(int a,int b){return (a+b)>=mod?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b)>=mod?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int &a,int b){static ll r;r=(ll)a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(ll x){x%=mod;return (x<0)?x+mod:x;}
cs int N=300005;
int l[N],r[N],vis[N],t[N],n,L,x[N];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read(),L=read();
	int res=n+1;
	for(int i=1;i<=n;i++)
		x[i]=read();
	for(int i=1;i<=n;i++){
		t[i]=read();
		res+=t[i]/(L*2),t[i]%=L*2;
		if(!t[i]){
			res--,vis[i]=1;
			continue;
		}
		l[i]=((2*(L-x[i]))>=t[i]),r[i]=(2*x[i]>=t[i]);
		if(!l[i]&&!r[i])vis[i]=1;
	}res-=l[n];
	int cnt=0,sum=0,ps=n;
//	for(int i=1;i<n;i++)if(!vis[i]&&(!l[i]||r[i])){ps=i;break;}
	for(int i=1;i<n;i++)if(!vis[i]){
		if(!l[i]){ps=i;break;}
		if(r[i])cnt++;
		else if(cnt)cnt--,res--;
	}
	sum+=cnt,cnt=0;
	for(int i=n-1;i>=ps;i--)if(!vis[i]){
		if(!r[i])break;
		if(l[i])cnt++;
		else if(cnt)cnt--,res--;
	}
	sum+=cnt,cnt=0;
	res-=sum/2;
	cout<<2ll*L*res<<'\n';
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll x, y;
    cin >> x >> y;
    int cnt = 0;
    while (x <= y) {
        x *= 2;
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next()); // 敵の数
        int k = Integer.parseInt(sc.next()); // 必殺技の使用回数
        ArrayList<Integer> hp = new ArrayList<>(n); // 各敵の体力
        for (int i = 0; i < n; i++) {
            hp.add(Integer.parseInt(sc.next()));
        }
        // 敵を昇順ソート
        Collections.sort(hp);
        long ans = 0;
        for (int i = 0; i < (n - k); i++) {
            ans += hp.get(i);
        }
        //        Collections.sort(hp, Collections.reverseOrder());
        //        // リストの先頭から先頭から必殺技の回数分敵を除去
        //        for (int i = 0; i < k; i++) {
        //            if (hp.isEmpty()) {
        //                break;
        //            }
        //            hp.remove(0);
        //        }
        //        // 残った敵体力の合計値が攻撃回数
        //
        //        for (Integer i : hp) {
        //            ans += i;
        //        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 63660
from collections import deque
scores = deque()

result = 0

N = int(input())
l = list(map(int, input().split()))
l.sort(reverse = True)

scores.append(l[0])

for i in range(1, N):
    scores.append(l[i])
    scores.append(l[i])
    result += scores.popleft()

print(result)


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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    char a;
    cin >> a;
    if (a-'a' >= 0 && a-'a' < 26) {
        cout << "a\n";
    } else {
        cout <<"A\n";
    }
}
/*

 */


Measured memory_bytes: 3592
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Tue Jan  8 23:51:17 2019
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	m := map[int]int{}
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		m[a]++
	}

	ans := 0
	for _, v := range m {
		if v%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7936