akhauriyash/Code-Regression huggingface dataset:
/*
*  Author : pritish.thakkar 
*/
#include<bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define inf 10000000070000000
#define rep(i,n) for(int i=0;i<n;i++)
#define fr first
#define sc second
#define clr(a) memset(a,0LL,sizeof a);
#define sn(t) scanf("%lld",&t)
#define pn(t) printf("%lld",t)
#define WHITE 0
#define BLACK 1
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
bool isUpper(char c) {return (c >= 'A' && c <= 'Z');}
bool isLower(char c) {return (c >= 'a' && c <= 'z');}
bool isalpha(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z');}
bool isalnum(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z')||(c >= '0' && c <= '9');}
char toUpper(char c){return isUpper(c)?c:c-'a'+'A';}
char toLower(char c){return isLower(c)?c:c+'a'-'A';}
ll hcf(ll a,ll b){return ((b == 0) ? a : hcf(b, a%b));} 
ll modpow(ll base, ll expo, ll mod){
    base  = base % mod;
    ll ret = 1LL;
    while(expo > 0){
        if(expo & 1LL)
                ret =( ret * base) % mod;
        base = (base * base )% mod;
        expo >>= 1LL;
    }
    return ret;
}
 
//-----------------------------------------------------------------------------------------------------------------------------
// Enter Your code here
 
ll sieve_size;
bitset <1000010> bs;
vector<ll> primes;
  
void sieve(ll upperbound){
sieve_size=upperbound+1;
bs.reset(),bs.flip();//set all nos. to 1
bs.set(0,false);bs.set(1,false);//except 0 ans 1
for(ll i=2;i<=sieve_size;i++){
    if(bs.test((size_t)i)){
        for(ll j=i*i;j<=sieve_size;j+=i){
            bs.set((size_t)j,false);
        }
        primes.push_back((ll)i);
        }
    }
}
 
// ------------------------------------------


void solve(){
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  ll a,b,c;
  cin>>a>>b>>c;
  if(b-a == c-b){
    cout<<"YES\n";
  }
  else{
    cout<<"NO\n";
  }

}


//-----------------------------------------------------------------------------------------------------------------------------
int main(){
std::ios::sync_with_stdio(0);
solve();
}  























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

int main(void){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    
    double s_dig = (double)(h*60+m)*(pi/360);
    double l_dig = (double)(m)*(pi/30);
    
    double rad = abs(s_dig - l_dig);
    
    double ct =  (double)(a*a + b*b) - (double)(2*a*b) * (double)cos(rad);
    
    double ans =  (double)sqrt(ct);
    
    cout << fixed << setprecision(20) << ans;
    
    return 0;
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

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

  int A = abs(x - a);
  int B = abs(x - b);

  cout << (A < B ? "A" : "B") << "\n";

  return 0;
}

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

using namespace std;

int main()
{
  int k;
  string s, s2[7];
  cin >> k >> s;
  if(s.length() <= k)cout << s;
  else if(s.length() > k)
  {
    s = s.substr(0, k) + "...";
    cout << s << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
using namespace std;
using Int = long long;
Int sum(vector<Int> tmpvec)
{
    Int tmptotal = 0;
    //Junsang****for (vector<Int>::iterator i = tmpvec.begin(); i != tmpvec.end(); i++)
    //Junsang****{
        //Junsang****tmptotal+=*i;
    //Junsang****}
    for (auto elem : tmpvec)
    {
        tmptotal+=elem;
    }
    return tmptotal;
}
int main(int argc, char* argv[])
{
    Int tmp, n;
    vector<Int> vec;
    cin >> n;
    for (Int i = 0; i < n; i++)
    {
        cin >> tmp;
        vec.push_back(tmp);
    }
    sort(vec.begin(), vec.end());
    cout << vec.front() << " " << vec.back() << " " << sum(vec) << endl;

    return 0;
}



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

float x1, y1, x2, y2, x3, y3, x4, y4;

int main(void) {
	int n;
	cin >> n;
	bool flag;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 == x2 && x3 == x4) {
			flag = true;
		} else if (((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3))){
			flag = true;
		} else {
			flag = false;
		}
		if (flag) 
			cout << "YES\n";
		else 
			cout << "NO\n";
	}
}


Measured memory_bytes: 3196
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   type Arr is array(1..26) of Character;
   A: Arr;
   C: Character;
begin
   A(1) := 'a';
   A(2) := 'b';
   A(3) := 'c';
   A(4) := 'd';
   A(5) := 'e';
   A(6) := 'f';
   A(7) := 'g';
   A(8) := 'h';
   A(9) := 'i';
   A(10) := 'j';
   A(11) := 'k';
   A(12) := 'l';
   A(13) := 'm';
   A(14) := 'n';
   A(15) := 'o';
   A(16) := 'p';
   A(17) := 'q';
   A(18) := 'r';
   A(19) := 's';
   A(20) := 't';
   A(21) := 'u';
   A(22) := 'v';
   A(23) := 'w';
   A(24) := 'x';
   A(25) := 'y';
   A(26) := 'z';
   get(C);
   for i in 1..25 loop
     if (A(i) = C) then put(A(i + 1));
     end if;
   end loop;
end main;

Measured memory_bytes: 3568
#include <stdio.h>
#include <string.h>
int main()
{   int  n,i,j,ans=0,cnt=0;
    char s[101];
    scanf("%d%s",&n,s);
    for(i=1;i<n-1;i++){
    int x[27]={0},
        y[27]={0};
        for(j=0;j<i;j++){
            x[(s[j]-'a')]=1;     
        }
        for(j=n-1;j>=i;j--){
            y[(s[j]-'a')]=1;
        }
        int k;
        for(k=0;k<26;k++){
            if(x[k]==1&&y[k]==1){
                cnt++;
            }
        }
        if(cnt>ans){
            ans=cnt;
            
        }
        cnt=0;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vi vec(N);
    rep(i, N) cin >> vec[i];
    vi ball(N, -1);
    vi ans;
    int bcnt = 0;
    for (int i = N - 1; i > -1; i--) {
        int subsum = 0;
        for (int j = 2; (i + 1) * j - 1 < N; j++) {
            int ind = (i + 1) * j - 1;
            subsum += ball[ind];
        }
        subsum %= 2;
        int to_add = subsum ^ vec[i];
        bcnt += to_add;
        ball[i] = to_add;
        if (ball[i]) {
            ans.push_back(i + 1);
        }    
    }

    cout << bcnt << endl;;
    for (auto aa : ans) {
        cout << aa << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5492
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<int,int>M;
int n,a[1<<18],ans;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		M[a[i]]++;
	}
	sort(a,a+n);
	for(int i=n;i--;)
		if(M[a[i]]-->0)
			for(int j=32;1L<<j>a[i];j--)
				if(M[(1<<j)-a[i]]-->0){ans++;break;}
	cout<<ans<<endl;
}

Measured memory_bytes: 48512
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
int main()
{
	ll n,k;
	cin>>n>>k;
	unordered_map<ll,ll>map;
	ll temp;
	for(ll i=1;i<=n;i++)
	{
		cin>>temp;
		map[i]=temp;
	}
	vector<ll>cpath;
	cpath.push_back(1);
	unordered_map<ll,ll>vmap;
	vmap[1]=0;
	int cpos=1;
	int i=1;
	while(vmap.find(map[cpos])==vmap.end())
	{
		vmap[map[cpos]]=i++;
		cpath.push_back(map[cpos]);
		cpos=map[cpos];
	}
	if(k>cpath.size()-1)
	{
		ll plength=(cpath.size()-1)-vmap[map[cpos]]+1;
		k=(k-cpath.size())%plength;
		k=k+vmap[map[cpos]];
		cout<<cpath[k]<<endl;
	}
	else
	{
		cout<<cpath[k]<<endl;
	}
	return 0;
}

Measured memory_bytes: 21208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S , X;
  int K;
  cin >> K >> S;
  
  if(S.size() <= K){
    cout << S << endl;
  }
  if(S.size() > K){
    for(int i = 0; i < K; i++){
      X += S.at(i);
    }
    cout << X + "..." << endl;
  }
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  vector<int> v(3);
  REP (i, 3) cin >> v[i];
  sort(v.begin(), v.end(), greater<int>() );

  int ans = 10 * v[0] + v[1] + v[2];

  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
diff = [0 for i in range(N)]
for i in range(N):
  if V[i] - C[i] > 0:
    ans += V[i] - C[i]
print(ans)

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
 
template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e5 + 5;
const int mod = 1e9 + 7;

int solve(int a,int b,int c){
	
	a = a % c;	
	if(b == 0) return 1;
	else if((b % 2) == 0) return solve((a * a) % c,b / 2,c) % c;
	else return (a * solve((a * a) % c,b / 2,c) % c) % c;
}

vector<int> adj[nax];
vector<int> in(nax,0);
vector<int> out(nax,0);
vector<int> dp(nax,0);
vector<int> vis(nax,false);

void dfs(int src){
	if(vis[src]) return;
	vis[src] = true;
	for(auto u : adj[src]){
		--in[u];
		dp[u] = max(dp[u],1 + dp[src]);
		if(in[u] == 0) dfs(u);
	}
	
	return;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m;
	cin >> n >> m;
	
	for(int i = 0; i < m; ++i){
		int u,v;
		cin >> u >> v;
		
		adj[u].push_back(v);
		++in[v];
	}
	
	for(int i = 1; i <= n; ++i){
		if(vis[i] == false && in[i] == 0) dfs(i);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++i) ans = max(ans,dp[i]);
	cout << ans;
	return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N, M;
    cin >> N;
    vector<int> T(N), P(M), X(M);
    rep(i, N) cin >> T[i];
    cin >> M;
    rep(i, M) {
        cin >> P[i] >> X[i];
    }

    rep(i, M) {
        int sum = 0;
        rep(j, N) {
            if (P[i] == j + 1) sum += X[i];
            else sum += T[j];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool f = false;
  if(s[0] == s[2]) f = true;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke#include <cctype>


Measured memory_bytes: 256
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  // #define MAX 100001
  #define md 998244353
  #define add accumulate
  #define ll long long int
  #define ld long double
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define repa(a,n) for(int i=a;i<n;i++)
  const int MAX=1e5+5;
  const int mod=1e9+7;
  const int N=3e5+9;
  const long double eps=1e-9;
  const ld PI=acos(-1.0);
    ll dx[]={1,0,-1,0};
	ll dy[]={0,1,0,-1};
  //
  //
  int main(){
  	hs;
  	ll n,ans=1,fst;	cin>>n;
  	cin>>fst;
  	rep(i,0,n-1){
  		ll k;
  		cin>>k;
  		ans+=(k>=fst);
  		fst=max(fst,k);
  	} 
  	cout<<ans;
  	return 0;
  }

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
#import bisect# lower_bound etc
#import numpy as np
def run():
    N = int(input())
    A = list(map(int, sysread().split()))
    A = sorted(A)
    for i in range(N-1):
        if A[i] == A[i+1]:
            print('NO')
            return None
    print('YES')


if __name__ == "__main__":
    run()

Measured memory_bytes: 25688
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < n; i++)

int main() {

	int N;
	vector<int> D;
	vector<int> c(13);

	scanf("%d", &N);

	D.push_back(0);
	c[0]++;
	rep(i, N) {
		int t;
		scanf("%d", &t);
		D.push_back(t);
		c[t]++;
	}

	if (*max_element(c.begin(), c.end()) >= 3 || c[0] >= 2 || c[12] >= 2) {
		printf("0\n");
		return 0;
	}

	rep(i, 13) {
		if (c[i] == 2) {
			*find(D.begin(), D.end(), i) = 24 - i;
		}
	}

	sort(D.begin(), D.end());

	for (int i = 1; i <= 24 / (N + 1) + 10; i++) {

		int l = 0;
		for (int p = 0; p < D.size() - 1; p++) {
			if (D[p + 1] - D[p] < i) {
				D[p + 1] = 24 - D[p + 1];
				sort(D.begin(), D.end());
				p--;
				l++;
				if (l > 100) break;
			}
		}

		int s = 114514;
		for (int p = 0; p < D.size() - 1; p++) {
			s = min(s, D[p + 1] - D[p]);
		}

		s = min(s, 24 - *(D.end() - 1));

		if (s < i) {
			printf("%d\n", i - 1);
			return 0;
		}
	}

	return 0;
}

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

int main()
{
    long long n, k , fin , sum = 0 ;
    cin >> n >> k ;
    long long arr[200100];
    for ( int i = 0 ; i < n ; ++i){
        cin >> arr[i];
    }
    sort( arr , arr+n) ;
    for ( int x = 0 ; x < n-k ; x ++){
        sum += arr[x];
    }
    cout << sum ;
    return 0;
}

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

typedef pair<int,int> II;

int G[20][100][100];
int F[100][100];
int memo[100];
int P[20];
int Q[20][51],R[20][51];
bool visited[100];

int fee(int c, int dist){
    int ret=0;
    for(int i=1;i<=P[c];i++){
        if(dist>Q[c][i]){
            ret+=(Q[c][i]-Q[c][i-1])*R[c][i-1];
        }else{
            ret+=(dist-Q[c][i-1])*R[c][i-1];
            break;
        }
    }
    return ret;
}

int main(){
    /*
    P[0]=3;
    Q[0][1]=3;Q[0][2]=6;Q[0][3]=100000;R[0][0]=10;R[0][1]=5;R[0][2]=3;
    for(int i=1;i<10;i++){
        cout<<i<<' '<<fee(0,i)<<endl;
    }
    return 0;
    */

    int N,M,C,s,g;
    while(cin>>N>>M>>C>>s>>g,N){
        s--;g--;
        fill(G[0][0],G[20][0],1e9);
        fill(F[0],F[100],1e9);
        for(int i=0;i<M;i++){
            int x,y,d,c;
            cin>>x>>y>>d>>c;
            x--;y--;c--;
            G[c][x][y]=G[c][y][x]=min(d,G[c][x][y]);
        }
        for(int c=0;c<C;c++){
            for(int i=0;i<N;i++) G[c][i][i]=0;
            for(int k=0;k<N;k++){
                for(int i=0;i<N;i++){
                    for(int j=0;j<N;j++){
                        G[c][i][j]=min(G[c][i][j],G[c][i][k]+G[c][k][j]);
                    }
                }
            }
        }
        for(int i=0;i<C;i++) cin>>P[i];
        for(int c=0;c<C;c++){
            for(int i=1;i<P[c];i++) cin>>Q[c][i];
            Q[c][P[c]]=100000;
            for(int i=0;i<P[c];i++) cin>>R[c][i];
        }
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                for(int c=0;c<C;c++){
                    if(G[c][i][j]!=1e9){
                        F[i][j]=F[j][i]=min(F[i][j],fee(c,G[c][i][j]));
                    }
                }
            }
        }
        //Dijkstra
        priority_queue<II,vector<II>,greater<II>> que;
        que.emplace(0,s);
        fill(visited,visited+100,false);
        fill(memo,memo+100,1e9);        
        while(!que.empty()){
            auto p = que.top(); que.pop();
            int cost=p.first, sta=p.second;
            if(visited[sta]){
                continue;
            }else{
                visited[sta]=true;
            }
            if(sta==g){
                while(!que.empty())que.pop();
                cout<<cost<<endl;
                break;
            }
            for(int i=0;i<N;i++){
                if(F[sta][i]!=1e9){
                    if(memo[i]>cost+F[sta][i]){
                        memo[i]=cost+F[sta][i];
                        que.emplace(memo[i],i);
                    }
                }
            }
        }
        if(!visited[g]) cout<<-1<<endl;        
    }
    return 0;
}

Measured memory_bytes: 3988
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    bool ispoor = false;
    if (a == b && b != c) ispoor = true;
    if (b == c && c != a) ispoor = true;
    if (c == a && a != b) ispoor = true;
    
    if (ispoor) {
        puts("Yes");
    }else {
        puts("No");
    }
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

constexpr int MAX = 10000;

int count(string &s, string &t) {
  int res = 0;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      res++;
    }
  }
  return res;
}

signed main() {
  string S, T;
  cin >> S >> T;

  int ans = MAX;
  for (size_t i = 0; i + T.size() <= S.size(); i++) {
    string s = S.substr(i, T.size());
    ans = min(ans, count(s, T));
  }

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

Measured memory_bytes: 3648
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
num=a[-1]
dp=[True]*num
seen=[0]*num
for i in range(n):
    num2=a[i]
    if dp[num2-1]==True:
        if seen[num2-1]==1:
            dp[num2-1]=False
        for j in range(2,num//num2+1):
            dp[j*num2-1]=False
    seen[a[i]-1]=1
ans=0
for i in range(n):
    if dp[a[i]-1]==True:
        ans+=1
print(ans)


Measured memory_bytes: 34852
#include <iostream>

using namespace std;

main(){
  int boal[3];
  boal[0]=1;
  boal[1]=0;
  boal[2]=0;
  for(int i=0;;i++){
    char a, b;
    if(scanf("%c,%c", &a, &b)==EOF) break;
    getchar();
    int p, n;
    if(a=='A') p=0;
    else if(a=='B') p=1;
    else if(a=='C') p=2;
    if(b=='A') n=0;
    else if(b=='B') n=1;
    else if(b=='C') n=2;
    if(p==n) continue;
    int tmp;
    tmp=boal[p];
    boal[p]=boal[n];
    boal[n]=tmp;
  }
  if(boal[0]==1) cout << 'A' << endl;
  else if(boal[1]==1) cout << 'B' << endl;
  else cout << 'C' << endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int smaller(int x, int y){
	if(x < y){
		return x;
	}
	return y;
}

int main(){
	string X, Y;
	cin >> X >> Y;
	int lenX = X.size();
	int lenY = Y.size();
	int dp[lenX+1][lenY+1];
	for(int i = 0; i <= lenX; i++){
		dp[i][0] = i;
	}
	for(int i = 0; i <= lenY; i++){
		dp[0][i] = i;
	}
	for(int i = 0; i < lenX; i++){
		for(int j = 0; j < lenY; j++){
			int replacecost = 0;
			if(X[i] != Y[j]){
				replacecost = 1;
			}
			dp[i+1][j+1] = smaller(dp[i][j]+replacecost, smaller(dp[i][j+1], dp[i+1][j])+1);
		}
	}
	cout << dp[lenX][lenY] << "\n";
}



Measured memory_bytes: 7084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e4+10;
const double eps=1e-6;

int G[20][20];
ll save[20];
bool vis[20];
ll minn;

void dfs(int num,ll cost){
	if(num==1){
		if(cost<minn)
			minn=cost;
		//return;
	}
	for(int i=0;i<=9;i++){
		if(vis[i])	continue;
		/*if(save[i]!=-1){
			if(cost+save[i]<minn)
				minn=cost+save[i];
			return;
		}*/
		vis[i]=1;
		dfs(i,cost+G[num][i]);
		vis[i]=0;
	}
}

void init(){
    memset(save,-1,sizeof(save));
    for(int i=0;i<=9;i++){
    	minn=inf;
    	vis[i]=1;
    	dfs(i,0);
    	vis[i]=0;
    	save[i]=minn;
    }
    //for(int i=0;i<=9;i++)
    	//cout<<" "<<save[i];
    //cout<<endl;
}

int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif

    int n,m;
    ll ans=0;
    cin>>n>>m;
    for(int i=0;i<=9;i++){
    	for(int j=0;j<=9;j++){
    		scanf("%d",&G[i][j]);
    	}
    }
    init();
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		int temp;
    		scanf("%d",&temp);
    		if(temp==1||temp==-1)	continue;
    		ans+=save[temp];
    	}
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S;
ll N;
ll L[100];
ll ans;
ll M = 1000000000;


int main() {
    cin >> N;
    for(int i=0;i<N;i++){
        cin >>L[i];
    }
    sort(L,L+N);
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                if(L[i]!=L[k] && L[j]!=L[k] && L[i]!=L[j]){
                    if(L[k]<L[i]+L[j]){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3672
H, W = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
move = []
for i in range(H-1):
	for j in range(W-1):
		if A[i][j] % 2 == 1:
			A[i][j] -= 1
			A[i][j+1] += 1
			move.append((i, j, i, j+1))
	if A[i][W-1] % 2 == 1:
		A[i][W-1] -=1
		A[i+1][W-1] += 1
		move.append((i, W-1, i+1, W-1))
for j in range(W-1):
	if A[H-1][j] % 2 == 1:
		A[H-1][j] -= 1
		A[H-1][j+1] += 1
		move.append((H-1, j, H-1, j+1))

print(len(move))

for (y1, x1, y2, x2) in move:
	print(y1+1, x1+1, y2+1, x2+1)

Measured memory_bytes: 22816
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let n = read_i64() as usize;
    let xs = read_vec_i64();
    if n == 1 {
        println!("1");
        return;
    }
    let mut l = 0;
    let mut r = 1;
    let mut t = xs[0];
    let mut res = 1;
    loop {
        if r < n && t & xs[r] == 0 {
            t = t ^ xs[r];
            r += 1;
            res += r-l;
            if r == n {
                break;
            }
        }
        else {
            t = t ^ xs[l];
            l += 1;
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 10492
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line[] = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int x = Integer.parseInt(line[1]);
        int min = 1000, sum = 0, temp;
        
        for (int i = 0; i < n; i++) {
            temp = Integer.parseInt(br.readLine());
            if (temp < min) min = temp;
            sum += temp;
        }
        
        
        
        System.out.println(n + (x-sum)/min);
    }
}


Measured memory_bytes: 21332
#include <stdio.h>
int n, A[1000000], cnt;
void insertionSort(int g) {
  int v;
  int i, j;
  for(i = g; i < n; i++) {
    v = A[i];
    j = i-g;
    while(j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}
void shellSort() {
  int G[100], m = 0, g = 0;
  int i;
  while(3*g+1 <= n) {
    g = 3*g+1;
    G[m++] = g;
  }
  printf("%d\n", m);
  for(i = m-1; i >= 0; i--) {
    if(i < m-1) printf(" ");
    printf("%d", G[i]);
    insertionSort(G[i]);
  }
  puts("");
  printf("%d\n", cnt);
  for(i = 0; i < n; i++) printf("%d\n", A[i]);
}
int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", A+i);
  shellSort();
  return 0;
}

Measured memory_bytes: 4520
#include <iostream>

#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
#define P pair<int,int>
using namespace std;
int main()
{
	int q;
	int a1 = 0;
	int a2 = 0;
	cin >> q;
	int a[200005];
	for (int i = 0; i < q; i++)
	{
		cin >> a[i];
		if (a[i] % 4 == 0)
			a1++;
		if (a[i] % 2 != 0)
			a2++;
	}
	if (a2 == a1 + 1 && q == a1 + a2)
	{
		cout << "Yes";
		return 0;
	}
	if (a1 >= a2)
	{
		cout << "Yes";
		return 0;
	}
	cout << "No";
}










Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    string str;
    cin >> str;
    
    // calculation
    int sum = 0;
    REP(i, str.length()) if (str[i] == '1') sum++;
    cout << sum << "\n";
    
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n,m;
  cin>>n>>m;
  map<ll,vector<ll>> cnt;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    cnt[a].push_back(b);
  }

  priority_queue<ll> que; 
  ll ans=0;
  reps(i,m){
    cnt[i].push_back(0);
    for(const auto& x:cnt[i]){
      que.push(x);
    }
    ans+=que.top();
    que.pop();
  }
  cout<<(ans)<<endl;


}


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

#define rep(i,n) for(int i=0;i<(n);i++)

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { // ans=mint(a).pow(b); // a^b
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n){ // 2のn乗
    if(n==0) return 1;
    mint x=f(n/2);
    x*=x;
    if(n%2==1) x*=2;
    return x;
}

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N;
    cin>>N;
    vector<ll> a(N);
    rep(i,N) cin>>a[i];
    mint b=1;
    mint ans=0;
    rep(i,61){
        ll sum=0;
        rep(j,N){
            sum+=a[j]&1;
            a[j]=a[j]>>1;
        }
        ans+=b*sum*(ll)(N-sum);
        b*=2;
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans+=a;
  }
  cout<<ans-n<<endl;
  return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    string c[6];
    for (int i = 0;i < h;++i) cin >> c[i];
    int ans = 0;
    for (int i = 0;i < (1<<h);++i) for (int j = 0;j < (1<<w);++j) {
        string d[6];
        for (int l = 0;l < 6;++l) d[l] = c[l];
        for (int l = 0;l < h;++l) if ((i>>l)&1) for (int m = 0;m < w;++m) d[l][m] = '.';
        for (int l = 0;l < w;++l) if ((j>>l)&1) for (int m = 0;m < h;++m) d[m][l] = '.';
        int cnt = 0;
        for (int l = 0;l < h;++l) for (int m = 0;m < w;++m) if (d[l][m] == '#') cnt++;
        if (cnt == k) ans++;
    }
    cout << ans << endl;
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,A;
  cin >> N >> A;
  vector<int> x(N);
  rep(i,N){
    cin >> x.at(i);
    x.at(i)-=A;
  }

  vector<vector<ll>> dp(N+1,vector<ll>(10000,0));
  dp.at(0).at(5000)=1;
  rep(i,N){
    rep(j,10000){
      dp.at(i+1).at(j) += dp.at(i).at(j);
      if(0 <= j+x.at(i) && j+x.at(i) < 10000){
        dp.at(i+1).at(j+x.at(i)) += dp.at(i).at(j);
      }
    }
  }
  cout << dp.at(N).at(5000) - 1 << endl;

  return 0;
}

Measured memory_bytes: 7412
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
#include<string>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
 
 
 
int main(void)
{
	int x;
 
	cin >> x;
	int n =1;
	bool f = false;
	while (100*n<=x)
	{
		if (100*n<=x && 105 * n>=x)
		{
 
			f = true;
		}
 
		n++;
	}
 
 
	if (f == false)cout << 0 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(S.size() - 1) == 's') cout << S + "es" << endl;
  else cout << S + "s" << endl;
}

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

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n>k){
        cout << k*x + (n-k) * y << "\n";
    }
    else{
        cout << n*x << "\n";
    }
}

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

int main(){
  int a, b, x;
  cin >> a >> b >> x;
  double ans;
  if(a*a*b/2 < x){
    double empty = a*a*b-x;
    empty /= a*a;
    empty *= 2;
    ans = atan(empty / a) / pi *180;
    printf("%.10f\n",ans);
  }
  else if(a*a*b/2 == x) cout << 45 << endl;
  else{
    double vol = x;
    vol /= a*b;
    vol *= 2;
    ans = 90 - (atan(vol/b) / pi *180);
    printf("%.10f\n",ans);
  }
}

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

bool cmp(pair<int,int>&a, pair<int,int>& b){
    return a.second > b.second;
}

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;

        int d,p;
        vector<pair<int,int> > ex(n);
        for(int i=0; i<n; i++){
            cin >> d >> p;
            ex[i] = make_pair(d,p);
        }
        sort(ex.begin(), ex.end(), cmp);

        for(int i=0; i<n; i++){
            if(ex[i].first < m){
                m -= ex[i].first;
                ex[i].first = 0;
            }else{
                ex[i].first -= m;
                m = 0;
                break;
            }
        }

        int cnt=0;
        for(int i=0; i<n; i++){
            cnt += ex[i].first * ex[i].second;
        }      
        cout << cnt << endl;
    }
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int x, y, n, m, k;
int a[N], b[N], c[N];

bool read() {
    if (!(cin >> x >> y >> n >> m >> k))
        return false;

    forn (i, n) cin >> a[i];
    forn (i, m) cin >> b[i];
    forn (i, k) cin >> c[i];

    return true;
}

void solve(int id = 0) {
    sort(a, a + n);
    reverse(a, a + n);
    sort(b, b + m);
    reverse(b, b + m);
    sort(c, c + k);
    reverse(c, c + k);

    int ans = accumulate(a, a + x, 0ll) + accumulate(b, b + y, 0ll);

    for (int z = 0; z < k && (x > 0 || y > 0); ++z) {
        if (x > 0 && a[x - 1] < c[z] && (y == 0 || a[x - 1] < b[y - 1])) {
            ans -= a[--x];
            ans += c[z];
        } else if (y > 0 && b[y - 1] < c[z]) {
            ans -= b[--y];
            ans += c[z];
        }
    }

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    //cin >> T;

    while (read())
        solve(T++);

    return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    string t;
    cin >> t;
    for (int i = 0; i < t.size(); ++i)
    {
        if (t[i] == '?')
        {
            t[i] = 'D';
        }
    }
    cout << t << endl;
    return 0;
}



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

using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
int main(){
    unsigned long N, K;
    cin >> N >> K;
    if(N == K){
        vector<unsigned long> P(N);
        for(auto& i : P)cin >> i;
        P.push_back(P[0]);
        for(unsigned long i = 0; i < N; ++i)if((P[i] + 1 + N - P[i + 1]) % N)return 0 & puts("No");
		puts("Yes");
		return 0;
    }
    if(~K & 1)return 0 & puts("Yes");
    vector<unsigned long> P(N);
    for(auto& i : P)cin >> i;
    BIT<int>bit(N);
	long long T=0;
	for(int i=0;i<N;i++)
	{
		T+=i-bit.sum(P[i]);
		bit.add(P[i],1);
	}
	cout<<(T%2?"No":"Yes")<<endl;
    return 0;
}




Measured memory_bytes: 4460
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>m;
  mii mp;
  ll a[n];
  pii b[m];
  for (ll i = 0; i < n; ++i)
  {
  cin>>a[i];
  }
  for (int i = 0; i < m; ++i)
  {
    cin>>x>>y;
    b[i] = {y,x};
  }
  sort(a,a+n);
  sort(b,b+m);
  reverse(b,b+m);
  x = 0;y=0;
  for (int i = 0; i < m; ++i)
  {
    k = upper_bound(a+x,a+n,b[i].F) - a-x;
    y = min(k,b[i].S);
    y--;
    if(y<0)
        continue;
    mp[{x,x+y}] = b[i].F;
    //cout<<x<<" "<<x+y<<"\n";
    x += (y+1);
  }
  for (auto it : mp)
  {  
    for (int i = it.F.F; i <= min(it.F.S,n); ++i)
    {
      a[i] = it.S;
    }
  }
  fr(j,0,n)
  c+=a[j];
  
  cout<<c<<" ";
}

signed main(){
  
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 6144
n,k = map(int,input().split())
t = [[0,0] for i in range(n)]
for i in range(n):
    a,b = map(int,input().split())
    t[i] = (a,b)
kk = 0
t = sorted(t, key=lambda t: t[0])

for i in range(n):
    kk += t[i][1]
    if kk >= k:
        print(t[i][0])
        break


Measured memory_bytes: 19700
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] scores = new int[2];
		String[] cards = new String[2];
		String str = null;

		int n = Integer.parseInt(sc.nextLine());

		for (int i = 0; i < n; i++) {
			str = sc.nextLine();
			cards = str.split(" ");
			scores = fight(scores, cards);
		}

			System.out.println(scores[0] + " " + scores[1]);


		sc.close();

	}

	private static int[] fight(int[] scores, String[] cards) {

			if (cards[0].compareTo(cards[1]) > 0) {
				scores[0] += 3;
			} else if (cards[0].compareTo(cards[1]) < 0) {
				scores[1] += 3;
			} else {
				scores[0]++;
				scores[1]++;
			}

		return scores;


	}

}



Measured memory_bytes: 30876
#include<bits/stdc++.h>
using namespace std;
char s[10000];
int a[1000];
int main() {
	scanf("%s",s);
	int tot=1;
	for(register int i=0; i<strlen(s); ++i) {
	  if(s[i]=='C'||s[i]=='c')
	  {
	  	for(int j=i+1;j<strlen(s);++j)
	  	if(s[j]=='F'||s[j]=='f') 
	  	{
	  		printf("Yes");
	  		exit(0);
		}
	  }
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
//#define mod 1000000007
#define mod 998244353


int K;
char S[105];
char S_[105];
signed main(){
    scanf("%lld",&K);
    scanf("%s",S);
    if(strlen(S)<=K){
        printf("%s\n",S);
    }else{
        S[K]='\0';
        printf("%s...\n",S);
    }
    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
int a;
int b;
int cnt[3];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    cin >> a >> b;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x <= a) cnt[0]++;
        else if (x <= b) cnt[1]++;
        else cnt[2]++;
    }
    cout << min({cnt[0], cnt[1], cnt[2]});
    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = 0
for k in range(K, N + 2):
    # k個足してできる最大の整数
    # 大きい順にk個選べばよい
    # N + (N - 1) + ... + (N - k + 1)
    # = (0+1+...+N) - (0+1+...+(N-k)) = B
    B = N * (N + 1) // 2 - (N - k) * (N - k + 1) // 2
    # 最小の整数は小さい順にk個選べばよい
    # 0 + 1 + ... + (k-1)
    A = (k - 1) * k // 2
    # k個足してできる整数の数
    ans += (B - A + 1)
print(ans % mod)

Measured memory_bytes: 10028
L = input()
 
for i in range(0,int(len(L))):
	if (i % 2) == 0:
		if L[i] == "L": #奇数
			print("No")
			break
	elif (i % 2) == 1:
		if L[i] == "R":
			print("No")
			break
else:print("Yes")

Measured memory_bytes: 3060