akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

#define M 1000000/* ハッシュ表の行数 */
#define L 14    /* ハッシュ表の列数 */
#define FOUND 1
#define NFOUND 0

char H[M][L]; /* Hash Table */

int getChar(char ch)
{
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i, len;

  len = strlen(str);
  for ( i = 0; i < len; i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key)
{
  return key % M;
}

int h2(int key)
{
  return 1 + key % (M-1);
}

/* ハッシュ表から文字列strを探索する関数 */
int find(char str[])
{
  int i = 0, n, str_key, a, b;

  str_key = getKey(str);                   /* strのkey値を求める */
  a = h1(str_key);
  b = h2(str_key);

  while(1)
    {	
      n = ( a + i*b) % M;     /* ハッシュ値を求める*/

      if( H[n][0] == '\0' || i>=M ) /* strが見つかなかった場合*/
	return NFOUND;
      else if( str_key == getKey(H[n]) )     /* strが見つかった場合 */
	return FOUND;
      i++;
    }
}

/* ハッシュ表に文字列strを挿入する関数 */
int insert(char str[])
{
  int i = 0, n, str_key, a,b;

   str_key = getKey(str);                   /* strのkey値を求める */
   a = h1(str_key);
   b = h2(str_key);

  while(1)
    {
     
	
      n = ( a + i*b) % M;     /* ハッシュ値を求める*/

      if( H[n][0] == '\0' )           /* その場所に挿入できる場合*/
	{
	  strcpy( H[n], str);
	  return 1;
	}
      else if( strcmp( H[n], str) == 0 )
	return 1;
      else
	i++;
    }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15404
def isok(a):
    for j in range(21):
        if(a>>j&1):
            if(bit[j]>0):
                return False
    return True
def bitplus(a):
    for j in range(21):
        if(a>>j&1):
            bit[j]+=1
def bitdif(a):
    for j in range(21):
        if(a>>j&1):
            bit[j]-=a>>j&1

N=int(input())
A=list(map(int,input().split()))
left=0
ans=0
bit=[0]*21
right=0
while(left<N):
    while(right<N and isok(A[right])):
        bitplus(A[right])
        right+=1
    ans+=right-left
    if right==left:
        right+=1
    else:
        bitdif(A[left])
    left+=1
print(ans)

Measured memory_bytes: 77644
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(double)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


vector<LL> allPrimes;

// Fills above vector allPrimes[] for a given n
void sieve(int n)
{
    // Create a boolean array "prime[0..n]" and
    // initialize all entries it as true. A value
    // in prime[i] will finally be false if i is
    // not a prime, else true.
    vector<bool> prime(n+1, true);
 
    // Loop to update prime[]
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it
        // is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p
            for (int i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
 
    // Store primes in the vector allPrimes
    for (int p=2; p<=n; p++)
        if (prime[p])
            allPrimes.push_back(p);
}
 
// Function to find all result of factorial number
LL factorialDivisors(LL n)
{
    sieve(n);  // create sieve
 
    // Initialize result
    LL result = 1;
 
    // find exponents of all primes which divides n
    // and less than n
    for (int i=0; i < allPrimes.size(); i++)
    {
        // Current divisor
        LL p = allPrimes[i];
 
        // Find the highest power (stored in exp)'
        // of allPrimes[i] that divides n using
        // Legendre's formula.
        LL exp = 0;
        while (p <= n)
        {
            exp = exp + (n/p);
            p = p*allPrimes[i];
        }
 
        // Multiply exponents of all primes less
        // than n
        result = result*(exp+1)%MOD;
    }
 
    // return total divisors
    return result;
}
int main(){
    int N;
    cin>>N;
    cout<<factorialDivisors(N)<<endl;
    return 0;
}


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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const int N = 1e5+123;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;

int n, m, x, y;
int ok[N], cnt[N];
int main (){
 ios_base
 cin >> n >> m;
 ok[1] = 1;
 for(int i = 1; i <= n; i ++){
  cnt[i] = 1;
 }
 for(int i = 1; i <= m; i ++){
  cin >> x >> y;
  if(ok[x] == 1) ok[y] = 1;
  if(cnt[x] == 1) ok[x] = 0;
  cnt[x] --;
  cnt[y] ++;
 }
 int cnt = 0;
 for(int i = 1; i <= n; i ++){
  if(ok[i] == 1) cnt ++;
 }
 cout << cnt;
 return  0;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int n, m;
bool edge[50][50];
bool visited[50];

void dfs(int pos, int a, int b) {
  rep (i, n) {
    if (!edge[pos][i]) continue;
    if ((a == pos && b == i) || (a == i && b == pos)) continue;
    if (visited[i]) continue;
    visited[i] = 1;
    dfs(i, a, b);
  }
}

int main() {
  memset(edge, 0, sizeof(edge));
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a][b] = edge[b][a] = 1;
  }

  int ans = 0;
  rep(i, n) REP(j, i, n) if (edge[i][j]) {
    memset(visited, 0, sizeof(visited));
    visited[0] = 1;
    dfs(0, i, j);
    int cnt = 0;
    rep(k, n) cnt += visited[k];
    if (cnt != n) ans++;
  }

  cout << ans << endl;
}


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

int
main(int argc, char *argv[])
{
        char find[11];
        char in[1001];
        char *word;
        int cnt = 0;
        
        scanf("%s", find);
        while (1) {
                scanf("%s", in);
                for (word = strtok(in, " "); word; word = strtok(NULL, " ")) {
                        if (!strcmp(word, "END_OF_TEXT")) goto END;
                        if (!strcasecmp(word, find)) cnt++;
                }
        }
END:
        printf("%d\n", cnt);
        return 0;
}

Measured memory_bytes: 556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;cin>>n;
    int a[n];
    bool s=true;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if((a[i]%2==0&&a[i]%3!=0)&&(a[i]%2==0&&a[i]%5!=0))s=false;
    }
    if(s)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100009];
int main()
{
	int x;
	cin >> a;
	x = strlen(a);
	if(x % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i <= x/2-1; i++)
	{
		if(a[i] == 'p' && a[x-i-1] != 'q')
		{
			cout << "No" << endl;
			return 0;
		}
		if(a[i] == 'q' && a[x-i-1] != 'p')
		{
			cout << "No" << endl;
			return 0;
		}
		if(a[i] == 'b' && a[x-i-1] != 'd')
		{
			cout << "No" << endl;
			return 0;
		}
		if(a[i] == 'd' && a[x-i-1] != 'b')
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 384
import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
cs = np.cumsum(p)
Max = 0
for i in range(n+1-k):
    if i == 0:
        Max = max(cs[k-1],Max)
    Max = max(cs[i+k-1]-cs[i-1],Max)
print((Max+k)/2)

Measured memory_bytes: 33724
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
 
using namespace std;

int main(){

	int k;
	cin>>k;

	vector<int> d(k,k+1);
	d[1]=1;
	queue<pair<int,int> > q;
	q.push(make_pair(2%k,2));
	q.push(make_pair(10%k,1));
	while(!q.empty()){
		pair<int,int > p =q.front();
		q.pop();
		if(p.second >=  d[p.first]) continue;
		d[p.first] = p.second;
		q.push(make_pair((p.first+1)%k,p.second+1));
		q.push(make_pair((p.first*10)%k,p.second));
	}
	cout<<d[0]<<endl;

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N),ANS(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
        ANS[A[i]]=i+1;
    }

    for(int i=0;i<N;i++){
        cout << ANS[i] << " ";
    }

    cout << endl;

}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string S;
  cin>>S;
  ll sum=0;
  for(int bit=0;bit<(1<<S.size()-1);bit++){
    ll t=S[0]-'0';
    for(int i=0;i<S.size()-1;i++){
      if(bit&(1<<i)){
        sum+=t;
        t=S[i+1]-'0';
      }else{
        t=t*10;
        t+=S[i+1]-'0';
      }
    }
    sum+=t;
  }
  
  cout<<sum<<endl;
}

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

int main() {
  int n;cin>>n;
  vector<string> vec(n);
  rep(i,n)cin>>vec[i];
  rep(i,n-1)for(int j=i+1;j<n;j++){
    if(vec[i]==vec[j]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  rep(i,n-1){
    if(vec[i][vec[i].size()-1]!=vec[i+1][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        vector<int> div;
        for(int j = 1; j * j <= i; ++j) {
            if(i % j == 0) {
                int k = i / j;
                div.push_back(j);
                if(k != j) div.push_back(k);
            }
        }
        ans += (bool) (i % 2 && div.size() == 8);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main() {
	char x[11];
	cin >> x;
	int l = strlen(x);
	int a;
	int min = 999;
	for (int i = 2;i < l;i++) {
		a = (x[i - 2] - '0') * 100 + (x[i - 1] - '0') * 10 + x[i] - '0';
		a = abs(753 - a);
		if (min > a) {
			min = a;
		}
	}
	cout << min << endl;
	return 0;
}

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 rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main(){
	ios::sync_with_stdio(0);
	string s;
	cin >> s;
	int n = sz(s);
	int ans = 0;
	int i = -1;
	int j = n;
	while(i < n) {
		int ax = 0, bx = 0;
		++i;
		while(i < n && s[i] == 'x') {
			++ax;
			++i;
		}
		--j;
		while(j >= 0 && s[j] == 'x') {
			++bx;
			--j;
		}
		ans += abs(ax-bx);
		if(i == n)
			break;
		if(s[i] != s[j]) {
			cout << "-1" << endl;
			return 0;
		}
	}
	assert(ans%2 == 0);
	cout << ans/2 << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define times(n,i) for(int i=0;i<n;i++)

int gcd(int x,int y){
    int c;
    while ( x != 0 ) {
    c=x; x=y%x; y=c;
    }
    return y;
}
int main(){
    int N,X;
    scanf("%d%d",&N,&X);
    vector<int> x(N);
    times(N,i){
        scanf("%d",&x[i]);
        x[i]=abs(X-x[i]);
    }
    int d=x[0];
    for(int i:x){
        d=gcd(d,i);
    }
    printf("%d\n",d);
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

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

int main() {
	ll x,a,b;
	cin >> x;
	

	for (ll i = -1000; i < 1001; i++) {
		for (ll j = -1000; j < 1001; j++) {
			a = i * i*i*i*i;
			b = j * j*j*j*j;
			if (a - b == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}	
	}	
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	int n,cnt;
	int[] ary;
	public static void main(String args[]) {
		new Main().run();
	}
	public void run() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		cnt = 0;
		ary = new int[n];
		for (int i = 0; i < n; i++) {
			ary[i] = scan.nextInt();
		}
		for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (ary[minj] > ary[j])
					minj = j;
			}
			if (i != minj) {
				int tmp = ary[i];
				ary[i] = ary[minj];
				ary[minj] = tmp;
				cnt++;
			}
		}
		writeArray();
		System.out.println(cnt);
	}
	public void writeArray() {
		System.out.print(ary[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + ary[i]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26392
function main(input) {
    var lines = input.split('\n');
    var line1 = lines[0].split(' ');
    var line2 = lines[1].split(' ');

    var N = parseInt(line1[0]);
    var M = parseInt(line1[1]);
    var X = parseInt(line1[2]);

    var tollgates = line2.map(function(str){return parseInt(str)});

    var costBeforeX = tollgates.reduce(function(cost, place){
        return place <= X ? cost + 1 : cost;
    }, 0);

    var costAfterX = M - costBeforeX;

    var answer = Math.min(costBeforeX, costAfterX);
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){

string S;
cin >> S;
int one = 0, zero = 0;
    for(int i = 0; i < S.size(); i++){ 
         if(S.at(i) == '0'){
             zero++;
         }else if(S.at(i) == '1'){
             one++;
         }

    }
 
int ans = min(zero, one) * 2;

cout << ans << endl;
}

Measured memory_bytes: 512
s=int(input())
l=[]
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1
while s not in l:
    #print(f"{len(l)} times")
    l.append(s)
    s=f(s)
    #print(f"list:{l}")
    #print(f"s{len(l)}:{s}")
print(len(l)+1)


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

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

using namespace std;
using lint=long long;

int main(){
	lint n,x; cin>>n>>x;

	lint ans=x;
	lint a=x,b=n,c=n-x,d=n-x;
	while(1){
		if(a>b) swap(a,b);
		if(c>d) swap(c,d);

		if(b==d){ ans+=b; break; }

		if(b>d){ lint m=b/d-(b%d==0?1:0); ans+=m*d; b-=m*d; }
		else   { lint m=d/b-(d%b==0?1:0); ans+=m*b; d-=m*b; }
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {
    fast();
    ll t;
    cin>>t;
    ll even=t/2;
    ll odd=t-even;
    double ans=odd/(double)t;
    cout<< fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

struct newint
{
    int x;
    int y;
};

int main()
{
    int h,w,d,q,a[400][400],l,r,v[90005],sum[90005],temp;
    newint p[90005];
    scanf("%d%d%d",&h,&w,&d);
    for (int i=1;i<=h;i++)
        for (int j=1;j<=w;j++)
            {
                scanf("%d",&a[i][j]);
                p[a[i][j]].x=i;
                p[a[i][j]].y=j;
            }
    for (int i=1;i<=h*w-d;i++)
        v[i]=abs(p[i].x-p[i+d].x)+abs(p[i].y-p[i+d].y);
    r=h*w;
    for (temp=1;temp<=d;temp++)
    {
    l=temp;
    while (l<r)
        {
            sum[temp]=sum[temp]+v[l];
            l=l+d;
        }
    }
    for (int i=d+1;i<=h*w;i++)
        sum[i]=sum[i-d]-v[i-d];
    scanf("%d",&q);
    int ans;
    while (q--)
        {
            scanf("%d%d",&l,&r);
            ans=sum[l]-sum[r];
            printf("%d\n",ans);
        }
    return 0;
}


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

using namespace std;

using ll = long long;

void solve(int n, vector<ll>& a, vector<ll>& sum, vector<ll>& p) {
    sum[0] = a[0];
    p[0] = 0;
    for (int i = 1, j = 0; i < n; i++) {
        sum[i] = sum[i - 1] + a[i];
        p[i] = p[i - 1];
        while (j < i) {
            ll tmp = p[i] + a[j];
            if (abs((sum[i] - tmp) - tmp) < abs((sum[i] - p[i]) - p[i])) {
                p[i] = tmp;
                j++;
            } else {
                break;
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<ll> sum1(n, 0), p(n, 0);
    solve(n, a, sum1, p);
    reverse(a.begin(), a.end());

    vector<ll> sum2(n, 0), s(n, 0);
    solve(n, a, sum2, s);
    reverse(sum2.begin(), sum2.end());
    reverse(s.begin(), s.end());

    ll ans = 1000000000000000LL;
    for (int i = 0; i < n; i++) {
        if (i + 1 < 2) continue;
        if (n - (i + 1) < 2) break;
        vector<ll> hoge = {p[i], sum1[i] - p[i], s[i + 1], sum2[i + 1] - s[i + 1]};
        ans = min(ans, *max_element(hoge.begin(), hoge.end()) - *min_element(hoge.begin(), hoge.end()));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template <long long mod,long long pri> struct NTT{
    using i64 = long long;
    i64 pw(i64 x,i64 r) {
        i64 ans=1;
        while(r){
            if(r&1) (ans*=x)%=mod;
            r>>=1;
            (x*=x)%=mod;
        }
        return ans;
    }
    i64 inv(i64 c){
        return pw(c,mod-2);
    }
    void DFT(vector<i64> a,vector<i64>& c,i64 n,bool iv=false){
        a.resize(n);c.clear();c.resize(n);
        if(n==1){
            c=a;
            return;
        }
        i64 z=pw(pri,(mod-1)/n);
        if(iv) z=inv(z);
        vector<i64> pz(n+1,1),t(n);
        for(i64 i=1;i<n;i*=2) for(i64 j=0;j<i;++j) t[j]*=2,t[j+i]=t[j]+1;
        for(i64 i=0;i<n;++i) c[i]=a[t[i]],pz[i+1]=(pz[i]*z)%mod;
        for(i64 i=2,l=(n>>1);i<=n;i<<=1,l>>=1){
            a.swap(c);
            for(i64 j=0;j<l;++j){
                for(i64 k=0;k<(i>>1);++k){
                    c[i*j+k]=(a[i*j+k]+a[i*j+k+(i>>1)]*pz[l*k])%mod;
                    c[i*j+k+(i>>1)]=(a[i*j+k]+a[i*j+k+(i>>1)]*pz[l*(k+(i>>1))])%mod;
                }
            }
        }
        if(iv){
            i64 k=inv(n);
            for(i64 i=0;i<n;++i) (c[i]*=k)%=mod;
        }
    }
    void mul(vector<i64> a,vector<i64> b,vector<i64>& c){
        i64 n=1;
        while(n<a.size()+b.size()-1) n<<=1;
        vector<i64> A,B,C(n);
        DFT(a,A,n);DFT(b,B,n);
        for(i64 i=0;i<n;++i) C[i]=(A[i]*B[i])%mod;
        DFT(C,c,n,true);
    }
};

template <size_t t> int_fast64_t Garner(array<pair<int_fast64_t,int_fast64_t>,t> mr){
    using i64 = int_fast64_t;
    array<i64,t> k;
    for(size_t i=0;i<t;++i){
        i64 a=1,b=0,mod=mr[i].first,r=mr[i].second;
        for(size_t j=0;j<i;++j) (b+=k[j]*a)%=mod,(a*=mr[j].first)%=mod;
        i64 s=mod-2,an=1;
        while(s){
            if(s&1) (an*=a)%=mod;
            s>>=1;
            (a*=a)%=mod;
        }
        k[i]=(an*(r+mod-b))%mod;
    }
    __int128 a=1,b=0;
    for(size_t i=0;i<t;++i) b+=(__int128)k[i]*a,a*=mr[i].first;
    return (i64)b;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    constexpr int p{200003};
    ll sq{},n,a;
    cin>>n;
    vector<ll> c(p),d(p-1),ans,ANS;
    fr(i,n){
        cin>>a;
        ++c[a];
        sq+=a*a%p;
    }
    ll k{1};
    fr(i,p-1){
        d[i]=c[k];
        (k*=2)%=p;
    }
    NTT<1224736769,3> ntt;
    NTT<998244353,3> NTT;
    ntt.mul(d,d,ans);
    NTT.mul(d,d,ANS);
    ll an{},AN{};
    k=1;
    for(auto&i:ans){
        (an+=i*k)%=1224736769;
        (k*=2)%=p;
    }
    k=1;
    for(auto&I:ANS){
        (AN+=I*k)%=998244353;
        (k*=2)%=p;
    }
    array<pair<int_fast64_t,int_fast64_t>,2> mr
    ={make_pair(1224736769ll,an),make_pair(998244353ll,AN)};
    ll An=Garner(mr);
    cout<<(An-sq)/2<<'\n';
}

Measured memory_bytes: 44924
MOD = 10**9 + 7

def mul(a, b):
    return [
        [sum(aij * bij for aij, bij in zip(ai, bi)) % MOD for bi in zip(*b)]
        for ai in a]

def pow(b, k):
    r = [[1 if i == j else 0 for i in range(len(b))] for j in range(len(b))]
    while k:
        if k & 1:
            r = mul(r, b)
        k >>= 1
        b = mul(b, b)
    return r


def main():
    N, K = (int(i) for i in input().split())
    A = []
    for i in range(N):
        A.append([int(j) for j in input().split()])
    A = [i for i in zip(*A)]
    v = [[1] * N]
    return sum(mul(v, pow(A, K))[0]) % MOD

print(main())


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(x) cerr<<#x": "<<(x)<<endl
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second

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

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int N = 200010;

int node, dst;
bool win[N];
vector<int> adj[N];

void dfs(int v, int p = -1, int depth = 0) {
	if(depth >= dst) node = v, dst = depth;

	for(auto u : adj[v]) if(u != p) dfs(u, v, depth + 1);
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int n, a, b;

	win[0] = true;
	for(int i = 1; i < N; ++i) {
		if(!win[i - 1]) win[i] = true;
		else if(i > 1 && !win[i - 2]) win[i] = true;
		else win[i] = false;
	}

	cin >> n;
	for(int i = 1; i < n; ++i) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs(1);

	dst = 0;
	dfs(node);

	cout << (win[dst] ? "First" : "Second") << '\n';

	return 0;
}


Measured memory_bytes: 20736
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long N, long T) = Slice2<long>();
            var Ai = Sarray();
            var maxDiff = 0L;
            var min = Ai[0];
            for (var i = 1; i < N; ++i)
            {
                min = Min(min, Ai[i]);
                maxDiff = Max(maxDiff, Ai[i] - min);
            }
            var minNum = 1L;
            var maxNum = 0L;
            min = Ai[0];
            var ans = 0L;
            for (var i = 1; i < N; ++i)
            {
                if (Ai[i] < min)
                {
                    ans += Min(minNum, maxNum);
                    min = Ai[i];
                    minNum = 1;
                    maxNum = 0;
                }
                else if (Ai[i] == min)
                {
                    ++minNum;
                }
                else if (maxDiff == Ai[i] - min)
                    ++maxNum;
            }
            ans += Min(minNum, maxNum);
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 38436
import java.util.Scanner;
 
public class Main
{
    public static void main(String[] args)
    {
	Scanner cin = new Scanner(System.in);
	while(cin.hasNext())
	{
		long a = cin.nextInt();
		long b = cin.nextInt();
		
		long m = a;
		long n = b;
		long p = m;
		while(n != 0){p = n; n = m%n; m = p;}
		
		
		System.out.println(m+" "+a*b/m);
	}

    }
}

Measured memory_bytes: 11000
N, M = map(int, input().split())

if M % 2 == 0:
    m = (2 * M + 1) // 2 + 1
else:
    m = (2 * M + 1) // 2

i = 1
while i <= m // 2:
    print(i, m - i + 1)
    i += 1

j = 1
while j <= (2 * M + 1 - m) // 2:
    print(m + j, (2 * M + 1) - j + 1)
    j += 1


Measured memory_bytes: 9232
N = gets.chomp.to_i


k = 0
# 答え出力用の順序は持っておく
l = []

# 幅優先探索用
tree = Hash.new{ |h, k| h[k] = []}

# 答えを持つ
ans = Hash.new{ |h,k| h[k] = {} }


(N-1).times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  tree[a] << b
  l << [a, b]
  ans[a][b] = 1
end

# キュー
queue = []

# 訪れた頂点の記録 → 木が一方通行なのでいらない
# visited = Hash.new(false)
# visited[1] = true

queue << [1, 0]


until queue.empty?
  edge, point = queue.shift

  base_point = 1


  i = 0
  tree[edge].each do |e|
    i += 1 if base_point + i == point
    ans[edge][e] = base_point + i

    i += 1

    k =  i > k ? i : k

    queue << [e, ans[edge][e]]
  end
end

p k
l.each do |a, b|
  p ans[a][b]
end

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

int main() {
	uint32_t N;
	cin >> N;
	
	vector<vector<double>> dp(2, vector<double>(N+1, 1));	
	for(uint32_t i=1; i<=N; i++) {
		double p;
		cin >> p;
		
		bool ic = i&1;
		bool ip = !ic;
		
		dp[ic][0] = dp[ip][0] * (1 - p);
		//cout << setprecision(3) << dp[ic][0] << " ";
		
		for(uint32_t j=1; j<i; j++) {
			dp[ic][j] = dp[ip][j-1] * p + dp[ip][j] * (1 - p);
			//cout << setprecision(3) << dp[ic][j] << " ";
		}

		dp[ic][i] = dp[ip][i-1] * p;
		//cout << setprecision(3) << dp[ic][i] << endl;
	}

	// N is odd
	double ans = accumulate(dp[1].begin() + N/2 + 1, dp[1].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  string s;
  cin>>s;
  int a=0;
  for(int t=0;t<4;t++){
    if(s[t]=='+')a++;
    if(s[t]=='-')a--;
  }

  cout<<a<<endl;
  return 0;
}


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

typedef long long LL;
typedef unsigned long long LONG;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MAXINT = 2147483647;
const int mod = 1000000007;
const long long MAXLONG = 9223372036854775807;
using namespace std;
typedef pair<int, int> PII;
#define ft fisrt
#define sd second
#define eb emplace_back
#define END '\n'

template <class T>
inline bool Read(T &ret)
{
	char c;
	int sgn;
	if (static_cast<void>(c = getchar()), c == EOF)
		return 0;
	while (c != '-' && (c < '0' || c > '9'))
		c = getchar();
	sgn = (c == '-') ? -1 : 1;
	ret = (c == '-') ? 0 : (c - '0');
	while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
		ret = ret * 10 + (c - '0');
	ret *= sgn;
	return 1;
}

template <class T>
inline void Write(T x)
{
	if (x < 0)
		putchar('-'), Write(x);
	if (x > 9)
		Write(x / 10);
	putchar(x % 10 + '0');
}


vector<int>R,G,B;
int n;
string s;
int check(int i,int j){
	int l=0,num=0;
	int k=j+(j-i)+1;
	if((s[i]=='R'&&s[j]=='G')||(s[j]=='R'&&s[i]=='G')){
		i++;j++;
		num=B[n]-B[j];
		if(k<=n) num-=(B[k]-B[k-1]);
	}
	else if((s[i]=='R'&&s[j]=='B')||(s[j]=='R'&&s[i]=='B')){
		i++;j++;
		num=G[n]-G[j];
		if(k<=n) num-=(G[k]-G[k-1]);
	}
	else if((s[i]=='B'&&s[j]=='G')||(s[j]=='B'&&s[i]=='G')){
		i++;j++;
		num=R[n]-R[j];
		if(k<=n) num-=(R[k]-R[k-1]);
	}
	return num;
}
void solve(int question_num)
{
	while (question_num--)
	{
		cin>>n;
		cin>>s;
		R.resize(n+1);
		G.resize(n+1);
		B.resize(n+1);
		for(int i=0;i<n;++i){
			if(s[i]=='R') R[i+1]=R[i]+1;
			else R[i+1]=R[i];
			if(s[i]=='B') B[i+1]=B[i]+1;
			else B[i+1]=B[i];
			if(s[i]=='G') G[i+1]=G[i]+1;
			else G[i+1]=G[i];
		}
		// for(int i=1;i<=n;++i)
			// cout<<R[i]<<' '<<G[i]<<' '<<B[i]<<endl;
		LL ans=0;
		for(int i=0;i<n-2;++i){
			for(int j=i+1;j<n-1;++j){
				if(s[i]!=s[j]){
					ans+=check(i,j);
				}
			}
		}
		cout<<ans;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	// cin >> t;
	solve(t);
	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

//最小公倍数を返す関数.gcdが必要.
long long int lcm(long long int x, long long int y){
	return x / gcd(x, y) * y;
}

int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	cout << b - b / c - b / d + b / (lcm(c,d)) - (a - a / c - a / d + a / (lcm(c,d))) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;

int64_t powm(int64_t a,int64_t b){//a^bを求める
	if(b==0){
		return 1;
	}else{
		int64_t temp = powm(a,b/2);
		temp = temp * temp;
		if(b%2==1){
			temp = temp * a;
		}
		return temp;
	}
}

int main(){
	ll a,b;
	cin>>a>>b;
	cout<<max<ll>((max<ll>(a+b,a-b)),a*b)<<endl;


}


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n=int(input())
s=input()
i=0
leftcnt=0
rightcnt=0
for i in range(len(s)):
    if s[i]==")":
        if leftcnt==0:
            rightcnt+=1
        else:
            leftcnt-=1
    else:
        leftcnt+=1
print("("*rightcnt+s+")"*leftcnt)

Measured memory_bytes: 63980
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    int max_x, min_y;
    
    cin >> A >> B >> max_x >> min_y;
    for(int i = 0; i < A; i++){
        int x;
        cin >> x;
        max_x = max(max_x, x);
    }
    for(int i = 0; i < B; i++){
        int y;
        cin >> y;
        min_y = min(min_y, y);
    }
    
    if(max_x >= min_y)
        cout << "War" << endl;
    else
        cout << "No War" << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200005;
int n;
int v[N];
ll cs[N];
ll dpL[N][2];
ll dpR[N][2];
ll calcL(int i, bool r) {
	ll &ret = dpL[i][r];
	if (ret != -1)
		return ret;
	ret = cs[i];
	if (i) {
		if (v[i] % 2 && r)
			ret = min(ret, cs[i - 1] + 1);
		else
			ret = min(ret, cs[i - 1]);
	}
	if (!r)
		ret = min(ret, calcL(i, true));
	if (i) {
		if (v[i] == 0)
			ret = min(ret, 1 + r + calcL(i - 1, r));
		else if ((v[i] & 1) && r)
			ret = min(ret, 1 + calcL(i - 1, r));
		else if ((v[i] & 1) == 0 && !r)
			ret = min(ret, 1 + calcL(i - 1, r));
		else
			ret = min(ret, calcL(i - 1, r));
	}
	return ret;
}
ll calcR(int i, bool r) {
	ll &ret = dpR[i][r];
	if (ret != -1)
		return ret;
	ret = cs[n] - cs[i];
	if (!r)
		ret = min(ret, calcR(i, true));
	if (i != n) {
		if (v[i + 1] % 2 && r)
			ret = min(ret, cs[n] - cs[i + 1] + 1);
		else
			ret = min(ret, cs[n] - cs[i + 1]);
		if (v[i + 1] == 0)
			ret = min(ret, 1 + r + calcR(i + 1, r));
		else if ((v[i + 1] & 1) && r)
			ret = min(ret, 1 + calcR(i + 1, r));
		else if ((v[i + 1] & 1) == 0 && !r)
			ret = min(ret, 1 + calcR(i + 1, r));
		else
			ret = min(ret, calcR(i + 1, r));
	}
	return ret;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &v[i]);
		cs[i] = cs[i - 1] + v[i];
	}
	memset(dpL, -1, sizeof(dpL));
	memset(dpR, -1, sizeof(dpR));
	ll res = 1e18;
	for (int i = 0; i <= n; ++i) {
		res = min(res, calcL(i, true) + calcR(i, false));
		res = min(res, calcL(i, false) + calcR(i, true));
	}
	for (int i = 1; i <= n; ++i) {
		if (v[i] == 0)
			continue;
		res = min(res, calcL(i - 1, true) + calcR(i, false));
		res = min(res, calcL(i - 1, false) + calcR(i, true));
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 21376
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >>a;
    cin >>b;
    if(a==b)
        cout << "a == b";
    else if(a>b) 
        cout << "a > b";
    else cout << "a < b";
    cout <<endl;
    
}



Measured memory_bytes: 3084
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <sstream>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int x;
  cin >> x;

  int M = 200;
  for (ll a = -M; a<=M; ++a) {
    for (ll b = -M; b<=M; ++b) {
      ll val = a*a*a*a*a - b*b*b*b*b;
      if (val == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }


  return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a+b==c||b+c==a||c+a==b){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// Scanner 2
var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	for i := 1; i <= 5; i++ {
		n := nextInt()
		if n == 0 {
			fmt.Println(i)
		}
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(2e5) +5;

vector<ll> ar;
vector<ll> br;
vector<ll> cr;

int main()
{
    idfc;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll i;
    ll e;
    for(i=0;i<a;i++)
    {
        cin>>e;
        ar.pb(e);
    }

    for(i=0;i<b;i++)
    {
        cin>>e;
        br.pb(e);
    }

    for(i=0;i<c;i++)
    {
        cin>>e;
        cr.pb(e);
    }
    sort(ar.begin(),ar.end(),greater<>());
    sort(br.begin(),br.end(),greater<>());
    sort(cr.begin(),cr.end(),greater<>());
    ll sa=0;
    ll sb=0;
    for(i=0;i<x;i++)sa+=ar[i];
    for(i=0;i<y;i++)sb+=br[i];
    ll ans=sa+sb;
    ll p1=x-1;
    ll p2=y-1;
    ll aa=0;
    ll bb=0;
    for(i=0;i<c;i++)
    {
        aa=0;
        bb=0;
        if(p1>=0)
        {
            aa=max(0ll,cr[i]-ar[p1]);
        }
        if(p2>=0)
        {
            bb=max(0ll,cr[i]-br[p2]);
        }
        if(aa>=bb)
        {
            ans+=aa;
            p1--;
        }
        else{
            ans+=bb;
            p2--;
        }
    }
    cout<<ans;
}

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

int main() {
    int N;
    std::cin >> N;

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

    std::sort(A, A + N);
    std::printf("%d\n", A[N-1] - A[0]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int br1, br2, n[100+1], l[100+1];
int main(){
    int kn, m, x;
    cin >> kn >> m >> x;
    for(int i = 0; i < m; i++){
        cin >> n[i];
        l[n[i]] = 1;
    }
    for(int i = 0; x!= i; i++){
        br1 += l[i];
    }
    for(int i = kn; x!= i; i--){
        br2 += l[i];
    }
    cout << min(br1,br2);
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = b = 0
n_list = list(itertools.permutations(range(1, N + 1)))
n_list.sort()
for i, p in enumerate(n_list):
	if p == P:
		a = i
	if p == Q:
		b = i
print(abs(a-b))

Measured memory_bytes: 45296
#include<iostream>

using namespace std;

int main(void) {
	int n = 0;
	int a[100000];
	int b[100000];
	int t = 0;


	cin >> n;



	for (int i = 0;i < n;i++) {
		cin>> a[i] >> b[i];
}
	for (int i = 0;i < n;i++) {
		t += b[i] - a[i] + 1;

	}

	cout << t << endl;

}

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int kotae=0;
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      a[i+1]=151515;
      kotae++;
    }
  }
  cout<<kotae<<endl;
  return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    int count = 0;
    bool is_kisu = false;
    while(true) {
        for(auto &hoge : a) {
            if(hoge % 2 != 0) is_kisu = true;
            else hoge /= 2;
        }
        if(is_kisu) break;
        else count++;
    }
    cout << count << endl;
    return 0;
}


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

int main() {
   string s; cin >> s;
    int count = 0, c = 0;
    if(s[0]=='A'){
        for(int j = 2; j < s.size()-1; j++){
        if(s[j]=='C')
        c++;
        }
        for(int i = 0; i < s.size(); i++){
            if(islower(s[i]))
                count++;
            }
        }
    if (c==1&&count==s.size()-2){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

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

int main() {

  int n;
  cin >> n;
  string ans = "No";
  for (int i = 1; i < 10; i++) {
      
     for (int j = 1; j < 10; j++) {
      if (n - (i * j) == 0) {
        ans = "Yes";
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int m;
  cin >> m;
  cout << 48-m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m[22][22] = {}, i, j, k,h, o, l=0, z, sam = 0, p, q;
ll a[200005] = {} , inf = 1000000000000;
ll b[100005] = {};

string s[22];
ll t[100005], xx[100005];
char ss,st;
const int MAX =100005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	cin >>h;
	l=2;
	while (h > 1) {
		h = h / 2;
		l*=2;
	}


	cout << l-1;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int c,d;
  cin >>c;
  int n[81];
  string a,b;
  for(;c>0;c--){
    for(int i=0;i<81;i++) n[i] = 0;
    cin >>a>>b;
    for(int i=0;i<min((int)a.size(),80);i++)n[i] = (int)(a[a.size()-i-1]-'0');
    for(int i=0;i<min((int)b.size(),80);i++)n[i] += (int)(b[b.size()-i-1]-'0');
    for(int i=0;i<80;i++){
      if(n[i]>=10){
	n[i+1]+=n[i]/10;
	n[i]%=10;
      }
    }
    if (n[80]>0||a.size()>80||b.size()>80)
      cout << "overflow" << endl;
    else{
      d = 80;
      while(!n[d])d--;
      if (d<0)d=0;
      for(;d>=0;d--)
	cout << n[d];
      cout << endl;
      }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#define INF 1001
using namespace std;

int main()
{
    int m,n,a,b,c,d,x[2],y1,y2;
    int w[20][20],di[20],f[20];
    for (int i=0; i<20; i++)
    {
	for (int j=0; j<20; j++)
	{
	    w[i][j]=INF;
	}
    }
    scanf("%d\n%d",&n,&m);
    for (int i=0; i<m; i++)
    {
	scanf("%d,%d,%d,%d",&a,&b,&c,&d);
	w[a][b] = c;
	w[b][a] = d;
    }
    scanf("%d,%d,%d,%d",&x[0],&x[1],&y1,&y2);
    for (int i=0; i<2; i++)
    {
	for (int j=0; j<20; j++)
	{
	    di[j] = INF;
	    f[j] = 0;
	}
	di[x[i]] = 0;
	for (int j=0; j<20; j++)
	{
	    int min = INF;
	    int p;
	    for (int k=0; k<20; k++)
	    {
		if (f[k] == 0 && min > di[k])
		{
		    min = di[k];
		    p = k;
		}
	    }
	    f[p]=1;
	    for (int k=0; k<20; k++)
	    {
		di[k] = std::min(di[k],di[p]+w[p][k]);
	    }
	}
	y1-=di[x[1-i]];
    }
    cout << y1-y2 << endl;
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
struct node
{
	int to;
	node *nxt;
}edges[MAXN*2+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
int n,m,q,col[MAXN+5],maxd[MAXN+5];
int V[MAXN+5],D[MAXN+5],C[MAXN+5];
void Init()
{
	memset(maxd,-1,sizeof(maxd));
}
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=Adj[v];
	Adj[v]=q;
}
void DFS(int u,int d,int c)
{
	if(col[u]==0)
		col[u]=c;
	if(maxd[u]>=d)
		return;
	if(d==0)
		return;
	maxd[u]=d;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		DFS(v,d-1,c);
	}
}
int main()
{
//	freopen("splatter.in","r",stdin);
//	freopen("splatter.out","w",stdout);
	Init();
	scanf("%d %d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		AddEdge(u,v);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
		scanf("%d %d %d",&V[i],&D[i],&C[i]);
	for(int i=q;i>=1;i--)
		DFS(V[i],D[i],C[i]);
	for(int i=1;i<=n;i++)
		printf("%d\n",col[i]);
	return 0;
}

Measured memory_bytes: 6400