akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 1000000007
#define inf 100000000
#define limit 200005
#define minval -100000000000000000
#define maxval 1000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
void input()
{
    int n;
    cin >> n;
    vlli a(n);
    
    rep(i,n)
        cin >> a[i];

    lli s1 = 0;
    rep(i,n)
        s1 = (s1 + a[i])%mod;

    s1 = (s1 * s1)%mod;

    lli s2 = 0;
    rep(i,n)
        s2 = (s2 + (a[i] * a[i])%mod)%mod;
    
    lli ans = 0;
    ans = (s1 + (mod - s2))%mod;

    ans = (ans * Power(2, mod-2))%mod;
    cout << ans << '\n';
}
int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}


Measured memory_bytes: 4780
n=int(input())
d=list(map(int,input().split()))
d.sort()
time=[0]*24
time[0]=1
for i in range(n):
  if i%2:
    time[d[i]]+=1
  else:
    time[-d[i]]+=1
if max(time)>1:
  print(0)
  exit()
ans=[]
cnt=1
for i in range(1,25):
  i=i%24
  if time[i]==0:
    cnt+=1
  else:
    ans.append(cnt)
    cnt=1
print(min(ans))

Measured memory_bytes: 3064
//SP
#include<iostream>
using namespace std;

void call(int n){
  int i = 1;

 	do{
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
  }else{
do{
  if ( x % 10 == 3 ){
    cout << " " << i;
   break;
  }
  x /= 10;
 }while( x );
 }
} while ( ++i <= n );

  cout << endl;
}

int main()
{
	int x;
	cin >> x;
	call(x);
	return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#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__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}


int main() {
  int n,m; cin >> n >> m;
  vector<pair<int,int>> x(m);
  rep(i,m) {
    cin >> x[i].second >> x[i].first;
    --x[i].first, --x[i].second;
  }
  sort(ALL(x));
  vector<int> r2l(n, -1);
  for(auto [r,l] : x) {
    umax(r2l[r], l);
  }

  int d = -1;
  int ans = 0;
  rep(r,n) {
    if (r2l[r] != -1) {
      int l = r2l[r];
      if(l >= d) {
        ++ans;
        d = r;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4560
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char** argv) {
  string s;
  int k;
  cin >> s;
  cin >> k;
  for (size_t i = 0; i < k; i++) {
    if (s[i] != '1') {
      cout << s[i];
      return 0;
    }
  }
  cout << '1';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
void solve()
{
   ll n;
   cin>>n;
   
   ll arr[n],i,j,sum=0;
   
   for(i=0;i<n;i++)
   cin>>arr[i];
   
   for(i=0;i<n-1;i++)
   for(j=i+1;j<n;j++)
   sum+=(arr[i]*arr[j]);
   
   
   cout<<sum;
   
   
}

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

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

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

    if(s[1]=='B'){
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}


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

int main(){
    int a, b;
    string s;
    cin >> a >> b;
    if (a == b){
        s = "==";
    }else if (a > b){
        s = ">";
    }else{
        s = "<";
    }
    cout << "a " << s << " b" << endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
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 VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(c-(a-b),0)<<endl;





    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        if((s1.substring(s1.length() - 1).equals(s2.substring(0,1))) && (s2.substring(s2.length() - 1)).equals(s3.substring(0,1))){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35576
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int n = Integer.parseInt(st.nextToken());
      int m = Integer.parseInt(st.nextToken());
      
      
      ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>(n+1);
      for(int k = 0; k <= n; k++) adj.add(new ArrayList<Integer>());
      
      for(int k = 0; k < m; k++){
         st = new StringTokenizer(f.readLine());
      
         int a = Integer.parseInt(st.nextToken());
         int b = Integer.parseInt(st.nextToken());
         
         adj.get(a).add(b);
         adj.get(b).add(a);
      }
      
      boolean[] seen = new boolean[n+1];
      int[] answer = new int[n+1];
      Queue<Integer> q = new LinkedList<Integer>();
      q.add(1);
      seen[1] = true;
      
      while(!q.isEmpty()){
         int i = q.poll();
         
         for(int nei : adj.get(i)){
            if(seen[nei]) continue;
            answer[nei] = i;
            seen[nei] = true;
            q.add(nei);
         }
      }
      
      if(check(answer)){
         out.println("Yes");
         for(int k = 2; k <= n; k++){
            out.println(answer[k]);
         }
      } else {
         out.println("No");
      }
      
     
      
      
      
      
      
      
      
      out.close();
   }
   
   public static boolean check(int[] array){
      for(int k = 2; k < array.length; k++){
         if(array[k] == 0) return false;
      }
      return true;
   }
   
      
}

Measured memory_bytes: 76356
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// ABC170-A
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<Integer> x = new ArrayList<>();

		for (int i = 0; i < 5; i++) {
			x.add(sc.nextInt());
		}

		for (Integer i : x) {
			if (i == 0) {
				System.out.println(x.indexOf(i) + 1);
			}
		}

		sc.close();
	}
}


Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
 
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;
 
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }
 
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }
 
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
 
    return ret;
}

void solve(long long N){
    ll ans = 0;
    for(int i = 1; i < N+1; i++)
    {
        ans += i;
    }

    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    int i = 0;
    while (i < N) {
        while (S[i] != T[0] && i < N) {
            i++;
        }
        if (i >= N) break;
        if (S.substr(i, N-i) == T.substr(0, N-i)) {
            cout << i + N << endl;
            return;
        }
      	i++;
    }

    if (i == N) {
        cout << 2*N << endl;
        return;
    }

}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


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

void main()
{
    auto N = readln.chomp.to!int;
    long[] as;
    auto MEMO = new long[](N+1);
    foreach (a; readln.split.to!(long[])) {
        ++MEMO[a];
        as ~= a;
    }
    long r;
    foreach (n; MEMO) {
        r += n * (n-1) / 2;
    }
    foreach (a; as) {
        auto n = MEMO[a];
        writeln(r - n * (n-1) / 2 + (n-1) * (n-2) / 2);
    }
}

Measured memory_bytes: 15592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  map<string, bool> mp;
  for(int i=0;i<n;++i) {
    string s; cin >> s;
    mp[s] = true;
  }
  int m; cin >> m;
  bool op = false;
  for(int i=0;i<m;++i) {
    string s; cin >> s;
    if(mp[s]) {
      if(op) {
        cout << "Closed by " << s << endl;
        op = false;
      } else {
        cout << "Opened by " << s << endl;
        op = true;
      }
    } else {
      cout << "Unknown " << s << endl;
    }
  }
}



Measured memory_bytes: 3260
from collections import deque

class UnionFind:
    def __init__(self, n):
        self.rank = [0]*n
        self.parent = [i for i in range(n)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        elif self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)



n = int(input())
s = [input() for _ in range(n)]


uf = UnionFind(n)

INF = 1001001001
ans = 0

for min_i in range(n):
    dist = [INF] * n
    dist[min_i] = 0
    q = deque([(min_i, 0, -1)])

    while q:
        v, d, p = q.popleft()
        box = []
        for nv in range(n):
            if s[v][nv] == '1':
                if nv == p:
                    continue
                if uf.same(v, nv):
                    print(-1)
                    exit()
                if d + 1 < dist[nv]:
                    dist[nv] = d + 1
                    q.append((nv, d + 1, v))
                    box.append(nv)
        for i in range(len(box) - 1):
            uf.merge(box[i], box[i + 1])
    ans = max(ans, max(dist) + 1)

print(ans)


Measured memory_bytes: 53996
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    bool G[n][n];
    rep(i, n) rep(j, n) G[i][j] = false;
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;
        G[a][b] = G[b][a] = true;
    }
    int p[n];
    iota(p, p + n, 0);
    int ans = 0;
    do {
        bool flag = true;
        rep(i, n - 1) if (!G[p[i]][p[i + 1]]) {
            flag = false;
            break;
        }
        ans += flag;
    } while (next_permutation(p + 1, p + n));
    printf("%d\n", ans);
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define array_length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, array_length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, array_length(a))rep(j, array_length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl h[n];
    cin(i,h);
    intl a[n];
    m0(a);
    intl cnt = 0;
    rep(i,n){
        intl m = h[i] - a[i];
        a[i] += m;
        cnt += m;
        repi(j, i + 1, n){
            m = min(m,h[j] - a[j]);
            a[j] += m;            
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
class DisjointSet():
    def __init__(self, size):
        self.size = size
        self.rank = [None] * size
        self.parents = [None] * size
        for i in range(size):
            self.makeSet(i)

    def makeSet(self, x):
        self.parents[x] = x
        self.rank[x] = 0

    def findSet(self, x):
        if x != self.parents[x]:
            self.parents[x] = self.findSet(self.parents[x])
        return self.parents[x]

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.parents[y] = x
        else:
            self.parents[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

N, M = map(int, input().split())
ds = DisjointSet(N)
for _ in range(M):
    a, b = map(int, input().split())
    ds.unite(a-1, b-1)

setdict = defaultdict(int)
for i in range(N):
    setdict[ds.findSet(i)] += 1

clist = list(sorted(list(setdict.values())))
# clist = set(setdict.values())
ans = 0
r = 0
for c in clist:
    ans += (c-r)
    r = c

# print(clist)
print(ans)




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

int main() {
	int n;
	cin >> n;
	int a[n];
	int count = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	for(int i=0;i<n;i++){
		int minj = i;
		for(int j=i+1;j<n;j++){
			if(a[j]<a[minj]){
				minj = j;
			}
		}
		if(a[i]>a[minj]){
			swap(a[i],a[minj]);
			count++;
		}
	}
	
	for(int i=0;i<n;i++){
		cout << a[i] ;
		if(i<n-1) cout << " ";
	}
	cout << endl;
	cout << count << endl;
	
	return 0;
}


Measured memory_bytes: 3100
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x,dp):
        ans[x] = bisect.bisect_left(dp, float("inf"))
        for y in v[x]:
            if d[y]:
                d[y] = 0
                i = bisect.bisect_left(dp,a[y])
                p = dp[i]
                dp[i] = a[y]
                dfs(y,dp)
                dp[i] = p

    n = I()
    a = LI()
    v = [[] for i in range(n)]
    for _ in range(n-1):
        x,y = LI()
        x -= 1
        y -= 1
        v[x].append(y)
        v[y].append(x)
    dp = [float("inf")]*n
    dp[0] = a[0]
    d = [1]*n
    d[0] = 0
    ans = [0]*n
    dfs(0,dp)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 362232
n = int(input())
l = list(map(int, input().split())) + [0]
ans = 0
min_v = 1000
curr = 0
last = -1
count = 0

for _ in range(n+1):
    for i in range(n+1):
        curr = l[i]
        if curr == 0:
            for j in range(last+1, i):
                l[j] -= min_v

            if i > last + 1:
                count += min_v

            last = i
            min_v = 1000
            curr = 0
        elif curr < min_v:
            min_v = curr
    last = -1

print(count)





Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

map<string, int> pl;

int main() {
	int n;
	string s;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		if (pl.find(s) == pl.end()) {
			pl[s] = 1;
		}
		else {
			pl[s] += 1;
		}
	}
	int mx = 0;
	for (auto it = pl.begin(); it != pl.end(); ++it) {
		if (it->second > mx) {
			mx = it->second;
		}
	}
	for (auto it = pl.begin(); it != pl.end(); ++it) {
		if (it->second == mx) {
			cout << it->first << endl;
		}
	}
	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

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

int main() {
  string s, t;
  cin >> s >> t;
  int ff = false;
  dep(i, s.length() - t.length(), 0) {
    int f = true;
    rep(j, 0, t.length()) {
      if(s[i + j] != t[j] && s[i + j] != '?') f = false;
    }
    if(f) {
      rep(j, 0, t.length()) {
        s[i + j] = t[j];
      }
      ff = true;
      break;
    }
  }

  if(ff) {
    rep(i, 0, s.length()) {
      if(s[i] == '?') cout << 'a';
      else cout << s[i];
    }
    cout << endl;
  }else {
    cout << "UNRESTORABLE" << endl;
  }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;

  ll sum; cin >> sum; sum --;
  int P = 1;

  rep(i, N - 1) {
    ll A; cin >> A;
    if(A == P + 1) {
      P++;
    } else if(A > P + 1) {
      sum += (A - 1) / (P + 1);
    }
  }

  cout << sum << endl;
  
  return 0;
}

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

int main(){
    vector<int> p, j;
    int b;
    for (int i = 0; i < 3; i++){
	cin >> b;
	p.push_back(b);
    }
    for (int i = 0; i < 2; i++){
	cin >> b;
	j.push_back(b);
    }

    cout << *min_element( p.begin(), p.end()) + *min_element( j.begin(), j.end()) - 50 << endl;
    
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep (i, m) cin >> b[i];
  vector<vector<int>> a(n, vector<int>(m));
  rep (i, n) {
    rep (j, m) cin >> a[i][j];
  }
  int cnt = 0;
  rep (i, n) {
    int sum = 0;
    rep (j, m) sum += a[i][j] * b[j];
    if (sum + c > 0) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def dist(x1, y1, x2, y2):
    dx = x1 - x2
    dy = y1 - y2
    return (dx ** 2 + dy ** 2) ** 0.5


xs, ys, xg, yg = map(int, input().split())
N = int(input())
XYR = [tuple(map(int, input().split())) for _ in range(N)]
edge = [[] for _ in range(N+2)]
#start = N
#goal = N+1

for i in range(N - 1):
    xi, yi, ri = XYR[i]
    for j in range(i + 1, N):
        xj, yj, rj = XYR[j]
        d = max(0, dist(xi, yi, xj, yj) - ri - rj)
        edge[i].append((j, d))
        edge[j].append((i, d))

for i in range(N):
    xi, yi, ri = XYR[i]

    ds = max(0, dist(xi, yi, xs, ys) - ri)
    edge[i].append((N, ds))
    edge[N].append((i, ds))

    dg = max(0, dist(xi, yi, xg, yg) - ri)
    edge[i].append((N + 1, dg))
    edge[N + 1].append((i, dg))

d = dist(xs, ys, xg, yg)
edge[N].append((N + 1, d))
edge[N + 1].append((N, d))


inf = 10**18
dist = [inf] * (N + 10)
dist[N] = 0
que = [(0, N)]
while que:
    c, s = heapq.heappop(que)
    if dist[s] < c:
        continue
    for t, cost in edge[s]:
        if dist[t] > dist[s] + cost:
            dist[t] = dist[s] + cost
            heapq.heappush(que, (dist[t], t))

print(dist[N + 1])

Measured memory_bytes: 128648
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#define MAXN 1000010
using namespace std;

int n;
char s1[MAXN],s2[MAXN];
vector<int> S[30];
int p[MAXN];

struct Queue{
	deque<int> Q;
	int d;

	void push_back(int x){ Q.push_back(x-d); }
	void push_front(int x){ Q.push_front(x-d); }
	int back(){ return Q.back()+d; }
	void pop_back(){ Q.pop_back(); }
	void pop_front(){ Q.pop_front(); }
	bool empty(){ return Q.empty(); }
	int size(){ return Q.size(); }
}Q;

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d",&n);
	scanf("%s%s",s1+1,s2+1);
	n=strlen(s1+1);
	for(int i=1;i<=n;i++) S[s1[i]-'a'].push_back(i);
	int ans=0;
	p[n+1]=n+1;
	for(int i=n;i>=1;i--){
		if(s2[i]==s2[i+1] && i>=p[i+1]){
			p[i]=p[i+1];
		}else{
			while(!S[s2[i]-'a'].empty() && S[s2[i]-'a'].back()>=p[i+1])
				S[s2[i]-'a'].pop_back();
			if(S[s2[i]-'a'].empty()){
				puts("-1");
				return 0;
			}
			p[i]=S[s2[i]-'a'].back();
			if(i>=p[i+1]){
				Q.d--;
				Q.push_front(p[i+1]-1);
				while(Q.back()>=i) Q.pop_back();
				Q.push_back(i);
			}else{
				while(!Q.empty()) Q.pop_back();
				if(p[i]<i) Q.push_back(i);
			}
			ans=max(ans,(int)Q.size());
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 14600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#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 int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int k;
    cin >> k;
    int now = 7;
    const int mod = k;
    rep(i, 1, 7 * k + 1) {
        if (now % k == 0) {
            cout << i << "\n";
            return 0;
        }
        now = (now * 10 + 7) % mod;
    }
    cout << "-1\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int count = 0;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				if (500 * a + 100 * b + 50 * c == X) {
					count++;
				}
			}
		}
	}
	cout << count << endl;

}






Measured memory_bytes: 3608
import sys

i = list(map(int, input().split()))
A = i[0]
B = i[1]
K = i[2]

yaku_A = []
yaku_B = []

for i in range(1,A+1):
    if A % i == 0:
        yaku_A.append(i)

for i in range(1,B+1):
    if B % i == 0:
        yaku_B.append(i)
        
SS = list(set(yaku_A) & set(yaku_B))
SSS = sorted(SS)
        
print(SSS[-K])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
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 INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> cnt(1010101);
    REP(i,N) cin >> A[i];
    REP(i,N){
        if(cnt[A[i]] > 0){
            cnt[A[i]]++;
            continue;
        }
        for(int k=A[i];k<1010101;k+=A[i]) cnt[k]++;
    }
    int ans = 0;
    REP(i,N) if(cnt[A[i]] == 1) ans++;
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

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

struct Point {
  double x, y;
};

void koch(int n, Point a, Point b) {
  if (n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  cout << s.x << " " << s.y << endl;
  koch(n-1, s, u);
  cout <<u.x << " " << u.y << endl;
  koch(n-1, u, t);
  cout << t.x << " " << t.y << endl;
  koch(n-1, t, b);
}

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

  Point a, b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y =0;

  cout << a.x << " " << a.y << endl;
  koch(n, a, b);
  cout << b.x << " " << b.y << endl;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <ctype.h>

int main() 
{
    char str;

    std::cin >> str;
    if (isupper(str)) {
        std::cout << "A" << std::endl;
    }
    else
    {
        std::cout << "a" << std::endl;
    }
}

Measured memory_bytes: 3608
using System; 
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
           long n = int.Parse(Console.ReadLine());
           long count = 0;
            for (long i = 1; i <= n; i++)
            {
                if (i % 3 == 0 && i % 5 == 0)
                {
                    //Console.WriteLine("FizzBuzz");
                }
                else if (i % 5 == 0)
                {
                    //Console.WriteLine("Buzz");
                }
                else if (i % 3 == 0)
                {
                    //Console.WriteLine("Fizz");
                }
                else
                {
                    
                    //Console.WriteLine(i);
                    count += i;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 17652
#include <stdio.h>
int main(){
  long int N,K,count,i,j,con,max,min;
  scanf("%ld %ld",&N,&K);
  count=0;
  min=0;
  max=0;
  for(i=0;i<N+1;i++){
    min=min+i;
    max=max+(N-i);
    if(i>=K-1){
      con=max-min+1;
      count=count+con;
    }
  }
  count=count%1000000007;
  printf("%ld",count);
  return 0;
}

Measured memory_bytes: 1728
import collections
n = int(input())
c = [0 for _ in range(n)]
for i in range(n):
    c[i] = input()
c = collections.Counter(c).most_common()
ans = []
first = c[0][1]
for i in c:
    if i[1] == first:
        ans.append(i[0])

ans.sort()
for l in ans:
    print(l)

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

int main() {
  for (int i = 0; i < 3000; i++) {
    int x = 0;
    int y = 0;
    cin >> x >> y;
    
    if (x == 0 && y == 0) {
      break;
    }
    else if (x > y) {
      int memo = 0;
      memo = x;
      x = y;//xに0をいれる
      y = memo;//yに1をいれる
      cout << x << " " << y << endl;
    //  cout << x << "Finished of sort" << y << endl;

    }
    else {
      cout << x << " " << y << endl;
    //  cout << "Not Changed"<< endl;
    }
  }
}



Measured memory_bytes: 3004
n = int(input())
data = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    data[a-1].append([b-1,c % 2])
    data[b-1].append([a-1,c % 2])

que = []
color = [-1 for _ in range(n)]
def dfs(a,data):
    # pop last index
    #a : current state
    if color[a] == -1:
        color[a] = 0
        que.append(a)
    else:
        return 0
    while len(que):
        a = que.pop()
        for i in data[a]:
            #i[0] is edge
            #i[1] is cost
            if color[i[0]] != -1:continue
        
            if i[1] == 0:
                color[i[0]] = color[a]
            else:
                color[i[0]] = 1 - color[a]  
            que.append(i[0])

for i in range(n):
    dfs(i,data)
for i in range(n):
    print(color[i])
        

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct event { ll type; ll t; ll pos; };

int main() {
  ll N, Q; cin >> N >> Q;
  vector<event> e;
  rep(i,N) {
    ll s, t, x; cin >> s >> t >> x;
    e.push_back({-1, (s-x)*2-1, x});
    e.push_back({1, (t-x)*2-1, x});
  }
  rep(i,Q) {
    ll d; cin >> d;
    e.push_back({0, d*2, 0});
  }
  sort(e.begin(), e.end(), [](const event &x, const event &y){return x.type<y.type;});
  sort(e.begin(), e.end(), [](const event &x, const event &y){return x.t<y.t;});

  multiset<ll> se;
  for (auto x: e) {
    // for (auto y: se) cout << y << " "; cout << endl;
    if (x.type==-1) se.insert(x.pos);
    else if (x.type==1) {
      auto it = se.find(x.pos);
      se.erase(it);
    }
    else if (x.type==0) {
      ll result = se.size() ? *(se.begin()) : -1 ;
      cout << result << endl;
    }
  }
  return 0;
}

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

int main(){
  string a;
  int ans = 0,temp = 0;
  cin >> a;
  for(int i; i < a.length(); i++){
    if( a[i] == 'A' || a[i] == 'T' || a[i] == 'C' || a[i] == 'G'){
      temp++;
      ans = max(temp,ans);
    }else{
      temp = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define p push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod=7+1e9;
const int inf=1e9;
const int N=1e5+50;
ll v[1000],w[1000];
ll dp[300][N+N];

int main()
{
#ifdef LOCAL
    freopen("input.in", "r", stdin);
#endif
    IOS;
    int n,W;
    cin>>n>>W;
    re(i,n)cin>>w[i]>>v[i];

    re(i,150)
       rep(j,1,N)dp[i][j]=1000000000000ll;

    dp[0][v[0]]=w[0];

    rep(i,1,n)
    {
        re(j,N)
        {
            if( v[i] <= j )
            {
                dp[i][j]=min( dp[i-1][j] , dp[i-1][j-v[i]] + w[i] );
            }
            else
               dp[i][j]=dp[i-1][j];
        }
    }
    int ans=0;
       //re(i,n){re(j,10)cout<<dp[i][j]<<" ";cout<<endl;}
       for(int i=0 ; i<N ;  ++i)
       {
           if(dp[n-1][i]<=W)ans=max(ans,i);
       }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 237184
#include <string.h>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};

typedef long long ll;

int main() {
  ll Q;
  cin >> Q;
  vector<ll> L(Q);
  vector<ll> R(Q);
  for (ll i = 0; i < Q; i++) {
    cin >> L[i] >> R[i];
  }

  ll N = 100000;
  // ll N = 10;

  vector<bool> isPrime(N + 1, true);
  // 0と1は素数ではない
  isPrime[0] = false;
  isPrime[1] = false;
  // 2からスタート
  for (ll i = 2; i <= N; i++) {
    if (isPrime[i] == false) continue;
    // 2は素数
    // 4, 6, 8, 10, ... は素数ではない
    // 3は素数
    // 6, 9, 12, 15, ... は素数ではない
    for (ll j = i * 2; j <= N; j += i) {
      isPrime[j] = false;
    }
  }

  vector<bool> a(N, false);
  for (ll i = 0; i < N; i++) {
    if (isPrime[i + 1] && isPrime[(i + 2) / 2]) {
      a[i] = true;
    }
  }

  vector<ll> sum(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    if (a[i]) {
      sum[i + 1] = sum[i] + 1;
    } else {
      sum[i + 1] = sum[i];
    }
  }

  // for (auto s : sum) {
  //   cout << s << endl;
  // }

  for (ll i = 0; i < Q; i++) {
    ll l = L[i];
    ll r = R[i];

    cout << sum[r] - sum[l - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 3072
//rohitaas_15
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define ll  long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
#define endl "\n"
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
int main()
{
	fastio();
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vr ans;
	vr red(a);
	vr green(b);
	vr nc(c);
	input(red,a);
	input(green,b);
	input(nc,c);
	sort(all(red));
	sort(all(green));
	sort(all(nc));
	f(0,x-1)
	{
		ans.pb(red[a-i-1]);
	}
	f(0,y-1)
	{
		ans.pb(green[b-i-1]);
	}
	f(0,c-1)
	{
		ans.pb(nc[c-i-1]);
	}
	sort(all(ans));
	reverse(all(ans));
	ll sum=0;
	f(0,x+y-1)
	{
		sum+=ans[i];
	}
	show(sum);

}







Measured memory_bytes: 8816
x, n = map(int,input().split())
p = list(map(int,input().split()))
a = 0
b = 0
for i in range(100):
    a = x - i
    b = x + i
    if p.count(a) == 0:
        print(x - i)
        exit()
    else:
        if p.count(b) == 0:
            print(x + i)
            exit()


Measured memory_bytes: 9180
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n;cin>>n;
       double res;
       if(n%2==0)res = 0.5;
       else res = (double)(n/2+1)/n;
       cout<<res;
    }
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long A, B, C, D;

long long GCD(long long a, long long b) {
    if(a == 0) {
        return b;
    }else if(b == 0) {
        return a;
    }else {
        long long r, temp;
        if(a < b) {
            temp = a;
            a = b;
            b = temp;
        }

        r = a % b;
        while(r != 0) {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }
}

int main() {
    cin >> A >> B >> C >> D;

    long long Lcm = C * D / GCD(C, D);
    long long b = B/C + B/D - B/Lcm;
    long long a = (A-1)/C + (A-1)/D - (A-1)/Lcm;

    cout << B - A + 1 - (b - a) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll n, a, sma, t[10], sum;
vector<ll> vec, G;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	int a[10];
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		sum += ((a[i] - 1) / 10 + 1) * 10;
		t[a[i] % 10]++;
	}
	for (int i = 1; i <= 9; i++)
	{
		if (t[i])
		{
			cout << sum - 10 + i << endl;
			return 0;
		}
	}
	cout << sum << endl;
	int www;
	cin >> www;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long
using intpair = pair<int, int>;

int mod = 1e9 + 7;

signed main(){
    int N, M;
    cin >> N >> M;
    
    vector<int> broken(M+1);
    collect(broken, M);
    broken[M] = N+1;
    
    rep(i, M-1){
        if(broken[i]+1 == broken[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }
    
    vector<int> F(1e5+10);
    F[0] = F[1] = F[2] = 1;
    reps(i,3,1e5+9) F[i] = (F[i-1] + F[i-2]) % mod;
    
    int res = F[broken[0]] % mod;
    rep(i,M){
        int steps = F[broken[i+1]-broken[i]-1];
        res = (res*steps) % mod;
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
using namespace std;
const int N=3e2+10;
int n,A,num[4];double dp[N][N][N];bool vis[N][N][N];
inline double DFS(int x,int y,int z){
	if(vis[x][y][z])return dp[x][y][z];
	if(x)dp[x][y][z]+=1.0*x*(DFS(x-1,y,z)+1.0);
	if(y)dp[x][y][z]+=1.0*y*(DFS(x+1,y-1,z)+1.0);
	if(z)dp[x][y][z]+=1.0*z*(DFS(x,y+1,z-1)+1.0);
	dp[x][y][z]+=1.0*(n-x-y-z);
	dp[x][y][z]*=(1.0/(1.0*(x+y+z)));
	vis[x][y][z]=true;return dp[x][y][z];
}
int main(){
	scanf("%d",&n);vis[0][0][0]=true;dp[0][0][0]=0.0;
	for(register int i=1;i<=n;i++)scanf("%d",&A),num[A]++;
	printf("%.14lf\n",DFS(num[1],num[2],num[3]));
	return 0;
}

Measured memory_bytes: 173952
n = int(input())

march = [0 for i in range(5)]

for i in range(n):
    s = input()
    if s[0] == 'M':
        march[0] += 1
    elif s[0] == 'A':
        march[1] += 1
    elif s[0] == 'R':
        march[2] += 1
    elif s[0] == 'C':
        march[3] += 1
    elif s[0] == 'H':
        march[4] += 1

c = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            c += march[i] * march[j] * march[k]

print(c)


Measured memory_bytes: 3188
#include <iostream>
#include <queue>
using namespace std;
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1
int color[MAX],d[MAX];
int N[MAX][MAX];
queue<int> Q;
int n;
void bfs(int u){
    Q.push(u);
    color[u] = GRAY;
    d[u] = 0;
    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        for(int v=0;v<n;v++){
            if(N[u][v]!=0&&color[v]==WHITE){
                Q.push(v);
                d[v] = d[u]+1;
                color[v] = GRAY;
            }
        }
        color[u] = BLACK;
    }
}
void bfs_init(){
    for(int i=0;i<n;i++){
        d[i] = NIL;
    }
    for(int i=0;i<n;i++){
        color[i] = WHITE;
    }
    bfs(0);
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]<<endl;
    }
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            N[i][j] = 0;
        }
    }
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            N[i][v-1] = 1;
        }
    }
    bfs_init();
    return 0;
}



Measured memory_bytes: 3052