akhauriyash/Code-Regression huggingface dataset:
import math

class Point:
    def __init__(self,arg_x,arg_y):
        self.x = arg_x
        self.y = arg_y


def roll(div1,div2):
    tmp_start = Point(div2.x-div1.x,div2.y-div1.y)
    tmp_end = Point(tmp_start.x*math.cos(math.pi/3) -tmp_start.y*math.sin(math.pi/3),
                    tmp_start.x*math.sin(math.pi/3) + tmp_start.y*math.cos(math.pi/3))
    ret = Point(tmp_end.x + div1.x,tmp_end.y + div1.y)
    return ret;


def outPut(point):
    print("%.8f %.8f"%(point.x,point.y))


def calc(left,right,count):
    div1 = Point((2*left.x + right.x)/3,(2*left.y + right.y)/3)
    div2 = Point((2*right.x + left.x)/3,(2*right.y + left.y)/3)
    peek = roll(div1,div2)

    if count > 1:
        calc(left,div1,count-1)
        calc(div1,peek,count-1)
        calc(peek,div2,count-1)
        calc(div2,right,count-1)
    else:
        outPut(left);
        outPut(div1);
        outPut(peek);
        outPut(div2);


N = int(input())
left = Point(0,0)
right = Point(100,0)

if N == 0:
    outPut(left)
    outPut(right)
else:
    calc(left,right,N)
    outPut(right)


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

int main(void) {
    int n;
    std::vector<int> a;
    int tmp;

    std::cin >> n;
    a.resize(n);
    for(int i = 1; i < n; i++) {
        std::cin >> tmp;
        a[--tmp]++;
    }

    for(int i = 0; i < n; i++) {
        std::cout << a[i] << std::endl;
    }

    return 0;
}


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

using namespace std;

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

long long  N;
long long count(long long sum, bool seven, bool five, bool three){
    if(sum > N)return 0;
    if(seven*five*three)return 1 + count(sum*10 + 7, true, five, three) + count(sum*10 + 5, seven, true, three) + count(sum*10 + 3, seven, five, true);
    else return count(sum*10 + 7, true, five, three) + count(sum*10 + 5, seven, true, three) + count(sum*10 + 3, seven, five, true);
}
int main(){
    cin >> N;
    cout << count(7, true, false, false) + count(5, false, true, false) + count(3, false, false, true);

    
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    for (int i=0; i<n/2; i++) {
        if (s[i] != s[n-i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i=0; i<(n-1)/4; i++) {
        if (s[i] != s[((n-1)/2)-i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char A[999],B[999],C[999];
int a,b,c,va,vb,v;
int main(){
	scanf("%*d");
	while(~scanf("%s%s",A,B)){
		a=strlen(A),b=strlen(B);
		while(a|b|v){
			va=(a?A[--a]-'0':0);
			vb=(b?B[--b]-'0':0);
			v+=va+vb;
			C[c++]=v%10+'0';
			v/=10;
		}
		if(c>80)
			puts("overflow");
		else{
			for(;c--;)
				putchar(C[c]);
			puts("");
		}
		c=0;
	}
}

Measured memory_bytes: 0
# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_d
# 22:25-23:08 give up
# 12:18-12:31 done


def main2():
    N, H = map(int, input().split())
    ab = [None] * N
    for i in range(N):
        ab[i] = list(map(int, input().split()))
    ab = sorted(ab, key=lambda x: x[1], reverse=True)

    a_maxs = [None] * N
    a_max = ab[-1][1]
    for i in range(N-1, -1, -1):
        a, _ = ab[i]
        if a > a_max:
            a_max = a
        a_maxs[i] = a_max
    
    # b_maxs = [None] * N
    # b_max = ab[]

    counts = [None] * (N+1)
    throw_dmg = 0
    for k in range(N+1):  # k回目まで投げる
        if k > 0:
            throw_dmg += ab[k-1][1]

        rest = H - throw_dmg

        if k == N:
            counts[k] = 10**10 if rest > 0 else k
            continue
        
        last_throw_dmg = ab[k][1]  # k < N

        # if a_max[k] >= 

        if rest <= 0:
            counts[k] = k
        # elif k == N:  # N回目まで投げても体力が残っていた場合（答えにはなり得ない）
        #     counts[k] = 10**10
        elif rest % a_maxs[k] == 0:
            counts[k] = k + rest // a_maxs[k]
        else:
            counts[k] = k + rest // a_maxs[k] + 1
    print(counts)
    return min(counts)


def main():
    N, H = map(int, input().split())
    ab = [None] * N
    for i in range(N):
        ab[i] = list(map(int, input().split()))
    ab = sorted(ab, key=lambda x: x[1], reverse=True)

    a_max = max([a for a, _ in ab])

    throw_dmg = 0
    n_throw = 0
    for _, b in ab:
        if b > a_max:
            throw_dmg += b
            n_throw += 1
            if throw_dmg >= H:
                return n_throw
        else:
            break

    rest = H - throw_dmg

    if rest % a_max == 0:
        return rest // a_max + n_throw
    else:
        return rest // a_max + 1 + n_throw


print(main())


Measured memory_bytes: 29736
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, N) FOR(i, 0, N)
#define SZ(x) ((int)(x).size())
 
const int MAXN = 57, INF = 100000007;
 
int main()
{	
	int N, p;
	ll a[MAXN], K = 0;
	cin >> N;
	REP(i, N) cin >> a[i];
	while (true){
		p = 0;
		REP(i, N) if (a[i] > a[p]) p = i;
		if (a[p] < N) break;
		K += a[p]/N;
		REP(j, N) if (j != p) a[j] += a[p]/N;
		a[p] -= N*(a[p]/N);		
	}
	cout << K;
	//cout << endl; system("pause");//please
	return 0;
}//don't forget about const, please

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AN {
public:
	void solve(istream& in, ostream& out) {
        int n;
        in >> n;
        if(n == 1) out << 1 << endl;
        else out << (1 + n) * n / 2 << endl;
	}
};

int main() {
	AN solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a;
	string res;
	cin >> a >> res;
	if (a >= 3200)
		cout << res << endl;
	else
		cout << "red\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
  { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 300009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 1e9 + 7;
class {
 public:
  void solve() {
    int n;
    cin >> n;
    vector<i64> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    i64 ans = 0, two = 1;
    for (int i = 0; i <= 60; ++i) {
      i64 zero = 0, one = 0, count = 0;
      for (int j = 0; j < n; ++j)
        if (a[j] >> i & 1ll)
          one++;
        else
          zero++;
      // for (int j = 0; j < n - 1; ++j) {
      //   if (a[j] >> i & 1ll) {
      //     one--;
      //     count += zero;
      //   } else {
      //     zero--;
      //     count += one;
      //   }
      // }
      (ans += two * one % MOD * zero % MOD) %= MOD;
      two = two * 2 % MOD;
    }
    cout << (ans % MOD + MOD) % MOD << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 2560
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
#define EPS (1e-10)
#define X real()
#define Y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;

double cross(P a, P b){ return a.X*b.Y - a.Y*b.X;}

vector<double> malfatti_circle(P a, P b, P c){
  const double A = abs(b-c), B = abs(a-c), C = abs(a-b), r = abs(cross(b-a,c-a))/(A+B+C),
    x = (-A+B+C)/2.0/r, y = (A-B+C)/2.0/r, z = (A+B-C)/2.0/r;
  vector<double> ret(3);
  double r_a, r_b, r_c, small = 0.0, large = r;
  for(int i = 0; i < 100; ++i){
    r_a = (small+large)/2.0;
    //printf("r_a = %.12f\n", r_a);
    double s = y*y, t = x*y*r_a - C*y - 2*r_a, u = C*C - 2.0*C*x*r_a + x*x*r_a*r_a;
    r_b = (-t - sqrt(t*t - s*u))/s;
    //printf("r_b = %.12f\n", r_b);
    //printf("s*r_b*r_b + 2*t*r_b + u = %.12f\n", s*r_b*r_b + 2*t*r_b + u);
    //printf("2*sqrt(r_a*r_b) + y*r_b + x*r_a = %.12f, C = %.12f\n", 2*sqrt(r_a*r_b) + y*r_b + x*r_a, C);
    s = z*z;
    t = x*z*r_a - B*z - 2*r_a;
    u = B*B - 2.0*B*x*r_a + x*x*r_a*r_a;
    r_c = (-t - sqrt(t*t - s*u))/s;
    //printf("r_c = %.12f\n", r_c);
    //printf("2*sqrt(r_a*r_c) + z*r_c + x*r_a = %.12f, B = %.12f\n", 2*sqrt(r_a*r_c) + z*r_c + x*r_a, B);

    //printf("2*sqrt(r_b*r_c) + y*r_b + z*r_c = %.12f, A = %.12f\n", 2*sqrt(r_b*r_c) + y*r_b + z*r_c, A);
    if(2*sqrt(r_b*r_c) + y*r_b + z*r_c > A){
      small = r_a;
    }else{
      large = r_a;
    }
  }
  ret[0] = r_a;
  ret[1] = r_b;
  ret[2] = r_c;
  return ret;
}

int main(){
  double x_a, y_a, x_b, y_b, x_c, y_c;
  while(cin >> x_a >> y_a >> x_b >> y_b >> x_c >> y_c, x_a||y_a||x_b||y_b||x_c||y_c){
    P a = P(x_a,y_a), b = P(x_b,y_b), c = P(x_c,y_c);
    vector<double> R = malfatti_circle(a,b,c);
    for(int i = 0; i < 3; ++i){
      printf("%.12f", R[i]);
      if(i < 3) cout << " ";
    }cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3244
import java.util.*;

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

        String[] s = new String[N];
        for(int i = 0; i < N; i++)
            s[i] = sc.next();       
        
        long count = 0;
        int[][] str = new int[N][26];
        String[] str2 = new String[N];
        for(int j = 0; j < N; j++){
            for(int i = 0; i < s[j].length(); i++){
                if(s[j].charAt(i) == 'a')
                    str[j][0]++;
                if(s[j].charAt(i) == 'b')
                    str[j][1]++;
                if(s[j].charAt(i) == 'c')
                    str[j][2]++;
                if(s[j].charAt(i) == 'd')
                    str[j][3]++;
                if(s[j].charAt(i) == 'e')
                    str[j][4]++;
                if(s[j].charAt(i) == 'f')
                    str[j][5]++;
                if(s[j].charAt(i) == 'g')
                    str[j][6]++;
                if(s[j].charAt(i) == 'h')
                    str[j][7]++;
                if(s[j].charAt(i) == 'i')
                    str[j][8]++;
                if(s[j].charAt(i) == 'j')
                    str[j][9]++;
                if(s[j].charAt(i) == 'k')
                    str[j][10]++;
                if(s[j].charAt(i) == 'l')
                    str[j][11]++;
                if(s[j].charAt(i) == 'm')
                    str[j][12]++;
                if(s[j].charAt(i) == 'n')
                    str[j][13]++;
                if(s[j].charAt(i) == 'o')
                    str[j][14]++;
                if(s[j].charAt(i) == 'p')
                    str[j][15]++;
                if(s[j].charAt(i) == 'q')
                    str[j][16]++;
                if(s[j].charAt(i) == 'r')
                    str[j][17]++;
                if(s[j].charAt(i) == 's')
                    str[j][18]++;
                if(s[j].charAt(i) == 't')
                    str[j][19]++;
                if(s[j].charAt(i) == 'u')
                    str[j][20]++;
                if(s[j].charAt(i) == 'v')
                    str[j][21]++;
                if(s[j].charAt(i) == 'w')
                    str[j][22]++;
                if(s[j].charAt(i) == 'x')
                    str[j][23]++;
                if(s[j].charAt(i) == 'y')
                    str[j][24]++;
                if(s[j].charAt(i) == 'z')
                    str[j][25]++; 
            }
            str2[j] = Arrays.toString(str[j]);
        }

        long first = 1;
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < N; i++){
            if(map.containsKey(str2[i])){
                map.put(str2[i], map.get(str2[i])+first);
            } else {
                map.put(str2[i], first);
            }
        }

        for(long val: map.values()){
            count += comb2(val);
        }
        System.out.println(count);
        sc.close();
    }

    static long comb2(long n){
        return n * (n-1) / 2;
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
char s[100][101];
bool used[100][100];
int sz[5];
int cnt[26];

int main() {
    scanf("%d%d", &n, &m);
    forn(i, n) scanf("%s", s[i]);
    forn(i, n) forn(j, m) {
        ++cnt[s[i][j] - 'a'];
    }
    forn(i, n) forn(j, m) {
        if (used[i][j]) {
            continue;
        }
        vector<PII> v;
        forn(p, 2) forn(q, 2) {
            int ni = (p ? i : (n - 1 - i));
            int nj = (q ? j : (m - 1 - j));
            if (used[ni][nj]) {
                continue;
            }
            used[ni][nj] = true;
            v.pb(mp(ni, nj));
        }
        ++sz[v.size()];
    }
    for (int i = 4; i >= 1; --i) {
        forn(_, sz[i]) {
            bool ok = false;
            forn(j, 26) if (cnt[j] >= i) {
                cnt[j] -= i;
                ok = true;
                break;
            }
            if (!ok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <string.h>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;



int main(){
  int N,K;
  cin>>N>>K;
  string str;
  cin>>str;
  str[K-1]=str[K-1]-'A'+'a';
  cout<<str;
return 0;
}


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

int main(){
  int n,m,l,r;
  cin >> n >> m;
  int bottom=0,upper=n;
  for (int i=0; i<m; i++){
    cin >>l >>r;
    bottom = max(bottom,l);
    upper = min(upper,r);
  }
  if (upper-bottom+1<0)cout << 0 << endl;
  else cout << upper - bottom + 1 << endl;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      if(4*i+2*j==y && i+j==x){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define INF 1 << 29

int N,A,B,C;
int l[8];

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int dfs(int cur,int a,int b,int c){
  if(cur == N){
    if(min(a,min(b,c)) > 0)
      return abs(a-A)+abs(b-B)+abs(c-C)-30;
    else
      return INF;
  }

  int ret0 = dfs(cur+1,a,b,c);
  int ret1 = dfs(cur+1,a+l[cur],b,c)+10;
  int ret2 = dfs(cur+1,a,b+l[cur],c)+10;
  int ret3 = dfs(cur+1,a,b,c+l[cur])+10;

  return min(min(ret0,ret1),min(ret2,ret3));
}

int main(void){
  scanf("%d%d%d%d",&N,&A,&B,&C);
  for(int i = 0;i < N;i++) scanf("%d",&l[i]);

  printf("%d\n",dfs(0,0,0,0));

  return 0;
}

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

int main() {
    ll h,w,tmp=0;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    bool flag = true;
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            cin>>a[i][j];
        }
    }
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            if(a[i][j] == '#') {
                if(tmp > j) flag = false;
                else tmp = j;
            }
        }
    }
    if(flag) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	maxi := 0
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
		maxi = max(maxi, a[i])
	}
	midi := float64(maxi) / 2.0
	ans := a[0]
	mind := 1e9 + 1.0
	for i := 0; i < n; i++ {
		d := abs(midi - float64(a[i]))
		if mind > d && a[i] != maxi {
			mind = d
			ans = a[i]
		}
	}
	fmt.Println(maxi, ans)
}
func abs(a float64) float64 {
	if a >= 0 {
		return a
	}
	return -a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 3072
n = int(input())
a = list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(n):
  if((a[i] % 2) == 0):
    cnt += 1
    if((((a[i] % 3) != 0)) and ((a[i] % 5) != 0)):
      print("DENIED")
      exit()
print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>a,b,c,d;
int n,m,q;
int ans = 0;
void brute(int sz,int last,vector<int>v){
if(sz==n){
        int sum = 0;
    for(int i = 0;i<q;i++){
        if(c[i]==v[b[i]-1]-v[a[i]-1]){
            sum += d[i];
        }
    }
    ans = max(ans,sum);
}
else{
    for(int i = last;i<=m;i++){
        v[sz] = i;
        brute(sz+1,i,v);
    }
}
}
int main(){
cin >> n >> m >> q;
a.resize(q);
b.resize(q);
c.resize(q);
d.resize(q);
for(int i = 0;i<q;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
}
vector<int>v(n);
for(int i = 1;i<=m;i++){
    v[0] = i;
    brute(1,i,v);
}
cout << ans;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N;
	cin >> N;
		vec(A);
		int sum = 0;
		fx(N) {
			vecp(A);
			sum ^= A[x];
		}
		fx(N) {
			cout << (sum ^ A[x]) << " \n"[x == N - 1];
		}
    return 0;
}



Measured memory_bytes: 4324
#include <iostream>

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9 + 7;

int a[N];

int main() {
	int n, cost = inf, mn = inf, mx = -inf;
	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	for (int i = mn; i <= mx; i ++) {
		int sum = 0;
		for (int j = 0; j < n; j ++) {
			sum += (a[j] - i) * (a[j] - i);
		}
		if (sum < cost) {
			cost = sum;
		}
	}
	cout << cost << endl;
	return 0;
}


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

const int mod = 1000000007;

int fac(int N) {
  if(N < 0) return 0;
  if(N == 1 || N == 0) return 1;
  int n = 1;
  while(N>0) {
    n *= N;
    n %= mod;
    N--;
  }
  return n;
}

signed main() {
  int N, M; cin >> N >> M;
  
  if(abs(N-M) > 1) {
    cout << 0 << endl;
    return 0;
  }
  
  if(abs(N-M) == 0) cout << (fac(N)*fac(M)*2)%mod << endl;
  else cout << (fac(N)*fac(M))%mod << endl;

}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int k = 0;
		while (k == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int H = Integer.parseInt(x[0]);
			int W = Integer.parseInt(x[1]);
			if (H == 0 && W == 0) {
				break;
			}
			int i = 0;
			String str = "";
			while (i < W) {
				str += "#";
				i++;
			}
			int j = 0;
			while (j < H) {
				System.out.println(str);
				j++;
			}
			System.out.println("");
		}
	}

}

Measured memory_bytes: 27608
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i32 n, a, b;
    std::cin >> n >> a >> b;
    std::cout << (std::abs(a-b)%2 ? "Borys" : "Alice") << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,x,i,l,s=0;
  cin >> n >> x;
  for (i=0;i<n;i++){
    cin >> l;
    s+=l;
    if (s>x) break;
  }
  cout << i+1 << endl; 
  return 0;
}

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

int main() {
  long long N;
  cin >> N;
  long long A, B;
  cin >> A >> B;
  long long count = N / (A + B);
  N %= A + B;
  if (N <= A) cout << count * A + N << endl;
  else cout << count * A + A << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int main(){
	boost;
	int a,b,c;
	cin>>a>>b>>c;
	if(c+b<=a)cout<<0;
	else cout<<c-(a-b);
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
    ll N;
    cin >> N;

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    N = N / 2;
    
    ll ans = 0;
    while (N >= 5) {
        N = N / 5;
        ans += N;    
    }
        
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type Set struct {
	before int
	after  int
}

func main() {
	var n int
	s := wordScanner()
	scanInts(s, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanInts(s, &a[i])
	}

	var bmax, amax int
	l := make([]Set, n)
	for i := 1; i < n; i++ {
		bmax = max(a[i-1], bmax)
		amax = max(a[n-i], amax)
		l[i].before = bmax
		l[n-i-1].after = amax
	}

	for i := range a {
		fmt.Println(max(l[i].before, l[i].after))
	}
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 9728
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        a: i32,
        b: i32,
    }
    println!("{}", min(n * a, b));
}

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

int main(){
    int n,l;
    cin>>n>>l;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int rope=0;
    bool ok=false;
    rep(i,n-1){
        if(a[i]+a[i+1]>=l){
            ok=true;
            rope=i+1;
        }
    }
    if(!ok)cout<<"Impossible"<<endl;
    else{
        cout<<"Possible"<<endl;
        for(int i=1; i<=n-1; ++i){
            if(i<rope)cout<<i<<endl;
        }
        for(int i=n-1; i>=0; --i){
            if(i>rope)cout<<i<<endl;
        }
        cout<<rope<<endl;
    }
}

Measured memory_bytes: 3784
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var max = 0;
        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            max = Math.Max(max, h[i]);
            if (max <= h[i])
            {
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
function Main(input) {
  input = input.split(' ')
  var a = input[0]
  var b = input[1]
  if (a > 9 || b > 9) {
    console.log(-1)
  } else {
    console.log(a*b)
  }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

bool dis[10];
int n, k;

inline int pow10(int n_) { int ans = 1; for (int i = 0; i < n_; ++i)ans *= 10; return ans; }
inline int log10(int n_) { for (int i = 0; true; ++i)if (pow10(i + 1) > n_)return i; }

int digit(int num,int dig)
{
	return num / pow10(dig) - (num / pow10(dig + 1) * 10);
}

int main()
{
	memset(dis, false, sizeof(dis));
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; ++i)
	{
		int d;
		scanf("%d", &d);
		dis[d] = true;
	}
	for (;;)
	{
		bool flag = true;
		for (int let = log10(n); let >= 0; --let)
		{
			if (dis[digit(n, let)])
			{
				n = (n / pow10(let) + 1) * pow10(let);
				flag = false;
				break;
			}
		}
		if (flag)break;
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
A = list(map(int, input().split()))

vis = set()
vis.add(1)
cnt = 0
cnt2town = {}
town2cnt = {}
cnt2town[0] = 1
town2cnt[1] = 0

cnt = 1
prev = 1
while cnt <= K:
    a = A[prev - 1]

    if a in vis:
        c = town2cnt[a]

        rem = K - cnt
        num_loop = cnt - c

        r = rem % num_loop
        print(cnt2town[c + r])

        exit()

    cnt2town[cnt] = a
    town2cnt[a] = cnt
    vis.add(a)

    prev = a
    cnt += 1


print(a)


Measured memory_bytes: 46248
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n;
std::multiset<long> st;
long ans;

int main(){
	scanf("%ld", &n);
	for(int i = 0; i < n; i++){
		long a;
		scanf("%ld", &a);
		st.insert(a);
	}
	while(st.size()){
		auto it1 = st.end();
		it1--;
		long a = *it1;
		st.erase(it1);
		long sum = 1;
		while(sum <= a){
			sum *= 2;
		}
		long b = sum - a;
		auto it = st.find(b);
		if(it != st.end()){
			st.erase(it);
			ans++;
		}
	}
	printf("%ld\n", ans);
	return 0;
}
		


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 n, k;
    cin >> n >> k;
    vector<i64> v(n);
    for (int i=0 ; i<n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    i64 ans{0};
    for (int i=0; i<k; ++i) {
        ans += v[i];
    }
    cout << ans <<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int W[N];
  int s1 = 0;
  for(int i=0; i<N; i++){
    cin >> W[i];
    s1 += W[i];
  }
  
  int s2 = 0;
  int sa1, sa2;
  int s2_b;
  for(int j=0; j<N; j++){
    s2 += W[j];
    if((s1-s2) <= s2){
      sa1 = s2-(s1-s2);
      s2_b = s2 - W[j]; 
      sa2 = (s1-s2_b)-s2_b;
      if(sa1>sa2){
        cout << sa2;
      }else{
        cout << sa1;
      }
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).ok();
    return word.trim().to_string();
}

fn main() {
    let s: Vec<char> = get_input().chars().collect();
    println!(
        "{}",
        if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] {
            "Bad"
        } else {
            "Good"
        }
    );
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int[] s = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				s[i] = sc.nextInt();
				sum += s[i];
			}
			int max = 0;
			int min = 0;
			for (int i = 0; i < n; i++) {
				if (s[max] < s[i])
					max = i;
				if (s[min] > s[i])
					min = i;
			}
			sum -= (s[max] + s[min]);
			int ave = sum / (n - 2);
			System.out.println(ave);
		}
	}
}

Measured memory_bytes: 29336
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int r; // 現在のレート：画面入力
      int g; // ゴールレート：画面入力
      
      cin >> r >> g;
      cout << g * 2 - r << endl;
      
		// (r+P)/2 = g
        // r+P = g * 2
        // P = g*2 - r
    }


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

typedef long long ll;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cout << fixed << setprecision(15);
  ll n; cin >> n;
  vector<pair<ll,ll>> factors;
  for (ll i = 2; i*i <= n; i++) {
    if (n % i == 0) {
      factors.emplace_back(i, 0);
      while (n % i == 0) {
        factors.back().second++;
        n /= i;
      }
    }
  }
  if (n > 1) factors.emplace_back(n, 1);
  int ans = 0;
  for (auto [f, t] : factors) {
    for (int i = 1; i <= t; i++) {
      t -= i;
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3672
class Node:
    def __init__(self, num=None, parent=None, left=None, right=None, type=None):
        self.num = num
        self.parent = parent
        self.left = left
        self.right = right
        self.type = type

    def __str__(self):
        return str(self.num)

def getType(node):
    if node.parent is None:
        return 'root'
    elif node.left is None and node.right is None:
        return 'leaf'
    else:
        return 'internal node'

def addNodeNumToResult (node, result):
    """
    Add node number to a list (converted to string)
    :param node: a node
    :param result: a list that stores result
    :return: Nothing
    """
    result.append(str(node.num))

def preParse(node, result):
    if node is None:
        return
    addNodeNumToResult(node, result)
    preParse(node.left, result)
    preParse(node.right, result)

def inParse(node, result):
    if node is None:
        return
    inParse(node.left, result)
    addNodeNumToResult(node, result)
    inParse(node.right, result)

def postParse(node, result):
    if node is None:
        return
    postParse(node.left, result)
    postParse(node.right, result)
    addNodeNumToResult(node, result)

# import sys
# sys.stdin = open('input.txt', 'r')

n = int(input())
nodes = []

# Initiate all nodes
for i in range(n):
    node = Node(i)
    nodes.append(node)

# Set parent, left and right from input
for i in range(n):
    num, leftNum, rightNum = map(int, input().split())
    node = nodes[num]
    if leftNum != -1:
        node.left = nodes[leftNum]
        node.left.parent = node
    if rightNum != -1:
        node.right = nodes[rightNum]
        node.right.parent = node

# Get root node
for node in nodes:
    node.type = getType(node)
    if node.type == 'root':
        root = node

result = []
preParse(root, result)
print('Preorder')
print('', end=' ')
print(' '.join(result))

result = []
inParse(root, result)
print('Inorder')
print('', end=' ')
print(' '.join(result))

result = []
postParse(root, result)
print('Postorder')
print('', end=' ')
print(' '.join(result))


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

int main(){
	int N,M;
	cin >> N >> M;
	int H[N];
	for(int i=0;i<N;i++) cin >> H[i];
	int Q[N]={0};

	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		if(H[a-1]>H[b-1]) Q[b-1]++;
		if(H[a-1]<H[b-1]) Q[a-1]++;
		if(H[a-1]==H[b-1]) {
			Q[a-1]++;
			Q[b-1]++;
		}
	}
	int sum =0;

	for(int i=0;i<N;i++){
		if(Q[i]==0) sum++;
	}
	cout << sum << endl;
}




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

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n)
    cin >> a[i];
  rep(i, n)
    cin >> b[i];
  rep(i, n)
    cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());  
  ll ans = 0;
  rep(i, n)
    ans += (lower_bound(a.begin(), a.end(), b[i]) - a.begin()) * (n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin()));
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>

int solve(int i,int m);
int A[20],n;

int main(){
  int q,m[200],i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++){
    if(solve(0,m[i]))
      printf("yes\n");
    else 
      printf("no\n");
  }

  return 0;
}

int solve(int i,int m){
  int res;
  if(m == 0)
    return 1;
  if(i >= n)
    return 0;
  res = solve(i+1,m)+solve(i+1,m-A[i]);
  return res;
}

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

ll n;
ll ma[4], mi[4];
ll ans;
inline void solve(int T) {
    cin >> n;
    ll x, y;
    rep(i, 0, 3) ma[i] = -1e12, mi[i] = 1e12;
    rep(i, 1, n) {
        cin >> x >> y;
        ma[0] = max(ma[0], x + y);
        ma[1] = max(ma[1], -x + y);
        ma[2] = max(ma[2], x - y);
        ma[3] = max(ma[3], -x - y);
        mi[0] = min(mi[0], x + y);
        mi[1] = min(mi[1], -x + y);
        mi[2] = min(mi[2], x - y);
        mi[3] = min(mi[3], -x - y);
    }
    rep(i, 0, 3) ans = max(ma[i] - mi[i], ans);
    cout << ans;
}
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    
    // system("pause");
}

Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
#define lp(i, n)  for(int i=0; i<(int)(n); ++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef long long ll;
typedef double db;
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main()
{

  string s;
   int count=0,mc=0;
   cin>>s;
   for(int i=0 ; i<s.size() ; i++)
   {
       if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
       {
        count++;
        }
        else
        {
            mc=max(mc,count);
            count=0;
        }
   }
mc=max(mc,count);
    cout<<mc;

go;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    string s;
    cin >> n >> s;
    ll count = 0;
    char current = 0;
    for (auto elem : s) {
        if (elem != current) {
            count++;
            current = elem;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n, k, q;
    cin>>n>>k>>q;

    int curr = k-q;
    mi m;
    while(q--){
        int x;
        cin>>x;
        m[x]++;
    }

    for(int i=1;i<=n;i++){
        int win = curr + m[i];

        if(win>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
} 

Measured memory_bytes: 6912
#include <iostream>
#include <math.h>
#include <queue>

using namespace std;

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

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return mod_pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll dp[410][410];


int main() {
    int N, C;
    cin >> N >> C;

    ll a[410], b[410];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }

    ll X[410][410];
    for(ll c = 0; c <= 400; c++){
        ll su = 0;
        for(int x = 0; x <= 400; x++){
            su = add(su, mod_pow(x, c));
            X[c][x] = su;
        }
    }

    for(int i = 0; i < 410; i++){
        for(int j = 0; j < 410; j++){
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= C; j++){
            for(int c = 0; j + c <= C; c++){
//                cout << i << " " << c << " " << " " << dp[i][j] << " " << X[c][b[i]] << " " << X[c][a[i]-1] << endl;
                dp[i+1][j+c] = add(dp[i+1][j+c], mul(dp[i][j], sub(X[c][b[i]], X[c][a[i]-1])));
            }
        }
    }


//    for(int i = 0; i < 3; i++){
//        for(int j = 0; j < 3; j++){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << dp[N][C] << endl;

    return 0;
}

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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif

vector<int> primes;
const int maxN = 1e6+5;
vector<int> p(maxN);

void pre(){
	p[1] = 1;
	p[2] = 0;
	for(ll i=2;i*i<maxN;i++){
		if(p[i]==1){
			continue;
		}
		for(ll j=i*i;j<maxN;j+=i){
			p[j]=1;
		}
	}
	for(int i=2;i<maxN;i++){
		if(p[i]==0){
			primes.push_back(i);
		}
	}
}
vector<int> cnt(maxN+1);
void solve(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;primes[j]*1LL*primes[j]<=a[i];j++){
			if(a[i]%primes[j]==0){
				cnt[primes[j]]++;
				while(a[i]%primes[j]==0){
					a[i] /= primes[j];
				}
			}
		}
		if(a[i] != 1){
			cnt[a[i]]++;
		}
	}
	bool se=true,co= true;
	for(int i=0;i<primes.size();i++){
		if(cnt[primes[i]]==n){
			se = false;
		}
		if(cnt[primes[i]] >=2){
			co = false;
		}
	}
	if(co){
		cout<<"pairwise coprime\n";
	}else if(se){
		cout<<"setwise coprime\n";
	}else{
		cout<<"not coprime\n";
	}
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	pre();
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long ans = 1;
    int n;
    cin >> n;
    for(int i = 1; i<= 3; ++i)
    {
        ans*=n;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
<?php
    $inArray = [];
    while (!feof(STDIN) ) {
        $inArray[] = trim(fgets(STDIN));
    }
    
    $baseStr = $inArray[0].$inArray[0].$inArray[0];
    if(strpos($baseStr, $inArray[1]) === FALSE){
        echo "No\n";
    } else {
        echo "Yes\n";
    }
?>


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n,resw=0,resb=0;
  cin>>s;
  n=s.length();
  for(int i=0;i<n;++i){
    if(i%2){
      if(s[i]=='1')resw++;
      else resb++;
    }
    else{
      if(s[i]=='1')resb++;
      else resw++;
    }
  }
  cout<<min(resw,resb);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> vc;
  for (int i = 1; i * i <= M; i++)
  {
    if (M % i == 0)
    {
      vc.push_back(i);
      vc.push_back(M / i);
    }
  }
  int ans = 0;
  for (int i = 0; i < vc.size(); i++)
  {
    int val = vc[i];
    if (ans < val && val <= M / N)
      ans = val;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()

    e = [0] * (n + 1)

    def num(m):
        return len(list(filter(lambda x: x>= m-1, e)))

    for i in range(2, n+1):
        cur = i
        for j in range(2, i+1):
            while cur % j == 0:
                e[j] += 1
                cur //= j
    
    print(num(75) + num(25)*(num(3) - 1) + num(15)*(num(5) - 1)
        + num(5)*(num(5) - 1)*(num(3) - 2) // 2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3696