akhauriyash/Code-Regression huggingface dataset:
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(f"{n}:", " ".join(list(map(str, prime_factorize(n)))))



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 k,x;
    cin >> k >> x;
    Yes(k * 500 >= x);
    return 0;
}

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

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

    int num[N + 1];
    fill(num, num + N + 1, 1);
    // 箱iにはボールがnum[i]個入っている

    bool red[N + 1];
    fill(red, red + N + 1, false);
    red[1] = true;
    // red[i] = 赤いボールが入っている「可能性がある」か

    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        if (red[x]) red[y] = true;
        // 赤ボールが移動するかもしれない

        --num[x];
        ++num[y];
        if (num[x] == 0) red[x] = false;
        // 空箱に赤ボールが入っている可能性は0
    }

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (red[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  vector<int> vec(3);
  
  for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  if (vec.at(0) == vec.at(1) && vec.at(1) != vec.at(2)) {
    cout << "Yes" << endl;
  }
  
  else if (vec.at(1) == vec.at(2) && vec.at(0) != vec.at(1)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        ls: [usize; n],
    }
    let mut cou = 0;
    for i in 0..ls.len() {
        let a = ls[i];
        for k in i + 1..ls.len() {
            let b = ls[k];
            if a == b {
                continue;
            }
            for m in k + 1..ls.len() {
                let c = ls[m];
                if a == c || b == c {
                    continue;
                }
                let max = max(max(a, b), c);
                if a + b + c - max > max {
                    cou += 1;
                }
            }
        }
    }
    println!("{}", cou);
}


Measured memory_bytes: 2184
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef std::pair<ll, ll> P;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main(){
  int n;

  cin >> n;

  vector<P > tasks;

  int a,b;

  rep(i,n){

  cin>>a>>b;
  tasks.emplace_back(b,a);
  }

  sort(all(tasks));

  ll work=0;
  bool ok=true;

  rep(i,n){

    work+=tasks[i].second;

    if (work>tasks[i].first){
      ok=false;
      break;

    }
  }

  cout << (ok ? "Yes" : "No" )<<endl;

  return 0;
}


Measured memory_bytes: 6512
n = gets.chomp

for i in n.to_i..999 do
  digit = i.to_s[0]
  for j in 1..(n.length-1) do
    break if i.to_s[j] != digit
    if j == i.to_s.length-1
      puts i.to_i
      exit
    end
  end
end


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    string s;
    cin >> s;

    int g = 0, p = 0;

    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(p+1<=g){
            p++;
            if (s[i] == 'g') ans++;
        }else{
            g++;
            if (s[i] == 'p') ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3728
using System;
class Program{
static void Main(){
  int[] a = new int[3];
  String[] input = Console.ReadLine().Split(' ');
  a[0] = Int32.Parse(input[0]);
  a[1] = Int32.Parse(input[1]);
  a[2] = Int32.Parse(input[2]);
  if (a[0] <= a[2] & a[0] + a[1] >= a[2]){
    Console.Write("YES");
  } else {
    Console.Write("NO");
  }
}
}


Measured memory_bytes: 11092
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    int n = s.size();
    vector<int>v;
    for(int i = 0 ;i<n;i++){
        if(i+1<n)
        if(s[i]==s[i+1]){
            v.push_back(i);
            v.push_back(i+1);
            break;
        }
        if(i+2<n)
        if(s[i]==s[i+2]){
            v.push_back(i);
            v.push_back(i+2);
            break;
        }
    }
    if(!v.empty()){
        cout<<v[0]+1<<" "<<v[1]+1;
    }
    else{
	cout << -1 << ' ' << -1 << endl;
    }

 

 
    
 
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<map>

using namespace std;

map<char,int> a;
int main(){
    string s;
    cin >> s;
    string  ans = "Good";
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ans = "Bad";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,aa,ans=0;
  cin >> a;
  while(cin >> a){
    if(aa > a){
      ans += aa - a;
    }else{
    aa = a;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

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

        long a = stdIn.nextLong();
        long b = stdIn.nextLong();
        long k = stdIn.nextLong();

        long x, y;
        if(k <= a){
            x = a - k;
            y = b;
        }else if(k <= a + b){
            x = 0;
            y = b - (k - a);
        }else{
            x = 0;
            y = 0;
        }

        System.out.println(x + " " + y);
    }
}

Measured memory_bytes: 23124
from collections import deque

def clamp(a,b,c):
  return min(max(a,b),c)

H,W = map(int,input().split())
A = [input() for _ in range(H)]

D = [[-1]*W for _ in range(H)]
dd = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque()
res = 0

for i in range(H):
  for j in range(W):
    if A[i][j] == "#":
      D[i][j] = 0
      Q.append([i,j,0])
      
while len(Q)>0:
  x,y,n = Q.popleft()
  for dx,dy in dd:
    xx = clamp(x+dx,0,H-1)
    yy = clamp(y+dy,0,W-1)
    if D[xx][yy] == -1:
      D[xx][yy] = n+1
      Q.append([xx,yy,n+1])
      res = n+1
      
print(res)

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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
ll modpow(ll a,ll b){
  ll r=1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

const int MX = 10002521;
ll fact[MX];
ll ifact[MX];

int h,w,k;

int main(){
  scanf("%d%d%d",&h,&w,&k);
  
  fact[0] = 1;
  FOR(i,1,MX)fact[i] = fact[i-1]*i%MOD;
  ifact[MX-1] = modpow(fact[MX-1], MOD-2);
  FORR(i,1,MX)ifact[i-1] = ifact[i]*i%MOD;
  ll factk;
  if(k<MX){
    factk = fact[k];
  }else{
    factk = fact[MX-1];
    FOR(i,MX,k+1)factk = factk*i%MOD;
  }
  ll factk1 = factk*(k+1)%MOD;

  ll ans = 0;
  ll hw = fact[h] * fact[w] % MOD;
  FOR(p,max(0,k-w),min(h,k)+1){
    ll X = p;
    ll Y = k-X;
    ll pp = hw * ifact[h-X] % MOD * ifact[w-Y] % MOD;
    ll ifxy = ifact[X] * ifact[Y] % MOD;
    ll val = factk1 * ifxy % MOD;
    val = val * ifact[3] % MOD * (2*X*Y%MOD + 3*k + 6) % MOD;
    val = (val - factk * ifxy % MOD + MOD) % MOD;
    ans += pp * val % MOD;
  }
  ans %= MOD;
  printf("%lld\n",ans);
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> R(N, { 0,0 });
	for (int i = 0; i < N; i++) {
		int X;
		cin >> X >> R[i].second;
		R[i].first = X + R[i].second;
	}
	sort(R.begin(), R.end());
	int ans = 0;
	int E = -1000000001;
	for (int i = 0; i < N; i++) {
		if (E <= R[i].first - 2 * R[i].second) {
			ans++;
			E = R[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
    }
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        UnionFind uf(n);
        for (int j = 0; j < m; ++j) {
            if(i == j) continue;
            uf.merge(a[j],b[j]);
        }
        if(uf.size(a[i]) < n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int at;
		at=n*a;
        System.out.print(Math.min(b,at));
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    if(n <= 6){
        cout << 1;
        exit(0);
    }
    if(n / 11 == 0){
        cout << 2;
        exit(0);
    }
    if(n % 11 == 0){
        cout << 2 * (n / 11);
    }else if(n % 11 <= 6){
        cout << 2 * (n / 11) + 1;
    }else{
         cout << 2 * (n / 11) + 2;
    }
}


Measured memory_bytes: 256
N= [int(i) for i in input().split()][0]
xn = [int(i) for i in input().split()]

x_mean = sum(xn) / N

if x_mean == int(x_mean):
  x_mean = int(x_mean)
  sum_ = 0
  for x in xn:
    sum_ += (x-x_mean)**2
  print(sum_)
else:
  x_mean = int(x_mean)
  sum1 = 0
  sum2 = 0
  for x in xn:
    sum1 += (x-x_mean)**2
    sum2 += (x-x_mean-1)**2
  print(min(sum1, sum2))
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >> n;
    map<ll,ll>ma;
    ll sum = 0;
    for(int i=0;i<=1e5+10;i++){
        ma[i]=0;
    }
    for(int i=0;i<n;i++){
        ll z;
        cin >>z;
        sum+=z;
        ma[z]++;
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int from,next;
        cin >> from >> next;
        if(!ma.count(from)){cout<<sum<<endl;
        
        
        continue;}
        sum+=(next-from)*ma.at(from);
        ma.at(next)+=ma.at(from);
        ma.at(from)=0;
        cout<<sum<<endl;
    }
}
    



Measured memory_bytes: 9852
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

int N, K;
bool has[105];

signed main()
{
	cin>> N>>K;
	rep(i, K) {
		int d; cin >> d;
		rep(j, d) {
			int a;cin >> a;
			has[a-1]=true;
		}
	}
	int ans=0;
	rep(i, N) ans += !has[i];
	cout<<ans<<endl;
}



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

using namespace std;

int main(){
    long long X;

    cin >> X;

    for(long long i=-200; i<=200; ++i){
        for(long long j=-200; j<=200; ++j){
            //long long calc = (i*i*i*i*i) - (j*j*j*j*j);
            long long calc = pow(i, 5) - pow(j, 5);
            if(calc == X){
                cout << i << " ";
                cout << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, y;

	cin >> n >> y;

	REP(i, n + 1) {
		REP(j, n + 1) {
			ll x = 10000 * i + 5000 * j + 1000 * (n - i - j);
			if (i + j > n) {
				break;
			}
			if (x == y) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
/*
    Author: Mohammad faisal
    Problem: unification
    Date: 06/08/2019

*/
// #include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int red=0, blue=0;
  red = count(s.begin(),s.end(),'0');
  blue = count(s.begin(),s.end(),'1');

  cout<<min(red,blue)*2<<endl;
  // cout<<2*count<<endl;
  return 0;
}
    

Measured memory_bytes: 512
#include <stdio.h>
int main(void) {
	long long int n;
	scanf("%lld",&n);
	long long int i,a[n];
	for(i=0;i<n;i++){
		scanf("%lld ",&a[i]);
	}
	long long int j,tmp;
	for(j=n-1;j>0;j--){
		for(i=0;i<j;i++){
			if(a[i]>a[i+1]){
				tmp=a[i];
				a[i]=a[i+1];
				a[i+1]=tmp;
			}
		}
	}
	for(j=n-1;j<n;j++){
	    for(i=1;i<=a[0];i++){
			if(a[0]%i==0&&a[j]%i==0){
				printf("%lld\n",i);
			}
		}
	}
	return 0;
}


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

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<ll> A(n+1);
    vector<ll> B(m+1);
    A.at(0) = 0;
    B.at(0) = 0;
    for(int i = 1;i <= n;i++){
        ll a;
        cin >> a;
        A.at(i) = A.at(i-1) + a;
    }
    for(int i = 1;i <= m;i++){
        ll b;
        cin >> b;
        B.at(i) = B.at(i-1) + b;
    }
    int ans = 0;
    int j = m;
    for(int i = 0; i <= n;i++){
        if(A.at(i) > k) break;
        while(A.at(i) + B.at(j) > k) j--;
        ans = max(ans,i+j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		long []sumA = new long [n+1];
		long []sumB = new long [m+1];
		
		for(int i = 0 ; i < n ;i++) {
			int a = Integer.parseInt(sc.next());
			sumA[i+1] = (long)(sumA[i] + a);
		}
		
		for(int i = 0 ; i < m ;i++) {
			int b = Integer.parseInt(sc.next());
			sumB[i+1] = (long)(sumB[i] + b);
		}
		
		int max = 0;
		
		for(int i = 0 ; i <= n ;i++) {
			if(sumA[i] > k) {
				continue;
			}
			
			int b = LowerBound(k, sumA[i],sumB,m);
			max = Math.max(i+b, max);
		}
		
		System.out.println(max);
		
	}
	
	static int LowerBound(int k , long t, long []sumB , int m) {
		if(t >= k) {
			return 0;
		}
		if(t + sumB[m] <= k) {
			return m;
		}
		
		int l = 0;
		int r = m;
		
		while(r-l > 1) {
			int tmp = (l+r)/2;
			if(t + sumB[tmp] > k) {
				r = tmp;
			}
			else if(t + sumB[tmp] < k) {
				l = tmp;
			}
			else {
				return tmp;
			}
		}
		
		
		return l;
	}
}


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

int main(){
  int n, m, x, y;
  vector<int> box;
  vector<int> hasRed;

  cin >> n >> m;
  box.resize(n, 1);
  hasRed.resize(n);
  hasRed[0] = 1;
  
  for(int i=0; i<m; ++i){
    cin >> x >> y;

    box[x-1]--;
    box[y-1]++;

    if(hasRed[x-1]){
      hasRed[y-1] = 1;
    }
    if(box[x-1]==0){
      hasRed[x-1] = 0;
    }
  }

  cout << accumulate(hasRed.begin(), hasRed.end(), 0) << endl;
  
  return 0;
}


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

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long A, long long B){
  if(A%3==0||B%3==0||(A+B)%3==0) cout<<YES<<endl;
  else cout<<NO<<endl;
}

// 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(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W=MI()
    if H==1 or W==1:
        print(1)
    else:
        print((H*W+1)//2)

main()


Measured memory_bytes: 38256
def sort(a):
    n = len(a)
    for i in range(1,n):
        for j in range(i):
            p = i-j
            if a[p] < a[p-1]:
                a[p], a[p-1] = a[p-1], a[p]
        print ' '.join(map(str, a))

n = int(raw_input())
a = map(int, raw_input().split(' '))
print ' '.join(map(str, a))
sort(a)

Measured memory_bytes: 6296
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int t=3;t-->0;){long r=-60*(s.nextInt()*60+s.nextInt())-s.nextInt(),a,b;r+=60*(s.nextInt()*60+s.nextInt())+s.nextInt();a=r/3600;r%=3600;b=r/60;r%=60;System.out.println(a+" "+b+" "+r);}}}

Measured memory_bytes: 11000
// https://atcoder.jp/contests/dp/tasks/dp_e

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w, i1, i2;
    cin >> n >> w;
    // dp[i] : 価値iの重さを最小化する
    vector<int> dp(1000001, INF);
    dp[0] = 0;
    int s = 0;
    REP(i, n) {
        cin >> i1 >> i2;
        for (int j = s; j >= 0; j--) {
            if (i1 + dp[j] <= w) {
                dp[j + i2] = min(dp[j + i2], dp[j] + i1);
            }
        }
        s += i2;
    }
    for (int i = s; i >= 1; i--) {
        if (dp[i] <= w) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 4224
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (abs(a - c) <= d)printf("Yes");
	else if (abs(a - b) <= d && abs(b - c) <= d)printf("Yes");
	else printf("No");
	return 0;
}

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

namespace ABC140D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            int N = int.Parse(NK[0]);
            int K = int.Parse(NK[1]);
            string S = Console.ReadLine();
            string SS = "R" + S + "L";
            //Console.WriteLine(SS);
            int l = SS.Length;
            int count = 0;
            for(int i = 0; i < l-1; i++)
            {
                if (SS[i].ToString() == "R")
                {
                    if (SS[i + 1].ToString() == "L")
                    {
                        count += 1;
                    }
                }
            }
            //Console.WriteLine(count);
            int happy = 0;
            int plus2 = 0;
            int plus1 = 0;
            if (S[0].ToString() == "L")
            {
                if (S[N - 1].ToString() == "R")
                {
                    happy = N - 2 * count + 2;
                    plus2 = Math.Max(count - 2, 0);
                    plus1 = 1;
                }
                else
                {
                    happy = N - 2 * count + 1;
                    plus2 = Math.Max(count - 1, 0);
                }
            }
            else
            {
                if (S[N - 1].ToString() == "R")
                {
                    happy = N - 2 * count + 1;
                    plus2 = Math.Max(count - 1, 0);
                }
                else
                {
                    happy = N - 2 * count;
                    plus2 = Math.Max(count - 1, 0);
                    plus1 = 1;
                }
            }
            //Console.WriteLine(happy);
            
                while (K>0&&plus2 > 0)
                {
                    happy += 2;
                    plus2 -= 1;
                    K -= 1;
                }
                while (K>0&&plus1 > 0)
                {
                    happy += 1;
                    plus1 -= 1;
                    K -= 1;
                }
            
            Console.WriteLine(happy);
        }
    }
}


Measured memory_bytes: 32460
#include <stdio.h>

int main(){
  int k,x;
  if(scanf("%d",&k)==1 && scanf("%d",&x)==1){}
  int i;
  if(x-k+1 < -1000000){
    for(i=-1000000;i<x+k;i++){
      printf("%d\t",i);
    }
  }else if(x+k-1 > 1000000){
    for(i=x-k+1;i<=1000000;i++){
      printf("%d\t",i);
    }
  }else{
    for(i=x-k+1;i<x+k;i++){
      printf("%d\t",i);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,A[100000];
  cin>>N; 
  for (int i(0);i<N;i++) cin>>A[i];
  sort(A,A+N);
  int maxi = A[N-1];
  double ans(0),tmp(1e9+1);
  for (int i(0);i<N-1;i++){
    if (tmp > abs(A[i]-maxi/(double)2)){
      ans = A[i];
      tmp = abs(A[i] - maxi/(double)2);
    }
  }
  cout << maxi << " " << int(ans) << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, cnt1, cnt2;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		int v;
		scanf("%d", &v);
		if(v & 1) ++cnt1;
		else ++cnt2;
	}
	if(cnt1 & 1) puts("NO");
	else puts("YES");
	return 0;
}
		

Measured memory_bytes: 3764
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <stdlib.h>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
using namespace std;

bool test = true;
#define log(x) if(test) cout << "[ " << #x << " = " << x << " ]\n";
#define log2(x, y) if(test) cout << "[ " << #x << " = " << x << ", " << #y << " = " << y << " ]\n"; 
#define logv(x) if(test) {cout << #x << " : { "; for(auto i : x) cout << i << " "; cout << "}\n";}; 

#define MX (ll)(1e14)

int main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    cin >> a >> b;
    int ans[n+1][m+1];
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++)
            ans[i][j] = 0;
    }
    
    for(int i=1; i<=b; i++) {
        for(int j=1; j<=a; j++) {
            ans[i][j] = 1;
        }
    }

    for(int i=b+1; i<=n; i++) {
        for(int j=a+1; j<=m; j++) {
            ans[i][j] = 1;
        }
    }

     for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++)
            cout << ans[i][j];
        cout << "\n";
    }
    

    
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int p[1000000];
int n;

int main(){
  cin>>n;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    p[a-1]++;
    p[b]--;
  }

  rep(i,1000000){
    if(i==0) continue;
    p[i]+=p[i-1];
  }

  int ans=0;
  rep(i,1000000){
    if(p[i]>=i)
      ans=i;
  }

  cout<<ans<<endl;


  return 0;
}



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

using namespace std;

int main(){
  int n;
  cin >> n;
  long long sum = 0;
  int a[n];
  int b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i] - (i+1);
  }
  sort(b,b+n);
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - (b[n/2] + i+1) );
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int A,B;
    cin >> A >> B;

    cout << max({A+B,A-B,A*B}) << endl;
    
    return 0;

}

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

if H==1 or W==1:
    print(1)
elif H%2==0 and W%2==0 or H%2==0 and W%2==1 or H%2==1 and W%2==0:
    print((H*W)//2)
else:
    print(((H*W)+1)//2)

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

int main(){
  int n,at=0;
  cin>>n;
  vector<int>t(n+1);
  for(int i=1;i<=n;i++){
    cin>>t[i];
    at+=t[i];
  }
  int m;
  cin>>m;
  vector<int>p(m+1);
  vector<int>x(m+1);
  for(int i=1;i<=m;i++){
    cin>>p[i]>>x[i];
  }
  for(int i=1;i<=m;i++){
    cout<<at-t[p[i]]+x[i]<<endl;
  }
}
      
      


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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i]; a[i]--;
    }
    ll ans = a[0];
    int now = 2;
    for(int i=1;i<n;i++){
        if(a[i]+1==now) now++;
        ans += a[i]/now;
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <iostream>
#include <unordered_map>
#include <utility>

using namespace std;

int main()
{
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        auto nextPoint = [](int i, int j, int d) {
            switch (d) {
            case 0:
                return make_pair(i - 1, j);
            case 1:
                return make_pair(i, j - 1);
            case 2:
                return make_pair(i + 1, j);
            case 3:
                return make_pair(i, j + 1);
            default:
                assert(false);
            }
        };

        unordered_map<int, pair<int, int>> m;
        m[0] = make_pair(0, 0);
        for (int i = 1; i < N; ++i) {
            int n;
            int d;
            cin >> n >> d;
            auto a = m[n];
            m[i] = nextPoint(a.first, a.second, d);
        }

        int x_max{-1};
        int x_min{999999999};
        int y_max{-1};
        int y_min{999999999};
        for (auto&& i : m) {
            x_max = max(x_max, i.second.first);
            x_min = min(x_min, i.second.first);
            y_max = max(y_max, i.second.second);
            y_min = min(y_min, i.second.second);
        }
        cout << (x_max - x_min + 1) << ' ' << (y_max - y_min + 1) << endl;
    }
}

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

int main()
{
  int64_t a,b,k,ans;
  cin>>a>>b>>k;
  if(a>k)
  {
    cout<<a-k<<" "<<b<<endl;
  }
  else
  {
    ans=a+b-k;
    if(ans<0)
      ans=0;
    cout<<"0"<<" "<<ans<<endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <queue>
#include <utility>
 
#define rep(i,n) for(int i = 0; i < n; i++)
 
using namespace std;
 
const int INF = 1e9;
 
int main(){
  int H, W;
  cin >> H >> W;
  
  int D[H][W];
  rep(i,H) fill(D[i], D[i]+W, INF);
  
  queue<pair<int,int> > que;
  rep(i,H){
    rep(j,W){
      char c;
      cin >> c;
      if(c == '#'){
        que.push(make_pair(i,j));
        D[i][j] = 0;
      }
    }
  }
  
  while(!que.empty()){
    pair<int,int> p = que.front();
    que.pop();
    
    int dy[] = {1,-1,0,0};
    int dx[] = {0,0,1,-1};
    
    rep(m,4){
      int y = p.first + dy[m];
      int x = p.second + dx[m];
      if(y < 0 || H <= y || x < 0 || W <= x) continue;
      if(D[y][x] != INF || D[y][x] < D[p.first][p.second] + 1) continue;
      D[y][x] = D[p.first][p.second] + 1;
      que.push(make_pair(y,x));
    }	
  }
  
  int ans = 0;
  rep(n,H){
    rep(o,W){
      ans = max(ans,D[n][o]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 12304
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const ll INF = 1LL << 60;

int main() {
    int N;
    cin >> N;
    vl a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    ll total = a[0];
    for (int i = 1; i < N; ++i) {
        total += a[i];
        a[i] += a[i - 1];
    }
    ll ret = INF;
    for (int i = 0; i < N - 1; ++i) {
        ll temp = abs(a[i] - (total - a[i]));
        ret = min(ret, temp);
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    string s;cin>>s;

    if(s=="SUN")cout<<7<<endl;
    else if(s=="MON")cout<<6<<endl;
    else if(s=="TUE")cout<<5<<endl;
    else if(s=="WED")cout<<4<<endl;
    else if(s=="THU")cout<<3<<endl;
    else if(s=="FRI")cout<<2<<endl;
    else if(s=="SAT")cout<<1<<endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int D, T, S;
  cin >> D >> T >> S;
  if (T * S >= D) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef stack<ii> si;
typedef long long ll;
bool c[420][420];
int vs[420][420];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int h,w;
ii dfs(int q, int r) {
	// b w
	ii ret = ii(0,0);
	si rec;
	rec.push(ii(q,r));
	while(!rec.empty()) {
		int a=rec.top().first,b=rec.top().second;
		rec.pop();
		if(vs[a][b]) {continue;}
		if(c[a][b]) {ret.first++;} else {ret.second++;}
		vs[a][b] = 1;
		for(int i=0;i<4;i++) {
			int u = a+dx[i],v=b+dy[i];
			if(u < 0 || u >= h) {continue;}
			if(v < 0 || v >= w) {continue;}
			if(vs[u][v]) {continue;}
			if(c[u][v] == c[a][b]) {continue;}
			rec.push(ii(u,v));
			//ret.first += ad.first;
			//ret.second += ad.second;
		}
	}
	return ret;
}
int main() {
	scanf("%d %d ",&h,&w);
	memset(vs,0,sizeof(vs));
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			char t;
			scanf("%c ",&t);
			c[i][j] = (t=='#');
		}
	}
	ll tot=0;
	for(int i=0;i<h;i++) 
		for(int j=0;j<w;j++) {
			ii ad = dfs(i,j);
			ll bf = ad.first,bs=ad.second;
			tot += bf*bs;
		}
	printf("%lld\n",tot);
}


Measured memory_bytes: 2432
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n, k, as1):
    if (n-1)%(k-1)==0:
        return (n-1)//(k-1)
    else:
        return (n-1)//(k-1)+1

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_n, str_k] = line.split(' ')
    line = sys.stdin.readline().rstrip()
    as1 = line.split(' ')
    return (int(str_n), int(str_k), [int(a) for a in as1])

def main():
    n, k, as1 = readQuestion()
    answer = solve(n, k, as1)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 14900
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

ll size = 0;

double recur(vector<pair<double, double>> v, ll l, ll r)
{
    if (l == r)
    {
        double cost = 0;
        for (ll i = 0; i < r; i++)
        {
            cost += sqrt((v[i + 1].first - v[i].first) * (v[i + 1].first - v[i].first) + (v[i + 1].second - v[i].second) * (v[i + 1].second - v[i].second));
        }
        size ++;
        return cost;
    }
    else
    {
        double cost = 0;
        for (ll i = l; i <= r; i++)
        {

            // Swapping done
            swap(v[l], v[i]);

            // Recursion called
            cost += (recur(v, l + 1, r));
            //backtrack
            swap(v[l], v[i]);
        }
        return cost;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double n;
    cin >> n;
    vector<pair<double, double>> v;
    for (ll i = 0; i < n; i++)
    {
        double a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    cout << fixed << setprecision(9) << recur(v, 0, n - 1) / size;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    print(ns()[:3])
    return

solve()


Measured memory_bytes: 9112
program main
  implicit none
  integer i, N, ans1
  !character(11) S, T
  read(*, *) N
  i = mod(N,10)
  if (i == 0) then
    write(*, *) 'pon'
  elseif (i == 1) then
    write(*, *) 'pon'
  elseif (i == 6) then
    write(*, *) 'pon'
  elseif (i == 8) then
    write(*, *) 'pon'
  elseif (i == 3) then
    write(*, *) 'bon'
  else
    write(*, *) 'hon'
  end if
   
  
  !write(*, *)
end program main


Measured memory_bytes: 2860
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int number = in.nextInt();
            if(number % 2 == 0){
                if (number % 3 != 0 && number % 5 != 0) {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, M;
	cin >> N >> M;
	long long A;
	priority_queue<long long>Sum;
	for (long long i = 0; i < N; i++) {
		cin >> A;
		Sum.push(A);
	}
	for (long long i = 0; i < M; i++) {
		long long X = Sum.top();
		Sum.pop();
		X /= 2;
		Sum.push(X);
	}
	long long ans = 0;
	while (!Sum.empty()) {
		ans += Sum.top();
		Sum.pop();
	}
	cout << ans << endl;
}

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

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        if (i % 2) {
            cout << (N + 1) / 2 - i / 2 - 1 << " " << (N + 1) / 2 + i / 2 + 1 << "\n";
        } else {
            cout << i / 2 + 1 << " " << N - i / 2 << "\n";
        }
    }
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A;
int main(){
  cin >> N;
  A.assign(N+10,0);
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }
  sort(A.begin()+1,A.begin()+N+1);
  cout << A[N/2+1]-A[N/2] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    if (N > 999)
    {
        cout << "ABD" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long[] A = new long[N];
    long sum = 0;
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
      sum += A[i];
    }

    int j = 0, k = 2;
    long p = A[0], q = 0, r = A[1] + A[2], s = sum - A[0] - A[1] - A[2];
    long minMaxDiff = Long.MAX_VALUE;
    for (int i = 1; i < N - 2; i++) {
      q += A[i];
      long diffPQ = Math.abs(p - q);
      while (j < i && Math.abs(p + A[j + 1] - q + A[j + 1]) < diffPQ) {
        j++;
        p += A[j];
        q -= A[j];
        diffPQ = Math.abs(p - q);
      }

      r -= A[i];
      long diffRS = Math.abs(r - s);
      while (k < N - 1 && Math.abs(r + A[k + 1] - s + A[k + 1]) < diffRS) {
        k++;
        r += A[k];
        s -= A[k];
        diffRS = Math.abs(r - s);
      }

      long maxDiff = maxDiff(p, q, r, s);
      if (maxDiff < minMaxDiff) minMaxDiff = maxDiff;
    }

    System.out.println(minMaxDiff);
  }

  static long maxDiff(long p, long q, long r, long s) {
    if (p > q) return maxDiff(q, p, r, s);
    if (q > r) return maxDiff(p, r, q, s);
    if (r > s) return maxDiff(p, q, s, r);
    return s - p;
  }
}


Measured memory_bytes: 73344
#include<bits/stdc++.h>
#define N 500000
#define INF (1e9)
using namespace std;
int n,s[N],ans;

void merge(int *A,int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  int L[N/2+1],R[N/2+1];
  for(int i=0;i<n1;i++)L[i]=A[left+i];
  for(int i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    ans++;
    if(L[i]<=R[j])A[k]=L[i],i++;
    else A[k]=R[j],j++;
  }
}

void mergeSort(int *A,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int A[N];
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  mergeSort(A,0,n);
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<A[i];
  }
  cout<<endl;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5068