akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.parents[x] > self.parents[y]:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    @property
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    @property
    def group_count(self):
        return len(self.roots)

    @property
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots)

INF = inf
MOD = 1000000007

n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()]for j in range(m)]    # nは行数

tmp = 0
res = 0

uf = UnionFind(n)
for i in range(m):
    a = A[i][0] - 1
    b = A[i][1] - 1
    uf.union(a, b)
res = uf.group_count - 1

print(res)


Measured memory_bytes: 49752
def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def factorial(n, mod)
  fs = [1]
  (1..n).each{ |k| fs << (fs[-1] * k) % mod }
  fs
end

def inv_factorial(n, mod)
  fs = [1]
  f = 1
  (1..n).each{ |k|
    f = f * k % mod
    fs << powmod(f, mod-2, mod)
  }
  fs
end


Mod = 1000000007
N,*A = `dd`.split.map(&:to_i)
M = A.inject(:+) - N*(N+1)/2
i = A.index(M); j = A.rindex(M)
X = i; Y = j-i-1; Z = N - j
#p [i,j,N+1,X,Y,Z]
$fs =     factorial(N+1, 1000000007)
$is = inv_factorial(N+1, 1000000007)

def comb(n,k)
  return 0 if n < k
  return 0 if k < 0
  $fs[n] * $is[n-k] % Mod * $is[k] % Mod
end

(1..N+1).each{ |k|
  p (comb(N+1,k) - comb(X+Z, k-1) + Mod) % Mod
}



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

int main() {
  string C;
  cin >> C;
  
  if( C == "a" || C == "i" || C == "u" || C == "e" || C == "o" ){
    cout << "vowel";
  }
  
 
   else{
    cout << "consonant";
  }
  
}

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

int main(){
  int K;
  string S;
  cin >>K>>S;
  if((int)S.size()<=K) {
    cout << S;
    return 0;
  }
  if((int)S.size() > K) {
    for(int i=0;i<K;++i) {
      cout << S[i];
    }
    cout << "...";
  }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define debug(x) (cout << "#x = " << (x) << '\n')

using namespace std;
typedef long long ll;

inline char gc() {
	static char buf[100000], *p1 = buf, *p2 = buf;
	return (p1 == p2) && (p2 = (p1 = buf) +
		fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
}

#define dd ch = getchar()
template <class T>
inline void read(T &x) {
	x = 0;
	int f = 0; char dd;
	for (; !isdigit(ch); dd) f ^= (ch == '-');
	for (; isdigit(ch); dd)  x = (x << 1) + (x << 3) + (ch ^ 48);
	x = f? -x: x;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 | 48);
}

template <class T>
inline void wrn(T x) {
	write(x), putchar(' ');
}

template <class T>
inline void wln(T x) {
	write(x), putchar('\n');
}

template <class T>
inline void wlnn(T x, T y) {
	wrn(x), wln(y);
}

const int N = 1e5 + 5;

int d;
char s[N];

int main()
{
	cin >> s + 1;
	int n = strlen(s + 1);
    if (n == 0) return puts("Yes"), 0;
    if (n & 1) return puts("No"), 0;
    for (int i = 1; i <= n; ++i) {
        d ^= 1;
        if (d && s[i] != 'h') return puts("No"), 0;
        if (!d && s[i] != 'i') return puts("No"), 0;
    }
	return puts("Yes"), 0;
}

/*

*/




Measured memory_bytes: 256
def action_handler(array, count)
  result = false
  current_nums = [0, 0, 0]
  time_index = 0
  x_index = 1
  y_index = 2
  for i in 0..(count - 1)
    is_first = i == 0
    is_last = i == (count - 1)
    if !is_last || (is_first && is_last)
      now_array = is_first ? current_nums : array[i]
      next_array = is_first ? array[i] : array[i + 1]
      dt = next_array[time_index] - now_array[time_index]
      dx = next_array[x_index] - now_array[x_index]
      dy = next_array[y_index] - now_array[y_index]
      #時間内に移動できるかの計算
      dxy = dx.abs + dy.abs
      if dxy <= dt
        new_dxy = dx + dy
        if dt.even? != new_dxy.even?
          return false
        else
          result = true
        end
      else
        return false
      end
    end
  end
  return result
end
=begin
def variable_finder(sec, coordinates)
  a = [coordinates[0] + 1, coordinates[1]]
  b = [coordinates[0] - 1, coordinates[1]]
  c = [coordinates[0], coordinates[1] + 1]
  d = [coordinates[0], coordinates[1] - 1]
  all_cases = [a, b, c, d]
  for x_i in 0..sec
    y_i = sec - x_i
    tmp = [coordinates[0] + x_i, coordinates[1] + y_i]
    tmp2 = [coordinates[0] - x_i, coordinates[1] + y_i]
    tmp3 = [coordinates[0] + x_i, coordinates[1] - y_i]
    tmp4 = [coordinates[0] - x_i, coordinates[1] - y_i]
    all_cases.push(tmp)
    all_cases.push(tmp2)
    all_cases.push(tmp3)
    all_cases.push(tmp4)
  end
  return all_cases.uniq
end
=end

#複数行に複数の要素が存在するとき
input = gets.chop.to_i
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

#p action_handler([[3, 1, 2], [6, 1, 1]], 2) => true
print action_handler(lines, input) ? 'Yes' : 'No'


Measured memory_bytes: 10876
n = int(input())
init = [int(s) for s in input().split()]

a = {}
init_sum = sum(init)

for i in init:
    if i not in a:
        a[i] = 1
    else:
        a[i] += 1

q = int(input())

ans = init_sum
for _ in range(q):
    (b, c) = [int(s) for s in input().split()]

    if b not in a:
        a[b] = 0

    ans -= (b * a[b])

    if c not in a:
        a[c] = a[b]
    else:
        a[c] += a[b]

    ans += (c * a[b])

    a[b] = 0

    print(ans)


Measured memory_bytes: 23144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 2005;

int n, k;
LL f[N][N], fac[N*N], inv[N*N];

LL Ksm(LL a, LL b) {
	LL res = 1;
	while(b) {
		if(b&1) res = res*a%mod;
		b /= 2;
		a = a*a%mod;
	}
	return res;
}

void Init() {
	fac[0] = inv[0] = 1;
	rep(i, 1, n*k)
	   fac[i] = fac[i - 1]*i%mod, inv[i] = Ksm(fac[i], mod - 2);
}

LL Cal(int n, int k) {
	return fac[n]*inv[k]%mod*inv[n - k]%mod;
}

int main() {
	cin>>n>>k;
	if(k == 1) {
		cout<<1<<endl;
		return 0;
	}
	Init();
	f[0][0] = 1;
	rep(i, 1, n)
	    rep(j, 0, i) {
	    	if(j < i) f[i][j] += f[i - 1][j];
	    	if(j) f[i][j] += f[i][j - 1]*(n - j + 1)%mod*Cal(n*k - j*k - i + j + k - 2, k - 2)%mod;
	    	f[i][j] %= mod;
	    }
	cout<<f[n][n]<<endl;
}

Measured memory_bytes: 88592
s = input()
n = len(s)
white_start = 0
black_start = 0
for i in range(n):
    if s[i] == '0' and i%2 == 0:
        black_start += 1
    elif s[i] == '0' and i%2 == 1:
        white_start += 1
    elif s[i] == '1' and i%2 == 0:
        white_start += 1
    else:
        black_start += 1
print(min(black_start,white_start))

Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
 
int main(){
  string N;
  cin>>N;
  int sum=0;
  for(int i=0;i<N.size();i++){
      sum+=N[i]-'0';
  }
  if(sum%9==0) puts("Yes");
  else puts("No");
    return 0; 
}

Measured memory_bytes: 3344
import math

def factors(n):
    l = int(math.sqrt(n)) + 1
    ret = {}
    nf2 = 0
    while n % 2 == 0:
        nf2 += 1
        n //= 2
    if nf2 != 0:
        ret[2] = nf2
    nf3 = 0
    while n % 3 == 0:
        nf3 += 1
        n //= 3
    if nf3 != 0:
        ret[3] = nf3
    # n = append_factors(n, ret, 2)
    # n = append_factors(n, ret, 3)
    i = 6
    while i*i <= n + 1:
        p1, p2 = i - 1, i + 1
        nfp1 = 0
        while n % p1 == 0:
            nfp1 += 1
            n //= p1
        if nfp1 != 0:
            ret[p1] = nfp1
        nfp2 = 0
        while n % p2 == 0:
            nfp2 += 1
            n //= p2
        if nfp2 != 0:
            ret[p2] = nfp2
        # n = append_factors(n, ret, i - 1)
        # n = append_factors(n, ret, i + 1)
        i += 6
    if n != 1:
        ret[n] = 1

    return ret

def minimum_sum(x):
    # find the minimum integer n where n(n+1)/2 <= x
    # n^2 < n(n+1) <= 2x < (n+1)(n+2) < (n+2)^2

    n = int(math.sqrt(x))
    while (n + 1)*(n + 2) <= 2*x:
        n += 1

    return n

def main():
    N = int(input())
    fs = factors(N)
    # print(fs)
    ans = 0
    for f in fs:
        ans += minimum_sum(fs[f])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    int a,i;
    string b;
    map<string,int> mp;
    scanf("%d\n",&a);
    for(i=0;i<a;i++){        
        cin>>b;
        auto itr = mp.find(b);
        if(itr == mp.end()){
            mp[b] = 1;
        }
        else{
            mp[b]++;
        }
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    //    std::cout << "key = " << itr->first           // キーを表示
      //                  << ", val = " << itr->second << "\n";    // 値を表示
    }
    map<int,vector<string>> mp2;
    int maxv = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        mp2[itr->second].push_back(itr->first);
        maxv = max(maxv,itr->second);
    };
    //cout<<maxv<<endl;
    for(auto itr = mp2.begin(); itr != mp2.end(); ++itr) {
        //std::cout << "key = " << itr->first;
        if(maxv == itr->first){
            int n = itr->second.size();
            sort(itr->second.begin(),itr->second.end());
            for(int i=0;i<n;i++){
                cout<<itr->second[i]<<endl;
            };
        }
    }    // 値を表示    
}

Measured memory_bytes: 26868
def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 61884
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[1010][10];

ll f[20];
ll calc(int x){
	if(x>=0)return f[x];
	else return 1;
}
int main(){
	f[0]=1,f[1]=1;
	rep(i,10)f[i+2]=f[i+1]+f[i];
	int n,m,w;
	cin>>n>>m>>w;
	dp[0][0]=1;
	rep(i,n)rep(j,m){
		dp[i+1][j]=dp[i][j]*f[j]*f[m-j-1]%mod;
		if(j>0)dp[i+1][j]+=dp[i][j-1]*f[j-1]*f[m-j-1]%mod;
		if(j<m-1)dp[i+1][j]+=dp[i][j+1]*f[j]*f[m-j-2]%mod;
		dp[i+1][j]%=mod;
	}
	cout<<dp[n][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    int temp = 0;

    rep(i, 1000, 1) {
        temp = i * k;
        if (temp >= a && temp <= b) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int m,n;
    in(m,n);
    vector<vector<int>> mat(m,vector<int>(n));
    rep(y,m){
        rep(x,n){
            in(mat[y][x]);
        }
    }
    vector<int> vec(n);
    in(vec);
    rep(i,m){
        int ans=0;
        rep(j,n){
            ans+=vec[j]*mat[i][j];
        }
        out(ans);
    }
}


Measured memory_bytes: 3292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		HashSet<Character> cset = new HashSet<Character>();
		for (char c : str.toCharArray()) {
			if (cset.contains(c)) {
				System.out.println("no");
				return;
			}
			cset.add(c);
		}
		System.out.println("yes");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    REP(i, h) cin >> a[i];
    map<int, bool> mp1, mp2;
    REP(i, h){
        bool flag = true;
        REP(j, w) if(a[i][j] == '#') flag = false;
        if(flag) mp1[i] = true;
    }
    REP(j, w){
        bool flag = true;
        REP(i, h) if(a[i][j] == '#') flag = false;
        if(flag) mp2[j] = true;
    }

    REP(i, h){
        REP(j, w){
            if(!mp1[i] && !mp2[j]) cout << a[i][j];
        }
        if(!mp1[i])cout << endl;
    }
}


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

int main(){
    ld a;
    scanf("%Lf",&a);
    ld b;
    scanf("%Lf",&b);
    ld x;
    scanf("%Lf",&x);

    x /= a;
    auto isNotSpill = [&](ld angle) {
		       if (angle < atan2(b, a)) {
			   return x < (a*b) - (a*a*tan(angle)/2);
                       } else {
			   return x < b*b * (1/tan(angle)) / 2;
                       }
		   };
    ld l = 0;
    ld r = 90;
    while (abs(l - r) > 1e-6) {
	ld m = (l+r)/2;
        if (isNotSpill(m * M_PI / 180)) {
	    l = m;
        } else {
	    r = m;
        }
    }
    cout << fixed << setprecision(12) << l << endl;
}


Measured memory_bytes: 384
#include <iostream>
 
int main(){
    int N;
    long long a[210000], res=0;
    std::cin >> N;
    for(int i=0;i<N;i++){
        std::cin >> a[i];
    }
 
    long long bucket[210000] = {0};
    for(int i=0;i<N;i++){
        bucket[a[i]]++;
    }
    
    for(int i=0;i<210000;i++){
        if(bucket[i]>=2){
            res += bucket[i]*(bucket[i]-1)/2;
        }
    }
 
    for(int k=0;k<N;k++){
        bucket[a[k]]--;
        std::cout << res-bucket[a[k]] << std::endl;
        bucket[a[k]]++;
    }
    return 0;
}

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

using namespace std;

const double pi = 4*atan(1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.setf(ios_base::fixed);
	cout.precision(8);
	double a, b, c;
	cin>>a>>b>>c;
	c*=pi/180;
	cout<<0.5*a*b*sin(c)<<'\n';
	cout<<a+b+sqrt(a*a+b*b-2*a*b*cos(c))<<'\n';
	cout<<b*sin(c)<<'\n';
	return 0;
}




Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
int main(void){
  
  string n;
  cin>>n;
  
  if(n[0] == '7'){
    cout<<"Yes"<<endl;
  }else if(n[1]=='7'){
    cout<<"Yes"<<endl;
  }else if(n[2]=='7'){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}



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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ll n; cin >> n;
	rep(i, n) {
		vector<ll> v(3);
		rep(i, 3) cin >> v[i];
		sort(all(v));
		if (pow(v[0], 2) + pow(v[1], 2) == pow(v[2], 2)) {
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;




int main() {
	int N;
	cin >> N;
	int ans = 1;
	for (int i = 0; i < 3; i++) {
		ans *= N;
	}

	cout << ans << endl;

	
	




	
	


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
const int INF = 1e18;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int n;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];

    int sum = 0;
    rep(i, n) sum += s[i];

    vector<vector<bool>> dp(n + 1, vector<bool>(10010, false));

    rep(i, n + 1) dp[i][0] = true;

    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 0; j < 10010; j++)
        {
            if (dp[i - 1][j])
            {
                dp[i][j] = true;
                if (j + s[i - 1] < 10010)
                    dp[i][j + s[i - 1]] = true;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 10010; i++)
    {
        if (dp[n][i])
        {
            ans = max(ans, (i % 10) ? i : 0);
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    long ans = 0;
    rep(i, a+1) rep(j, b+1) rep(k, c+1) {
        if (500*i + 100*j + 50*k == x) ans++; 
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i) >> b.at(i);
    }

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    int res = 0;
    int i = 0;
    while (i < N && a.at(0) < b.at(i))
    {
        int bi = b.at(i);
        i++;

        H -= bi;
        res++;
        if (H <= 0)
        {
            cout << res << endl;
            return 0;
        }
    }

    int a0 = a.at(0);
    res += (H + a0 - 1) / a0;
    cout << res << endl;
}

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

int main() {
    ll x;
    cin>>x;
    ll money = 100;
    ll ans = 0;
    for(;;){
        ans++;
        money*=1.01;
        if(money>=x){
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
N = int(input())
S = [input() for i in range(N)]

S_first = [S[i][0] for i in range(N)]
march = ['M','A','R','C','H']
march_number = [0]*5

for i in range(5):
    march_number[i] = S_first.count(march[i])

import itertools
ans = 0
for v in itertools.combinations(march_number,3):
    ans += v[0]*v[1]*v[2]
print(ans)

Measured memory_bytes: 10648
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    long long int n, k, ans = 1;
    std::cin >> n >> k;
    for(int i = 0;i < n;i++){
        if(ans > k){
            ans += k;
        }
        else{
            ans += ans;
        }
    }
    std::cout << ans;

    return 0;
}

Measured memory_bytes: 256
import sys

global status, d
status = {}
d=0

def bfs(keys, GRAPH, depth=0):
    global status
    if depth>10: quit

    buf =[]
    for e in keys:
        if status[e]==-1:
            status[e]=depth
            for e2 in GRAPH[e]:
                try:
                    if status[e2] == -1:
                        buf.append(e2)
                except:
                    pass
    if buf !=[]:
        bfs(buf, GRAPH, depth+1)
    return

n = int(raw_input())
x = {}
for i in range(n):
    seq = map(int,raw_input().split())
    key = seq[0]
    if key != 0:
        x[key] = seq[2:]
    else:
        x[key]=[]
    status[key] = -1

for e in x.keys():
    if e == 1:
        bfs([e], x)

for e in x.keys():
    print e, status[e]

Measured memory_bytes: 4276
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int a[1100];
int main() {
  int n, m;
  while (scanf("%d %d", &n, &m), n|m) {
    REP(i, n) {
      scanf("%d", &a[i]);
    }
    int prev = m + 1;
    int target = -1;
    int targetCnt = 0;
    REP(i, n) {
      int sum = 0;
      while (sum  + a[i] <= m) {
        sum += a[i];
      }
      if (sum > prev) { continue; }
      else if (sum < prev) {
        prev = sum;
        target = i;
        targetCnt = 1;
      } else if (sum == prev) {
        if (a[i] > a[target]) { continue; }
        else if (a[i] < a[target]) {
          prev = sum;
          target = i;
          targetCnt = 1;
        } else {
          targetCnt++;
        }
      }
    }
    if (targetCnt >= 2) {
      printf("%d\n", n);
    } else {
      printf("%d\n", target + 1);
    }
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>

static const int VERTEX_MAX = 100000;
static const int INF = 1 << 29;

using namespace std;


vector<int>		Graph[VERTEX_MAX];		//各頂点から他の頂点への出辺
int				Indegree[VERTEX_MAX];	//各頂点の入次数
bool			Used[VERTEX_MAX];		//各頂点のソート済みフラグ

int				num_vertex;
int				num_edge;
vector<int>		sorted_vertices;		//トポロジカルソートされた頂点


void breadth_first_search(int vertex) {
	queue<int> queue;
	queue.push(vertex);
	Used[vertex] = true;

	while (!queue.empty()) {
		int front_v = queue.front();
		queue.pop();
		
		//ここに来る頂点は入次数が0なのでソートされた行列にpushbackできる
		sorted_vertices.push_back(front_v);

		for (int i = 0; i < Graph[front_v].size(); i++) {
			int next_v = Graph[front_v][i];
			Indegree[next_v]--;		//front_vからの入辺がなくなるので入次数を一つ減らす

			if (Indegree[next_v] == 0 && !Used[next_v]) {
				Used[next_v] = true;
				queue.push(next_v);
			}
		}
	}
}



void topological_sort() {
	//入次数初期化
	for (int v_i = 0; v_i < num_vertex; v_i++) {
		Indegree[v_i] = 0;
	}
	//入力条件から入次数を入力
	for (int v_i = 0; v_i < num_vertex; v_i++) {
		for (int i = 0; i < Graph[v_i].size(); i++) {
			int v = Graph[v_i][i];
			Indegree[v]++;
		}
	}
	
	for (int v_i = 0; v_i < num_vertex; v_i++) {
		if (Indegree[v_i] == 0 && !Used[v_i]) {//源点か、現時点で入次数が0で未使用の頂点に対して幅優先探索
			breadth_first_search(v_i);
		}
	}
	return;
}


int main() {
	cin >> num_vertex >> num_edge;

	for (int i = 0; i < num_vertex; i++) {
		Used[i] = false;
	}

	int s, t;
	for (int i = 0; i < num_edge; i++) {
		cin >> s >> t;
		Graph[s].push_back(t);
	}

	topological_sort();	

	for (vector<int>::iterator it = sorted_vertices.begin(); it != sorted_vertices.end(); ++it) {
		cout << *it << endl;
	}
	return 0;	
}


Measured memory_bytes: 6036
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
string a;
int b[26];
int main(){
  cin >> a;
  int len=a.length();
  for(int i=0;i<len;i++){
    b[a[i]-'a']++;
  }
  long long int ans=1;
  for(int i=0;i<len;i++){
    ans+=(len-(i+1)-(b[a[i]-'a']-1));
    b[a[i]-'a']--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            int non = 0;
            int two = 0;
            int four = 0;
            for(var i=0;i<N;i++){
                if(a[i]%4==0)four++;
                else if(a[i]%2==0)two++;
                else non++;
            }
            if(four-non>=0&&two>0){
                Console.WriteLine("Yes");
                return;
            }
            if(two==0&&four-non>=-1){
                Console.WriteLine("Yes");
                return;
            }
            Console.WriteLine("No");
        
        
        }
    } 
}

Measured memory_bytes: 20832
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
//using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX
 
 
 
 
void solve()
{
    int n;
    cin >> n;
    int arr[n];
    inp(arr, n);
    int ans = 0;
    rep(i,0,n-1)
    {
        ans += ((arr[i]%2==1)&(i%2==0));
    }

    cout << ans << endl;
}
 
 
signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 3648
from sys import stdin, stdout


def solve(mw, iw, iv):
    vs = sum(iv)
    A = [[float('inf') for i in range(vs+1)] for i in range(len(iv) + 1)]        
    A[0][0] = 0
    rs = 0
    for i in range(1, len(iv) + 1):
        rs += iv[i-1]
        for j in range(vs + 1):
            if i > rs: break
            if j < iv[i-1]: A[i][j] = A[i-1][j]
            else: A[i][j] = min(A[i-1][j], A[i-1][j-iv[i-1]] + iw[i-1])
    ans = 0
    for i in range(len(A[0])-1, -1, -1):
        if A[-1][i] != float('inf') and A[-1][i] <= mw:
            return i

# def test():
#     f = open('a.txt', 'r')
#     t = int(f.readline())
#     count, error = 1, 0
#     for _ in range(t):
#         try:
#             n, mw = f.readline().split()
#             iw, iv = [], []
#             for _ in range(int(n)):
#                 w, v = f.readline().split()
#                 iw.append(int(w))
#                 iv.append(int(v))
#             ans = int(f.readline())
#             output = solve(int(mw), iw, iv)
#             if ans != output:
#                 error += 1 
#                 stdout.write(f"Case #:{count} (WA) | Ans: {ans} Output: {output}\n")
#             else:
#                 stdout.write(f"Case #:{count} Pass\n")
#         except RuntimeError:
#             error += 1
#             stdout.write(f"Case #{count} (RE)")
#         count += 1
#     if error == 0: stdout.write("All test cases passed")
#     else: stdout.write(f"Passed: {count-error-1} | Errors: {error}")

def main():
    iw, iv = [], []
    n, mw = [int(i) for i in stdin.readline().split()]
    for _ in range(n):
        w,v = [int(i) for i in stdin.readline().split()]
        iw.append(w)
        iv.append(v)
    print(solve(mw, iw, iv))

main()
# test()



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

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

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> cnt(1000005, 0);

  for (ll x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i <= 1000005; i += x) cnt[i]++;
  }
  for (ll x : a)
    if (cnt[x] == 1) ans++;

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


Measured memory_bytes: 12776
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int N;
set<int> A[55];
set<int> possibleB[55][55];

bool is_possible(int max_mod) {
  REP(i,N) {
    bool ok = false;
    for (int v: A[i]) if (possibleB[i][max_mod].find(v) != possibleB[i][max_mod].end()) {
      ok = true;
    }
    if (!ok) return false;
  }
  return true;
}

int main() {
  // ios_base::sync_with_stdio(0);

  scanf("%d", &N);
  REP(i,N) {
    int a;
    scanf("%d", &a);
    A[i].insert(a);
  }
  REP(i,N) {
    int b;
    scanf("%d", &b);
    possibleB[i][0].insert(b);

    FOR(j,1,55) {
      for (int v: possibleB[i][j-1]) {
        possibleB[i][j].insert(v);
        if (v < j)
          for (int k = j + v; k < 55; k += j)
            possibleB[i][j].insert(k);
      }
    }
  }

  if (!is_possible(51)) {
    printf("-1\n");
    return 0;
  }

  LL result = 0;
  FORD(i,51,1) {
    if (!is_possible(i-1)) {
      result += 1LL<<i;
      REP(j,N) {
        set<int> tmp = A[j];
        for (int k: tmp) A[j].insert(k%i);
      }
    }
  }
  printf("%lld\n", result);
}


Measured memory_bytes: 7424
#include <iostream>
using namespace std;
int memo[50];
int fib(int n)
{
	if(n == 0 || n == 1)	
		memo[n] = 1;
	
	if(memo[n] != 0)
	{
		return memo[n];
	}
	else 
	{
		memo[n] = fib(n - 1) + fib(n - 2);
		return memo[n];
	}
}

int main()
{
	int n;
	cin >> n;
	
	cout << fib(n) << endl;
	
	return 0;
}


Measured memory_bytes: 3096
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class CmbMod:
    def __init__(self, n, p):
        """
        二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める
        """
        self.n = n
        self.p = p
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]

    def cmb_mod(self, n, r):
        """
        二項係数nCr(mod p)をO(r)にて計算。nが大きいがrは小さい時に使用。
        """
        numer, denom = 1, 1
        for i in range(r):
            numer = (numer * (n - i)) % self.p
            denom = (denom * (i + 1)) % self.p
        return (numer * pow(denom, self.p - 2, self.p)) % self.p

    def prep(self):
        """
        二項係数nCr(mod p)をO(1)で求める為の前処理をO(N)にて実行。
        """
        for i in range(2, self.n + 1):
            self.fact.append((self.fact[-1] * i) % self.p)
            self.inv.append((-self.inv[self.p % i] * (self.p // i)) % self.p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % self.p)

    def cmb_mod_with_prep(self, n, r):
        """
        二項係数nCr(mod p)をO(1)で求める。事前にprepを実行する事。
        """
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.p


def resolve():
    s = int(input())
    n = s // 3

    cmb = CmbMod(s, mod)
    cmb.prep()
    res = 0
    for i in range(1, n + 1):
        diff = s - i * 3
        t = cmb.cmb_mod_with_prep(diff + i - 1, diff)
        res += t
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9424
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a.back() - a.front() << endl;
}

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

ll mod=1e9+7;
ll add(ll a,ll b){return (a+b)%mod;}
ll mul(ll a,ll b){return (a*b)%mod;}

ll pow(ll a,ll b){
  if(b==0)return 1;
  else if(b%2==0)return pow(a*a%mod,b/2);
  else return pow(a*a%mod,b/2)*a%mod;
}



#define MAX 100005
int pa[MAX];
int ra[MAX];
void init(){
  for(int i=0;i<MAX;i++){
    pa[i]=i;
    ra[i]=0;
  }
}

int find(int x){
  if(pa[x]==x)return x;
  else return pa[x]=find(pa[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(ra[x]<ra[y])swap(x,y);
  pa[y]=x;
  if(ra[x]==ra[y])ra[x]++;
}

bool same(int x,int y){
  return (find(x)==find(y));
}

int n,m,a,b;

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    init();
    for(int i=0;i<m;i++){
      scanf("%d %d",&a,&b);
      unite(a,b);
    }
    ll cnt=0;
    for(int i=1;i<=n;i++)
      if(find(i)==i)
        cnt++;
    
    cout<<add(pow(2LL,cnt),(cnt==n?0:1))<<endl;
  }
  return 0;
}

Measured memory_bytes: 2020
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = explode(" ", trim(fgets(STDIN)));

  $gya = 0;
  for ($i=0; $i<$n; $i++) {
    $gya += 1 / $a[$i];
  }

  echo 1 / $gya;

Measured memory_bytes: 4604
#include<iostream>
#include<math.h>

using namespace std;

int main(){
	int i,d,s;
	while(cin>>d){
		s=0;
		for(i=0;i<600;i+=d){
			s+=d*i*i;
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

bool is_add_valid(int now, int new_data) {
    rep(i, 21) {
        int mask = (0x01 << i);
        if (((now & mask) != 0)  && ((new_data & mask) != 0)) {
            return false;
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) {
        cin >> A[i];
    }
    int L = 0, R = 0;
    ll count = 0;
    ll now;
    now = 0;
    while (1) {
        while (R < N && is_add_valid(now, A[R]) == true) {
            now += A[R];
            R++;
            
            if (R >= N || is_add_valid(now, A[R]) == false) {
                //count += R - L;//(R - L) * (R - L + 1) / 2;
                break;
            }
        }
        count += R - L;
        now -= A[L];
        L++;
        if (L >= N) {
            break;
        }

    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    long long int sum=0;
    int arr[a],brr[b],crr[c+x+y];
    for(int i=0;i<a;i++)
    {
        cin>>arr[i];
        //cout<<arr[i]<<" ";
    }
    //cout<<"--a---\n";
    for(int i=0;i<b;i++)
    {
        cin>>brr[i];
        //cout<<brr[i]<<" ";
    }
    //cout<<"--b---\n";
    sort(arr,arr+a,greater<int>());
    sort(brr,brr+b,greater<int>());
    for(int i=0;i<c;i++)
    {
        cin>>crr[i];
        //cout<<crr[i]<<" ";
    }
   
    for(int i=c;i<c+x;i++)
    {
        crr[i]=arr[i-c];
        // cout<<crr[i]<<" ";
    }
    for(int i=c+x;i<c+x+y;i++)
    {
        crr[i]=brr[i-c-x];
         //cout<<crr[i]<<" ";
    }
    //cout<<"-----c-------\n";
    sort(crr,crr+c+x+y,greater<int>());
    for(int i=0;i<x+y;i++)
    {
        sum+=crr[i];
       // cout<<crr[i]<<" ";
    }
    
    cout<<sum;
}

Measured memory_bytes: 2176
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [N, X, M] = lines[0].split(' ').map(Number)

let a = X
const map = {}
const loop = []
const pre = [a]
for (let i = 1; i < N; i++) {
    a = a * a % M
    if (map[a] === 2){
        break
    } else if (map[a]) {
        loop.push(a)
        pre.pop()
    } else {
        pre.push(a)
    }
    map[a] = (map[a] || 0) + 1
}

const suf = []
for (let i = 0; i < (N - pre.length) % (loop.length || 1); i++) {
    suf.push(loop[i])
}

const sum = loop.reduce((a, b) => a + b, 0)
const lt = loop.length ? Math.floor(((N - pre.length) / loop.length)) : 0

console.log(
    pre.reduce((a, b) => a + b, 0) +
    sum * lt +
    suf.reduce((a, b) => a + b, 0)
)


Measured memory_bytes: 40416
def check(table, n)
  if n == 2
    table.find {|x| x == 2}
  else
    (1..7).each do |i|
      if table[i] > 0 and table[i + 1] > 0 and table[i + 2] > 0
        tmp = table.dup
        3.times {|j| tmp[i + j] -= 1}
        return true if check(tmp, n - 3)
      end
    end
    (1..9).each do |i|
      if table[i] >= 3
        table[i] -= 3
        return true if check(table, n - 3)
        table[i] += 3
      end
    end
    false
  end
end

$<.readlines.map(&:chomp).map {|n| n.chars.map(&:to_i)}.each do |data|
  table = Array.new(10, 0)
  data.each {|i| table[i] += 1}
  result = (1..9).map do |i|
    added = table.dup
    added[i] += 1
    next if added[i] > 4
    check(added, 14) ? i : nil
  end.compact
  puts result.empty? ? 0 : result.join(" ")
end


Measured memory_bytes: 7132
#include<bits/stdc++.h>
using namespace std;
double t,c,v;
int main()
{
	cin>>t;
	c=t*1.0/3;
	v=c*1.0*c*1.0*c;
	cout.setf(ios::fixed);  
	cout<<fixed<<setprecision(12)<<v/*<<endl<<fixed<<setprecision(12)<<c<<endl*/; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll a[200][200];
	ll max = 0;
	for (ll i = 0; i < 2; i++) {
		for (ll j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	for (ll i = 0; i < N; i++) {
      	ll x=0;
		for (ll j = 0; j <= i; j++)x += a[0][j];
		for (ll j = i; j < N; j++)x  +=  a[1][j];
		if(x>max)max=x;
	}
	cout << max << endl;
}

	








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

using int64 = long long;

int main() {
  int64 n, m;
  cin >> n >> m;

  int64 r = 1;
  const int sq = sqrt(m + 0.1);
  for (int64 k = 1; k <= sq; ++k) {
    if (m % k)
      continue;
    if (k >= n)
      r = max(r, m / k);
    else if (m / k >= n)
      r = max(r, k);
  }
  cout << r << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *args[])
{
	int a,b=0;
	int m,n=0;

	scanf("%d %d", &a,&b);

	m = a * b;
	n = (a + b) * 2;

	printf("%d %d\n", m,n);

	return 0;
}

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

int main(){
  int a=0, b=0, c=0, d=0;
  int l=0, r=0;
  cin >> a >> b >> c >> d;
  l=a+b;
  r=c+d;
  if(l < r){
    cout << "Right" << endl;
  }else if(l==r){
    cout << "Balanced" << endl;
  }else{
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n,a[100005];
	cin>>n;
	for (int i=0;i<n;i++) {
		int t;
		cin>>t;
		a[t-1]=i+1;
	}
	for (int i=0;i<n;i++) {
		cout<<a[i]<<' ';
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,p;
string s;
map<int,int> mp;  //存余数和对应的个数 
ll ans=0;
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("input.txt","r",stdin);
	cin>>n>>p>>s;
	if(p==2 or p==5)
	{
		int pt=p;
		for(int i=0;i<n;i++)
			if((s[i]-'0')%pt==0) ans+=i+1;
	}
	else
	{
		mp[0]++;
		int num=0;
		int m=1;
		for(int i=n-1;~i;i--)
		{
			num=(num+(s[i]-'0')*m)%p;
			ans+=mp[num];
			mp[num]++;
			m=(m*10)%p;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 916
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[] dx = {1,0,-1,0};
		int[] dy = {0,1,0,-1};
		int max = 0;

		String[][] maze = new String[h][w];
		for(int i = 0; i < h; i++) {
			maze[i] = sc.next().split("");
		}

		for (int sx = 0; sx < h; sx++) {
			for (int sy = 0; sy < w; sy++) {
				/*for (int gx = 0; gx < h; gx++) {
					for (int gy = 0; gy < w; gy++) {*/
						int[][] d = new int[h][w];
						//if(sx == gx && sy == gy) break;
						//if(maze[gx][gy].equals("#") || maze[sx][sy].equals("#")) break;
						if(maze[sx][sy].equals("#")) continue;
						for(int i = 0; i < h; i++) {
							for(int j = 0; j < w; j++ ) {
								d[i][j] = 1000;
							}
						}
						d[sx][sy] = 0;
						point point = new point(sx, sy);
						Queue<point> que = new ArrayDeque<point>();
						que.add(point);
						while(0 != que.size()) {
							point p = que.poll();
							//if(p.x == gx && p.y == gy) break;
							for(int i = 0; i < 4; i++) {
								int cx = p.x + dx[i];
								int cy = p.y + dy[i];
								if(cx >= 0 && cx <= h-1 && cy >= 0 && cy <= w-1 && !maze[cx][cy].equals("#")  && d[cx][cy] == 1000) {
									d[cx][cy] = d[p.x][p.y] + 1;
									que.add(new point(cx, cy));
								}
							}
						}
						for (int i = 0; i < h; i++) {
							for (int j = 0; j < w; j++) {
								if(d[i][j] < 1000) max = Math.max(max, d[i][j]);
							}
						}
						//max = Math.max(max, d[gx][gy]);
					/*}
				}*/
			}
		}
		//System.out.println(Arrays.toString(maze[0]));
		System.out.println(max);
		sc.close();
	}
	public static class point{
		int x; int y;
		point(int x,int y){
			this.x = x; this.y =y;
		}
	}
}

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

int main(){
  int x,y; cin>>x>>y;
  int a[]={0,1,2,1,3,1,3,1,1,3,1,3,1};
  if(a[x]==a[y])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256