akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a >= 13)
    cout << b << endl;
  else if(a>=6 & a<=12)
    cout << b/2 << endl;
  else cout << "0" << endl;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	bool s = (x >= a&&x <= a + b);
	cout << (s ? "YES" : "NO") << endl;

}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  998244353;
int arr[mxn];
int n, m, k, q;
string s, t;
int x, y;

void solve() {
   cin >> x >> y;
   cout << x * y << endl;
}

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


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

using namespace std;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ///cout << "debug" << endl;
    //int ans = 0;
    int n, m;
    long long k;
    cin >> n >> m >> k;
    int ans = 0;
    vector < long long > a(n), b(m);
    for(int i = 0 ; i < n ; ++i) {
        cin >> a[i];
        if(i) {
            a[i] += a[i - 1];
        }
        if(a[i] <= k) {
            ans = max(ans, i + 1);
        }
    }
    for(int i = 0 ; i < m ; ++i) {
        cin >> b[i];
        if(i) {
            b[i] += b[i - 1];
        }
        if(b[i] <= k) {
            ans = max(ans, i + 1);
        }
    }
    for(int i = 0 ; i < n ; ++i) {

        int lo = 0, hi = m - 1;
        long long already = a[i]; /// sum of all minutes
        while(hi - lo >= 5) {
            int mid = (hi + lo) / 2;
            if(b[mid] + already <= k) {
                lo = mid;
            }
            else {
                hi = mid;
            }
        }
        for(int pos = hi ; pos >= lo ; --pos) {
            if(already + b[pos] <= k) {
                ans = max(ans, (i + 1) + (pos + 1));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6364
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

def solve():
    import copy

    N, K = list(map(int,input().split()))
    As = list(map(int, input().split()))

    if K == 1:
        print(0)
        return

    # 最も左にある建物を除く、N-1個の建物について、絶対に見えるようにするかしないかをbit全探索する
    ans = float("inf")
    for bit in range(2**(N-1)):  # 2**14 = 16384
        tmpAs = copy.deepcopy(As)
        highest = tmpAs[0]
        total = 0
        see = 1  # 見えるビルの数
        for i in range(N-1):  # 14
            if bit>>i&1:
                see += 1
                if tmpAs[i+1] <= highest:
                    total += (highest-tmpAs[i+1])+1
                    tmpAs[i+1] = highest+1
            highest = max(highest, tmpAs[i+1])

        if see >= K:
            ans = min(ans, total)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 100010;
int n, k;
vector<ll> a;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    COMinit();

    ll ans = 0;
    rep(i, n) {
        ans += a[i] * COM(i, k-1);
        ans %= MOD;
        ans -= a[i] * COM(n-i-1, k-1);
        ans %= MOD;
    }
    cout << ans << endl;
}


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

class Echo
{
    static void Main(string[] args)
    {
        var number = int.Parse(Console.ReadLine());

        var input = Console.ReadLine();

        string  first ="";
        string second = "";
        var ans = "";

        for(var i = 0; i < number; i++)
        {
            if(i < number / 2)
            {
                first += input[i].ToString();
            }
            else if (number /2 <= i)
            {
                second += input[i].ToString();
            }
        }


        if(first == second)
        {
            ans = "Yes";
        }
        else
        {
            ans = "No";
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    vector<int> as(5);
    int k;
    for(int i=0; i<5; ++i){
        cin >> as[i];
    }
    cin >> k;
    for(int i=0; i<5; ++i){
        for(int j=0; j<5; ++j){
            if(abs(as[i]-as[j])>k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int case_num, gx, gy, p, x1, y1, x2, y2;
    int count[16][16];
    int banh[16][16], banv[16][16];
    cin >> case_num;
    for (int case_i = 0; case_i < case_num; ++case_i) {
        cin >> gx >> gy >> p;
        for (int y = 0; y <= gy; ++y) {
            for (int x = 0; x <= gx; ++x) {
                banh[x][y] = banv[x][y] = false;
            }
        }
        for (int i = 0; i < p; ++i) {
            cin >> x1 >> y1 >> x2 >> y2;
            if (x1 == x2) {
                banv[x1][max(y1, y2)] = true;
            } else {
                banh[max(x1, x2)][y1] = true;
            }
        }
        for (int y = 0; y <= gy; ++y) {
            for (int x = 0; x <= gx; ++x) {
                if (x == 0 && y == 0) {
                    count[x][y] = 1;
                } else {
                    count[x][y] = 0;
                    if (x > 0 && !banh[x][y]) {
                        count[x][y] += count[x - 1][y];
                    }
                    if (y > 0 && !banv[x][y]) {
                        count[x][y] += count[x][y - 1];
                    }
                }
            }
        }
        if (count[gx][gy] > 0) {
            cout << count[gx][gy] << endl;
        } else {
            cout << "Miserable Hokusai!" << endl;
        }
    }
    return 0;
}

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

int main(){
    long long A;
    std::string B;
    std::cin >> A >> B;
    
    long long ans = A * (B[0] - '0') * 100;
    if(B.size() >= 3){
        long long tmp = (A * (B[2] - '0')) * 10;
        ans = ans + tmp;
    }
    if(B.size() >= 4){
        long long tmp = (A * (B[3] - '0'));
        ans = ans + tmp;
    }
    
    std::cout << ans / 100 << std::endl;
    
    return 0;
}



Measured memory_bytes: 3628
a,b=map(int,input().split())
s=list(str(input()))
flag=False
numls=[str(i) for i in range(10)]
if s[a]!="-":
    flag=True
else:
    for i in range(a-1):
        if s[i] not in numls:
            flag=True
    for j in range(b):
        if s[a+j+1] not in numls:
            flag=True
print("YNeos"[flag::2])


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

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int R[11];
int G[211][211];
int dp[1<<8][8];
int r;

int solve(int mask, int p) {
  if(mask == (1<<r) - 1) return 0;
  int &res = dp[mask][p];
  if(res != -1) {
    return res;
  }
  res = 100000000;
  if(!mask) {
    rep(i,0,r) {
      res = min(res, solve(1<<i, i));
    }
    return res;
  }
  rep(i,0,r) if(!((mask>>i)&1)) {
    res = min(res, G[R[p]][R[i]] + solve(mask | (1<<i), i));
  }
  return res;
}

int main() {
  int n,m;
  scanf("%d%d%d",&n,&m,&r);
  rep(i,0,r) {
    S(R[i]);
    R[i]--;
  }
  rep(i,0,n) rep(j,0,n) {
    if(i != j) G[i][j] = 100000000;
  }
  while(m--) {
    int u,v,c;
    S2(u,v);
    S(c);
    u--; v--;
    G[u][v] = G[v][u] = c;
  }
  rep(k,0,n) {
    rep(i,0,n) rep(j,0,n) {
      G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
    }
  }
  memset(dp, -1, sizeof(dp));
  P(solve(0,0));
  return 0;
}


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

int main(void) {
    int a,b;
    cin>>a>>b;
    if (a==1&&b==2) {
        cout<<3<<endl;
    } else if (a==1&&b==3) {
        cout<<2<<endl;
    } else if (a==2&&b==1) {
        cout<<3<<endl;
    } else if (a==2&&b==3) {
        cout<<1<<endl;
    } else if (a==3&&b==1) {
        cout<<2<<endl;
    } else if (a==3&&b==2) {
        cout<<1<<endl;
    }
}

Measured memory_bytes: 256
s=input()[::-1]

isOk=False
while len(s)>=5:
    if s[:5]=="maerd" or s[:5]=="esare":
        s=s[5:]
    elif len(s)>=6 and s[:6]=="resare":
        s=s[6:]
    elif len(s)>=7 and s[:7]=="remaerd":
        s=s[7:]
    else:
        break
    
    if len(s)==0:
        isOk=True

print("YES") if isOk else print("NO")

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

using namespace  std;

typedef long long ll;

ll mod = 1e9 + 7;
ll f[1000010];

ll fpow(ll a,ll b,ll p){
    ll res = 1;
    while(b > 0) {
        if (b & 1) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        b >>= 1;
    }
    return res % p;
}

//求逆元  1/(n-m)! = inv((n-m)!)
ll pw(ll a,ll p){
    return fpow(a,p-2,p);
}

ll nCk(ll n, ll k,ll p){
    f[0] = 1;
    for(int i = 1;i<=n;i++){
        f[i] = f[i-1] * i % p;
    }
    return f[n] * fpow(f[n-k],p-2,p) % p * fpow(f[k],p-2,p) % p;
}
ll x,y;
int main(){
    cin >> x >> y;

    if((x + y) % 3 || (x + x - y) < 0 || (y + y - x)< 0){
        cout << 0 << endl;
    }else{
        ll a = (x + x - y)/3;
        ll b = (y + y - x)/3;
        cout << nCk(a + b,b,mod) << endl;
    }
    return 0;
}

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

int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll ans;
  if(n>=b){
    ans=b-1;
  }else{
    ans=n;
  }
  ll cal=((a*ans)/b)-a*(ans/b);
  cout << cal << endl;
  return 0;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<P> ai(n);
    rep(i, n) ai[i] = P(a[i], i);
    sort(ai.rbegin(), ai.rend());
    
    auto dp = make_vec<ll>(n+1, n+1);

    rep(i, n) {
        for (int j = 0; j <= i; ++j) {
            int l = 0, r = n-1;
            l += j; r -= (i - j);
            chmax(dp[i+1][j], dp[i][j] + 1LL * ai[i].first * (r - ai[i].second));
            if (j+1 <= n) chmax(dp[i+1][j+1], dp[i][j] + 1LL * ai[i].first * (ai[i].second - l));
        }
    }

    ll ans = 0;
    rep(j, n+1) chmax(ans, dp[n][j]);
    cout << ans << endl;
}


Measured memory_bytes: 34612
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(18);

	string s; cin >> s;
	int ans = 0;

	rep(i, 0, sz(s)) {
		int j = sz(s)-i-1;
		if (j < i) break;
		ans += s[i] != s[j];
	}

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


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

typedef long long ll;

int main() {
    string s, t;
    int i, j;
    cin >> s >> t;
    
    for (i = s.size()-t.size(); i>=0; i--) {
        for (j = 0; j < t.size(); j++) {
            if (s[j+i]!=t[j]&&s[i+j]!='?') break;
        }
        if (j==t.size()) break;
    }

    if (i < 0) cout << "UNRESTORABLE" << endl;
    else {
        for (j = 0; j < t.size(); j++) s[i+j]=t[j];
        for (i=0;i<s.size();i++) if (s[i]=='?') s[i] = 'a';
        cout << s<< endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*

const val MOD = 1000000007L
const val INF = Long.MAX_VALUE - 1

fun main(args: Array<String>) {
    val s = readList().first()

    var count = 0
    var prev = ""
    var now = ""
    s.forEach {
        now += it
        if (prev == now) {
        } else {
//            println(prev)
            prev = now
            now = ""
            count++
        }
    }
    println(count)
}

fun readList() = readLine()!!.split(' ')


inline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> {
    return HashMap(this)
}

Measured memory_bytes: 43876
from fractions import gcd 

l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
D = l[3]

E = C * D //gcd(C,D)

f = B//C - (A-1)//C
f = f+(B//D - (A-1)//D)
ans = B-A+1-f + B//E-(A-1)//E
print(ans)


Measured memory_bytes: 5560
#include<bits/stdc++.h>
 
using namespace std;
long long int MOD(long long int a){
if(a>0)
  return a;
else 
  return (-1)*a;
}
int main(){
  long long int n,m;
  cin>>n>>m;
  long long int rem=n%m;
  if(n==0 || m==0)
    cout<<n;
  else 
  cout<<min(rem,MOD(m-rem));
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    ll N;
    ll T[1001],A[1001];
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>T[i]>>A[i];
    ll X=1,Y=1;
    REP(i,N){
        if(i==0){
            X=T[i],Y=A[i];
            continue;
        }
        X=T[i]*max(X/T[i]+(X%T[i]?1:0),Y/A[i]+(Y%A[i]?1:0));
        Y=A[i]*max(X/T[i]+(X%T[i]?1:0),Y/A[i]+(Y%A[i]?1:0));
        DEB(X)DEB(Y)END
     }
    ans=X+Y;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
sc = m.times.map { gets.split.map(&:to_i) }

l = 0
r = 9

if n == 2
  l = 10
  r = 99
elsif n == 3
  l = 100
  r = 999
end

l.upto(r) do |x|
  flag = true
  sc.each do |e|
    s = e[0]
    c = e[1].to_s
    xx = x.to_s
    if xx[s - 1] != c
      flag = false
      break
    end
  end
  if flag
    puts x
    exit
  end
end

puts '-1'


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 5e5 + 555;
void solve()
{
	
	string s;
	cin >> s;
	sort(all(s));
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes";
	else cout << "No";


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


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

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    int sum2 = 0;
    rep(j, n) cin >> a[0][j];
    rep(j, n){
        cin >> a[1][j];
        sum2 += a[1][j];
    }

    sum2 += a[0][0];
    int ans = sum2;
    for(int i = 1; i < n; ++i){
        chmax(ans, sum2);
        sum2 = sum2 + a[0][i] - a[1][i-1];
    }

    cout << ans << endl;

return 0;
}

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

int main() {
    long long int n,temp;
    long double k,a,b;
    cin>>n;
    if(n%2==0)
    temp=n/2;
    else
    temp=n/2+1;
    a=n;
    b=temp;
    k=b/a;
    cout<<fixed<<setprecision(10)<<k;
     

  return 0;
    
}
    


Measured memory_bytes: 256
N = int(input())
S = input()

#区切り位置は文字数-1（スライサーは1～N-1）
max = 0
for i in range(1, N, 1):
  a = len( set(S[:i]) & set(S[i:]) )
  if max < a: max = a
    
print(max)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s,t;
	cin >> s >> t;
	vector<vector<int>> alfas(26);
	int n = s.size();
	for(int i =0;i<n;++i)
	{
		alfas[s[i]-'a'].push_back(i);
	}
	for(int i = 0;i<26;i++)
	{
		alfas[i].push_back(MOD);
	}
	ll ans=0;
	ll now = -1;
	for(int i =0;i<t.size();i++)
	{
		now = *upper_bound(alfas[t[i]-'a'].begin(),alfas[t[i]-'a'].end(),now);
		//cout<<alfas[t[i]-'a'].size()<<endl;
		//cout<<now<<endl;
		if(now==MOD)
		{
			ans+= n;
			now = -1;
			now = *upper_bound(alfas[t[i]-'a'].begin(),alfas[t[i]-'a'].end(),now);
			if(now==MOD)
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	cout<<ans+now+1<<endl;

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

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

int main(){
  int N;
  cin>>N;
  VL A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  ll Z=0;
  map<PLL,ll> M;
  map<PLL,ll> M2;
  ll ans=1;
  ll mod=1e9+7;
  rep(i,N){
    if(A[i]<0){
      A[i]=-A[i];
      B[i]=-B[i];
    }
    if(A[i]==0 and B[i]==0) Z++;
    else if(A[i]==0) M[mp(0,1)]++;
    else if(B[i]==0) M2[mp(0,1)]++;
    else if(B[i]>0){
      ll tmp=gcd(A[i],B[i]);
      M[mp(A[i]/tmp,B[i]/tmp)]++;
    }else{
      ll tmp=gcd(A[i],abs(B[i]));
      M2[mp(abs(B[i])/tmp,A[i]/tmp)]++;
    }
  }
  VL X(200001);
  X[0]=1;
  rep(i,200000) X[i+1]=X[i]*2%mod;
  auto itr=M.begin();
  rep(i,M.size()){
    PLL tmp=itr->first;
    if(M2.find(tmp)!=M2.end()) (ans*=(X[M[tmp]]+X[M2[tmp]]+mod-1)%mod)%=mod;
    else (ans*=X[M[tmp]])%=mod;
    itr++;
  }
  itr=M2.begin();
  rep(i,M2.size()){
    PLL tmp=itr->first;
    if(M.find(tmp)==M.end()) (ans*=X[M2[tmp]])%=mod;
    itr++;
  }
  ans=(ans+Z+mod-1)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 20352
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int>a(n, 0);
	vector<int>sum(n, 0);
	if (s[0] == 'W') {
		a[0] = 1;
		sum[0] = 1;
	}
	for (int i = 1; i < n; i++) {
		if (s[i] == 'W')a[i] = 1;
		sum[i] += sum[i - 1] + a[i];
	}
	int minNum = n;
	minNum = min(minNum, (n - 1) - (sum[n - 1] - sum[0]));
	minNum = min(minNum, sum[n - 2]);
	for (int i = 1; i < n - 1; i++) {
		int left = (n - 1 - i) - (sum[n - 1] - sum[i]);
		int right = sum[i - 1];
		minNum = min(minNum, left + right);
	}
	cout << minNum << endl;
	return 0;
}

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

int main(){
				int N;
				cin >> N;
				int C[N],S[N],F[N];

				for(int i = 0; i < N - 1; i++) cin >> C[i] >> S[i] >> F[i];

				for(int i = 0; i < N ; i++){
								int T = 0;
								for(int j = i; j < N - 1; j++){
												if( T < S[j]) T = S[j];
											 	if((T - S[j])%F[j]) T += F[j] - (T - S[j]) % F[j];	
												T += C[j];
								}
								cout << T << endl;	
				}
				return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int H,W;
    cin >> H >> W;
    int h,w;
    cin >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
result = []
count = 0
for x in range(0,n-1):
    if h[x] >= h[x+1]:
        count += 1
    else:
        result.append(count)
        count = 0
result.append(count)
print(max(result))

Measured memory_bytes: 14224
import heapq as h
import sys

input=sys.stdin.readline


N,M=map(int,input().split())
to=[set([]) for i in range(0,N)]
fr=[set([]) for i in range(0,N)]
for i in range(0,N+M-1):
    a,b=map(int,input().split())
    to[a-1].add(b-1)
    fr[b-1].add(a-1)

root=-1
for i in range(0,N):
    if fr[i]==set([]):
        root=i
        break

parent=[-1 for i in range(0,N)]
visited=set([])
q=[]
q.append(root)
h.heapify(q)
sub=[]
h.heapify(sub)
while q!=[]:
    while q!=[]:
        x=h.heappop(q)
        visited.add(x)
        for p in to[x]:
            if visited>=fr[p]:
                h.heappush(sub,p)
                parent[p]=x
        if q==[]:
            q=sub
            sub=[]
            h.heapify(sub)
            break

for i in range(0,N):
    print(parent[i]+1)


Measured memory_bytes: 105708
#include<stdio.h>
#define N 100000
#define INF 1000000000
  
struct C{
    
  char s;
  int value;
    
};
  
struct C L[N], R[N];
  
void merge(struct C *, int, int, int);
void mergeSort(struct C *, int , int);
int partition(struct C *, int, int);
void quickSort(struct C *, int, int);
  
  
  
int main(){
    
  int num;
  int i;
  int j;
  struct C A[N], B[N];
  char S[10];
  int stable;
  
  stable = 1;
    
  scanf("%d", &num);
  
  for ( i = 0; i < num; i++ ) {
      
    scanf("%s %d", S, &j);
      
    A[i].s = S[0];
    B[i].s = S[0];
    A[i].value = j;
    B[i].value = j;
      
  }
  
  mergeSort(A, 0, num);
  quickSort(B, 0, num-1);
  
  for ( i = 0; i < num; i++ ){
    if ( A[i].s != B[i].s ) stable = 0;
  }
  
  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < num; i++ ) {
    printf("%c %d\n", B[i].s, B[i].value);
  }
  
  return 0;
}
  
void merge(struct C A[], int left, int mid, int right){
    
  int i, j, k;
  int n1;
  int n2;
    
  n1 = mid - left;
  n2 = right - mid;
  
  for ( i = 0; i < n1; i++ ) {
    L[i] = A[left + i];
  }
  for ( i = 0; i < n2; i++ ) {
    R[i] = A[mid + i];
  }
  
    
  L[n1].value = INF;
  R[n2].value = INF;
  
  i = 0;
  j = 0;
    
  for ( k = left; k < right; k++ ){
      
    if ( L[i].value <= R[j].value ){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}
   
void mergeSort(struct C A[], int left, int right ){
    
  int mid;
    
  if ( left + 1 < right ){
      
    mid = (left + right)/2;
      
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
  
int partition(struct C A[], int p, int r){
    
  int i, j;
  struct C t, x;
  
  x = A[r];
  i = p - 1;
    
  for ( j = p; j < r; j++ ){
      
    if ( A[j].value <= x.value ){
        
      i++;
        
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
      
  }
    
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
    
  return i+1;
}
  
void quickSort(struct C A[], int p, int r){
  
  int q;
    
  if ( p < r ){
      
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
      
  }
    
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
int hyd(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

signed main(){
    int N;cin>>N;
    int A=1,B=1;
    REP(i,N){
        int x,y;cin>>x>>y;
        int n=max(hyd(A,x),hyd(B,y));
        A=n*x;B=n*y;
    }
    cout<<A+B<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
A = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

if (N-1-M)*2 > N:
    print('Impossible')
    exit()

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)
for x,y in XY:
    if uf.is_same(x,y): continue
    uf.unite(x,y)
for i in range(N):
    uf.root(i)

from collections import defaultdict
dic = defaultdict(lambda: [])
for i in range(N):
    r = uf.root(i)
    dic[r].append(A[i])
if len(dic)==1:
    print(0)
    exit()

ans = 0
arr = []
c = 0
for k in dic.keys():
    dic[k].sort(reverse=True)
    ans += dic[k].pop()
    c += 1
    for a in dic[k]:
        arr.append(a)
rem = (N-1-M)*2 - c
if rem > len(arr):
    print('Impossible')
else:
    arr.sort()
    ans += sum(arr[:rem])
print(ans)

Measured memory_bytes: 33824
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

int dp[10000009],ans=1;
int sum[1000009];
set<int>s1,s2;
signed main(){
  int h,w;
  cin>>h>>w;
  set<int>st;
  map<int,int>M;
  vector<int>a(h),b(w);
  r(i,h)cin>>a[i],M[a[i]]++,s1.insert(a[i]);
  r(j,w)cin>>b[j],M[b[j]]++,s2.insert(b[j]);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  
  dp[h*w]=1;
  sum[h*w]=1;

  if(M[h*w]!=2){
    cout<<0<<endl;
    return 0;
  }

  for(int i=h*w-1,k=1;i>=1;i--,k++){
    int A=lower_bound(a.begin(),a.end(),i)-a.begin(); A=h-A;
    int B=lower_bound(b.begin(),b.end(),i)-b.begin(); B=w-B;
    int C=A*B;
    if(M[i]>=3){
      cout<<0<<endl;
      return 0;
    }
    if(M[i]==2)dp[i]=1;
    else if(M[i]==1){
      if(s1.count(i))dp[i]=B;
      else dp[i]=A;
    }
    else dp[i]=C-k;
    if(dp[i]<0){
      return 1;
    }
    //cout<<i<<' '<<dp[i]<<endl;
  }
  for(int i=1;i<=h*w;i++) ans*=dp[i] , ans%=1000000007;

  cout<<ans<<endl;
}


Measured memory_bytes: 73088
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

struct Node{
  int key;
  Node *parent,*left,*right;
};
Node *root=0,*NIL=0;

void insert(int k){
  Node* y=NIL;
  Node* x=root;
  Node* z;
  z=(Node*)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL) root=z;
  else{
    if(y==NIL){
      root=z;
    }else{
      if(z->key<y->key) y->left=z;
      else y->right=z;
    }
  }
}

void inorder(Node* u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node* u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n;
  string command;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    string com;
    cin >> com;
    if(com=="print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
    else if(com=="insert"){
      int z;
      cin >> z;
      insert(z);
    }
  }
}

Measured memory_bytes: 26696
object Main extends App {
	val temp = scala.io.StdIn.readInt
	val A = scala.io.StdIn.readLine.split(" ").map(_.toLong).reverse

	var x = 2L
	var y = 2L

	for(i<-0 until temp){
		val t = x/A(i)

		if(x%A(i) == 0){
			x = t * A(i)
		}else{
			x = (t + 1) * A(i)
		}

		y = y/A(i)*A(i) + A(i) - 1
	}

	if(x > y) println(-1)
	else println(s"$x $y")
}

Measured memory_bytes: 49036
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;



int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	ll K;
	cin >> K;
	vector<ll> a(10);
	iota(a.begin(), a.end(), 0);

	for(int i =1;a.size() <= K;i++) {
		ll last = a[i] % 10, next = a[i] * 10 + last;
		if (last)a.push_back(next - 1);//lastが０で無ければ……
		a.push_back(next);
		if (last < 9) a.push_back(next + 1);
	}
	cout << a[K] << endl;


	return 0;
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
#define _for(i, a, b) for (int i = (a); i < (b); i++)
#define _count(i, a, b) for (int i = (a); i <= b; i++)
#define PB emplace_back
#define MINI -2147483648
#define MAXI 2147483647
#define MAXLL 9223372036854775807
#define MINLL -9223372036854775808
#define VI vector<int>
#define VB vector<bool>
#define VLL vector<long long>
#define LL long long
#define ULL unsigned long long
#define ALL(X) X.begin(), X.end() 
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
//#define Remilia_is_so_cute
#define StarBurst std::ios::sync_with_stdio(false),cin.tie(NULL);
#define lowerBit(x) x&-x
using namespace std;
 
inline void R_P(vector<int> &vec) {
  int temp;
  cin>>temp;
  vec.push_back(temp);
} 
inline bool checkMax(int &base, int test) {
  return (test > base) ? base = test, true : false; 
}
 
inline bool checkMin(int &base, int test){
  return (test < base)? base = test, true : false;
}
template <class T>
void test(vector<T> &vec, const string &warn) {
  cout<<warn<<'\n';
  _for(i, 0, vec.size())
    cout<<vec[i]<<' ';
  cout<<"\nTest end..............\n";
}

int n, m;
VB vis(200000, false);
vector<VI> graph(200000, VI(0, 0));
void DFS(int &s, int v) {
  vis[v] = true;
  s++;
  for(int X : graph[v])
    if (!vis[X])
      DFS(s, X);
}
int main () {
  StarBurst
  #ifdef Remilia_is_so_cute
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  
  cin >> n >> m;
  
  _for(i, 0, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].PB(b);
    graph[b].PB(a);
  }
  
  int ans = 0;
  _for(i, 0, n) {
    int tmp = 0;
    if (!vis[i]) {
      DFS(tmp, i);
      ans = max(ans, tmp);
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 23500
#include <iostream>
#include <string>
#include <vector>
#define N 12
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b-a == c-b){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//ITP1-8-C: Counting Characters
//2019.05.19

#include <stdio.h>

int main(void){
  int count[26] = {0};
  int i;
  char c;

  while (scanf("%c", &c) != EOF) {
    if (c >= 'A' && c <= 'Z') {
      i = c - 'A';
      count[i] = count[i] + 1;
    }else if (c >= 'a' && c <= 'z') {
      i = c - 'a';
      count[i] = count[i] + 1;
    }
  }
  for (i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, count[i]);
  }

  return 0;
}


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

#define debug(x) cout << #x << "=" << x << '\n'
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define forn(i, a, b) for(int i = int(a); i < int(b); i++)
#define forn_r(i, b, a) for(int i = int(b); i > int(a); i--)
#define printArray(arr, len) for(int i = 0; i < len; i++) cout << arr[i] << (i == len - 1 ? '\n' : ' ')

void test_case() {
    int n;
    cin >> n;
    
    if(n >= 30) {
    	cout << "Yes" <<'\n';
    } else {
    	cout << "No" <<'\n';
    }

    return;
}

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

    // int t;
    // cin >> t;

    // while(t--) {
        test_case();
    // }
    
    return 0;
}


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

using namespace std;

int main(void){
	string o, e;

	cin >> o >> e;

	for (int i = 0; i < o.size() + e.size(); i++){
		if (i % 2 == 0)
			cout << o[i/2];
		else
			cout << e[i/2];
	}

	cout << endl;
}


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

using namespace std;

int main() {
    int x;
    cin >> x;

    if(x <= 599) {
        cout << 8 << endl;
    }else if(x <= 799) {
        cout << 7 << endl;
    }else if(x <= 999) {
        cout << 6 << endl;
    }else if(x <= 1199) {
        cout << 5 << endl;
    }else if(x <= 1399) {
        cout << 4 << endl;
    }else if(x <= 1599) {
        cout << 3 << endl;
    }else if(x <= 1799) {
        cout << 2 << endl;
    }else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll A , B , N;
    cin >> A >> B >> N;
    if(N >= B - 1){
        cout << (A * (B - 1)) / B - A * ((B - 1) / B) << endl;
    }
    else{
        cout << (A * (N)) / B - A * ((N) / B) << endl;
    }
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
    int n,m;
    int x[1000];
    int s[1000];
    int masu=0;
    while(true){
        masu=0;
    cin>>n>>m;
	if(n==0&&m==0){
		break;
	}
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<m;i++){
        cin>>s[i];
    }
    int i=0;
    while(true){
        masu+=s[i];
        if(masu>=n-1){
            cout<<i+1<<endl;
            break;
        }
        masu+=x[masu];
        if(masu>=n){
            cout<<i+1<<endl;
            break;
        }
        i++;
    }
    }
    return 0;
} 

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

ll F(ll x) {
  ll res = x;
  res -= (x / C + x / D - x / lcm(C, D));
  return res;
}

int main() {
  ll A, B;
  cin >> A >> B >> C >> D;
  ll ans = F(B) - F(A-1);
  cout << ans << '\n';
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i,n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());
  ll t = 0;
  rep(i,n) {
    t += p[i].second;
    if (t > p[i].first) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> s(n+1);
  int m;
  for(int i = 0; i < n; i++){
    cin >> m;
    s.at(i+1) = s.at(i) + m+1;
  }
  
  int ans = 0;
  int tmp = 0;
  for(int i = 0; i + k <= n; i++){
    tmp = s.at(i+k) - s.at(i);
    if(ans < tmp) ans = tmp;
  }
  cout<<fixed<<setprecision(5);
  cout << ans / 2.0;
}



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



int main(){
	int N;
	cin>>N;
	vector<int> A(N);
	map<int,int> mp;
	for(int i=0;i<N;i++){
		cin>>A[i];
		mp[A[i]]++;
	}
	sort(A.begin(),A.end(),greater<int>());
	int ans = 0;
	for(int i=0;i<N;i++){
		if(mp[A[i]]==0)continue;
		long long a = (long long)1;
		while(a<=A[i])a*=2;
		if(A[i]*2!=a){
			if(mp[A[i]]>0&&mp[a-A[i]]>0){
				mp[A[i]]--;
				mp[a-A[i]]--;
				ans++;
			}
		}
		else{
			if(mp[A[i]]>1){
				ans++;
				mp[A[i]]-=2;
			}
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A, B, C, D;
    string S;
    ll maxi = 0;
    ll count = 0;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    cin >> S;
    rep2(i, min(A, B), max(C, D)) {
        if(i != min(A, B) && S[i - 1] == '#' && S[i] == '#') {
            cout << "No" << endl;
            return 0;
        } else if(max(A, B) - 1 <= i && i <= min(C, D) + 1) {
            if(S[i] == '.') {
                count++;
            } else {
                maxi = max(maxi, count);
                count = 0;
            }
        }
    }
    maxi = max(maxi, count);
    if(((A < B && C > D) || (A > B && C < D)) && maxi < 3) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main(){
    ll n;
    ll k;
    cin >> n >> k;

    ll fract1 = n % k;
    ll fract2 = abs(k - fract1);

    if(fract1 < fract2){
        cout << fract1 << endl;
    }else{
        cout << fract2 << endl;
    }
}

Measured memory_bytes: 3604
import java.util.*;

	public class Main {

		public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if((A-B)>C) System.out.println(0);
        else System.out.println(C-(A-B));
	}
}


Measured memory_bytes: 23252
#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;

int main()
{
    int x;
    cin >> x;
    if (x < 1200)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
    return 0;
}

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

int main(){
  int N, Nalt, M;
  cin >> N;
  Nalt = N;
  M = 0;
  while(Nalt > 0){
    M += Nalt%10;
    Nalt /= 10;
  }
  if(N%M == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int a[100005];
int b[100005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; read(n);
 
  for (int i = 1; i <= n; i++) {
    int r = n - i;
    int l = i - 1;
    b[i] = abs(r - l);
  }
  sort(b + 1, b + n + 1);

  for (int i = 1; i <= n; i++)
    read(a[i]);

  sort(a + 1, a + n + 1);;

  bool ok = true;
  for (int i = 1; i <= n; i++)
    ok = ok && a[i] == b[i];
  if (!ok) die(0);

  ll MOD = 1'000'000'007ll;
  ll ans = 1;
  for (int i = 1; i < n; i++)
    if (a[i] == a[i + 1])
      ans = ans * 2 % MOD;
  write(ans);
}



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

int main() {
    int n;
    cin >> n;
    vector<p> v;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        v.push_back(p(b, a));
    }
    sort(v.begin(), v.end());
    ll cur = 0;
    int f = 1;
    for (int i = 0; i < n; i++) {
        if (cur + v[i].second > v[i].first) f = 0;
        cur += v[i].second;
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>

#define maxn 50

using namespace std;

int f[maxn + 2];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> f[i];
    sort(f + 1, f + n + 1);
    int rez = 0;
    for (int i = n - k + 1; i <= n; i++)
        rez = rez + f[i];
    cout << rez;
    return 0;
}


Measured memory_bytes: 256