akhauriyash/Code-Regression huggingface dataset:
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  200005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
ll edges;
pair <ll,pii> edgelist[N];
vi link(N),ww(N,1);
ll find(ll x)
{
  while(x!=link[x]) x=link[x];
  return x;
}
bool same(ll i,ll j)
  {return find(i)==find(j);}
void unite(ll a,ll b)
{
  a=find(a);
  b=find(b);
  if(ww[a]<ww[b]) swap(a,b);
  ww[a]+=ww[b];
  link[b]=a;
}
void solve()
{
  ll n,m;
  cin>>n>>m;
  rep(i,1,n+1) link[i]=i;
  rep(i,0,m){
    ll x,y;
    cin>>x>>y;
    if(!same(x,y)) unite(x,y);
  } 
  ll ans=0;
  rep(i,1,n+1) ans=max(ans,ww[find(i)]);
  cout<<ans<<endl; 
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 6236
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a) {
    int[] a2;
    for (int i = 0; i < a.length; i++)
        a2 ~= a[i] - i - 1;

    a2.sort();
    long median = a2[a2.length / 2];
    return a2.map!(e => abs(e - median)).sum;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 11480
#include <stdio.h>

int main(void)
{
  int n[10000], q[500], n1, q1, i, j, k = 0;
  scanf("%d", &n1);
  for (i = 0; i < n1; i++)  {
    scanf("%d", &n[i]);
  }
  scanf("%d", &q1);
  for (i = 0; i < q1; i++)  {
    scanf("%d", &q[i]);
  }

  for (i = 0; i < q1; i++)  {
    j = 0;
    while (n[j] != q[i])  {
      if (j == n1)  {
        break;
      }
      j++;
    }
    // printf("j = %d\n", j);
    if (j != n1)  {
      k++;
    }
  }

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

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long t[n],a[n];
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long t_u[n],t_l[n];
    t_u[0] = t[0];
    t_l[0] = t[0];
    for(int i=1; i<n; i++){
        if(t[i] > t[i-1]){
            t_u[i] = t[i];
            t_l[i] = t[i];
        }
        else{
            t_u[i] = t[i];
            t_l[i] = 1;
        }
    }
    long long a_u[n],a_l[n];
    a_u[n-1] = a[n-1];
    a_l[n-1] = a[n-1];
    for(int i=n-2; i>=0; i--){
        if(a[i] > a[i+1]){
            a_u[i] = a[i];
            a_l[i] = a[i];
        }
        else{
            a_u[i] = a[i];
            a_l[i] = 1;
        }
    }
    long long mod = 1000000007;
    long long ans = 1;
    for(int i=0; i<n; i++){
        long long u = min(t_u[i],a_u[i]);
        long long l = max(t_l[i],a_l[i]);
        if(u < l){
            ans = 0;
            break;
        }
        else{
            ans *= u-l+1;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)
 
	n := scanInt()
	m := scanInt()
 
	a := make([]int, m)
	b := make([]int, m)
 
	for i := 0; i < m; i++ {
		a[i] = scanInt()-1
		b[i] = scanInt()-1
	}
 
	uf := make(unionFind, n)
	uf.init()
 
	ans := make([]int, m+1)
	ans[m] = n*(n-1)/2
	for i := 0; i < m; i++ {
		ans[m-1-i] = ans[m-i]
		if uf.find(a[m-1-i]) != uf.find(b[m-1-i]) {
			ans[m-1-i] -= uf.size(a[m-1-i])*uf.size(b[m-1-i])
			uf.unite(a[m-1-i], b[m-1-i])
		}
		debug(ans[m-1-i])
	}
 
	for i := 0; i < m; i++ {
		fmt.Fprintln(wr, ans[i+1])
	}
}

type unionFind []int

func (uf *unionFind) init() {
	for i := 0; i < len(*uf); i++ { (*uf)[i] = -1 }
}

func (uf *unionFind) find(x int) int {
	if (*uf)[x] < 0 { return x }
	(*uf)[x] = uf.find((*uf)[x])
	return (*uf)[x]
}

func (uf *unionFind) unite(x, y int) {
	x, y = uf.find(x), uf.find(y)
	if x != y {
		if (*uf)[x] > (*uf)[y] { x,y = y,x }
		(*uf)[x] += (*uf)[y]
		(*uf)[y] = x
	}
}

func (uf *unionFind) size(x int) int {
	return -(*uf)[uf.find(x)]
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define array_length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    string s;
    cin >> s;
    intl idx = 0; 
    intl idx2 = 0;
    rep(i, s.length()){
        if(s[i] == 'A'){
            idx = i;
            break;
        }
    }
    repd(i, s.length() - 1){
        if(s[i] == 'Z'){
            idx2 = i;
            break;
        }
    }

    cout << idx2 -idx + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(-1000<=a&&a<=1000){
        if(-1000<=b&&b<=1000){
            if(a==b){
                printf("a == b\n");
            }
            else if(a > b){
                printf("a > b\n");
            }
            else{
                printf("a < b\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2044
a,b,c,d,e =input().split(' ')
f = int(a)
g = int(b)
h = int(c)
i = int(d)
j = int(e)
high =[f,g,h,i,j]
for dazy in range(5):
    if high[dazy] != dazy+1:
        print(dazy+1)

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

int main(){
    int x1, y1, r1, x2, y2, r2;
    cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;

    int dist = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
    int r = (r1+r2)*(r1+r2);
    int rd = (max(r1,r2)-min(r1,r2))*(max(r1,r2)-min(r1,r2));

    if(dist > r)    cout << 4 << endl;
    else if(dist == r)  cout << 3 << endl;
    else if(dist == rd) cout << 1 << endl;
    else if(dist < rd)  cout << 0 << endl;
    else                cout << 2 << endl;

    return 0;
}


Measured memory_bytes: 3104
import math
[a,b,kakudo]=[int(item) for item in input().split()]

h=b*math.sin(math.radians(kakudo))
c=(a*a+b*b - 2*a*b*math.cos(math.radians(kakudo)))**(0.5)
S=a*h/2
print("{} {} {}".format(S,a+b+c,h))


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

using namespace std;
typedef long long ll;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool res = 0;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) res = 1;
    }
    if (res) cout << "OK";
    else cout << "NG";
}


Measured memory_bytes: 3572
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static int solve(String S) {
        int result = -1;
        int lower = 1;
        int upper = S.length();
        while (lower <= upper) {
            int middle = (lower + upper) / 2;
            if (check(S, middle)) {
                result = middle;
                lower = middle + 1;
            } else {
                upper = middle - 1;
            }
        }

        return result;
    }

    static boolean check(String S, int K) {
        int leftIndex = S.length() - K;
        int rightIndex = K - 1;

        return leftIndex > rightIndex
                || IntStream.rangeClosed(leftIndex, rightIndex).map(S::charAt).distinct().count() == 1;
    }
}

Measured memory_bytes: 31032
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans = 0;
		ans += Math.max(n, m);
		if(m < n) {
			ans += Math.max(m, n-1);
		}else {
			ans += Math.max(m-1, n);
		}
		System.out.println(ans);
		sc.close();
	}
	
}



Measured memory_bytes: 21844
from bisect import bisect

S = input()
N = len(S)
r_idx = [i for i in range(N) if S[i] == 'R']
l_idx = [i for i in range(N) if S[i] == 'L']

ans = [0] * N
for i in range(N):
    if S[i] == 'R':
        j = l_idx[bisect(l_idx, i)]
        if (j - i) % 2 == 0:
            ans[j] += 1
        else:
            ans[j - 1] += 1
    else:
        j = r_idx[max(0, bisect(r_idx, i) - 1)]
        if (i - j) % 2 == 0:
            ans[j] += 1
        else:
            ans[j + 1] += 1
            
print(*ans)


Measured memory_bytes: 52572
import java.util.Scanner;
class Main{
public static void main(String[] args){

Scanner sc = new Scanner(System.in);

while(true){
 int x = sc.nextInt();
 int y = sc.nextInt();

if(x==0 && y==0){
break;
}else if(x<=y){
System.out.println(x+" "+y);
}else{
System.out.println(y+" "+x);
}

}

}

}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};

typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

ll mod = 1e9 + 7;
bool sieve[1001];
int cnt[1001];

void make_sieve(void) {
  rep(i, 1001) sieve[i] = true;
  sieve[0] = sieve[1] = false;
  for (int i = 2; i * i <= 1000; i++) {
    if (!sieve[i]) continue;
    for (int j = i + i; j <= 1000; j += i)
      sieve[j] = false;
  }
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N, A, B;

  cin >> N >> A >> B;
  vector<int> X(N);
  rep(i, N) cin >> X[i];

  ll res = 0;
  rep(i, N-1) {
    ll d = X[i+1] - X[i];
    if (d * A < B) res += d * A;
    else res += B;
  }

  cout << res << endl;
  return 0; 
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int L, N; cin >> L >> N;
	vector<int> X(N); rep(i, 0, N) {
		cin >> X[i];
	}

	rep(mask, 0, 1 << N) {
		int x = 0;
		int t = 0;
		int l = 0, r = N - 1;
		rep(i, 0, N) {
			if (mask >> i & 1) {
				t += X[l] - x;
				x = X[l];
				l++;
			}
			else {
				t += abs(-(L - X[r]) - x);
				x = -(L - X[r]);
				r--;
			}
			//dump(i, t, x, l, r);
		}
		dump(t, bitset<10>(mask));
	}


	auto solve = [&](vector<int> X) {
		vector<int> sl(N);
		vector<int> sr(N);
		sl[0] = X[0];
		sr[0] = L - X[N - 1];
		rep(i, 0, N - 1) {
			sl[i + 1] = sl[i] + X[i + 1];
			sr[i + 1] = sr[i] + (L - X[N - 1 - i - 1]);
		}
		dump(sl, sr);

		int ans = 0;
		rep(start, 0, N) {
			int a = 0;
			int goal = start + (N - start) / 2;
			dump(start, goal);
			if ((N - start) % 2) {
				// 反時計周りで終わる
				dump(goal, N - 1 - (goal + 1));
				if (N - 1 - (goal + 1) >= 0) {
					a += sl[goal] * 2;
					dump(a);
					if (start > 0)
						a -= sl[start - 1] * 2;
					dump(a);
					a += sr[N - 1 - (goal + 1)] * 2;
					dump(a);
					a -= X[goal];
					dump(a);
				}
				else {
					a += sl[goal];
					if (start > 0)
						a -= sl[start - 1];
				}
			}
			else {
				// 時計回りで終わる
				a += sl[goal - 1] * 2;
				if (start > 0)
					a -= sl[start - 1] * 2;
				a += sr[N - 1 - goal] * 2;
				a -= L - X[goal];
			}
			chmax(ans, a);
			dump(a);
		}
		return ans;
	};

	int ans = solve(X);
	rep(i, 0, N)X[i] = L - X[i];
	reverse(all(X));
	dump(X);
	chmax(ans, solve(X));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
int n, m, q;
vector<int> B; //一つ前の数字を代入しておく。
vector<int> tui(int u)
{
    vector<int> A(n);
    if (u == 0)
    {
        rep(i, n)
        {
            A[i] = 1;
        }
        B = A;
        return A;
    }
    int i = 0;
    if (B[n - 1 - i] != m)
    {
        B[n - 1 - i] += 1;
    }
    else if (B[n - 1 - i] == m)
    {
        for (int j = n - 2 - i; j >= 0; j--)
        {
            if (B[j] != m)
            {
                B[j] += 1;
                for (int h = j + 1; h < n; h++)
                {
                    B[h] = B[j];
                }
                break;
            }
        }
    }
    return B;
}
int main()
{
    cin >> n >> m >> q;
    //これから長さnで大きさm以下の数列を全て書き出す
    //最後まで行ったら最大値を返す。
    B.resize(n);
    vector<ll> a(q), b(q), c(q), d(q);
    rep(i, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    //生成しまくるまで
    vector<int> s(n);
    int i = 0;
    int flag = 0;
    ll max1 = 0;
    while (1)
    {
        ll count = 0;
        flag = 0;
        s = tui(i);
        /* for (int x : s)
        {
            cout << x;
        }*/

        rep(i, n)
        {
            if (s[i] != m)
            {
                flag = 1;
                break;
            }
        }
        rep(j, q)
        {
            if (s[b[j] - 1] - s[a[j] - 1] == c[j])
            {
                count += d[j];
            }
        }
        max1 = max(max1, count);
        if (flag == 0)
        {
            break;
        }
        i++;
    }
    cout << max1 << endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	sort.Ints(A)

	saidaiti := A[len(A)-1]
	saishouti := A[0]
	A = A[1 : len(A)-1]

	fuidx := 0
	for fuidx < len(A) && A[fuidx] < 0 {
		fuidx++
	}
	fu := A[:fuidx]
	sei := []int{}
	if fuidx < len(A) {
		sei = A[fuidx:]
	}

	sousa := [][]int{}

	// 最大値探し
	for _, v := range fu {
		sousa = append(sousa, []int{saidaiti, v})
		saidaiti = saidaiti - v
	}

	// 最小値探し
	for _, v := range sei {
		sousa = append(sousa, []int{saishouti, v})
		saishouti = saishouti - v
	}

	// 最後
	sousa = append(sousa, []int{saidaiti, saishouti})
	fmt.Println(saidaiti - saishouti)

	for _, s := range sousa {
		fmt.Println(s[0], s[1])
	}

}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};

int main(){
	string s; cin >>s;
	cout << count(all(s), '1') <<"\n";
}


Measured memory_bytes: 256
def gcd(a,b):
  while b:
    a,b = b, a % b
  return a

N,X=map(int,input().split())
x=list(map(int,input().split()))

ans = x[0] - X

for i in range(1,N):
  ans = gcd(ans, x[i] - X)

print(abs(ans))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll mn = LINF, t;
    ll a[n],b[n];
    rep(i,n){
        cin >> a[i] >> b[i];
        if(b[i] < mn){
            mn = b[i];
            t = a[i];
        }
    }
    cout << mn + t << endl;
    return 0;
}

Measured memory_bytes: 1792
from heapq import *

an, bn, cn, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
la = len(a)
lb = len(b)
lc = len(c)

ans = []
hp = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
heapify(hp)
sumi = {(0, 0, 0)}
for _ in range(k):
    hpk = heappop(hp)
    mx = hpk[0]
    ai = hpk[1]
    bi = hpk[2]
    ci = hpk[3]
    if ai + 1 < la and (ai + 1, bi, ci) not in sumi:
        heappush(hp, [mx + a[ai] - a[ai + 1], ai + 1, bi, ci])
        sumi.add((ai + 1, bi, ci))
    if bi + 1 < lb and (ai, bi + 1, ci) not in sumi:
        heappush(hp, [mx + b[bi] - b[bi + 1], ai, bi + 1, ci])
        sumi.add((ai, bi + 1, ci))
    if ci + 1 < lc and (ai, bi, ci + 1) not in sumi:
        heappush(hp, [mx + c[ci] - c[ci + 1], ai, bi, ci + 1])
        sumi.add((ai, bi, ci + 1))
    ans += [-mx]

print(*ans, sep="\n")


Measured memory_bytes: 5232
#include<stdio.h>
#include<stdlib.h>

int main(){
	int N, M, C, B[21], *A[21], i, j, sum = 0, count = 0;
	scanf("%d%d%d", &N, &M, &C);
	for(i = 0; i < M; i++){ scanf("%d", &B[i]); }
	for(j = 0; j < N; j++){
		A[j] = (int *)malloc(sizeof(int)*M);
		for(i = 0; i < M; i++){
			scanf("%d", &A[j][i]);
			sum += A[j][i]*B[i];
		}
		if(sum+C > 0){ count++; }
		sum = 0;
	}

	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
char s[10001],ss[10001];
int main(){
	int l,i,ans=0;
	
	cin>>s;
	l=strlen(s);
	for(i=0;i<l;i++){
		if(s[i]=='B'){
			if(ans>0)
				ans--;
		}
		else{
		ss[++ans]=s[i];
		}
	}
	for(i=1;i<=ans;i++){
	cout<<ss[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;
const int INF = INT_MAX/2;


int h,w, k;
char A[10][10];

void printbit(int no) {
	for (int x = 0; x < 6; x++) {
		if ((1 << x) & no) cout << "1";
		else cout << "0";
	}
	cout << "\n";
}

int32_t main(){
	cin >> h >> w >> k;
	for (int i =0;i<h;i++) {
		for (int j =0;j<w;j++) {
			cin >> A[i][j];
		}
	}
	
	int ans = 0;
	
	for (int bitx = 0; bitx < (1 << h); bitx++) {
		for (int bity = 0; bity < (1 << w); bity++) {
			
			int co = 0;
			
			for (int i =0;i<h;i++) {
				for (int j =0;j<w;j++) {
					if (!((1 << i) & bitx) and !((1 << j) & bity)) {
						if (A[i][j] == '#') co++;
					}
				}
			}
			
			if (co == k) {
				ans++;
				//cout << "rows: "; printbit(bitx);
				//cout << "cols: "; printbit(bity);
				//cout << "\n";
			}
		}
	}
	
	cout << ans;
	
}









Measured memory_bytes: 3632
#include <iostream>

int main() {
  int A[3][3];
  int B[10] = {-1};
  int n;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      std::cin >> A[i][j];
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> B[i];
  
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < n; ++k)
        if (A[i][j] == B[k]) A[i][j] = -1;
  
  // 横
  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (A[i][j] == -1) cnt++;
    }
    if (cnt == 3) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  // 縦
  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (A[j][i] == -1) cnt++;
    }
    if (cnt == 3) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  // 斜め
 int cnt1 = 0;
 int cnt2 = 0;
 for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (i == j && A[i][j] == -1) cnt1++;
      if (i+j == 2 && A[i][j] == -1) cnt2++;
    }
  }
  if (cnt1 == 3 || cnt2 == 3) {
    std::cout << "Yes" << std::endl;
    return 0;
  }
  std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int c = b-a;
	int d = 0;
	for(int i=0;i<c-1;i++){
		d+=i+1;
	}
	
	printf("%d",d-a);

	
		
	return 0;
}

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

double dis(pair<int,int> t1, pair<int,int> t2) {
    int x1 = t1.first;
    int x2 = t2.first;
    int y1 = t1.second;
    int y2 = t2.second;
    return sqrt(pow((x1-x2),2) + pow((y1-y2),2));
}

int f(int n) {
    int a = 1;
    while (n > 0) {
        a *= n;
        n--;
    }
    return a;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<pair<int,int>> town(n);
    vector<int> a(n);
    rep(i, n) {
        scanf("%d %d", &town[i].first, &town[i].second);
        a[i] = i;
    }
    double sum = 0;
    do {
        rep(i, n) {
            if (i != 0) {
                pair<int,int> t1, t2;
                t1 = town[a[i-1]];
                t2 = town[a[i]];
                sum += dis(t1, t2);
            }
        }
    } while (next_permutation(a.begin(), a.end()));
    double ans = sum / f(n);
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;   
const int mod = 1e9 + 7;
const int N = 200000 + 10;
int power(int b, int exp){
    int res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}
int main(){
    long long h;
    cin >> h;
    for(int i = 60; i >= 0; i--){
        if(h & (1LL << i)){
            printf("%lld\n", (1LL << (i + 1)) - 1);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
n, q = map(int, input().split())

edge = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edge[a].append(b)
    edge[b].append(a)

imos = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    imos[p] += x

q = deque([(0, -1)])
while q:
    v, p = q.pop()
    for u in edge[v]:
        if u == p:
            continue
        imos[u] += imos[v]
        q.append((u, v))

print(' '.join([str(x) for x in imos]))


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

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N = 3;
	string s[N];
	
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < N; i++) {
		transform(s[i].begin(), s[i].end(), s[i].begin(), ::toupper);
		cout << s[i][0];
	}
	cout << endl;

	return (0);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt = 0
s = 0
m = 10**10
for i in range(n):
  if a[i] < 0:
    cnt += 1
  s += abs(a[i])
  m = min(m, abs(a[i]))

if cnt % 2 == 0:
  print(s)
else:
  print(s - 2 * m)

Measured memory_bytes: 14412
#include<bits/stdc++.h>
    #define int long long
    #define rint register int
    using namespace std;
     
    template<typename tp> inline void read(tp &x) {
      x = 0; char c = getchar(); int f = 0;
      for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
      for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
      if (f) x = -x;
    }
    const int N = 3e5 + 2333;
    const int M = N * 2;
    struct Edge {
      int nxt, to, w;
    }e[M];
    int head[N], e_cnt = 0;
    int n, m, ans = 0, mn = 1e18;
    int sz[N], dp[N], f[N], isheart[N], cc = 0;
    inline void add(int x, int y, int w) {
      e[++ e_cnt] = (Edge) {head[x], y, w}; head[x] = e_cnt;
    }
     
    inline void upd(int u, int v, int w) {
      sz[u] += sz[v];
      dp[u] += min(sz[v], n - sz[v]) * w + dp[v];
    }
     
    inline void del(int u, int v, int w) {
      sz[u] -= sz[v];
      dp[u] -= min(sz[v], n - sz[v]) * w + dp[v];
    }
     
    inline void dfs(int u, int fat) {
      sz[u] = 1; f[u] = 0;
      for (int i = head[u]; i; i = e[i].nxt) {
        int v = e[i].to;
        int w = e[i].w;
        if (v != fat) {
          dfs(v, u);
          upd(u, v, w);
          f[u] = max(f[u], sz[v]);
        }
      }
      f[u] = max(f[u], n - sz[u]);
      if (f[u] * 2 <= n)
        isheart[u] = true, ++ cc;
    }
     
    inline void gao(int u, int v, int w) {
      int res = dp[u] + dp[v];
      res += min(sz[u], sz[v]) * w;
      // cout << u << " " << v << " " << dp[u] << " " << dp[v] << " " << res << "\n";
      if (cc == 2 && isheart[u] && isheart[v])
        ans = max(ans, res * 2 - w);
      else if(cc == 1 && (isheart[u] || isheart[v]))
        ans = max(ans, res * 2 - w);
    }
     
    inline void fsd(int u, int fat) {
      for (int i = head[u]; i; i = e[i].nxt) {
        int v = e[i].to;
        int w = e[i].w;
        if (v != fat) {
          del(u, v, w); gao(u, v, w); upd(v, u, w);
          fsd(v, u);
          del(v, u, w); upd(u, v, w);
        }
      }
    }
     
    main(void) {
      read(n);
      for (int i = 2; i <= n; i ++) {
        int x, y, w; read(x); read(y); read(w);
        add(x, y, w); add(y, x, w); mn = min(mn, w);
      }
      dfs(2, 0);
      // for (int i = 1; i <= n; i++)
      //   if (isheart[i]) cout << i << "\n";
      fsd(2, 0);
      cout << ans << "\n";
    }

Measured memory_bytes: 20096
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a = 0, b = 0, i = 0,j = 0, k =0;
    for(k=0 ;; k++){
        cin >> a >> b;
        if((a==0)||(b==0))break;

        for(i = 0; i < a; i++){
            for(j = 0; j < b; j++){
               cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }

}

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	int n, k; cin >> n >> k;
	map<int, bool> mp;
	while (k--) {
		int x; cin >> x;
		while (x--) {
			int y; cin >> y;
			mp[y] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (!mp[i]) ans++;
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N, a;
  string str;
  cin >> N;
  
  for (int i = 0; i < N; i++){
  cin >> str;
  
  if (str == "Y"){
    a++;
  }
  else 
    a = a;
  }
  
  
  if (a == 0){
    cout << "Three";
  }
  else 
    cout << "Four";

}

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	// (x,y)にあるやつはx+y*wに格納されてるよ
	vector<bool> hasWall(w * h, false);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		for (int j = 0; j < w; j++)
		{
			// (x,y)=(j,i)
			if (s[i][j] == '#') {
				hasWall[j + i * w] = true;
			}
		}
	}

	vector<int> row(w * h), column(w * h), ans(w * h);
	// y行目について
	for (int y = 0; y < h; y++) {
		int a = 0;
		int nextSpace = w * y;
		for (int x = 0; x < w; x++) {
			if (!hasWall[x + y * w]) {
				a++;
			}
			if (hasWall[x + y * w] || x == w - 1) {
				if (a > 0) {
					for (int i = nextSpace; i < nextSpace + a; i++) {
						row[i] = a;
					}
				}
				a = 0;
				nextSpace = x + y * w + 1;
			}
		}
	}
	// x行目について
	for (int x = 0; x < w; x++) {
		int a = 0;
		int nextSpace = x;
		for (int y = 0; y< h; y++) {
			if (!hasWall[x + y * w]) {
				a++;
			}
			if (hasWall[x + y * w] || y == h - 1) {
				if (a > 0) {
					for (int i = nextSpace; i < nextSpace + a*w; i+=w) {
						column[i] = a;
					}
				}
				a = 0;
				nextSpace = x + y * w + w;
			}
		}
	}

	for (int i = 0; i < w * h; i++) {
		ans[i] = row[i] + column[i] - 1;
	}

	cout << *max_element(ans.begin(),ans.end()) << endl;

	return 0;
}

Measured memory_bytes: 51712
#include <cstdio>
#include <cstring>
using namespace std;

char s[10];

int main() {
    for(int i = 0; i < 3; i++) {
        scanf("%s", s);
        if(i == 0)
            printf("%c", s[0]);
        if(i == 1)
            printf("%c", s[1]);
        if(i == 2)
            printf("%c", s[2]);
    }
    printf("\n");
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    else if(s=="Rainy")
        cout<<"Sunny"<<endl;
}

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

def color(n):
    if n < 400:
        return 0
    elif n < 800:
        return 1
    elif n < 1200:
        return 2
    elif n < 1600:
        return 3
    elif n < 2000:
        return 4
    elif n < 2400:
        return 5
    elif n < 2800:
        return 6
    elif n < 3200:
        return 7
    else:
        return 8

clr = list(map(color, a))
n = len(set(clr))
if 8 not in clr:
    print('{} {}'.format(n, n))
else:
    free_cnt = clr.count(8)
    min_n = max(n-1, 1)
    # max_n = min(n+free_cnt-1, 8)
    max_n = n+free_cnt-1
    print('{} {}'.format(min_n, max_n))


Measured memory_bytes: 3064
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
int xx = 0;
int yy = 0;

if(x == 2){
xx = 1;
}else if(x == 4||x == 6||x == 9||x == 11){
xx = 2;
}else{
xx = 3;
}

if(y == 2){
yy = 1;
}else if(y == 4||y == 6||y == 9||y == 11){
yy = 2;
}else{
yy = 3;
}

if(xx == yy){
System.out.println("Yes");
}else{
System.out.println("No");
}

}
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	n-=1;
	for(int i=m-n;i<=n+m;i++)
		printf("%d ",i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
long long dist[100010];
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	string S;
	cin >> S;

	string ans = "Yes";
	for (int i = 0; i < S.size();++i) {
		if ((i + 1) % 2 == 1) {
			if (S[i] != 'R'&&S[i] != 'U'&&S[i] != 'D') {
				ans = "No";
				break;
			}
		}
		else {
			if (S[i] != 'L'&&S[i] != 'U'&&S[i] != 'D') {
				ans = "No";
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4480
N=int(input())
S=list(str(input()))
ans=0
for i in range(1000):
  si=list(str(i).zfill(3))
  ii=0
  for j in range(N):
    if S[j]==si[ii]:
      ii+=1
      if ii==3:
        break
  if ii==3:
    ans+=1
print(ans)

Measured memory_bytes: 44256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int n,i,j;
	int ice[9],p;
	while(1) {
		cin >> n;
		if(n==0)break;
		for(i=0;i<=9;i++) ice[i]=0;
		for(i=0;i<n;i++) {
			cin >>p;
			ice[p]++;
		}
		for(i=0;i<=9;i++) {
			if(ice[i]>0) {
				for(j=0;j<ice[i];j++) {
					cout << "*";
				}
				cout << endl;
			}
			else cout << "-" << endl;
		}
	}
	exit(0);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007ll;
const int N = 100100;

int n , m ;
int s , t ;
bool vis[N] , in[N];
ll  dis[2][N] , mem[2][N];
vector<pair<int,ll>>adj[N];
priority_queue<pair<ll,int>>Q;

void dij(int _,int u){
dis[_][u]=0ll;
Q.push({0ll,u});
while( !Q.empty() ){
    int u = Q.top().second;
    Q.pop();

    for(auto p:adj[u]){
        int v = p.first;
        ll d = p.second;
        if( dis[_][v] > dis[_][u]+d ){
            dis[_][v] = dis[_][u]+d;
            Q.push( {-  dis[_][v],v} );
        }
    }
}
}

void dfs(int u){
vis[u]=in[u]=1;
if( u == s )return;
for(auto p:adj[u]){
    int v = p.first;
    ll d = p.second;
    if( vis[v] )continue;
    if( dis[0][v] +d == dis[0][u] )
        dfs(v);
}
}

ll dp(int _,int u){
if( _ && u==s)return 1ll;
if(!_ && u==t)return 1ll;

ll &ret=mem[_][u];
if( ret !=-1 )return ret;
ret=0;
for(auto p:adj[u]){
    int v = p.first;
    ll d = p.second;
    if( in[v] )
        if( dis[_][u]+d == dis[_][v] )
        ret=( ret + dp(_,v) )%mod;
}
return ret;
}

int main(){

scanf("%d %d",&n,&m);
scanf("%d %d",&s,&t);

while( m-- ){
    int u,v;ll d;
    scanf("%d %d %lld",&u,&v,&d);
    adj[u].push_back({v,d});
    adj[v].push_back({u,d});
}

for(int i=0;i<2;i++)
    for(int j=1;j<=n;j++)
        dis[i][j]=1ll<<60;

dij(0,s);
dij(1,t);
dfs(t);
memset(mem,-1,sizeof mem);
ll ans = dp(0,s) * dp(1,t) %mod;

//printf("%lld\n",ans);

for(int i=1;i<=n;i++)
    if( in[i] && dis[0][i]==dis[1][i] ){
        ans = ( ans - dp(0,i)*dp(1,i)%mod*dp(1,i)%mod*dp(0,i)%mod + mod )%mod;
    }

//printf("%lld\n",ans);
ll mx = dis[0][t];
for(int i=1;i<=n;i++)
for(auto p:adj[i]){
    int j = p.first;
    ll d = p.second;
    if( in[i] && in[j] )
    if( dis[0][i]+d == dis[0][j]  )
    if( dis[1][i]   == dis[1][j]+d)
    if( dis[0][i] < mx/2 )
    if( dis[0][j] > mx/2 )
    if( dis[1][j] < mx/2 )
    if( dis[1][i] > mx/2 )
    if( dis[0][i]+d+dis[1][j]==mx  )
        ans = ( ans - dp(1,i)*dp(0,j)%mod*dp(1,i)%mod*dp(0,j)%mod + mod )%mod;

}
printf("%lld\n",ans);
return 0;
}


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

int main() {
  int n ;
  cin >> n ;
  
  vector<int> x(n);
  
  int sum=0;
  for(int i = 0;i<n ;i++){
   cin >> x.at(i);
    sum+=x.at(i)-1;
  }
  cout << sum << endl;
}
  
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
    int n,x;
    int l[100];
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int cnt = 1;
    int c;
    for(int i=0;i<n;i++){
        c += l[i];
        if(c <= x)
            cnt++;
        else
        {
            break;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

//a>b>c = c>b>a b>a>c = c>a>b b>c>a = a>c>b

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  string A,B;
  cin >> N;
  cin >> A >> B;
  for(int i=1;i<=N*2;i++){
    if(i%2==1) cout << A.at(i/2);
    else cout << B.at(i/2-1);
  }
  cout << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int G = 0;
  for (auto a : A) G = gcd(G, a);
  if (G > 1) return cout << "not coprime" << "\n", 0;

  auto pf = [&](long n) {
    map<long, int> ret;
    for (long i = 2; i * i <= n; i++) {
      while (n % i == 0) ret[i]++, n /= i;
    }
    if (n != 1) ret[n]++;
    return ret;
  };

  vector<bool> B(1e6+1);
  for (int i = 0; i < N; i++) {
    for (auto [a, b] : pf(A.at(i))) {
      if (B.at(a)) return cout << "setwise coprime" << "\n", 0;
      else B.at(a) = true;
    }
  }
  cout << "pairwise coprime" << "\n";
}


Measured memory_bytes: 7108
#include<iostream>
#include<vector>
#include<stack>
#include<map>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	vector<vector<int> >bridgearr;

	int tmp1,tmp2;
	for(int i=0;i<M;++i){
		vector<int>bridge;
		cin>>tmp1>>tmp2;
		tmp1--;
		tmp2--;
		bridge.push_back(tmp1);
		bridge.push_back(tmp2);
		bridgearr.push_back(bridge);
	}
	vector<int>breakbridge;
	breakbridge.push_back(-1);
	breakbridge.push_back(-1);
	int ans=0;
	for(int i=0;i<M;++i){
		vector<vector<int> >bridgetmp=bridgearr;
		bridgetmp[i]=breakbridge;
		/*
		for(int j=0;j<M;++j){
			cout<<bridgetmp[j][0]<<" "<<bridgetmp[j][1]<<endl;
		}
		*/
		map<int,int>vertex;
		stack<int>S;
		S.push(0);
		int state;
		int tmpans=0;
		//cout<<endl;
		//cout<<i<<endl;
		// DFSによりグラフ全体が非連結であるかを調べる
		while(!S.empty()){
			state=S.top();
			//cout<<state<<endl;
			S.pop();
			if(vertex[state]==0){
				vertex[state]=1;
				tmpans++;
			}
			if(tmpans==N){
				//cout<<"ans"<<endl;
				ans++;
				break;
			}
			for(int j=0;j<M;++j){
				if(bridgetmp[j][0]==state && vertex[bridgetmp[j][1]]==0){
					S.push(bridgetmp[j][1]);
				}
				else if(bridgetmp[j][1]==state && vertex[bridgetmp[j][0]]==0){
					S.push(bridgetmp[j][0]);
				}
			}
		}
	}
	cout<<M-ans<<endl;
}


Measured memory_bytes: 256
# 10
import sys
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if ((x + y) % 2) != (t % 2):
        print('No')
        sys.exit()
    if t < x + y:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    long a,b,c,d;
    cin >> a >> b >> c >> d;
    long const mod = 998244353;
    vector<vector<long> >dp(c+3000,vector<long>(d+3000));
    dp[a][b] = 1;
    for(long i=1;i<=(c+d-a-b);i++){
        for(long j=max(0L,b+i-d);j<=min(i,c-a);j++){
            dp[a+j][b+i-j] = dp[a+j-1][b+i-j] * (b+i-j) + dp[a+j][b+i-j-1] * (a+j) - dp[a+j-1][b+i-j-1] * (a+j-1) * (b+i-j-1);
            while(dp[a+j][b+i-j] < 0){
                dp[a+j][b+i-j] += mod * 10000000;
            }
            dp[a+j][b+i-j] %= mod;
            // dp[a+j][b+i-j] %= mod;
            
        }
        
    }
    cout << dp[c][d] << endl;
}

Measured memory_bytes: 284524
import itertools

n=int(input())
name=("M","A","R","C","H")
name_cnt={}
for i in range(n):
    s=input()
    s0 = s[0]
    if s0 in name:
        if s0 in name_cnt.keys():
            name_cnt[s0] += 1
        else:
            name_cnt[s0] = 1
l=list(name_cnt.keys())

if len(l) < 3:
    print(0)
elif len(l) == 3:
    ans=1
    for v in name_cnt.values():
        ans *= v
    print(ans)
else:
    ans=0
    for c in itertools.combinations(l,3):
        ans1=1
        for i in c:
            ans1 *= name_cnt[i]
        ans += ans1
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    int d = 0;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a%4 == 0) ans++;
        else if (a%2 == 0) d++;
    }

    cout << ((ans+d/2)>=n/2?"Yes":"No") << endl;
}


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

int main(){
    int h, w;
    cin >> h >> w;

    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }

    int frag = 0;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
                cout << c[i][j];
        }
        cout << endl;

        if(frag == 0){
            frag++;
            i--;
        }else{
            frag--;
        }
        //t << i << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,count=0;
  cin >> A >> B;
  for(int i=A; i<=B; i++){
    if(i/10000==i%10 && (i/1000)%10==(i%100)/10) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int l[4], r[4];

int main()
{
    double a, b;
    
    while(cin >> a >> b)
    {
        l[a < 0.2 ? 3 : a < 0.6 ? 2 : a < 1.1 ? 1 : 0]++;
        r[b < 0.2 ? 3 : b < 0.6 ? 2 : b < 1.1 ? 1 : 0]++;
    }
    
    for(int i = 0; i < 4; i++)
    {
        cout << l[i] << ' ' << r[i] << endl;
    }
    
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    if(x%2==1&&i%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
N, Y = map(int, input().split())

a = 0

for i in range(N+1):

    for ii in range(N+1):

        iii = N - i - ii

        if iii < 0:
            break
        ans = 10000 * i + 5000 * ii + 1000 * iii
        if ans == Y:
                print(i,ii,iii)
                a += 1
                break

    if a != 0:
        break

if a == 0:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a1,a2,a3;

    scanf("%d%d%d", &a1, &a2, &a3);

    {
        if ((a1+a2+a3)>=22)
        {
            printf("bust\n");
        }

        else
        {
            printf("win\n");
        }
    }

    return 0;

}





Measured memory_bytes: 128
let array = [ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 ]
let input_line: Int = Int(readLine()!)!
let number = input_line - 1
print(array[number])

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <string>
using namespace std;

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

    string s, t;
    cin >> s >> t;

    int64_t l = n * m / __gcd(n, m);

    map<int64_t, int> a;

    for (int i = 0; i < n; i++) {
        a[i * l / n] = i;
    }

    for (int i = 0; i < m; i++) {
        if (a.count(i * l / m) && s[a[i * l / m]] != t[i]) {
            cout << -1 << endl;

            return 0;
        } 
    }

    cout << l << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
const double PI = acos(-1.0);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    REP(i, N){
        int a, b;
        cin >> a >> b;
        ans += b-a+1;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[3005][3005];

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < t.size(); j++)
        {
            if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
            dp[i+1][j+1] = max(dp[i+1][j], dp[i+1][j+1]);
        }
    }
    string ans = "";
    int i = s.size(), j = t.size();
    while (i>0 && j>0) {
        if(dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else {
            ans = s[i-1] + ans;
            i--, j--;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 38808
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef unsigned long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


LL dp[102][100];

int main(){
    LL N;cin >> N;
    vector<LL> v(101,0);
    for (int i = 2; i <= N; i++) {
        int t=i;
        for (int j = 2; j <= N; j++) {
            while(t%j==0){
                v[j]++;
                t/=j;
            }
        }
    }
    dp[0][1]=1;
    for (int i = 0; i <= N; i++) {
        for (int j = 1; j <= 75; j++) {
            for (int k = 0; k <= v[i]; k++) {
                if(j*(k+1)<=75) dp[i+1][j*(k+1)]+=dp[i][j];
            }
        }
    }
    cout << dp[N+1][75] << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  
  sort(p.begin(), p.end());
  
  int total_price = 0;
  for(int i = 0; i < k; i++) total_price += p[i];
  
  cout << total_price << endl;
    
}

Measured memory_bytes: 3632
while 1:
    (H, W) = [int(num) for num in input().split()]
    if H == W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7012