akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

signed main(void) {
    int n;
    cin >> n;
    cout << n/500*500 << endl;
}



Measured memory_bytes: 3096
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int A, B, M;
  cin >> A >> B >> M;
  vi a(A), b(B);
  cin >> a >> b;
  vector<tuple<int, int, int>> xyc(M);
  vector<vector<pii>> p(A);
  rep(i, 0, M) {
    int x, y, c;
    cin >> x >> y >> c;
    x--, y--;
    xyc[i] = make_tuple(x, y, c);
    p[x].eb(y, c);
  }
  int ans = (*min_element(all(a))) + (*min_element(all(b)));
  rep(i, 0, A) {
    for (pii x : p[i]) {
      int j = x.first;
      int c = x.second;
      chmin(ans, a[i] + b[j] - c);
    }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 9216
//=======================================
// abc144a
//
//  2019/10/27
//=======================================

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[])
{
	cin.tie(0);
  ios::sync_with_stdio(false);

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

  if(a<10 && b<10) cout << a*b << endl;
  else  cout << -1 << endl; 

  return 0;
}

Measured memory_bytes: 256
#!python3

# input
N = int(input())
s = input()

d = {"S": "W", "W": "S"}


def f(x, y, i, j):
    if y == "S":
        if s[j] == "o":
            return x
        else:
            return d[x]
    else:
        if s[j] == "o":
            return d[x]
        else:
            return x


def solve(t):
    l = [None] * N
    l[0], l[1] = t
    l[-1] = f(l[1], l[0], 1, 0)
    for i in range(2, N - 1):
        l[i] = f(l[i - 2], l[i - 1], i - 2, i - 1)
    x = f(l[-3], l[-2], -3, -2)
    y = f(l[-2], l[-1], -2, -1)
    if x == l[-1] and y == l[0]:
        return l
    else:
        return None
        

def main():
    l = [("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")]
    ans = None
    for t in l:
        ans = solve(t)
        if ans is not None:
            break
    if ans is None:
        print(-1)
    else:
        print("".join(ans))
    

if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    ll A[100005];

    cin >> N;

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

    ll ans = 0;

    ll prev = 0;

    for (int i = 0; i < N; ++i) {
        if (prev == 0) {
            ans += (A[i] - 1);
            prev = 1;
        } else if (A[i] == prev) {
        } else if (A[i] == (prev + 1)) {
            prev = prev + 1;
        } else if (A[i] > (prev + 1)) {
            ans += (A[i] - 1) / (prev + 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int mn[200010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi(),k=gi(),x,y;
	memset(mn,63,sizeof mn);
	while(k--){
		x=gi(),y=gi();
		mn[x]=std::min(mn[x],y);
	}
	int R=1;
	for(int i=2;i<=n;++i){
		if(mn[i]<=R){
			printf("%d\n",i-1);
			return 0;
		}
		if(mn[i]!=R+1)++R;
	}
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define umii            unordered_map<int,int>
#define lli             list<int>             
#define gcd(m,n)        __gcd(m,n)   
#define mib             map<int,bool>
 
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}
 
//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();
  int n;
  cin>>n;
  int arr[n];
  
  for(int i=0;i<n;i++)
  cin>>arr[i];
  
  int dp[n];
  
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  
  for(int i=2;i<n;i++)
  dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
  
  cout<<dp[n-1];


}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define POS(i, j) ((i) * (m + 1) + (j))

i32 find (i32 a, i32 b, i32 c, i32 d, i32 *dp, i32 m) {
  return dp[POS(c, d)] - dp[POS(c, b - 1)] - dp[POS(a - 1, d)] + dp[POS(a - 1, b - 1)];
}

void run (void) {
  i32 n, m, q;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &n, &m, &q);
  i32 *v = (i32 *) calloc ((n + 1) * (m + 1), sizeof (i32));
  i32 *ex = (i32 *) calloc ((n + 1) * (m + 1), sizeof (i32));
  i32 *ey = (i32 *) calloc ((n + 1) * (m + 1), sizeof (i32));
  for (i32 i = 1; i <= n; ++i) {
    for (i32 j = 1; j <= m; ++j) {
      scanf ("%1" SCNi32, v + POS(i, j));
      ex[POS(i, j)] = v[POS(i, j)] & v[POS(i - 1, j)];
      ey[POS(i, j)] = v[POS(i, j)] & v[POS(i, j - 1)];
    }
  }
  for (i32 i = 1; i <= n; ++i) {
    for (i32 j = 1; j <= m; ++j) {
      v[POS(i, j)] += v[POS(i - 1, j)] + v[POS(i, j - 1)] - v[POS(i - 1, j - 1)];
      ex[POS(i, j)] += ex[POS(i - 1, j)] + ex[POS(i, j - 1)] - ex[POS(i - 1, j - 1)];
      ey[POS(i, j)] += ey[POS(i - 1, j)] + ey[POS(i, j - 1)] - ey[POS(i - 1, j - 1)];
    }
  }
  while (q--) {
    i32 a, b, c, d;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32 "%" SCNi32, &a, &b, &c, &d);
    i32 ans = find (a, b, c, d, v, m) - find (a + 1, b, c, d, ex, m) - find (a, b + 1, c, d, ey, m);
    printf ("%" PRIi32 "\n", ans);
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 48640
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    ++ans;
    N /= K;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    string S; cin >> S;

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 764
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] args) {
		List<Integer> primes = new ArrayList<>(1<<16);
		for(int i = 2; i < 55555; i++) {
			boolean primeFlag = true;
			for(int prime : primes) {
				if(prime*prime>i) break;
				primeFlag &= (i%prime!=0);
			}
			if(primeFlag) {
				primes.add(i);
			}
		}
		List<Integer> primesFive = primes.stream()
			.filter(num -> num%5==1)
			.collect(Collectors.toList());

		Scanner scan = new Scanner(System.in);
		int input = scan.nextInt();

		String ans = primesFive.subList(0,input).stream().map(num->num.toString()).collect(Collectors.joining(" "));
		System.out.println(ans);
	}
}


Measured memory_bytes: 28420
N, X = [int(x) for x in input().split()]

list01=[]
for i in range(N):
  j = int(input())
  list01.append(j)
 
j = 0
mass = sum(list01)

while mass <= X:
  j += 1
  mass = sum(list01) + min(list01) * j

print(N + j -1)

Measured memory_bytes: 3060
N = int(input())
a = [int(i) for i in input().split()]

def get_gcd(a,b):
        if a<b:
                a,b = b,a

        if a%b == 0:
                return b
        else:
                return get_gcd(b,a%b)

def get_lcm(a,b):
        return a*b//get_gcd(a,b)

def get_lcm_list(numbers):
        ans = get_lcm(numbers[0],numbers[1])
        for i in range(2,len(numbers)):
                ans = get_lcm(ans,numbers[i])
        return ans

M = get_lcm_list(a)
print(sum([(M-1)%i for i in a]))

Measured memory_bytes: 3316
import sys
def input():
    return sys.stdin.readline()[:-1]
from collections import *
from math import atan2, pi
from bisect import *
mod = 10**9+7

L = input()
N = len(L)
dp = [0] * N
dp[0] = 1
T = 2
for i in range(1, N):
    if L[i] == '1':
        dp[i] = (dp[i-1] * 3 + T) % mod
        T = T * 2 % mod
    else:
        dp[i] = dp[i-1] * 3 % mod
print((dp[-1] + T) % mod)


Measured memory_bytes: 7540
n = int(input())
A = list(map(int,input().split()))
mod = 998244353
ans = 1

def pow(x, y):
    m = x
    ans = 1
    while y != 0:
        if y % 2 == 1:
            ans = (ans * m) % mod
        m = (m*m)% mod
        y //= 2
    return ans
# print(A)
# print(pow(3,4))
import sys
if A[0] != 0:
    print(0)
else:
    B = [0] * (max(A)+1)
    for i in range(n):
        # print("i",i)
        B[A[i]] += 1
    # print(B)
    if B[0] != 1:
        print(0)
        sys.exit()
    for i in range(len(B)-1):
        ans = (ans * pow(B[i], B[i+1])) % mod
    print(ans)


Measured memory_bytes: 54444
#include<iostream>
#include<vector>
#include<algorithm>

#define all(c) (c).begin(),(c).end()

using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int>p(n);
  for(int i=0;i<n;i++)cin >> p[i];
  sort(all(p), greater<int>());
  int sum=0;
  for(int i=0;i<n;i++){
    if(i==0)sum+=p[i]/2;
    else sum +=p[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
#define LL long long

//int x[110],y[110],h[110];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	int ans = 1;
	for(int i = 1;i <= sqrt(m + 1);++i){
		if(m % i == 0 && m / i >= n)ans = max(i,ans);
		if(m % i == 0){
			if(i >= n)ans = max(m/i,ans);
		}
	}
	printf("%d",ans);
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  string s;
  cin >> s;
  string ret;
  if(s == "ABC")ret = "ARC";
  else ret = "ABC";
  cout << ret << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    if(a[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < n-1; i++)
    {
        if(a[i+1] - a[i] >1 ){
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = 0;
    int delta = 0;
    set<int> s;
    map<int, int> mp;
    for (int i = n - 1; i >= 0; i--)
    {
        if(mp[a[i] - i] >0){
            continue;
        }
        mp.clear();
        mp[a[i] - i]++;
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

pair<int, int> i_to_pair(int x)
{
	int sentou = to_string(x)[0] - '0';
	int matubi = to_string(x)[to_string(x).size() - 1] - '0';
	return make_pair(sentou, matubi);
}

int main()
{
	ll n, T;
	cin >> n >> T;
	vector<ll> t(n);
	for (int i = 0; i < n; i++) cin >> t[i];
	sort(t.begin(), t.end());
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ans += min(t[i] - t[i - 1], T);
	}
	cout << ans + T << endl;
}

Measured memory_bytes: 1792
S = input()
T = input()

count = []
for i in range(len(S) - len(T) + 1):
    match_count = 0
    for s, t in zip(S[i:i+len(T)], T):
        if s in t:
            match_count += 1
    count.append(match_count)

print(len(T) - max(count))
            

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll N=in<ll>(),A=in<ll>(),B=in<ll>();
	if(A>B) swap(A,B);
	if(!((B-A)%2LL)){
		out((B-A)/2LL);
	}
	else{
		ll C=A-1;
		ll D=B-C;
		ll E=C+((D-1)/2LL)+1LL;

		C=N-B;
		D=A+C;
		ll F=C+((N-D-1LL)/2LL)+1LL;
		out(min(E,F));
	}

	return 0;
}


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

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

    int countC=0;
    int remC;
    for(int i=2;i<=s.size()-2;i++){
        if(s[i]=='C'){
            countC++;
            remC=i;
        }  
    }

    bool isL=true;
    for(int i=1;i<=s.size()-1;i++){
        if(i!=remC&&(s[i]>='A'&&s[i]<='Z')) isL=false;
    }

    if(s[0]=='A'&&countC==1&&isL) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

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

int main(){
  ll n;
  cin >> n;
  string ans;
  while(n){
    n--;
    ans += 'a'+n%26;
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int max = 0;
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int l = sc.nextInt();
            max = Math.max(max, l);
            sum += l;
        }
        if (max < sum - max) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}

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

    int  ans = 0;

    for(int i=1; i <= k; i++){
        for(int j=1; j <= k; j++){
            for(int o=1; o <= k; o++){
                ans += gcd(i,gcd(j,o));
            }
        }
    }

    cout << ans<<endl;
}





Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();
	vector<int> a(n),pre;
	trav(i,a)i=in();
	partial_sum(all(a),back_inserter(pre));
	
	int ans=-1,cur,mv;
	
	for(int sign=0;sign<2;sign++)
	{
		cur=0,mv=0;
		for(int i=0;i<n;i++)
		{
			int x=pre[i]+cur;
			if(i%2==sign and x>=0)
			{
				cur-=(x+1);
				mv+=(x+1);
			}
			else if(i%2!=sign and x<=0)
			{
				cur+=(1-x);
				mv+=(1-x);
			}
			
		}
		if(ans<0 or ans>mv)ans=mv;
	}
	cout<<ans;
	
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPE(x) typeid(x).name()
vector<char>choices;
vector<string>pk;
int main(){
	ll N,A,B,C;
	cin>>N>>A>>B>>C;
	int ans=1;
	for(int i=1;i<=N;++i){
		string s;
		cin>>s;
		pk.push_back(s);
	}
	for(int i=0;i<N;++i){
		string s;
		s=pk[i];
		bool aa=0,bb=0,cc=0;
		if(s=="AB")aa=1,bb=1;
		if(s=="AC")aa=1,cc=1;
		if(s=="BC")bb=1,cc=1;
		if(i==N-1){
			if(aa&&bb){
				if(A>0){
					choices.push_back('B');
				}
				else if(B>0){
					choices.push_back('A');
				}
				else{
					cout<<"No";return 0;
				}
			}
			if(aa&&cc){
				if(A>0){
					choices.push_back('C');
				}
				else if(C>0){
					choices.push_back('A');
				}
				else{
					cout<<"No";return 0;
				}
			}
			if(bb&&cc){
				if(B>0){
					choices.push_back('C');
				}
				else if(C>0){
					choices.push_back('B');
				}
				else{
					cout<<"No";return 0;
				}
			}
			break;
		}
		if(aa&&bb){
			if(A<=0&&B<=0){
				cout<<"No";return 0;
			}
			if(A>B){
				choices.push_back('B');
				--A;++B;
			}
			else if(A!=1&&B!=1){
				choices.push_back('A');
				--B;++A;
			}
			else if(A==0&&B==1){
				choices.push_back('A');
				--B;++A;
			}
			else {
				int needa=0,needb=0;
				if(pk[i+1]=="AC"){
					needa=1;
				}
				if(pk[i+1]=="AB"){
					needa=1;
				}
				if(needa==1){
				choices.push_back('A');
					++A;--B;
				}
				else{
				choices.push_back('B');
					++B;--A;
				}
			}
		}
		if(aa&&cc){
			if(A<=0&&C<=0){
				cout<<"No";return 0;
			}
			if(A>C){
				choices.push_back('C');
				--A;++C;
			}
			else if(A!=1&&C!=1){
				choices.push_back('A');
				--C;++A;
			}
			else if(A==0&&C==1){
				choices.push_back('A');
				--C;++A;
			}
			else {
				int needa=0,needc=0;
				if(pk[i+1]=="AB"){
					needa=1;
				}
				if(pk[i+1]=="AC"){
					needa=1;
				}
				if(needa==1){
				choices.push_back('A');
					++A;--C;
				}
				else{
				choices.push_back('C');
					++C;--A;
				}
			}
		}
		if(bb&&cc){
			if(B<=0&&C<=0){
				cout<<"No";return 0;
			}
			if(B>C){
				choices.push_back('C');
				--B;++C;
			}
			else if(B!=1&&C!=1){
				choices.push_back('B');
				--C;++B;
			}
			else if(B==0&&C==1){
				choices.push_back('B');
				--C;++B;
			}
			else {
				int needb=0,needc=0;
				if(pk[i+1]=="AB"){
					needb=1;
				}
				if(pk[i+1]=="BC"){
					needb=1;
				}
				if(needb==1){
				choices.push_back('B');
					++B;--C;
				}
				else{
				choices.push_back('C');
					++C;--B;
				}
			}
		}
		if(A<0||B<0||C<0){
			cout<<"No";return 0;
		}
	}
	cout<<"Yes\n";
	for(auto i:choices){
		cout<<i<<'\n';
	}
}
/*
2 1 1 0
AB
AC
2 1 1 0
AB
BC
*/

Measured memory_bytes: 7468
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200005

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
inline int gcd(int a, int b){if(b == 0)return a; return gcd(b, a%b);}
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[N];
int main(){
    int j,k,i,T,ca=0, n, m, K;
    scanf("%s", s);
    n = strlen(s);
    m = 0;
    ll ans = 0;
    per(i, 0, n){
        if(i && s[i] == 'C' && s[i-1] == 'B')m++, i--;
        else if(s[i] == 'A'){
            ans += m;
        }
        else m = 0;
    }
    printf("%lld\n", ans);
}



Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main(void)
{
  long long int N,M,A=0,a;
  cin >> N;
  cin >> M;
  for(int i=0;i<M;i++){ cin >> a; A+=a;}
  cout << ((N-A >= 0)? (N-A):(-1));
  return 0;
}


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

struct Node {
    int key;
    Node *left, *right, *parent;
};

Node *root = nullptr, *NIL = nullptr;

Node* find(Node *u, int k) {
    while (u != nullptr && k != u -> key) {
        if (k < u -> key) {
            u = u->left;
        } else {
            u = u -> right;
        }
    }
    return u;
}

void insert(int k) {
    Node* y = NIL;
    Node* x = root;
    Node* z;

    //z = (Node*)malloc(sizeof(Node));
    z = new Node();
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key > x->key) {
            x = x -> right;
        } else{
            x = x -> left;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z -> key < y->key) {
            y -> left = z;
        } else {
            y ->right = z;
        }
    }
}

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

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

int main() {
    int n,i,x;
    std::string com;

    scanf("%d", &n);
    for (int i=0; i <n; i++) {
        std::cin >> com;
        if (com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t!=nullptr) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
        else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



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

int main() {
  long long H, W;
  cin >> H >> W;
  if (H == 1 || W == 1)
    cout << 1 << endl;
  else
    cout << ((W + 1) / 2) * ((H + 1) / 2) + (W / 2) * (H / 2) << endl;
}

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

int main()
{
    int N,h[25],i,m,sum=1;
    scanf("%d",&N);
    for(i=0; i<N; i++)
        scanf("%d",&h[i]);
    m=h[0];
    for(i=1; i<N; i++)
    {
        if(h[i]>=m)
        {
            m=h[i];
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
n = gets.to_i
as = gets.split.map(&:to_i).sort

p = as[-1]
q_i = as.bsearch_index { |a| a > p.to_f/2 }
q = as[q_i]
r = as[q_i-1]

if n == 2
  puts "#{as[-1]} #{as[0]}"
elsif (p.to_f/2-q).abs > (p.to_f/2-r)
  puts "#{p} #{r}"
else
  puts "#{p} #{q}"
end


Measured memory_bytes: 10104
#include <stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d){
		printf("Left");
	}else if(a+b==c+d){
		printf("Balanced");
	}else if(a+b<c+d){
		printf("Right");
	}
	return 0;
}

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

#define MAX_N 100291

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void quickSort( int *, int, int );
int median( int, int, int );
void insertionSort( int *, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 0, 176 );
	}

	return 0;
}

void quickSort( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] ), tmp;

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			tmp = data[ i ];
			data[ i ] = data[ j ];
			data[ j ] = tmp;

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

Measured memory_bytes: 988
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, D, ans = 0;
	vector<int> t, F;
	
	cin>>N>>D;
	
	t.resize(N+2);
	F.resize(N+2);
	
	t[0] = 0;
	F[0] = 1;
	t[N+1] = INF;
	
	for(int i = 1; i <= N; i++){
		cin>>t[i]>>F[i];
	}
	
	for(int i = 0, num = 0; i <= N; i++, num++){
		if(num > D || t[i + 1] - t[i] < abs(F[i+1] - F[i])){
			cout<<-1<<endl;
			return 0;
		}
		
		if(t[i+1] - t[i] >= F[i+1] + F[i] - 2){
			ans += num*(F[i]-1);
			num = 0;
		} else {
			ans += num*(t[i+1] - t[i]);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;

int main(void) {
	char str[5] = "\0";
	scanf("%s", str);
	if ((str[0] == str[1] && str[1] == str[2]) || (str[1] == str[2] && str[2] == str[3]))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll factorial(int n,int M){
  ll ret=1;
  if(n<=1) return 1;
  
  for(int i=1;i<=n;i++){
    ret = (ret*i)%M;
  }
  
  return ret;
}

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1)
    ret=(ret*k)%M;
  
  return ret;
}




int main(){
  int n,a[SIZE];
  map<int,int> ss;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    ss[a[i]]++;
  }

  bool flag = true;
  if(n%2){
    for(int i=0;i<n;i+=2){
      flag &= (i==0 && ss[i]==1) || (i!=0 && ss[i]==2);
    }
  }else{
    for(int i=1;i<n;i+=2){
      flag &= (i!=0 && ss[i]==2);
    }
  }
  
  if(flag == false){
    puts("0");
  }else{
    printf("%lld\n",power(2,n/2,mod));
  }
  
  return 0;
}


Measured memory_bytes: 4480
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;

int X,Y,A,B,C;
int a[maxn], b[maxn], c[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>X>>Y>>A>>B>>C;
  for(int i=0;i<A;i++)cin>>a[i];
  for(int i=0;i<B;i++)cin>>b[i];
  for(int i=0;i<C;i++)cin>>c[i];
  sort(a, a+A, greater<int>());
  sort(b, b+B, greater<int>());
  vector<int> ans;
  for(int i=0;i<X;i++)ans.push_back(a[i]);
  for(int i=0;i<Y;i++)ans.push_back(b[i]);
  for(int i=0;i<C;i++)ans.push_back(c[i]);
  sort(ans.begin(), ans.end(), greater<int>());
  ll ret = 0;
  for(int i=0;i<X + Y;i++)ret+=ans[i];
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3572
package main 

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	s := make([]string,n)
	lists := make(map[string]int)
	
	for i,_ := range s {
		fmt.Scan(&s[i])
		lists[s[i]]++
	}
	
	max := lists[s[0]]
	for i,_ := range lists {
		if max < lists[i] {
			max = lists[i]
		}
	}
	
	var maxlists []string
	for i, _ := range lists{
		if lists[i] == max {
			maxlists = append(maxlists, i)
		}
	}
	sort.Strings(maxlists)
	
	for i,_ := range maxlists {
		fmt.Println(maxlists[i])
	}
}

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

int main() {
    int N; cin >> N;
    int T; cin >> T;
    int ans = 1000000;
    rep(i, N) {
        int c, t; cin >> c >> t;
        if (T >= t) ans = min(ans, c);
    }
    if (ans == 1000000) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

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

int main() {
  int N, now, count = 0;
  priority_queue<int> d;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> now;
    d.push(now);
  }
  now = d.top();
  d.pop();
  count++;
  while(!d.empty()) {
    if(d.top() < now) {
      now = d.top();
      count++;
    }
    d.pop();
  }
  cout << count << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
point_list = []

for i in range(n):
    x, y = map(int, input().split())
    point_list.append([x,y])

max1 = [point_list[0][0] + point_list[0][1], 0]
min1 = [point_list[0][0] + point_list[0][1], 0]
max2 = [point_list[0][0] - point_list[0][1], 0]
min2 = [point_list[0][0] - point_list[0][1], 0]

for i in range(1, n):
    sum1 = point_list[i][0] + point_list[i][1]
    sum2 = point_list[i][0] - point_list[i][1]
    if sum1 > max1[0]:
        max1 = [sum1, i]
    
    if sum1 < min1[0]:
        min1 = [sum1, i]

    if sum2 > max2[0]:
        max2 = [sum2, i]
    
    if sum2 < min2[0]:
        min2 = [sum2, i]
    
man1 = abs(point_list[max1[1]][0]-point_list[min1[1]][0]) + abs(point_list[max1[1]][1]-point_list[min1[1]][1])
man2 = abs(point_list[max2[1]][0]-point_list[min2[1]][0]) + abs(point_list[max2[1]][1]-point_list[min2[1]][1])

ans = max([man1, man2])
print(ans)

Measured memory_bytes: 39148
from collections import Counter
import numpy as np


num_bar = int(input())
bar_list = list(map(int, input().split()))
counter = Counter(bar_list)
bars = np.unique(bar_list)

ans = 0
for longest in bars:
    for b1 in bars:
        min_b2 = longest - b1
        if min_b2 <= 0:
            continue
        target = bars[(bars < longest) & (bars > min_b2)]
        for t in target:
            if t - b1 >= 0:
                continue
            ans += counter[longest] * counter[b1] * counter[t]

print(ans)


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  string S;
  cin >> S;
  if(S=="ABC"){
    cout << "ARC";
  }else{
    cout << "ABC";
  }
  return 0;
}


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

using namespace std;
#define int long long
int x, y, a, b, c, p[100001], q[100001], r[100001];
 
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> x >> y >> a >> b >> c;
  //we have to eat x red and y green;
  for(int i = 0; i < a; i++) {
    cin >> p[i];
  }
  for(int i = 0; i < b; i++) {
    cin >> q[i];
  }
  for(int i = 0; i < c; i++) {
    cin >> r[i];
  }
  int ans = 0;
  sort(p, p + a, greater<int>());
  sort(q, q + b, greater<int>());
  sort(r, r + c);
  vector<int> f;
  for(int i = 0; i < x; i++) {
    f.push_back(p[i]);
  }
  for(int i = 0; i < y; i++) {
    f.push_back(q[i]);
  }
  sort(f.rbegin(), f.rend());
  int i = c-1, j = x+y-1;
  while(i>=0 && j>=0 && r[i] > f[j]) {
    f[j] = r[i];
    i--;
    j--;
  } 
  for(int x : f) ans += x;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7636
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        
   
    }
    for(int i=n-1;i>=0;i--){
        cout<<a[i];
            if(i==0){
                break;
            }
        cout<<' ';
        
    }
 cout<<endl;
    
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int n;
char s[100005];
ll dp[100005][13];

int main(){
	int n;
	ll k,q;
	cin >> n >> k >> q;
	int num[100000];
	for(int i=0;i<n;i++) num[i] = 0;
	for(int i=0;i<q;i++){
		int a;
		cin >> a;
		num[a-1]++;
	}
	for(int i=0;i<n;i++){
		if(q-num[i]<k){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, M; cin >> N >> M;
    set<int> st;

    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;

        if (a == 1) {
            auto ret = st.insert(b);
            if (!ret.second) { cout << "POSSIBLE" << endl; return 0; }
        }
        if (b == N) {
            auto ret = st.insert(a);
            if (!ret.second) { cout << "POSSIBLE" << endl; return 0; }
        }
    }

    cout << "IMPOSSIBLE" << endl;
}

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

int main() {
  int h,sum,n;
  cin >> h >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sum = accumulate(vec.begin(),vec.end(),0);
  if(sum >= h){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

Measured memory_bytes: 640
use std::io::*;
use std::str::*;
use std::collections::*;

fn main() {
    let (n, q) = {
        let line = read_vec::<usize>();
        (line[0], line[1])
    };
    let mut queues = Vec::with_capacity(n);
    let mut results = Vec::with_capacity(n);
    for _ in 0..n {
        queues.push(VecDeque::new());
        results.push(0);
    }
    for _ in 0..(n - 1) {
        let (a, b) = {
            let line = read_vec::<usize>();
            (line[0], line[1])
        };
        queues[a - 1].push_back(b - 1);
        queues[b - 1].push_back(a - 1);
    }
    for _ in 0..q {
        let (x, p) = {
            let line = read_vec::<usize>();
            (line[0], line[1])
        };
        results[x - 1] += p
    }
    let mut queue = VecDeque::new();
    queue.push_back(0);
    let mut visited = HashMap::new();
    while queue.len() > 0 {
        let i = queue.pop_front().unwrap();
        visited.insert(i, true);
        for &j in &queues[i] {
            let visit = match visited.get(&j) {
                Some(&x) => x,
                _ => false,
            };
            if visit {
                continue;
            }
            results[j] += results[i];
            visited.insert(j, true);
            queue.push_back(j);
        }
    }
    println!("{}", results.iter().map(|&i| i.to_string()).collect::<Vec<String>>().join(" "));
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line: String = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 48796
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
struct node
{
    int a,b;
}req[100005];
bool cmp(node p1,node p2)
{
    if(p1.a!=p2.a)
        return p1.a<p2.a;
    else return p1.b>p2.b;
}
int main()
{
    int n,m;
    bool vis[100005];
    memset(vis,false,sizeof(vis));
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&req[i].a,&req[i].b);
    }
    sort(req,req+m,cmp);
    int k=req[0].b,cot=0;
    for(int i=1;i<m;i++)
    {
        if(k>req[i].a&&k<=req[i].b) continue;
        if(req[i].b<k&&req[i].b>req[i-1].a)
        {
            k=req[i].b;
            continue;
        }
        if(!vis[k]) cot++,vis[k]=true;
        k=req[i].b;
    }
    if(!vis[k]) cot++,vis[k]=true;
    cout<<cot<<'\n';
}


Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pre = Integer.parseInt(s.substring(0, 2));
        int post = Integer.parseInt(s.substring(2));
        if ((pre == 0 || pre >= 13) && (post >= 1 && post <= 12)) {
            System.out.println("YYMM");
        } else if ((pre >= 1 && pre <= 12) && (post == 0 || post >= 13)) {
            System.out.println("MMYY");
        } else if ((pre >= 1 && pre <= 12) && (post >= 1 && post <= 12)) {
            System.out.println("AMBIGUOUS");
        } else {
            System.out.println("NA");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int participant = Integer.parseInt(sc.next());
        int issue = Integer.parseInt(sc.next());
        
        int max=0;
        for(int i=0; i<participant; i++){
            int sum = 0;
            for(int j=0; j<issue; j++){
                sum += Integer.parseInt(sc.next());
            }
            max = Math.max(max,sum);
        }
        System.out.println(max);
    }

}



Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

const ll INF = 1LL<<60;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> c(n), p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];
    vector<P> loop(n);
    vector<ll> sums;
    vector<vector<ll>> g;
    int gi = 1;
    rep(i, n){
        if (loop[i].first != 0) continue;
        int j = i, s = 0;
        vector<ll> ten;
        ll sum = c[i];

        loop[j] = make_pair(gi, s);
        ten.push_back(c[j]);
        j = p[i];
        while(loop[j].first == 0){
            ten.push_back(c[j]);
            sum += c[j];
            loop[j] = make_pair(gi, ++s);
            j = p[j];
        }
        g.push_back(ten);
        sums.push_back(sum);
        gi++;
    }

    ll ans = -INF;
    rep(i,n){
        int lNum = loop[i].first-1, pos = loop[i].second;
        ll sum = 0;
        ll kk = k;
        if (sums[lNum] > 0 && kk > g[lNum].size()){
            sum += (kk / g[lNum].size() - 1) * sums[lNum];
            kk %= g[lNum].size();
            kk += g[lNum].size();
            ans = max(ans, sum);
        }else if (kk > g[lNum].size()){
            kk = g[lNum].size();
        }
        while(kk){
            pos = (pos+1) % g[lNum].size();
            sum += g[lNum][pos];
            ans = max(ans, sum);
            kk--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define MOD 1000000007

int N, M;

vector<ll> over(int x){
  vector<ll>ret(x);
  ll h = x-2;
  ll c = x;
  for(int i=0;i<(x+1)/2;i++){
    ret[i] = ret[x-i-1] = c;
    c += h;
    h -= 2;
  }
  return ret;
}

int main(){
  cin >> N >> M;
  vector<ll>X(N);
  vector<ll>Y(M);
  for(auto &x: X) cin >> x;
  for(auto &y: Y) cin >> y;

  vector<ll>overX = over(N-1);
  vector<ll>overY = over(M-1);
  //  for(auto &x: overX) cout << x << " "; cout << endl;
  //  for(auto &y: overY) cout << y << " "; cout << endl;

  ll h = 0;
  for(int i=0;i<N-1;i++){
    int j = i+1;
    h = (h + (X[j]-X[i])*overX[i]) % MOD;
  }

  ll w = 0;
  for(int k=0;k<M-1;k++){
    int l=k+1;
    w = (w + ((Y[l]-Y[k])*overY[k]) % MOD) % MOD;
  }

  //  cout << h << " " << w << endl;
  cout << (h*w)%MOD << endl;
  return 0;
}


Measured memory_bytes: 3328