akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define MAX 2000000
int HSIZE = 0;
int tree[MAX];
void heapIncreaseKey(int i, int key) {
    if(key < tree[i]) {
        cout << "error: new key is smaller than curren key" << endl;
        return;
    }
    tree[i] = key;
    while(i > 1 && tree[i / 2] < tree[i]) {
        swap(tree[i / 2], tree[i]);
        i = i / 2;
    }
}
void insert(int key) {
    HSIZE++;
    tree[HSIZE] = -2147483648;
    heapIncreaseKey(HSIZE, key);
}
void maxHeapify(int idx) {
    int l = 2 * idx;
    int r = l + 1;
    int largest;
    if(l <= HSIZE && tree[l] > tree[idx]) {
        largest = l;
    } else {
        largest = idx;
    }

    if(r <= HSIZE && tree[r] > tree[largest]) {
        largest = r;
    }

    if(largest != idx) {
        swap(tree[idx], tree[largest]);
        maxHeapify(largest);
    }
}

int heapExtractMax() {
    // error handling
    if(HSIZE < 1) {
        cout << "error: heap under flow" << endl;
        return -1;
    }
    // take root. then override root with tree[HSIZE]
    int max = tree[1];
	tree[1] = tree[HSIZE--];
    maxHeapify(1);
    return max;
}

int main() {
    int key;
    char com[10];
    while(1) {
        scanf("%s", com);
        if(string(com) == "end") {
            break;
        } else if(string(com) == "insert") {
            scanf("%d", &key);
            insert(key);
        } else if(string(com) == "extract") {
            printf("%d\n", heapExtractMax());
        }
    }
}


Measured memory_bytes: 7184
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n, k;

    while(cin >> n >> k, n+k){
        int ans = -50000;
        int sum = 0;
        vi series;
        for(int i=0; i < n; i++){
            int m;
            cin >> m;
            series.push_back(m);

            if(i < k-1) sum += m;
            else {
                sum += m-series[i-k];
                ans = max(ans, sum);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1728
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	long long ret=inf;
	for(int i=0;i<=100000;i++){
		long long tmp=i*2*c;
		tmp+=max(0,d-i)*a;
		tmp+=max(0,e-i)*b;
		ret=min(ret,tmp);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;


	return 0;
}

Measured memory_bytes: 256
def fact(n, r):
    calc_a = 1
    calc_b = 1
    for i in range(1, r + 1):
        calc_a = (calc_a * (n + 1 - i)) % p
        calc_b = (calc_b * i) % p
    ans = (calc_a * pow(calc_b, p - 2, p)) % p
    return ans


p = (10 ** 9) + 7
x, y = map(int, input().split())
if ((2 * y - x) % 3 == 0) & ((2 * x - y) % 3 == 0) & (2 * y >= x) & (2 * x >= y):
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    print(fact(a + b, min(a, b)))
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define vec2 vector<vector<int>>
#define set setprecision
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	int n;
	cin >> n;
	vec a(n);
	int k;
	rip(i, n)cin >> a[i];
	if (n < 100) {
		int maxxx = 0;
		rip(i, n) {
			if (i != 0) k = a[0];
			else  k = a[1];
			rip(j, n) {
				if (j != i)k = gcd(k, a[j]);
			}
			maxxx = max(maxxx, k);
		}
		cout << maxxx << endl;
	}
	else {
		int p[100009], r[100009];
		int l = a[0];//subetenosaidaikouyakusuu
		rip(i, n) {
			l = gcd(l, a[i]);
			p[i] = l;
		}
		int k = a[n - 1];
		rip(i, n) {
			int j = n - 1 - i;
			k = gcd(k, a[j]);
			r[j] = k;
		}
		p[-1] = l;
		r[n] = l;
		int maxx = 0;
		rip(i, n) {
			maxx = max(maxx, gcd(p[i - 1], r[i + 1]));
		}
		cout << maxx << endl;
	}
}


Measured memory_bytes: 1408
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 100005;
const double mm = 1e+30;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
void solve()
{
    ll h,a;
    cin>>h>>a;
    ll an=0;
    while(h>0){
        an++;
        h-=a;
    }
    pr(an);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int cs[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> cs[i][j];
        }
    }

    bool ok = false;
    for (int a0 = 0; a0 <= 100; a0++) {
        for (int a1 = 0; a1 <= 100; a1++) {
            for (int a2 = 0; a2 <= 100; a2++) {
                int b0 = cs[0][0] - a0;
                int b1 = cs[0][1] - a0;
                int b2 = cs[0][2] - a0;

                bool ok_b0 = (b0 == cs[1][0] - a1 && b0 == cs[2][0] - a2);
                bool ok_b1 = (b1 == cs[1][1] - a1 && b1 == cs[2][1] - a2);
                bool ok_b2 = (b2 == cs[1][2] - a1 && b2 == cs[2][2] - a2);

                if (ok_b0 && ok_b1 && ok_b2)
                    ok = true;
            }
        }
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;
}


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

using namespace std;

int gcd(int x, int y)
{
  int small = min(x, y);
  int big = max(x, y);
  if(small == 0) return big;
  return gcd(small, big%small);
}

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

  int Lgcd[N];
  int Rgcd[N];
  Lgcd[0] = 0;
  Rgcd[N-1] = 0;
  for(int i = 1; i < N; i++){
    Lgcd[i] = gcd(Lgcd[i-1], A[i-1]);
  }
  for(int i = N-2; i >= 0; i--){
    Rgcd[i] = gcd(A[i+1], Rgcd[i+1]);
  }

  int GCD[N];
  for(int i = 0; i < N; i++){
    GCD[i] = gcd(Lgcd[i], Rgcd[i]);
  }
  sort(GCD, &GCD[N]);

  cout << GCD[N-1] << "\n";

  /******
  int GCD[N];
  for(int i = 0; i < N; i++){
    int L = A[0];
    int R = A[N-1];
    if(i == 0) L = 0;
    for(int j = 0; j < i; j++){
      L = gcd(L, A[j]);
      //      cout << "L: " << L << "\n";
    }
    if(i == N-1) R = 0;
    for(int j = N-1; j > i; j--){
      R = gcd(A[j], R);
      //      cout << "R: " << R << "\n";
    }
    GCD[i] = gcd(L, R);
  }

  //  for(int i = 0; i < N; i++){
  //    cout << GCD[i] << "\n";
  //  }

  //  int max = *max_element(GCD, &GCD[N]);
  sort(GCD, &GCD[N]);
  int max = GCD[N-1];
  cout << max << "\n";
  ******/

  return 0;
}


Measured memory_bytes: 1792
fun main(A: Array<String>) {
    abc000X()
}

fun abc000X() {
    val (k, n) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }

    a.indices.map{
        val d=Math.abs(a[it]-a[(it+1)%n])
        Math.max(d,k-d)
    }.min().let(::println)
}


Measured memory_bytes: 84576
n = int(input())
S = [int(i) for i in input().split()]
infty = 10**10
cnt = 0
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
    L = A[left:mid] + [infty]
    R = A[mid:right] + [infty]
    
    i = 0
    j = 0
    for k in range(left, right):
        global cnt
        if(L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            if(L[i] != infty):
#                 print("LR", L[i], R[j])
                cnt += len(L) - 1  - i
#     print(cnt)
            
def mergeSort(A, left, right):
    if (left + 1 < right):
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
mergeSort(S, 0, len(S))
# print(" ".join([str(st) for st in S]))
print(cnt)


Measured memory_bytes: 27476
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int q;
	cin>>q;
	int cnt=0;
	string t="";
	string f="";
	while(q--){
		int x,y;
		char c;
		cin>>x;
		if(x==1){
			cnt++;
			continue;
		}
		else{
			cin>>y>>c;
			if(y==1){
				if(cnt%2==0)t+=c;
				else f+=c;
			}
			else{
				if(cnt%2==0)f+=c;
				else t+=c;
			}
		}
	}
	reverse(t.begin(),t.end());
	s=t+s+f;
	if(cnt%2)reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m;
	int dp[34] = {0};
	dp[0] = 1;
	rep(i,30)rep(j,3)dp[i+j+1] += dp[i];
	while(cin >> n , n)
		cout << (dp[n]+3649)/3650 << endl;

}

Measured memory_bytes: 0
n = int(input())
ans = 0
for i in (1, 3, 5):
    if n / 10**i >= 1:
        ans += 10**i - 10**(i-1)
    elif n / 10**(i-1) >= 1:
        ans += n - 10**(i-1) + 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int score[2] = {0};
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 4; j++) {
			int tmp;
			cin >> tmp;
			score[i] += tmp;
		}
	}
	cout << max(score[0], score[1]) << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9+7;
const int maxn = 5e5+5;
inline ll read()
{
    ll s = 0, f = 1;
    char ch = getchar();
    for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;
    for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
    return s * f ;
}
inline void out(ll x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) out(x/10);
    putchar(x%10+'0');
}
deque<char>q;
signed main()
{
    string s;
    int t;
    cin>>t;
    cin>>s;
    int k = 0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] == '(')
        {
            q.push_back(s[i]);
            k++;
        }
        else
        {
            if(k>0)
            {
                q.push_back(s[i]);
                k--;
            }
            else
            {
                q.push_back(')');
                q.push_front('(');
            }
        }
    }
    while(k--)
        q.push_back(')');
    while(!q.empty())
    {
        cout<<q.front();
        q.pop_front();
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b,c,d,p,A,B;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	A=a*p;
	if(p<=c){
		B=b;
	}
	else{
		B=b+d*(p-c);
	}
	if(A>=B){
		printf("%d\n",B);
	}
	else{
		printf("%d\n",A);
	}
	return 0;
}

Measured memory_bytes: 596
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	m := make([]int64, n)
	var cnt int64

	for i := int64(0); i < n; i++ {
		m[i] = nextInt(sc)
	}

	for _, v := range m {
		if v == 2 {
			cnt++
			continue
		}
		if v%2 == 0 {
			continue
		}
		sqrtV := math.Sqrt(float64(v))
		for i := int64(3); float64(i) <= sqrtV; i += 2 {
			if v%i == 0 {
				cnt--
				break
			}
		}
		cnt++
	}
	fmt.Println(cnt)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1220
#include<stdio.h>

int main() {
	char s[13];

	scanf("%s", s);

	printf("%c%c%c%c %c%c%c%c%c%c%c%c\n", s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11]);

	return 0;
}

Measured memory_bytes: 128
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# /home/remina/PycharmProjects/atcoder/A-500YenCoins.py
#

n, k = map(int, input().split())
s = input()
ans = ""

for i in range(n):
    if i == k-1:
        s_tmp = s[i]
        ans += s_tmp.lower()
    else:
        ans += s[i]

print(ans)



Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int k, n; cin >> k >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  int ans = a[n - 1] - a[0];
  FOR(i, 1, n) chmin(ans, k - a[i] + a[i - 1]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AtCoder {
    public class Program {
        static int[] getKeys() {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(delimiter);
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        public static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        public static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }


        static void Main() {
            var Key = getKeys();
            Console.WriteLine((double)Key[0] / Key[1]);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
long long int mod=1000000007;
struct modint{
    long long int x;
    modint(long long int x=0):x(x%mod){}//メンバ変数を初期化する。
    modint& operator+= (const modint a){
        if((x+=a.x)>=mod){x-=mod;}//%は遅い
        return *this;//関数を終了するためにはreturnを返さなければならないが、return aとでもするとその値が代入されてしまう。そこで、計算された後の自分自身のアドレス、つまり何もしないようにしている？
    }
    modint& operator-= (const modint a){
        if((x+=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator*= (const modint a){
        x*=a.x;
        x%=mod;
        return *this;
    }
    modint operator+(const modint a) const{//引数の横のconstは関数自体がconstつまりメンバ変数の変更ができなくなるということ。バグ防止に役立つ
        modint copy(*this);//constがあるのでメンバ変数をいじれないから値だけコピーする
        return copy+=a;
    }
    modint operator-(const modint a)const{
        modint copy(*this);
        return copy-=a;
    }
    modint operator*(const modint a)const{
        modint copy(*this);
        return copy*=a;
    }
    modint pow(long long int t)const{//繰り返し二乗法
        if(t==0) return 1;
        modint a=pow(t>>1);//tを1/2倍したものの累乗
        a*=a;//aを二乗する
        if(t&1) a*=*this;//ビット形式での一桁目が1、つまりtが奇数ならば、もう一回掛ける。
        return a;
    }
    modint inv() const{
        return pow(mod-2);
    }
    modint operator/=(const modint a){
        return (*this)*=a.inv();
    }
    modint operator/(const modint a){
        modint copy(*this);
        return copy/=a;
    }
};




//ここから
struct combination {
    vector<modint> fact,ifact;//階乗＝factoria
    combination(lli n):fact(n+1),ifact(n+1){//fact=階乗、ifactはその逆元
        fact[0]=1;//0!=1
        for(lli i=1;i<=n;i++) fact[i]=fact[i-1]*i;
        ifact[n]=fact[n].inv();//invは計算が重いので一回で済ませたい
        for(lli i=n;i>=1;i--) ifact[i-1]=ifact[i]*i;
    }
    modint operator()(lli n,lli k){
        if(k<0||k>n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
//modintで足し算、引き算を扱う場合余りを扱っている関係上負の値になりえない問題でも
//負の値になることがあるので、そこのフォローをする！
int main(){
    modint n,m,k,ans;
    cin>>n.x>>m.x>>k.x;
    modint i;
    modint s;
    s.x=1;
    combination c(n.x*m.x);
    for(i.x=1;i.x<=(n.x);i.x++){
        ans+=(n-i)*m*m*i;
    }
    for(i.x=1;i.x<=(m.x);i.x++){
        ans+=(m-i)*n*n*i;
    }
    ans*=c((n*m-s-s).x,(k-s-s).x);
    out(ans.x);
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long n,k;
	cin>>n>>k;
	vector<int>tel(n),vst(n);
	rep(i,n)cin>>tel[i];
	rep(i,n)tel[i]--;
	vst[0]=1;
	int p=0,searching=0,found=0,memp,memt=0;
	while(k){
	    k--;
	    p=tel[p];
	    if(searching==0){
	        if(vst[p]==0)vst[p]=1;
	        else{
	            searching=1;
	            memp=p;
	        }
	    }
	    else if(found==0){//searching
	        memt++;
	        if(p==memp){
	            found=1;
	            k%=memt;
	        }
	    }
	    //cout<<p;
	}
	cout<<p+1;
	return 0;
}

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

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

ll num(ll n, ll x) {
    if(n == -1) {
        return 0;
    } else {
        return n / x + 1;
    }
}

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

    ll a, b, x;
    cin >> a >> b >> x;

    cout << num(b, x) - num(a - 1, x) << endl;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>
#include <map>

#define forin(i, f, t) for(ll i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    
    int evens[8] = {2,10,3,9,4,8,6,12};
    int odds[8] = {6,2,10,3,9,4,8,12};
    
    if (n == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
    } else if (n % 2 == 0) {
        for (auto i = 0; i < n; i++)
            cout << evens[i % 8] + (i / 8) * 12 << " ";
    } else {
        for (auto i = 0; i < n; i++)
            cout << odds[i % 8] + (i / 8) * 12 << " ";
    }
    
}



Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N,M,X = map(int, lines.pop(0).split(' '))
    A = list(map(int, lines.pop(0).split(' ')))
    less = more = 0
    for i in A:
        if i < X:
            less += 1
        else:
            more += 1
    print(min(more, less))


#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", min(min(a+b, a+c), b+c));
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#include<cstdlib>
#include<stack>
#include<algorithm>
#include<set>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	long long n;
	scanf("%lld",&n);
	printf("%lld",n*(n-1)/2);
}

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

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	int x,y;
        	cin>>x>>y;
        	if(y%2==0&&y>=2*x&&y<=4*x)
        	cout<<"Yes";
        	else cout<<"No";  
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3776
n=int(input())
C = list(input())
ans = 0
N = n-1
for l in range(n):
    if C[l] == "W":
        for r in range(N,0,-1):
            if r<=l:
                print(ans)
                exit()
            if C[r] == "R":
                #print(C)
                C[l] = "R"
                C[r] = "W"
                #print(C)
                #print("-----------------")
                ans += 1
                N = r-1
                break
print(ans)

Measured memory_bytes: 10624
#include<iostream>

using namespace std;

static const int MAX_N = 40;
static const int MAX_V = 10;

static const int INF = 1000000;

int N;
int Ma;
int Mb;
int a[MAX_N + 1];
int b[MAX_N + 1];
int c[MAX_N + 1];

int dp[MAX_N + 1][MAX_N * MAX_V + 1][MAX_N * MAX_V + 1];

int main() {
    cin >> N;
    cin >> Ma >> Mb;

    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
    }

    //////

    for (int i = 0; i <= MAX_N; i++) {
        for (int j = 0; j <= MAX_N * MAX_V; j++) {
            for (int k = 0; k <= MAX_N * MAX_V; k++) {
                dp[i][j][k] = INF;
            }
        }
    }

    //////

    dp[0][0][0] = 0;
    for (int i = 1; i <= MAX_N; i++) {
        for (int j = 0; j <= MAX_N * MAX_V; j++) {
            for (int k = 0; k <= MAX_N * MAX_V; k++) {
                if (dp[i - 1][j][k] == INF) continue;

                dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
                dp[i][j + a[i]][k + b[i]] = min(dp[i - 1][j][k] + c[i], dp[i][j + a[i]][k + b[i]]);
            }
        }
    }

    int ans = INF;
    for (int j = 1; j <= MAX_N * MAX_V; j++) {
        for (int k = 1; k <= MAX_N * MAX_V; k++) {
            if (j * Mb == k * Ma) ans = min(ans, dp[N][j][k]);
        }
    }

    if (ans == INF) ans = -1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 25984
#include <stdio.h>

int main() {
    int A, B, C, D, out=0;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    if (A < B) out = A;
    else out = B;
    if (C < D) out += C;
    else out += D;
    printf("%d\n", out);
    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;


const int MAXN = 2e5 + 20;

int a[MAXN], l[MAXN];


int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    int n, k;
    cin >> n >> k;
    set<int> st;

    int pre = -1;
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    	if(i && a[i] < a[i - 1])
    		pre = i - 1;
    	l[i] = i - pre;
    }
    for(int i = 0; i < k; i++) {
    	st.insert(a[i]);
    }
    int res = l[k - 1] < k;
    bool tmp = l[k - 1] >= k;
    for(int i = 0; i + k < n; i++) {
    	st.erase(a[i]);
    	if(!(a[i] <= *st.begin() && *prev(st.end()) <= a[i + k]) && l[i + k] < k){
    		res++;
    		// debug << "at" << i << a[i] << *st.begin() << *prev(st.end()) << a[i + k] << endl;
    	}
    	if(l[i + k] >= k)
    		tmp = true;
    	st.insert(a[i + k]);

    }
    cout << res + tmp << endl;

    return 0;
}






















Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
 
void solve()
  {
   int n;
   cin>>n;
   double sum = 0.0;
   //vector<int> v(n);
   loop(i,0,n)
    {
      int x;
      cin>>x;
      sum += (1.0/x);
    }
   sum = 1.0/sum;
   cout<<fixed<<setprecision(10);
   cout<<sum;
  } 
signed main()
 {
 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static int Partition(int[] A, int p, int r)
    {
        int x = A[r];
        int i = p - 1;
        int temp = 0;
        for (int j = p; j < r; j++)
        {
            if (A[j] <= x)
            {
                i++;
                temp = A[i];
                A[i] = A[j];
                A[j] = temp;
            }
        }
        i++;
        temp = A[i];
        A[i] = A[r];
        A[r] = temp;
        return i;
    }
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int m = Partition(A, 0, n - 1);
        for (int i = 0; i < m; i++) Console.Write("{0} ", A[i]);
        Console.Write("[{0}] ", A[m]);
        for (int i = m + 1; i < n - 1; i++) Console.Write("{0} ", A[i]);
        Console.WriteLine(A[n - 1]);
    }
}


Measured memory_bytes: 30304
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
LL H = 1, X, ans;
int N;
LL need[51];
LL P[51];
void solve(LL x, LL h,int r){
	if(x == 0) return;
	else if(h == x) need[r]++;
	else if(x >= (h + 1) / 2){
		ans++;
		need[r - 1]++;
		solve(x - (h + 1) / 2, (h - 3) / 2, r - 1);
	}else{
		solve(x - 1, (h - 3) / 2, r - 1);		
	}
}


int main(){
	cin >> N >> X;
	P[0] = 1;
	for(int i = 1; i <= N; i++){
		H = H * 2 + 3;
		P[i] = P[i - 1] * 2 + 1;
	}
	solve(X, H, N);
	for(int i = 0; i <= N; i++){
		ans += need[i] * P[i];
	}
	cout << ans << endl;
	return 0;
}

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

static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve(){
  int ans = 0;

  bool V[MAX];
  for(int i=0; i<n; i++){
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B+n);
  for(int i=0; i<n; i++) T[B[i]] = i;
  for(int i=0; i<n; i++){
    if(V[i]) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while(1){
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if(V[cur]) break;
    }
    ans += min(S + (an-2)*m, m+S+(an+1)*s);
  }
  return ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    s = VMAX;
    for(int i=0; i<n; i++){
      cin >> A[i];
      s = min(s, A[i]);
    }
    int ans = solve();
    cout << ans << endl;

    return 0;

}

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

int n, cc, tt, ans=0;
vector<int> s(500000, 0);
vector<int> t(500000, 0);
vector<int> c(500000, 0);

vector< vector<int> > table(60, vector<int>(500000, 0));
int main() {
    cin >> n >> cc;
    for (int i = 0; i < n; ++i) {
        cin >> s.at(i);
        cin >> t.at(i);
        cin >> c.at(i);
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = s.at(i); j <= t.at(i); ++j)
        {
            table.at(c.at(i)-1).at(j) = 1;
        }
    }

    for (int time = 0; time <= 100000; ++time)
    {
        int counts=0;
        for (int i = 0; i < cc; ++i)
        {
            counts += table.at(i).at(time);
        }

        ans = max(ans, counts);
    } 

    // for (int c = 0; c < 4; ++c)
    // {
    //     cout << "[";
    //     for (int i = 0; i < 10; ++i) cout << table.at(c).at(i);
    //     cout << "]" << endl;
    // }

    cout << ans << endl;
}

Measured memory_bytes: 125440
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

n = int(input())

a = [int(i) for i in input().split()]

#ans = a[0]


a = sorted(a)
ans = a[0]

for i in range(1,n):
    ans *=a[i]
    if ans == 0:
        print(0)
        sys.exit()
    if ans > 1000000000000000000:
        print(-1)
        sys.exit()

print(ans)
    

Measured memory_bytes: 21608
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    s=input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))
    h.append(int(s[2]))
for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if h[i]>0:
                hh=h[i]+abs(cx-x[i])+abs(cy-y[i])
                break
        flag=True
        for i in range(n):
            if h[i]!=max(0,hh-abs(cx-x[i])-abs(cy-y[i])):
                flag=False
                break
        if flag:
            print(cx,cy,hh)

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

int main() {
	string s; cin >> s;
	int a, b;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'A')a = i;
	}
	rep(i, s.size()) {
		if (s[i] == 'Z')b = i;
	}
	cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

L = 40

N, K = reads()
A = reads()
K = K + 1

def f(X):
  return sum(X ^ a for a in A)

maj = 0
for j in range(L):
  if sum(a & (1 << j) > 0 for a in A) <= N // 2:
    maj |= (1 << j)

ans = 0
for i in range(L):
  if K & (1 << i) == 0:
    continue
  X = K & ((~0) << (i+1)) | (maj & ((1 << i) - 1))
  ans = max(ans, f(X))

print(ans)


Measured memory_bytes: 14840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main(void)
{
	long int N = 0;
	cin >> N;

	string s;
	long int count = 0;
	unordered_map<string, int> resHashTable;

	for (int i = 0; i < N; i++)
	{
		cin >> s;
		sort(s.begin(), s.end());
		auto iter = resHashTable.find(s);
		if (iter == resHashTable.end())
		{
			resHashTable.emplace(s, 0);
		}
		else
		{
			count += ++resHashTable[s];
		}
	}

	cout << count << "\n";
	return 0;
}

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

int main ()
{
    int r,g,b;
    int d,e,f,h;
    cin >>r>>g>>b;
    d = r*100;
    e = g*10;
    f = b*1;
    h = d+e+f;
    if(h%4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll M = N-1;
    ll out = 0;
    rep(i,sqrt(M)){
        if(M%(i+1)==0){
            if(i==0 || i+1==M/(i+1)) out++;
            else out += 2;
        }
    }
    rep(i,sqrt(N)){
        if(N%(i+1)==0){
            if(i!=0){
                ll L = N/(i+1);
                while(L%(i+1)==0) L /= i+1;
                if(L%(i+1)==1) out++;
            }
        }
    }
    if(N-1>1) out++;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	if(n>=10){
		n=n%10;
	}
	if(n==2||n==4||n==5||n==7||n==9){
		printf("hon\n");
	}
	else if(n==3){
		printf("bon\n");
	}
	else{
		printf("pon\n");
	}
	return 0;
}

Measured memory_bytes: 1656
class UnionFind(object):

    def __init__(self, N):
        self._tree = [i for i in range(N)]
        self._rank = [0] * (N + 1)
        self.size = [1] * N
        self.inconvenience = N * (N - 1) // 2

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.inconvenience -= self.size[x] * self.size[y]
        if self._rank[x] < self._rank[y]:
            self._tree[x] = y
            self.size[y] += self.size[x]
        else:
            self._tree[y] = x
            self.size[x] += self.size[y]

        if self._rank[x] == self._rank[y]:
            self._rank[x] += 1


N, M = map(int, input().split())
A_B = [tuple(map(int, input().split())) for _ in range(M)]

result = list()
uf = UnionFind(N)
for a, b in reversed(A_B):
    result.append(max(0, uf.inconvenience))
    uf.unite(a - 1, b - 1)
for r in reversed(result):
    print(r)


Measured memory_bytes: 94808
#include<stdio.h>
int main(void)
{
	int n, i, j, a, b = 0, m = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		if (i % 10 == 0)m += 1;
		a = i;
		for (j = 0; j < m; j++) {
			if (a % 10 == 3) {
				b = 1;
				break;
			}
			a /= 10;
		}
		if (i % 3 == 0 || b)printf(" %d", i);
		b = 0;
	}
	printf("\n");
	
	return(0);
}


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

int main(void){
    
    string input1,input2;
    string ans="Yes";
    
    cin >> input1 >> input2;

    for(int i=0;i<input1.length();i++){
        if(input1[i]!=input2[i]) ans ="No" ;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3632
i,A=-1,a[14]={0,1,1,1,7,4,1,336,384,334,220,108,36,6},b[10]={108,220,334,384,334,220,108,36,6};main(){long long n;scanf("%lld",&n);if(n<14)A=a[n];else if(n==27||n==134217723)A=976;else if(n==29||n==536870907)A=4;else if(n==61||n==2305843009213693946)A=1;else if(n==1152921504606846970)A=220;else if(n==268435451)A=108;else for(i=0;i<9;i++)if(pow(2,i+5)-n==4)A=b[i];printf("%d",A);}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main(){long N;
cin >> N;
long ans = 1;
erep(i, N){
    ans = ans * i % MOD;
}

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




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(){
	long x;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> x;
#else
	std::cin >> x;
#endif

	std::cout << std::bitset<32>(x) << std::endl;
	std::cout << std::bitset<32>(~x) << std::endl;
	std::cout << std::bitset<32>((x << 1)) << std::endl;
	std::cout << std::bitset<32>((x >> 1)) << std::endl;

   
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int S = accumulate(A.begin(), A.end(), 0);
    int num = 0;
    for(int a : A) if(a*4*M >= S) num++;
    cout << (num >= M ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
   
#define M 1333331
#define NIL (-1)
#define L 14
   
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;
    for (i = 0; i < strlen(str); 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)); }
   
int find(char str[]){
    long long ii = getKey(str);
    int i;
    int hh1 = h1(ii);
    int hh2 = h2(ii);
    for (i = 0; i<M ; i++){
      if (H[(hh1 + i*hh2) % M][0] == '\0'){return 0;}
        else if (strcmp(H[(hh1 + i*hh2) % M], str) == 0){ return 1; }
    }
    return 0;
    /* your task */
   
}
   
int insert(char str[]){
    long long ii = getKey(str);
    int hh1 = h1(ii);
    int hh2 = h2(ii);
    int i;
    for (i = 0; i<M; i++){
        if (H[(hh1 + i*hh2) % M][0]== '\0'){
            strcpy(H[(hh1 + i*hh2)%M], str);
            return 0;
        }
    }
    return 0;
    /* your task */
   
}
   
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: 18836
def main():
    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]

    now_list = []
    next_list = []

    for i in range(high):
        for j in range(width):
            if data[i][j] == '#':
                now_list.append([i, j])

    count = 0

    while 1:
        for now_data in now_list:
            i, j = now_data

            kari_i1, kari_i2 = i - 1, i + 1
            kari_j1, kari_j2 = j - 1, j + 1

            if kari_i1 >= 0:
                a, b = kari_i1, j
                if data[a][b] == '.':
                    next_list.append([a, b])
                    data[a][b] = '#'

            if kari_i2 <= high - 1:
                a, b = kari_i2, j
                if data[a][b] == '.':
                    next_list.append([a, b])
                    data[a][b] = '#'

            if kari_j1 >= 0:
                a, b = i, kari_j1
                if data[a][b] == '.':
                    next_list.append([a, b])
                    data[a][b] = '#'

            if kari_j2 <= width - 1:
                a, b = i, kari_j2
                if data[a][b] == '.':
                    next_list.append([a, b])
                    data[a][b] = '#'

        now_list = next_list
        next_list = []


        if len(now_list) == 0:
            break
        else:
            count += 1


    print(count)



if __name__ == '__main__':
    main()


Measured memory_bytes: 177468
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::{min, max};
use std::mem::swap;

#[fastout]
fn main() {
    input! {
    n: usize,
    t: usize,
    mut ab: [(usize, usize); n]
    }
    ab.sort();
    let mut dp = vec![0; 6005];
    for i in 0..n {
        let mut prev = vec![0; 6005];
        swap(&mut dp, &mut prev);
        let (a, b) = ab[i];
        for j in 0..6005 {
            dp[j] = if j < a || j - a >= t {
                prev[j]
            } else {
                max(prev[j], prev[j - a] + b)
            }
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 2320
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int r;
  cin>>r;
  cout<<3*r*r;
}

Measured memory_bytes: 3560
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
wana = 1
for a in aa:
	if a%2 == 0:
		wana *= 2
	else:
		wana *= 1

print(3**N-wana)

Measured memory_bytes: 4212
n = int(input())
tsk = []
for i in range(n):
	a,b = map(int,input().split())
	tsk.append([a,b])

tsk.sort(key = lambda x:x[1])

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if t > l[1]:
		ans = 'No'
		break
print(ans)

Measured memory_bytes: 40784
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  n, k = I()
  p = LI()
  p.sort()
  ans = 0
  for i in range(k):
    ans += p[i]
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 9204