akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define assn(n,a,b) assert(n<=b && n>=a)
using namespace std;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) for(i=0;i<b;i++)
#define rep1(i,b) for(i=1;i<=b;i++)
#define pdn(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define pn printf("\n")
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define MOD 1000000007
LL mpow(LL a, LL n)
{LL ret=1;LL b=a;while(n) {if(n&1)
    ret=(ret*b)%MOD;b=(b*b)%MOD;n>>=1;}
return (LL)ret;}
#define MAXK 100000
#define MAXN 1000000000
int ar[MAXK];
int get(int n, int k){
    int i=0;
    while(i<k and ar[i]<=n)i++;
    return n-i;
}
typedef unsigned long long int ULL;
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
 
bool isSafe(int r, int c, vector<vector<int> > arr) {
	int n = arr.size();
	int m = arr[0].size();
	return (r>=0 && r<n && c>=0 && c<m);
}
 
/////////////////////////////////////////////////////////////
bool func(pair<LL,LL> a, pair<LL,LL> b) {
	if(a.first < b.first) return true;
	else {
		if(a.second>b.second) return true;
		else return false;
	}
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    LL t,i,n,a,b,ans,mn;
    cin>>n;
    ans=0ll;
    rep1(i,n) {
    	if(!(i%3==0 || i%5==0 || (i%3==0 && i%5==0))) ans += i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 4
#define N2 46

int Fin[N][N]={
  {1,2,3,4},
  {5,6,7,8},
  {9,10,11,12},
  {13,14,15,0}};

int P[N*N]={3,0,1,2,
              3,0,1,2,
              3,0,1,2,
              3,0,1,2};
int Q[N*N]={3,0,0,0,
            0,1,1,1,
            1,2,2,2,
            2,3,3,3};

int min=N2;

void sorting(int X[N][N], int Xj[N][N], int n)
{
  int i,j,k,l,d=0,f=0,tmp[N][N];

  for(i=0;i<N;i++) {
    for(j=0;j<N;j++) {
      if(Fin[i][j]!=X[i][j]) f++;
      if(X[i][j]==0) {
        k=i;
        l=j;
      }
      else
        d+=abs(j-P[X[i][j]])+abs(i-Q[X[i][j]]);

    }
  }
  if(f==0) {
    if(min>n) {
      min=n;
    }
    return;
  }
  if(d+n>min) return;


  if(k>0 && k<N) {
    memcpy(tmp,X,sizeof(int)*N*N);
    f=tmp[k][l];
    tmp[k][l]=tmp[k-1][l];
    tmp[k-1][l]=f;
    if(memcmp(tmp,Xj,sizeof(int)*N*N)!=0)
      sorting(tmp, X, n+1);
  }
    if(l>0 && l<N) {
    memcpy(tmp,X,sizeof(int)*N*N);
    f=tmp[k][l];
    tmp[k][l]=tmp[k][l-1];
    tmp[k][l-1]=f;
    if(memcmp(tmp,Xj,sizeof(int)*N*N)!=0)
      sorting(tmp, X, n+1);
  }
 if(k>=0 && k<N-1) {
    memcpy(tmp,X,sizeof(int)*N*N);
    f=tmp[k][l];
    tmp[k][l]=tmp[k+1][l];
    tmp[k+1][l]=f;
    if(memcmp(tmp,Xj,sizeof(int)*N*N)!=0)
      sorting(tmp, X, n+1);
  }
  if(l>=0 && l<N-1) {
    memcpy(tmp,X,sizeof(int)*N*N);
    f=tmp[k][l];
    tmp[k][l]=tmp[k][l+1];
    tmp[k][l+1]=f;
    if(memcmp(tmp,Xj,sizeof(int)*N*N)!=0)
      sorting(tmp, X, n+1);
  }

}

int main()
{
  int i,j,Data[N][N];

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      scanf("%d",&Data[i][j]);
    }
  }
  sorting(Data,Data,0);

  printf("%d\n",min);
  return 0;
}



Measured memory_bytes: 2084
while True:
    try:
        inp = map(str, raw_input().split())
        s = []
        for i in inp:
            if   i == "+": s.append( s.pop(-2) + s.pop(-1) )
            elif i == "-": s.append( s.pop(-2) - s.pop(-1) )
            elif i == "*": s.append( s.pop(-2) * s.pop(-1) )
            elif i == "/": s.append( s.pop(-2) / s.pop(-1) )
            else: s.append(float(i))
        print s[0]
    except:
        break

Measured memory_bytes: 4244
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define size(c) (int)((c).size())
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    int n; cin >> n;
    vector<int> a(2*n);
    cin >> a;
    sort(all(a));
    int ans = 0;
    rep(i, n){
        ans += a[2*i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
n,m,k=map(int,input().split())

can=[]
for i in range(n+1):
    for j in range(m+1):
        can.append(n*j+i*m - 2*i*j)


# can_m=[]
# can_n=[]

# for i in range(m+1):
#     can_m.append(i*n)
# for i in range(m+1):
#     p = can_m[i]
#     for j in range(1,m):
#         s = i*n - i*j + j*(m-i)
#         can_m.append(s)

# for i in range(n+1):
#     can_n.append(i*m)
# for i in range(n+1):
#     p = can_n[i]
#     for j in range(1,n):
#         s = i*m - i*j + j*(n-i)
#         can_n.append(s)

if (k in can): #or (k in can_n):
    print('Yes')
else:
    print('No')

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

int main(){
  long x[1000],y[1000];
  int n;
  cin>>n;
  cout<<fixed<<setprecision(10);
  for(int i=0; i<n; i++){
    cin>>x[i];
  }

  for(int i=0; i<n; i++){
    cin>>y[i];
  }

  double maxn=0;
  for(int p=1; p<4; p++){
    double sum=0;
    for(int i=0; i<n; i++){
      sum += pow(abs(x[i]-y[i]),p);
      maxn = max((double)abs(x[i]-y[i]),maxn);
    }
    cout<<pow(sum,(double)1/p)<<endl;
  }
  cout<<maxn<<endl;
}




Measured memory_bytes: 3480
inp = input()
inn = [int(e) for e in input().split()]
c = []
for d in inn:
    if d > 0:
        c.append(1)

    else:
        c.append(0)
k = [abs(d) for d in inn]


if c.count(0) % 2 == 1:
     k.sort()
     a = k.pop(0)
     aa = sum(k) - a
     print(aa)
else:
    k.sort()
    aa = sum(k)
    print(aa)


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

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

	string S;
	cin >> S;

	vector<int> c( 256 );
	c[S[0]] += 1;
	c[S[1]] += 1;
	c[S[2]] += 1;
	cout << (c['a'] == 1 && c['b'] == 1 && c['c'] == 1 ? "Yes" : "No") << endl;

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll ans = LLONG_MAX;
  ll total = 0;
  ll tmp = 0;
  for(int i = 0; i < n; ++i){
    tmp += a[i];
    if (i % 2) {
      if(tmp >= 0) {
        total += abs(tmp) + 1;
        tmp = -1;
      }
    } else {
      if(tmp <= 0) {
        total += abs(tmp) + 1;
        tmp = 1;
      }
    }
  }
  ans = total;
  total = 0;
  tmp = 0;
  for(int i = 0; i < n; ++i){
    tmp += a[i];
    if (i % 2 == 0) {
      if(tmp >= 0) {
        total += abs(tmp) + 1;
        tmp = -1;
      }
    } else {
      if(tmp <= 0) {
        total += abs(tmp) + 1;
        tmp = 1;
      }
    }
  }

  ans = min(total, ans);
  cout << ans << endl;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

def check(m):
    # 全体攻撃
    b = B * m
    H2 = [h-b for h in H]
    # 単体攻撃
    cnt = 0
    for h in H2:
        if h > 0:
            cnt += ceil(h, A)
    # 必要な単体攻撃の回数がm以下ならOK
    return cnt <= m

N, A, B = MAP()
H = LIST(N)
# Aを単体攻撃、Bを全体攻撃とする
A -= B

# 二分探索
res = bisearch_min(0, 10**9, check)
print(res)


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
        int h[100001] = {};
        int n, k;
        ci >> n >> k;

        rep(i, n) ci >> h[i];

        sort(h, h + n);

        int mn = 1000000001;

        for(int i = 0; i < n - k + 1; i++) {
                mn = min(mn, h[i + k - 1] - h[i]);
        }

        co << mn << en;

        return 0;
}

Measured memory_bytes: 640
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)
#define MOD (ll)(1e9+7)
 
#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)
 
//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;

ll ones[11], nines[11];
bool ores[11], nres[11];
ll n;

bool check(ll ans, ll guess) {
    bool b1 = ans > guess && to_string(ans) > to_string(guess);
    bool b2 = ans <= guess && to_string(ans) <= to_string(guess);
    return b1 || b2;
}

bool input(ll cur) {
    char ch;
    cin >> ch;

    bool b = ch == 'Y';
    // b = check(n,cur);
    // if (b) cout << 'Y' << endl;
    // else cout << 'N' << endl;
    return b;
}


void solve() {
    //cin >> n;
    ll cur = 1;
    rep(i,0,11) {
        ones[i] = cur;
        cur *= 10;
        nines[i] = cur-1;
    }

    // ll n; cin >> n;
    // rep(i,0,10) {
    //     cout << check(n,ones[i]) << " " << check(n,nines[i]) << endl;
    // }



    rep(i,0,11) {
        cout << "? " << ones[i] << endl;
        ores[i] = input(ones[i]);
        cout << "? " << nines[i] << endl;
        nres[i] = input(nines[i]);
    }

    ll nd = 0;
    rep(i,0,11) {
        if (ores[i] && nres[i])
            nd = i+1;
    }
    if (nd == 11) {
        rep(i,0,11) {
            if (ores[i] && nres[i]) {
                nd = i+1;
                break;
            }
        }
    }

    ll l = ones[nd-1], r = nines[nd-1]+1;
    while (l < r) {
        ll mid = (l+r)/2; mid *= 10;
        cout << "? " << mid << endl;
        bool b = input(mid);
        if (b) {
            r = (l+r)/2;
        }
        else {
            l = 1+(l+r)/2;
        }
    }
    cout << "! " << l << endl;
}
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

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

int main(){
    int n, two=0, four=0;
    cin >> n;
    int A[n];
    for(int i=0 ; i<n ; i++){
        cin >> A[i];
        if(A[i]%4==2){
            two++;
        }else if(A[i]%4==0){
            four++;
        }
    }
    if(two%2==0 || (two%2==1 && n%2==1)){
        if((n-two)/2<=four){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if((n-two)/2<four){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

alias P = Tuple!(int, "h", int, "w");
alias C = Tuple!(int, "i", int, "c");

void main()
{
    auto hwm = readln.split.to!(int[]);
    auto H = hwm[0];
    auto W = hwm[1];
    auto M = hwm[2];
    auto hs = new C[](H);
    foreach (i, ref c; hs) c.i = i.to!int;
    auto ws = new C[](W);
    foreach (i, ref c; ws) c.i = i.to!int;
    bool[P] ps;
    foreach (_; 0..M) {
        auto hw = readln.split.to!(int[]);
        auto p = P(hw[0]-1, hw[1]-1);
        ps[p] = true;
        ++hs[p.h].c;
        ++ws[p.w].c;
    }
    sort!"a.c > b.c"(hs);
    sort!"a.c > b.c"(ws);
    auto max_h = hs[0].c;
    auto max_w = ws[0].c;

    foreach (h; hs) {
        if (h.c < max_h) break;
        foreach (w; ws) {
            if (w.c < max_w) break;
            if (P(h.i, w.i) !in ps) {
                writeln(max_h + max_w);
                return;
            }
        }
    }
    writeln(max_h + max_w - 1);
}

Measured memory_bytes: 31628
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

tuple<int, int> input_int2() {
	int a, b;
	cin >> a >> b;	
	return forward_as_tuple(a, b);
}

tuple<int, int, int> input_int3() {
	int a, b, c;
	cin >> a >> b >> c;	
	return forward_as_tuple(a, b, c);
}

vector<int> input_int_array(int n,vector<int> vec) {
	for (int i=0,tmp=0; i<n && cin >> tmp; i++) vec[i]=tmp;
	return vec;
}

vector<vector<int>> input_int_matrix(int n, int m, vector<vector<int>> matrix) {
	int tmp;
	for(int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> tmp;
			matrix[i][j] = tmp;
		}
	}
	return matrix;
}

const int MAX_N = 20;
const int MAX_M = 20;

int N, M, C;
vector<vector<int>> A(MAX_N, vector<int>(MAX_M));
vector<int> B(MAX_M);

void input() {
	tie(N,M,C) = input_int3();
	B = input_int_array(M, B);
	A = input_int_matrix(N, M, A);
}

void print_matrix(int N, int M, vector<vector<int>> matrix) {
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++) {
			cout << A[i][j] << " ";
		}
		cout << endl;
	}	
}

int solve() {
	int count = 0;
	for(int i=0; i<N; i++) {
		int value = 0;
		for(int j=0; j<M; j++) {
			value += A[i][j]*B[j];
		}
		if(value+C>0) count++;
	}
	return count;
}

int main() {
	input();
	cout << solve() << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int n; cin >> n;

    P red[n], blue[n];
    rep(i, n){
        int a, b; cin >> a >> b;
        red[i] = {b, a};
    }
    rep(i, n){
        int c, d; cin >> c >> d;
        blue[i] = {c, d};
    }

    priority_queue<P, vector<P>, greater<P>> queblue;
    rep(i, n){
        queblue.push(blue[i]);
    }

    int ans = 0;
    while(!queblue.empty()){

        P tempblue = queblue.top();
        queblue.pop();

        // cout << tempblue.first << " " << tempblue.second << endl;

        vector<P> vred;
        rep(i, n){
            
            if(red[i].first != -1 && red[i].first < tempblue.second && red[i].second < tempblue.first){
                vred.push_back(red[i]);
            }
        }

        if(!vred.empty()){
            sort(vred.begin(), vred.end(), greater<P>());
            rep(i, n){
                if(red[i] == vred[0]){
                    red[i] = {-1, -1};
                }
            }
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
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; }

ll N;

void func(ll cur, int use, ll &counter){
    if(cur > N)return;
    if(use == 0b111) counter++;

    func(cur*10+7, use|0b001, counter);
    func(cur*10+5, use|0b010, counter);
    func(cur*10+3, use|0b100, counter);
}

int main(){
    cin >> N;
    ll ans = 0;
    func(0, 0, ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const long long mod=1000*1000*1000+7;
string s[2];
long long modes;
int n,i,lst;
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n;
    cin>>s[0];
    cin>>s[1];
    if(s[0][0]==s[1][0]) modes=3,i=1,lst=0;
    else modes=6,i=2,lst=1;
    while(i<n)
    {
        if(s[0][i]==s[1][i])
        {
            if(lst==0)
                modes=(2LL*modes)%mod;
            lst=0;
            i++;
        }
        else
        {
            if(lst==0)modes=(2LL*modes)%mod;
            else modes=(3LL*modes)%mod;
            i+=2;
            lst=1;
        }
    }
    cout<<modes;
    return 0;
}


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

bool allCharEquals(string s){
  char awal = s[0];
  for(int i=1; i<s.size(); i++)
    if(s[i] != awal) return false;
  return true;
}

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

  int ans = INT_MAX;
  for(char ch = 'a'; ch <= 'z'; ch++){
    string temp = s;
    int process = 0;
    while(!allCharEquals(temp)){
      string newString = "";

      for(int i=0; i<temp.size()-1; i++){
        if(temp[i] == ch || temp[i+1] == ch){
          newString += ch;
        }
        else {
          newString += temp[i];
        }
      }

      temp = newString;
      process++;
    }

    ans = min(ans, process);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3616
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

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

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,Q;
string S;
vi res;

signed main(){

    in(N,Q);
    in(S);
    resize(res,N);
    char prev;
    REP(i,1,N){
        if(S[i-1]=='A'&&S[i]=='C'){
            res[i]++;
        }
    }
    show(res);
    rep(i,N-1){
        res[i+1]+=res[i];
    }
    show(res);

    rep(i,Q){
        int l,r;
        in(l,r);
        l--;r--;
        out(res[r]-res[l]);
    }

    return 0;
}


Measured memory_bytes: 1856
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define vec vector
#define prq priority_queue
#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=double;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int n;
vec<vec<vec<ld>>> dp;

ld solve(int s1,int s2,int s3)
{
    int sum=s1+s2+s3;
    if(!sum)
        return 0;
    if(dp[s1][s2][s3]>=0)
        return dp[s1][s2][s3];
    ld res=(ld)n/sum;
    if(s1)
        res+=(ld)s1/sum*solve(s1-1,s2,s3);
    if(s2)
        res+=(ld)s2/sum*solve(s1+1,s2-1,s3);
    if(s3)
        res+=(ld)s3/sum*solve(s1,s2+1,s3-1);
    return dp[s1][s2][s3]=res;
}

int main()
{
    scanf("%d",&n);
    dp.assign(n+1,vec<vec<ld>>(n+1,vec<ld>(n+1,-1)));
    vec<int> s(3);
    for(int i=0;i<n;++i)
    {
        int a;
        scanf("%d",&a);
        ++s[a-1];
    }
    printf("%.12f\n",solve(s[0],s[1],s[2]));
}



Measured memory_bytes: 216960
using System;
class Program
{
    public static void Main()
    {
        string[] import = Console.ReadLine().Split(' ');
        int n, k;
        n = int.Parse(import[0]);
        k = int.Parse(import[1]);
        import = Console.ReadLine().Split(' ');
        int[] l = new int[n];
        for (int i = 0; i < n; i++)
            l[i] = int.Parse(import[i]);
        Array.Sort(l);
        Array.Reverse(l);
        int ans = 0;
        for (int i = 0; i < k; i++)
            ans += l[i];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if true
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

ss = inputs[0][0]

# body
if $debugFlag
  p ss
end

arr = []
cnt = 0
ss.length.times do |i|
  if ss[i..i] == "A" or ss[i..i] == "T" or ss[i..i] == "C" or ss[i..i] == "G"
    cnt += 1
  else
    cnt = 0
  end
  arr << cnt
end
pd arr
puts arr.max


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
// #define INPUT_OUTPUT { \
//     freopen("input.txt","r",stdin); \
//     freopen("output.txt","w",stdout); \
// }
void solve() {
    string s ;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]) cout << "Yes" << "\n" ;
    else cout << "No" << "\n" ;
}
int main(){
    //INPUT_OUTPUT ;
    int t=1 ;
    //cin >> t ;
    while(t--) solve() ;
    return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int n ;
int s ;
int ans ;
int sum ;
bool vis[12] ;

void init ( ) ;
void DFS ( int source , int k ) ;

int main ( )
{
	while ( scanf ( "%d %d" , &n , &s ) == 2 && ( n || s ) ) {
		init ( ) ;
		DFS ( 0 , 0 ) ;
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void init ( )
{
	memset ( vis , false , sizeof ( vis ) ) ;
	ans = 0 ;
	sum = 0 ;
}

void DFS ( int source , int k )
{
	if ( source == n ) {
		if ( sum == s ) {
			ans++ ;
		}
		return ;
	}
	for ( int i = k ; i <= 9 ; i++ ) {
		if ( vis[i] == false ) {
			vis[i] = true ;
			sum += i ;
			DFS ( source + 1 , i ) ;
			vis[i] = false ;
			sum -= i ;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	ll MIN=min(n,m/2);
	m-=MIN*2;
	ans+=MIN;
	ans+=m/4;
	cout <<ans;
}

Measured memory_bytes: 256
# include<stdio.h>

int main(){
	int N,K,count,i;
	int A[100050];
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	count=1;
	N= N-K;
	while(1){
		if(N==0){
			break;
		}
		else if(N<K){
			count++;
			break;
		}
		else if(K<=N){
			count++;
			N=N-K+1;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 512
# import sys
# import math #sqrt,gcd,pi
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

# mod = int(1e9+7)
mod = 998244353
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    n,m = readInt()
    # インデックスを部屋番号として、各部屋から繋がっている部屋の番号をリストに持つ
    graph = [[] for i in range(n)]
    for i in range(m):
        x,y = readInt()
        graph[x-1].append(y-1)
        graph[y-1].append(x-1)
    # 各部屋に設定する番号を記録する
    v = [-1 for i in range(n)]
	# 部屋1は -1 以外にしておく
    v[0] = [0]
    # queueを作成し部屋1（インデックスは0）を入れる
    q = queue.Queue()
    q.put(0)
    while not q.empty():
      	# queueの先頭（今いる部屋の番号）を取り出す
        x = q.get()
        # 今いる部屋と繋がっている部屋を順に探索する
        for y in graph[x]:
          	# -1ではない場合は既に探索済みなのでスキップする
            if v[y]!=(-1):
                continue
            # あとで探索する為にqueueに入れておく
            q.put(y)
            v[y] = x
    print("Yes")
    for i in range(1,n):
        print(v[i]+1)
    return

if __name__=='__main__':
    main()


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  int H, W, N;
  cin >> H >> W >> N;

  int maxHW = max(H, W);
  cout << (N + maxHW - 1) / maxHW << endl;


  return 0;
}


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

int n;
char s[500000+5];
int a[500000+5];

int main(){
    scanf("%s",s);
    n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]=='<'){
            a[i+1]=max(a[i+1],a[i]+1);
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='>'){
            a[i]=max(a[i],a[i+1]+1);
        }
    }
    long long sum=0;
    for(int i=0;i<=n;i++) sum+=1ll*a[i];
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 2688
l = [[0 for i in range(13)] for j in range(4)]
n = int(input())

g = {0:"S",1:"H",2:"C",3:"D"}
h = {"S":0, "H":1, "C":2, "D":3}

for i in range(n):
    s,r = input().split()
    l[h[s]][int(r)-1] = 1

for i in range(4):
    for j in range(13):
        if l[i][j] == 0:
            print(g[i],j+1)

Measured memory_bytes: 7716
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        a: [String;n],
    }

    let a = a
        .into_iter()
        .map(|e| {
            let mut num = 0;
            let mut count = 0;
            let mut flag = false;
            for c in e.chars() {
                if c == '.' {
                    flag = true;
                    continue;
                }
                if flag {
                    count += 1;
                }
                num = num * 10 + c as usize - '0' as usize;
            }
            num * 10usize.saturating_pow(9 - count)
        })
        .collect::<Vec<_>>();

    let mut vec = vec![vec![0; 19]; 19];
    let mut sums = vec![vec![0; 20]; 20];
    let mut count = 0usize;
    for mut e in a {
        let mut twos = 0usize;
        let mut fives = 0usize;
        while e % 2 == 0 {
            e /= 2;
            twos += 1;
        }
        while e % 5 == 0 {
            e /= 5;
            fives += 1;
        }
        if twos > 18 {
            twos = 18;
        }

        if fives > 18 {
            fives = 18;
        }
        vec[twos][fives] += 1;

        count += sums[18 - twos][18 - fives];

        sums = vec![vec![0; 20]; 20];
        for i in 0..19 {
            for j in (0..19).rev() {
                sums[i][j] = sums[i][j + 1] + vec[i][j];
            }
        }
        for j in 0..19 {
            for i in (0..19).rev() {
                sums[i][j] += sums[i + 1][j];
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 17200
#include <bits/stdc++.h>
#define this-> tt
#define long long ll
using namespace std;
int main ()
{
 int a,b,c,k;
 cin>>a>>b>>c>>k;
 if (k<=a)cout<<k<<endl;
 else if (k<=a+b)cout<<a<<endl;
 else
cout << a - (k - a - b);


    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3636
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


s=data()
cnt=0
if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)


Measured memory_bytes: 72872
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display,
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

#[derive(PartialEq, PartialOrd, Copy, Clone)]
struct Real(f64);

impl std::ops::Deref for Real {
    type Target = f64;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl std::ops::DerefMut for Real {
    fn deref_mut(&mut self) -> &mut f64 {
        &mut self.0
    }
}
impl std::cmp::Eq for Real {}
impl Ord for Real {
    fn cmp(&self, other: &Real) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    let n = readl!(usize);
    let t = readlvec!(i32);
    let v = readlvec!(i32);
    let inf: f64 = 1e20;
    let mut dp = vec![-inf; 101];
    dp[0] = 0.;
    let max = |x, y| if x < y { y } else { x };
    for i in 0..n {
        for _ in 0..t[i] {
            let mut next = vec![-inf; 101];
            for k in 0..v[i]+1 {
                next[k as usize] = max(next[k as usize], dp[k as usize] + k as f64);
                if k < v[i] {
                    next[k as usize] = max(next[k as usize], dp[k as usize] + k as f64 + 0.25);
                    next[k as usize + 1] =
                        max(next[k as usize + 1], dp[k as usize] + k as f64 + 0.5);
                }
                if k > 0 {
                    next[k as usize-1] = max(next[k as usize-1], dp[k as usize] + k as f64 - 0.5);
                }
            }
            dp = next;
        }
    }
    printfln!("{}", dp[0]);
}


Measured memory_bytes: 4476
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int P, Q, R;
  scanf("%d %d %d", &P, &Q, &R);

  // solve
  printf("%d\n", min(min(P + Q, Q + R), R + P));
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int n; cin >> n;
	ll sum = 0;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		mp[x]++;
		sum += x;
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int b, c; cin >> b >> c;
		sum += 1LL * (c - b) * mp[b];
		mp[c] += mp[b];
		mp[b] = 0;
		cout << sum << "\n";
	}
}

Measured memory_bytes: 8052
#include<stdio.h>
int main()
{
    int s,m,h,t;
    scanf("%d",&t);
    h=t/3600;
    t=t%3600;
    m=t/60;
    t=t%60;
    s=t;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int main() {
	int N,x,y;
	cin>>N;
  	if(N<4) {
    	printf("No\n"); return 0;
    }
	if(N%4==0 or N%7==0 or (N-4)%7==0 or (N-7)%4==0){
		printf("Yes\n"); return 0;
	} 
	//if 4x+7y == N => 7y = (N-4x) , so N-4x is divisible by 7
	int lim = N>>2;  //N/4
	bool found = false;
	for(int x=0;x<=lim and !found; x++){
		int y = (N-4*x)/7;
		if(y<0) continue;
		if(4*x + 7*y == N) found = true;
	}
	printf("%s\n", found ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def bfs(s=0):
    que = deque([s])
    visited = [False] * N
    visited[s] = True
    while que:
        v = que.popleft()
        for u in E[v]:
            if not visited[u]:
                par[u] = v
                visited[u] = True
                que.append(u)

N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
par = [-1] * N
bfs()
cnt = len([i for i in par if i == -1])
if cnt > 1:
    print('No')
else:
    print('Yes')
    for p in par[1:]:
        print(p+1)

Measured memory_bytes: 34828
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(ReadLine());
      string[] input = ReadLine().Split();
      int d = int.Parse(input[0]);
      int x = int.Parse(input[1]);
      List<int> a = new List<int>();
      int ans = 0;
      for (int i=0;i<n;i++)
      {
        ans += ((d-1)/int.Parse(ReadLine()))+1;
      }
      WriteLine(ans+x);
      
    }
}

Measured memory_bytes: 27784
from copy import copy

X, Y, A, B, C = [int(n) for n in input().split(' ')]
p = [int(n) for n in input().split(' ')]
q = [int(n) for n in input().split(' ')]
r = [int(n) for n in input().split(' ')]

p.sort()
q.sort()

apple = p[-X:] + q[-Y:] + r
apple.sort()

print(sum(apple[-X-Y:]))


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 3636
a, b, m = map(int, input().split())
a2 = list(map(int, input().split()))
b2 = list(map(int, input().split()))
ans = min(a2) + min(b2)
for i in range(m):
    x, y, c = map(int, input().split())
    temp = a2[x - 1] + b2[y - 1] - c
    ans = min(ans, temp)
print(ans)

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

using namespace std;
#define int long long
#define INF 10e9
int32_t main() {
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    vector<int> dp(N,INF);
    dp[0]=0;
    cin>>A[0];
    
    //dp[1]=abs(A[1]-A[0]);
    for(int i=1;i<N;i++)
    {
        cin>>A[i];
        for(int j=i-1;i-j<=K && j>=0 ;j--)
        
        {dp[i]=min(dp[i],dp[j]+abs(A[i]-A[j]));}
        
       // cout<<dp[i]<<" ";
        
    }
    cout<< dp[N-1];
    return 0;
    
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int n, ans, a[210];

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n * 2) scanf("%d", &a[i]);
    sort(a + 1, a + 2 * n + 1);
    FOR(i, 1, n) ans += a[2 * i - 1];
    printf("%d\n", ans);
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
double dp[5000][5000];
int main()
{
	int N;
	cin >> N;

	vector<double> P;
	fx(N) {
		double p;
		cin >> p;
		P.push_back(p);
	}

	dp[0][1] = 1;
	dp[0][0] = 1;
	fx(N) {
		for (int y = 0; y <= x;y++) {
			dp[x + 1][y] +=(1- P[x])*dp[x][y];
		}
		for (int y = 0; y <= x; y++) {
			dp[x + 1][y+1] += P[x] * dp[x][y];
		}
	}
	double ans = 0;
	fyg(N+1,N/2+1) {
		ans += dp[N][y];
	}
	cout << fixed << setprecision(10) << ans << endl;

    return 0;
}



Measured memory_bytes: 117248
#include<stdio.h>

int main()
{
   int n,i,j,tot,max;
   max=tot=0;
   scanf("%d",&n);
    for(j=0;j<n;j++)
    {scanf("%d",&i);
    if(i%2!=0) tot++;
    if(i%4==0) max++;
    }
   if(max>=tot||(tot-max==1&&tot+max==n)) printf("Yes");
   else printf("No");
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int max(int cnt, ...);
inline int min(int cnt, ...);
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	n -= n/k*k;
	cout<<min(n, k-n)<<endl;
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	tms(cnt) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	tms(cnt) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


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

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  cout << (long)a * b / gcd(a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
for i in range(5,B,6):
    p = (i-5)//6
    ini = (i*5-1)//6
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Measured memory_bytes: 11936