akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    bool b = true;
    if(S.size() + 1 == T.size()) {
        for(int i = 0; i < S.size(); i++) {
            if(S[i] == T[i]) {
                b = true;
            } else {
                b = false;
                break;
            }
        }
    } else {
        b = false;
    }
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
n = int(input())
p = 1
ans = ""
for i in range(32):
    mod = n%(-2*p)
    if mod>0 and p<0:
        if -2*p>0: mod -= (-2*p)
        else: mod += (-2*p)
    if mod<0 and p>0:
        if -2*p>0: mod += (-2*p)
        else: mod -= (-2*p)
    if mod==p:
        ans += "1"
        n -= p
    else :
        ans += "0"
    p *= -2
ans = ans[::-1].lstrip("0")
if len(ans): print(ans)
else: print(0)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {

		String s = new Scanner(System.in).next();
		final int REKI = 2019;
		int[][] ans = new int[2][REKI];

		int a = 0;
		for(int i = 0 ; i < s.length() ; i++ ) {
			int temp =Character.getNumericValue(s.charAt(i));;
			for(int j = 0 ; j < REKI ; j++ ) {
				ans[1][(j*10+temp) %REKI] += ans[0][j];
			}
			a+= ans[1][0];
			ans[1][temp] +=1;
			ans[0] = ans[1].clone();
			Arrays.fill(ans[1], 0);
		}

		System.out.println(a);
	}

}

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

using namespace std;

int main()
{
    int a[5],b[5];
    int sum=0,minn=10,mark;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<5;i++)
    {
        b[i]=a[i]%10;
        if(b[i]<minn&&b[i])
        {
            minn=b[i];
            mark=i;
        }
    }
    if(minn!=10)
    {
        for(int i=0;i<5;i++)
        {
            if(i!=mark&&b[i]!=0) a[i]+=10-b[i];
        }
    }
    //for(int i=0;i<5;i++)
        //cout<<a[i];
    for(int i=0;i<5;i++)
    {
        sum+=a[i];
    }
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 55
#define mo 1000000007
#define ll long long
int n;
ll C[N][N],f[N][N];
int main(){
	scanf("%d",&n);
	for (int i=0;i<=n;++i){
		C[i][0]=1;
		for (int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	f[1][0]=f[1][1]=n;
	for (int i=1;i<n;++i)
		for (int j=0;j<=i;++j)
			for (int k=(j==0?2:j);i+k<=n;k+=2){
				int t=(k-j)/2;
				for (int x=0;x<=k;++x)
					(f[i+k][abs(x-t)]+=f[i][j]*C[n-i][k]%mo*C[k][x])%=mo;
			}
	printf("%lld\n",f[n][0]);
	return 0;
}

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


void solve(long long N, std::vector<long long> d){
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size() << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

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

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string s;
  cin >> s;
  cout << s.front();
  cout << s.size()-2;
  cout << s.back();

  return 0;
}


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

int main()
{
    // 頂点数と辺数
    int N, M;
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    vector<vector<int>> G(N);
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty())
    {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v])
        {
            if (dist[nv] != -1)
            {
                continue; // すでに発見済みの頂点は探索しない
            }
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }

    for (auto x : dist)
    {
        if (x == -1)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v)
    {
        cout << dist[v] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10188
#include <stdio.h>
#define INF 2100000000

void mco();
int m[100][100];
int p[100];
int n;
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  
  mco();

  
  printf("%d\n",m[1][n]);
  
  
  return 0;
}

void mco(){
  int i,j,l,k,q=INF;
  for (i=1;i<=n;i++){
    m[i][i] = 0;
  }
  for (l=2;l<=n;l++){
    for (i=1;i<n-l+2;i++){
      j = i+l-1;
      m[i][j] = INF;
      for (k=i;k<=j-1;k++){
        if(q > m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]) q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];//m[i][j] = min(m[i][j], q)
        m[i][j] = q;
      }
      q = INF;
    }
  }
}



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

using namespace std;

using LL = long long;

const LL MOD = 1000000007;
LL fac[2020];

LL power(LL a, LL b) {
    LL x = 1, y = a;
    while (b > 0) {
        if (b % 2) x = (x * y) % MOD;
        y = (y * y) % MOD;
        b /= 2;
    }
    return x % MOD;
}

LL mod_inv(LL n) {
    return power(n, MOD - 2);
}

LL nCr(LL n, LL k) {
    if (k == 0 || k == n) return 1;
    return (fac[n] * mod_inv(fac[k]) % MOD * mod_inv(fac[n - k]) % MOD) % MOD;
}

int main() {
    int n, k; cin >> n >> k;
    
    fac[0] = 1;
    for (int i = 1; i <= n; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD;
    }
    
    for (int i = 1; i <= k; ++i) {
        // group blues: k - 1 choose i - 1
        // place reds: i - 1 set, (n - k + 1) choose i
        if (i - 1 > n - k) {
            cout << 0 << endl;
        } else {
            LL ans = (nCr(k - 1, i - 1) * nCr(n - k + 1, i)) % MOD;
            cout << ans << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
const int maxn = 1e5+100;
char ax[maxn];
int ans[maxn],temp[maxn];
int main(){
    scanf("%s",ax+1);
    int len = strlen(ax+1);
    int temp = 0;
    for(int i = 1;i<=len;i++){
        if(ax[i]=='L'){
            int pos = i,c = temp;
            while(i<=len&&ax[i]=='L')temp++,i++;
            int bouns = temp - c;
            int retime = min(bouns,c) - 1;
            if(bouns==c)ans[pos] = ans[pos-1] = temp/2;
            else if(c>bouns){
                if(retime%2==1)ans[pos-1] = temp/2 + temp%2,ans[pos] = temp/2;
                else ans[pos] = temp/2 + temp%2,ans[pos-1] = temp/2;
            }
            else{
               if(retime%2==0)ans[pos-1] = temp/2 + temp%2,ans[pos] = temp/2;
               else ans[pos] = temp/2 + temp%2,ans[pos-1] = temp/2;
            }
            temp = 0;
            i--;
            continue;
        }
        temp++;
    }
    for(int i = 1;i<=len;i++){
        if(i!=1)printf(" ");
        printf("%d",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 896
a=gets.chomp.chars.push("A")
b=gets.chomp.chars.push("B")
c=gets.chomp.chars.push("C")
turn='a'
while true  
  case turn
  when 'a'
    turn = a.shift
  when 'b'
    turn = b.shift
  when 'c'
    turn = c.shift
  when "A"
    puts turn
    break
  when "B"
    puts turn
    break
  when "C"
    puts turn
    break
  end
end

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> ps(a), qs(b), rs(c);
  rep(i, a) cin >> ps[i];
  rep(i, b) cin >> qs[i];
  rep(i, c) cin >> rs[i];

  sort(ps.rbegin(), ps.rend());
  sort(qs.rbegin(), qs.rend());

  vector<int> v;
  rep(i, x) v.push_back(ps[i]);
  rep(i, y) v.push_back(qs[i]);
  rep(i, rs.size()) v.push_back(rs[i]);
  sort(v.rbegin(), v.rend());

  ll res = 0;
  rep(i, x + y) res += v[i];
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

int main(){
    int W,H;
    cin >> W >> H;
    vector<int> p(W,0);
    vector<int> q(H,0);
    for(int i=0; i<W; i++){
        cin >> p[i];
    }
    for(int i=0; i<H; i++){
        cin >> q[i];
    }
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    p.push_back(1000000007);
    q.push_back(1000000007);

    int i=0;
    int j=0;
    int k=0;
    long long ans=0;
    while(i<W+H){
        if(p[j]<q[k]){
            ans+=(long long) p[j]*(H-k+1);
            //cout << p[j] << endl;
            j++;
        }else{
            ans+=(long long) q[k]*(W-j+1);
            //cout << q[k] << endl;
            k++;
        }
        i++;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000
int N,M,L,D;
int K[MAX_N];
int ans;
vector<char> C;
bool bool_ans;
int X[100][100];
double dis;


int solve(void) {
  rep(i,0,N) {
    rep(j,i+1,N) {
      dis = 0;
      rep(k,0,D) {
        dis += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      dis = sqrt(dis);

      if((dis - (int)dis) <= 0.000000001) {
        ans++;
      }
    }
  }

  return ans;
}

int main (void)
{
  cin >> N >> D;
  rep(i,0,N) {
    rep(j,0,D) {
      cin >> X[i][j];
    }
  }

  ans = solve();
  put(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }


int main(){
    ll N=ii();
    ll S=0;
    ll mod=1E9+7;
    vector<ll> A;
    REP(i,0,N){
        ll a=ii();
        S+=a;
        S%=mod;
        A.push_back(a);
    }
    ll m=0;
    ll ret=0;
    REP(i,0,N-1){
        S=(S-A[i]+mod)%mod;
        ll t=A[i]*S;
        t%=mod;
        ret+=t;
        ret%=mod;
    }
    oie(ret);

    return 0;
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll h, w;
  cin >> h >> w;

  if (h == 1 or w == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll t = (h+1)/2;
  cerr << t << endl;
  ll ans = h*(w/2);
  if (w%2) ans += t;
  cout << ans << endl;
}


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

int calc(int x) {
    int ret = 0;
    while (x > 0) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int sum = calc(i);
        if (sum >= a && sum <= b)
            ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String first;
        char table[] = new char[20000];
 
        int M,h,left,right;
 
 
        try {
 
            while(!(first = br.readLine()).equals("-")){
 
                for(int i = 0; i < first.length(); i++){
                    table[i] = first.charAt(i);
                }
 
                left = 0;
                right = first.length()-1;
 
                M = Integer.parseInt(br.readLine());
 
                for(int loop = 0; loop < M; loop++){
                    h = Integer.parseInt(br.readLine());
 
                    for(int i = 0; i < h; i++){
                        table[right+1+i] = table[left+i];
                    }
                    left += h;
                    right += h;
                }
 
                for(int i = left; i <= right; i++){
                    System.out.printf("%c", table[i]);
                }
                System.out.printf("\n");
            }
 
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[100005];
ll Q[100005];
ll R[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    REP(i, A) {
        cin >> P[i];
    }
    REP(i, B) {
        cin >> Q[i];
    }
    REP(i, C) {
        cin >> R[i];
    }
    sort(P, P + A, greater<ll>());
    sort(Q, Q + B, greater<ll>());
    sort(R, R + C, greater<ll>());

    priority_queue<ll, vector<ll>> q0;
    priority_queue<ll, vector<ll>> q1;
    REP(i, X) {
        q0.push(P[i]);
    }
    REP(i, Y) {
        q0.push(Q[i]);
    }
    REP(i, std::min(X + Y, C)) {
        q1.push(R[i]);
    }
    ll ans = 0;
    REP(i, X + Y) {
        ll a = q0.top();
        ll b = 0;
        if (!q1.empty())
            b = q1.top();

        if (a > b) {
            ans += a;
            q0.pop();
        }
        else {
            ans += b;
            q1.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

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

int bitcnt(int x) {
    if(x == 0) {
        return 0;
    } else {
        return bitcnt(x >> 1) + (x & 1);
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    // Failed to predict input format
    int N = 0;
    cin >> N;

    vector<int> A(N, 0);
    vector<vector<int>> x(N, vector<int>(N, 0));
    vector<vector<int>> y(N, vector<int>(N, 0));
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        for (size_t j = 0; j < A[i]; j++)
        {
            cin >> x[i][j] >> y[i][j];
            // cout << "x = " << x[i][j] << ", y = " << y[i][j] << endl;
        }
    }

    // cout << "0" << endl;

    int maxh = 0;
    for (size_t k = 0; k < static_cast<long long>((1 << N)); k++)
    {
        int l = 0;
        // checking
        for (size_t i = 0; i < N; i++)
        {
            if((k & (1 << i))) {
                for (size_t j = 0; j < A[i]; j++)
                {
                    l += (y[i][j] ^ ((k >> (x[i][j] - 1)) & 1));
                }
            } 
        }
        // cout << "(l, bitcnt(k)) = " << l << ", " << bitcnt(k) << endl;
        if (l == 0)
        {
            maxh = max(maxh, bitcnt(k));
        }
    }

    cout << maxh << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    string s;
    cin >> s;
    stack<char> stk;
    ll n = s.size();
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'S') stk.push('S');
        else if(!stk.empty() and stk.top()=='S')
            stk.pop();
        else
            stk.push('T');
    }
        cout << stk.size() << endl;
}

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

int main() {
  float a, b;
  cin >> a >> b;
  cout << ceil((a + b) / 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define vi vector<int>
#define pii pair<int,int>
#define se second
using namespace std;
int n,t,a,b,c,x,y,k;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n >>k ;
	vi v(n);
	for (int&i:v) cin >> i;
	sort(v.begin(),v.end());
	long long ans = 0;
	for (int i = 0; i < k; i++) ans += v[i];
	cout << ans;
	
	
}

Measured memory_bytes: 3620
import heapq

N = int(input())
seq = list(map(int, input().split()))

zenhan = seq[:N]
kouhan = list(map(lambda x: -x, seq[2*N:])) #後半は-1倍しておく
heapq.heapify(zenhan)
heapq.heapify(kouhan)

zenhan_sum_max = [0 for i in range(N + 1)] #zenhan_sum_max[i] = a0, ..., a_(N+i-1)からN個取るときの最大値
kouhan_sum_min = [0 for i in range(N + 1)] #kouhan_sum_min[i] = a_(N+i), ..., a_(3N-1)からN個取るときの最小値

zenhan_sum_max[0] = sum(seq[:N])
kouhan_sum_min[N] = sum(list(map(lambda x: -x, seq[2*N:])))
for i in range(N):
    new = seq[N + i]
    pop = heapq.heappushpop(zenhan, new)
    zenhan_sum_max[i + 1] = zenhan_sum_max[i] + new - pop

for i in range(N - 1, -1, -1):
    new = -seq[N + i]
    pop = heapq.heappushpop(kouhan, new)
    kouhan_sum_min[i] = kouhan_sum_min[i + 1] + new - pop

print(max([zenhan_sum_max[i] + kouhan_sum_min[i] for i in range(N + 1)]))


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int N; cin >> N;
	vector<int> in(N, 0); //??\?¬???° 
	vector<int> next(N); //?¬?????????????id
	rep(i, 0, N) {
		int v; cin >> v;
		v = (i + v) % N;
		next[i] = v;
		in[v]++;
	}
	dumpc(in);
	dumpc(next);

	queue<int> Q;
	rep(i, 0, N)if (in[i] == 0)Q.push(i); //??\?¬???°???0?????????(????????????????????????)????????\????????\??????

	int ans = N;
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		ans--;
		int v = next[u];
		in[v]--;
		if (in[v] == 0)Q.push(v); //??\?¬???°???0?????????(????????????????????????)????????\????????\??????
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}


//深さ優先探索
void dfs(vector<string> &m,vector<vector<bool>> &seen, ll x, ll y, ll h, ll w){

	seen[y][x]=true;

	
	for(ll i=0;i<4;i++){
		ll nx=x,ny=y;
		if(i==0){ //up
			ny=y-1;
		}
		else if(i==1){ //down
			ny=y+1;
		}
		else if(i==2){ //right
			nx=x+1;
		}
		else{ //left
			nx=x-1;
		}

		if(nx<0 || nx>=w || ny<0 || ny>=h){
			continue;
		}
		if(seen[ny][nx]){
			continue;
		}
		
		if(m[ny][nx]=='#'){
			continue;
		}

		dfs(m,seen,nx,ny,h,w);
	}
}


void solve(){
	double ans=0;

	double r;
	cin>>r;

	ans=2*r*M_PI;

	cout<<ans<<endl;
}

int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 3768
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print(math.factorial(N)%MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15392
A = int(input())
B = int(input())
C = int(input())
X = int(input())//50
ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 10*i+2*j+k == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int m = saori.saori_hayami();
		int[] a = new int[m];
		int[] b = new int[m];
		int[] ans = new int[n];
		for(int i = 0;i < m;i++){
			a[i] = saori.saori_hayami();
			b[i] = saori.saori_hayami();
		}
		for(int i = 0;i < m;i++){
			ans[a[i]-1]++;
			ans[b[i]-1]++;
		}
		for(int i = 0;i < n;i++){
			System.out.println(ans[i]);
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct unionFind {
  vector<int> par;
  vector<int> sizes;

  unionFind (int n) : par(n), sizes(n, 1) {
    rep(i, n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};


signed main() {
	ll n, k, l;
  cin >> n >> k >> l;

  unionFind uf_1(n + 1);
  unionFind uf_2(n + 1);

  rep(i, k) {
    ll p, q;
    cin >> p >> q;
    uf_1.unite(p, q);
  }

  rep(i, l) {
    ll r, s;
    cin >> r >> s;
    uf_2.unite(r, s);
  }

  map<pair<ll, ll>, ll>mp;

  for(int i = 1; i <= n; i++) {
    mp[make_pair(uf_1.find(i), uf_2.find(i))]++;
  }

  for(int i = 1; i <= n; i++) {
    cout << mp[make_pair(uf_1.find(i), uf_2.find(i))];
    cout << ((i != n) ? " " : "\n");
  }

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int m = 0;
    while (m*(m+1)/2 < N) m++;
    while (m <= N && N > 0) {
        cout << m << endl;
        N -= m;
        m--;
    }
    if (N > 0) cout << N << endl;
    return 0;
}

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

int main() {
    int n;cin>>n;
    int a[n];
    
    
    
    int i,j,k;
    for(i=0;i<n;i++)
    { 
      cin>>a[i];             
    }
    if(n==1)
    {
        cout<<"0"<<endl;
        return 0;
    }
    else if(n==2)
    {
        cout<<abs(a[1]-a[0])<<endl;
        return 0;
    }
    
    int dp[n];
    for(i=0;i<n;i++)
    {
        dp[i]=INT_MAX;
    }
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
       dp[i] = min(abs(a[i] - a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

const ll MOD = 1000000007;
//const ll MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n; cin >> n;

    vector<ll> d(n), c(n);
    REP(i, n) cin >> d[i] >> c[i];

    ll D = 0, S = 0;
    REP(i, n) {
        D += c[i];
        S += d[i] * c[i];
    }

    print((D - 1) + (S - 1) / 9);
}

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

int main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes" << endl;
    return 0;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public final class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();

			int ans = 1;
			while (true) {
				if (n < Math.pow(k, ans)) {
					break;
				}

				ans++;
			}

			System.out.println(ans);
		}
	}

}


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

int main() {
    
    long long n,m;
    cin >> n >> m;
    if(n == 1 && m == 1)cout << 1 << endl;
    else if(n == 1 || m == 1)cout << n*m -2 << endl;
    else if(n == 2 || m == 2)cout << 0 << endl;
    else cout << (n-2)*(m-2) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#define N 123
using namespace std;
int n,cut1,cut2;
char c[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>c[i];
	for(int i=1;i<=n;i++)
	{
		if(c[i] == '(') cut1++;
        else if(c[i] == ')')
        {
            cut1--;
            if(cut1<0)
			{
				cut2++;
				cut1=0;
			}
        }
    }
	for(int i=1;i<=cut2;i++) cout<<"(";
    for(int i=1;i<=n;i++) cout<<c[i];
    for(int i=1;i<=cut1;i++) cout<<")";
    cout<<endl;
    return 0;
}

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

int main() {
  string S;
  cin>>S;
  int A;
if(S=="SAT") A=1;
else if(S=="FRI") A=2;
else if(S=="THU") A=3;
else if(S=="WED") A=4;
else if(S=="TUE") A=5;
else if(S=="MON") A=6;
else A=7;
  cout<<A<<endl;
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B;
    int R = C + D;
    if(L > R) cout << "Left" <<endl;
    else if(L==R) cout << "Balanced" << endl;
    else cout << "Right" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n,m;
int h[N];
int u,v;
vector<int> p[N];

int main() {
    ios::sync_with_stdio(false);
    cin>>n>>m;
     for(int i=1;i<=n;++i) cin>>h[i];

     while(m--){
         cin>>u>>v;
         p[u].pb(v);
         p[v].pb(u);
     }
     int cnt=0;
     for(int i=1;i<=n;++i){
         bool flag=1;
         for(auto x:p[i]){
             if(h[i]<=h[x]){
                 flag=0;
                 break;
             }
         }
         if(p[i].empty() || flag==1) cnt++;
     }
     printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 30392
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>
#include<array>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline ll modpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

inline ll mod(ll val, ll m) {
	ll res = val % m;
	if (res < 0) res += m;
	return res;
}


int main() {
	int n;
	array<array<int, 3>, 3> a;

	REP(i, 0, 3) {
		REP(j, 0, 3) {
			cin >> a[i][j];
		}
	}

	cin >> n;

	vector<int> b(n);

	REP(i, 0, n) cin >> b[i];

		REP(i, 0, 3) {
			REP(j, 0, 3) {
				REP(k, 0, n) {
					if (a[i][j] == b[k]) {
						a[i][j] = -1;
					}
				}
			}
		}
	string answer = "No";
	REP(i, 0, 3) {
		if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) {
			answer = "Yes";
		}
	}
	REP(i, 0, 3) {
		if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) {
			answer = "Yes";
		}
	}
	if (a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1) answer = "Yes";
	if (a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1) answer = "Yes";

	cout << answer;

	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
    int n,x,m[100],min,s=0,i,tmp;
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)
        scanf("%d",&m[i]);
    min=m[0];
    for(i=0;i<n;i++){
        x-=m[i];
        if(min>m[i]){
            tmp=min; min=m[i]; m[i]=tmp;
        }
        s++;
    }
    while(1){
        x-=min;
        if(x>=0)
            s++;
        else
            break;
    }
    printf("%d\n",s);
    return 0;
}

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

int main(void){
    double a,sum;
    
    while (scanf("%lf", &a)!=EOF){
        sum=0;
        for(int i=1; i<=10; i++){
            sum+=a;
      //      printf("%2d:%8f (sum:%.6f)\n",i,a,sum);
            if (i%2) a *= 2;
            else a /= 3;
        }
        printf("%f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1076
#include<stdio.h>
#define MAX 1000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,L,x;
  l=i*2;
  r= 2*i+1;

  if(l<=H && A[l]>A[i]) L=l;
  else L=i;
   if(r<=H && A[r]>A[L]) L=r;

   if(L!=i){
     x=A[i];
     A[i]=A[L];
     A[L]=x;
     maxHeapify(L);
   }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);

   for(i=H/2;i>=1;i--) maxHeapify(i);

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



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

if a%2==1 or b%2==1 or c%2==1:
    print("0")
    exit()

for i in range(1,1000000):
    a2=(b//2)+(c//2)
    b2=(a//2)+(c//2)
    c2=(a//2)+(b//2)
    
    a,b,c=a2,b2,c2
    
    if a%2==1 or b%2==1 or c%2==1:
        print(i)
        exit()

print("-1")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stdio.h>
#include <cmath>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  double a,b,C;
  cin >> a >> b >> C;

  double S,L,h;

  S = a * b * sin(PI*C/180.) / 2.;
  
  double c = sqrt(a*a+b*b-2*a*b*cos(PI*C/180.));
  L = a + b + c;

  h = b * sin(PI*C/180.);

  printf("%.10f\n", S);
  printf("%.10f\n", L);
  printf("%.10f\n", h);     
}



Measured memory_bytes: 3400
#include<stdio.h>
#include<vector>
using namespace std;

int main(){
//	W→0 H→1 x→2 y→3 r→4
	vector<int> num;
	for(int i=0; i<5; i++){
		int tmp=0;
		scanf("%d",&tmp);
		num.push_back(tmp);
	}
	if(num[2]>=num[4] && num[3]>=num[4]){
		if((num[2]+num[4])<=num[0] && (num[3]+num[4])<=num[1]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



int main()
{
  int n;
  cin >> n;
  int tmp;
  string res = "APPROVED";
  REP(i,n){
    cin >> tmp;
    if(tmp%2 == 1) continue;
    if(tmp%3 != 0 && tmp%5 != 0){
      res = "DENIED";
      break;
    }
  }
  cout << res << "\n";
  return 0;
}


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

using namespace std;

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

	int a,b;

	cin >> a >> b;

	if(a<=b)
	{
		for(int i=0;i<b;i++)
		{
			cout << a;
		}
		cout << '\n';
	}
	else
	{
		for(int i=0;i<a;i++)
		{
			cout << b;
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

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

    if(a + b + c - max(a, max(b,c)) == max(a, max(b, c))) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3552
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if(y%2==0){
    if(4*x>=y&&2*x<=y){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
    int H, W;

    while (scanf("%d%d", &H, &W) == 2 && !(H == 0 && W == 0)) {
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++)
                putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            Console.WriteLine((n * (n - 1)) / 2 + (m * (m - 1) )/ 2);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.reverse()
b.reverse()
ans = 0
capacity = 0
for i in range(N):
    ans += min(b[i] + capacity, a[i])
    capacity = max(b[i] - max(a[i] - capacity, 0), 0)
ans += min(a[-1], capacity)
print(ans)

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

int main() {
  int64_t A, B, M;
  cin >> A >> B >> M;
  vector<int64_t> a(A);
  vector<int64_t> b(B);
  vector<int64_t> c(M);
  vector<int64_t> x(M);
  vector<int64_t> y(M);
  
  for (int i = 0; i < A; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < B; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  
  int count=0;
  count=*min_element(a.begin(), a.end())+*min_element(b.begin(), b.end());
  //count =  min(a) + min(b);
  for(int i=0; i<M; i++){
      if(count>a[x[i]-1]+b[y[i]-1]-c[i]){
        count=a[x[i]-1]+b[y[i]-1]-c[i];
      }
    }
  cout << count;
}


Measured memory_bytes: 4224
text=input()
num_of_command=int(input())

for command_ID in range(num_of_command):
    command=input().split()
    start=int(command[1]);
    ed=int(command[2])+1;

    if command[0]=="replace":
        pre=text[:start]
        replace_text=command[3];
        after=text[ed:]
        text=pre+replace_text+after      
    elif command[0]=="reverse":
        text=text[:start]+text[start:ed][::-1]+text[ed:]
    elif command[0]=="print":
        print(text[start:ed])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll res = 0;
    for (ll i = 1; i <= n; i++) {
        ll en = i * (n / i);
        res+=(en+i)*ll(n/i)/2LL;
    }
    cout<<res<<newl;
}

Measured memory_bytes: 3648
import numpy as np
N, W = map(int,input().split())
#普通に書くとTLEだったのでNumpy化
dp = np.zeros(W+1,dtype=int)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(int(dp[-1]))

Measured memory_bytes: 15424
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sum_=sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        sum_+=C[A[i]-1]
print(sum_)

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))
    ans = 0
    for i in range(N-1):
        diff = t[i+1] - t[i]
        ans += (diff<T)*(diff) + (diff>=T)*T
    ans += T
    print(ans)

if __name__ == "__main__":
    main()       


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

int A, B;

int main() {
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


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

int main() {
    int64_t N, M;
    cin >> N >> M;

    int64_t even_num = (M + 1) / 2;
    int64_t sep = even_num * 2;
    for (int64_t i = 0; i < even_num; i++) {
        cout << i + 1 << " " << sep - i << endl;
    }

    int64_t right = (N % 2 == 0 ? N - 1 : N);
    for (int64_t i = 0; i < M - even_num; i++) {
        cout << sep + 1 + i << " " << right - i << endl;
    }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, a[100000], max = 0, count[100000] = { 0 }, an = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		count[a[i]]++;
		if (a[i] > max) {
			max = a[i];
		}
	}
	for (int i = 0; i <= max; i++) {
		if (i == 0) {
			an = count[0] + count[1];
		}
		else {
			if (count[i - 1] + count[i] + count[i + 1] >= an) {
				an = count[i - 1] + count[i] + count[i + 1];
			}
		}
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 896