akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/
int n;
string s,t;
vector<string>sfi,sse;
signed main() {
	cin>>n;
	rep(i,n){
		cin>>s;
		string s1=s,s2=s;
		rep(j,s.size()){
			if(s1[j]=='?'){
				s1[j]='a';
				s2[j]='z';
			}
		}
		sfi.push_back(s1);
		sse.push_back(s2);
	}
	cin>>t;
	sfi.push_back(t);
	sse.push_back(t);
	sort(all(sfi));
	sort(all(sse));
	int ans1=-1,ans2;
	rep(i,sfi.size()){
		if(sfi[i]==t&&ans1==-1)ans1=i;
		if(sse[i]==t)ans2=i;
	}
	for(int i=min(ans1,ans2)+1;i<=max(ans1,ans2);i++){
		cout<<i<<" ";
	}
	cout<<max(ans1,ans2)+1<<endl;
}


Measured memory_bytes: 1408
# frozen_string_literal: true

# induce sort (internal routine)
def sa_is_induce(s, ls, sum_l, sum_s, lms)
  n = s.size
  sa = [-1]*n

  buf = *sum_s # deep copy
  lms.each{ |lms|
    if lms != n then
      sa[buf[s[lms]]] = lms
      buf[s[lms]] += 1
    end
  }

  buf = *sum_l # deep copy
  sa[buf[s[-1]]] = n-1
  buf[s[-1]] += 1
  sa.each{ |v|
    if v>=1 && !ls[v-1] then
      sa[buf[s[v-1]]] = v-1
      buf[s[v-1]] += 1
    end
  }

  buf = *sum_l # deep copy
  sa.reverse_each{ |v|
    if v>=1 && ls[v-1] then
      buf[s[v-1]+1] -= 1
      sa[buf[s[v-1]+1]] = v-1
    end
  }

  return sa
end

# SA-IS (internal routine)
def sa_is(s, upper)
  n = s.size

  return [] if n == 0
  return [0] if n == 1

  ls = [false]*n
  (n-2).downto(0){ |i|
    ls[i] = s[i]==s[i+1] ? ls[i+1] : s[i]<s[i+1]
  }

  sum_l = [0]*(upper+1)
  sum_s = [0]*(upper+1)
  n.times{ |i|
    if ls[i] then
      sum_l[s[i]+1] += 1
    else
      sum_s[s[i]] += 1
    end
  }
  0.upto(upper){ |i|
    sum_s[i] += sum_l[i]
    sum_l[i+1] += sum_s[i] if i<upper
  }

  lms = (1 ... n).select{ |i| !ls[i-1] && ls[i] }
  m=lms.size
  lms_map = [-1]*(n+1)
  lms.each_with_index{ |lms, id| lms_map[lms] = id }

  sa = sa_is_induce(s, ls, sum_l, sum_s, lms)

  return sa if m == 0

  sorted_lms = sa.select{ |sa| lms_map[sa] != -1 }
  rec_s = [0]*m
  rec_upper = 0
  rec_s[lms_map[sorted_lms[0]]] = 0
  1.upto(m-1){ |i|
    l, r = sorted_lms[i-1, 2]
    end_l = lms[lms_map[l]+1]||n
    end_r = lms[lms_map[r]+1]||n
    same = true
    if end_l-l != end_r-r then
      same = false
    else
      while l < end_l do
        break if s[l] != s[r]
        l+=1
        r+=1
      end
      same = false if l==n || s[l]!=s[r]
    end
    rec_upper += 1 if not same
    rec_s[lms_map[sorted_lms[i]]] = rec_upper
  }

  sa_is(rec_s, rec_upper).each_with_index{ |rec_sa, id|
    sorted_lms[id] = lms[rec_sa]
  }

  return sa_is_induce(s, ls, sum_l, sum_s, sorted_lms)
end

# suffix array for array of integers
def suffix_array(s, upper = nil)
  if not upper then
    # compression
    n = s.size
    idx = (0 ... n).sort_by{ |l, r| s[l] < s[r] }
    t = [0]*n
    upper = 0
    t[idx[0]] = 0
    idx.each_cons(2){ |i, j|
      upper += 1 if s[i] != s[j]
      t[j] = upper
    }
    s = t
  end

  return sa_is(s, upper)
end

# suffix array for string
def suffix_array(s)
  return sa_is(s.bytes, 255)
end

# lcp array for array of integers
def lcp(s, sa)
  n = s.size
  rnk = [0]*n
  sa.each_with_index{ |sa, id|
    rnk[sa] = id
  }
  
  lcp = [0]*(n-1)
  h = 0
  n.times{ |i|
    h -= 1 if h > 0
    next if rnk[i] == 0
    j = sa[rnk[i]-1]
    h += 1 while j+h<n && i+h<n && s[j+h]==s[i+h]
    lcp[rnk[i]-1] = h
  }
  return lcp
end

# lcp array for string
def lcp_array(s, sa)
  return lcp(s.bytes, sa)
end

s = gets.chomp
lcp = lcp_array(s, suffix_array(s))
ans = s.size*(s.size+1)/2
lcp.each{ |lcp|
  ans -= lcp
}
puts ans


Measured memory_bytes: 67204
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long;
using lli = long long int;


void ABC076C()
{
	string S1, T;
	cin >> S1 >> T;

	int nS = S1.size();
	int nT = T.size();
	priority_queue<string, vector<string>, greater<string>> candidates;
	for (int i = 0; i <= nS - nT; ++i)
	{
		string cand(S1);
		for(int k = 0; k < i; ++k)
			cand[k] = S1[k] == '?' ? 'a' : S1[k];

		int j = 0;
		for (; j < nT; ++j)
		{
			char a = S1[i + j];
			char b = T[j];
			if (a != '?' && a != b)
				break;
			cand[i + j] = T[j];
		}
		if (j == nT)
		{
			for(int k = i+ nT; k < nS; ++k)
				cand[k] = S1[k] == '?' ? 'a' : S1[k];
			candidates.push(cand);
		}
	}
	string ret = candidates.empty() ? "UNRESTORABLE" : candidates.top();
	cout << ret << endl;
}

int main()
{
	ABC076C();
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    X = cin.intListList(N)
    R = list(itertools.permutations(range(N)))
    ans = 0
    for p in R:
        l = 0.0
        for i in range(N - 1):
            x = X[p[i + 1]][0] - X[p[i]][0]
            y = X[p[i + 1]][1] - X[p[i]][1]
            l += (x ** 2 + y ** 2) ** 0.5
        ans += l
    ans /= len(R)
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 47344
#include<bits/stdc++.h>
using namespace std;
int nd1[1003][1003],nd0[1003][1003];
int n,k,ans,x,y;
char t;
int qz1[1003][1003],qz0[1003][1003];
int query(int x,int y)
{
	int ans1=0,ans2=0;
	ans1+=qz1[k][k]-qz1[x][k]-qz1[k][y]+qz1[x][y]+qz1[x][y];
	ans1+=qz0[x][k]+qz0[k][y]-qz0[x][y]-qz0[x][y];
	ans2+=qz0[k][k]-qz0[x][k]-qz0[k][y]+qz0[x][y]+qz0[x][y];
	ans2+=qz1[x][k]+qz1[k][y]-qz1[x][y]-qz1[x][y];
	return max(ans2,ans1);
}
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>x>>y>>t;
		int tx=x,ty=y;
		x%=k;y%=k;
		if (x==0)x=k;
		if (y==0)y=k;
		// printf("%d %d\n",x,y);
		if (((abs(tx-x)+abs(ty-y))/k)%2==1)
		{
			if (t=='W')t='B';else t='W';
			// printf("change\n");
		}
		if (t=='W')nd0[x][y]++;else nd1[x][y]++;
	}
	for (int i=1;i<=k;i++)
	{
		for (int j=1;j<=k;j++)
		{
			qz1[i][j]=qz1[i-1][j]+qz1[i][j-1]-qz1[i-1][j-1]+nd1[i][j];
			qz0[i][j]=qz0[i-1][j]+qz0[i][j-1]-qz0[i-1][j-1]+nd0[i][j];
			 // printf("%d ",qz0[i][j]);
		}
		 // printf("\n");
	}
	for (int i=0;i<=k+1;i++)
	{
		for (int j=0;j<=k+1;j++)
		{
			ans=max(ans,query(i,j));
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 16000
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define LL long long
const int N=100005;
LL a[N];
int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,n;LL x,ans=0;
    scanf("%d%lld",&n,&x);
    for (i=1;i<=n;i++) scanf("%lld",&a[i]);
    if (a[1]>x) ans+=a[1]-x,a[1]=x;
    if (a[n]>x) ans+=a[n]-x,a[n]=x;
    for (i=2;i<=n-1;i++)
    {
        LL y=a[i-1]+a[i];
        if (y>x) ans+=y-x,a[i]-=y-x;
    }
    LL y=a[n-1]+a[n];
    if (y>x) ans+=y-x;
    printf("%lld\n",ans);
    
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int k,t,a[102],maxx,sum;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mx(const I&a,const I&b){return a>b ? a : b;}
int main()
{
	//freopen("K Cakes.in","r",stdin);
	//freopen(".out","w",stdout);
	read(k,t);
	for(int i=1;i<=t;i++) 
	{
		read(a[i]);
		maxx=mx(maxx,a[i]);
		sum+=a[i];
	}
	if(sum-maxx>=maxx) printf("0\n");
	else printf("%d\n",maxx-(sum-maxx)-1);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 26 21:20:10 2020

@author: NEC-PCuser
"""

N = (int(input()))

A = list(map(int, input().split()))

A.sort()

ans = 0
for i in range(0, len(A) - 1):
    if A[i] * 2 >= A[i + 1]:
        ans += 1
    else:
        ans = 0
    A[i + 1] += A[i]
        
ans += 1

print(ans)        

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

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


Measured memory_bytes: 256
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]

def hantei(A,x):
  abs_0 = abs(A[0][1]) + abs(A[0][2])
  if A[0][0] < abs_0 or (A[0][0] - abs_0) % 2 != 0:
    return("No")
  for i in range(1, x):
    abs_i = abs(A[i][1] - A[i-1][1]) + abs(A[i][2] - A[i-1][2])
    if A[i][0] - A[i-1][0] < abs_i or (A[i][0] - A[i-1][0] - abs_i) % 2 != 0:
      return("No")
  return("Yes")

print(hantei(txy, N))

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

int main() {
  int N;
  cin >> N;
  
  char c[N];
  for (int i = 0; i < N; i++) cin >> c[i];
  
  vector<int> s_W(N+1, 0), s_E(N+1, 0);
  
  for (int i = 0; i < N; i++) {
    if (c[i] == 'W') {
      s_W[i+1] = s_W[i] + 1;
      s_E[i+1] = s_E[i];
    }
    if (c[i] == 'E') {
      s_W[i+1] = s_W[i];
      s_E[i+1] = s_E[i] + 1;
    }
  }
  
  

  int ans = N;
  for (int i = 1; i < N+1; i++) {
    int x;
    x = s_W[i-1] - s_W[0] + s_E[N] - s_E[i];   

    if (x < ans) ans = x;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 998244353;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

int main() {

	cout << fixed << setprecision(10);
	ll n;
	cin >> n;
	vector<vector<ld> > table(n, vector<ld>(n));
	vector<ld> x(n), y(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}

	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < n; j++)
		{
			table[i][j] = pow((ld)(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2)), 0.5);
		}
	}

	ld sum = 0;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < n; j++)
		{
			sum += table[i][j];
		}
	}
	sum /= n * (n - 1);
	sum *= n - 1;
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define _min(_x, _y) ((_x)>(_y)?(_y):(_x))
#define _abs(_x) ((_x)>0?(_x):(-(_x)))
int main(void)
{
  long N,A,minA,minuscount,index,answer;
  scanf("%ld", &N);
  minA = 1000000000;
  minuscount = 0;
  answer = 0;
  for (index = 0; index < N; ++index) {
    scanf("%ld", &A);
    if (A < 0) minuscount++;
    A = _abs(A);
    answer += A;
    minA = _min(minA, A);
  }    
  if ((minuscount+2)/2 == (minuscount+1)/2) {
    answer -= (minA*2);
  }
  printf("%ld\n", answer);
  return 0;
}

Measured memory_bytes: 128
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
    int a = next<int>(in);
    int b = next<int>(in);
    int c = next<int>(in);
    for (int res = 0; res < 500000; ++res) {
        if ((a & 1) || (b & 1) || (c & 1)) {
            out << res << endl;
            return;
        }
        int a1 = b / 2 + c / 2;
        int b1 = a / 2 + c / 2;
        int c1 = a / 2 + b / 2;
        a = a1;
        b = b1;
        c = c1;
    }
    out << -1 << endl;
}


int main() {
    solve(cin, cout);
    return 0;
}



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

namespace Atcoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split(" ").Select(i=>long.Parse(i)).ToArray();
            long a = input[0];
            long b = input[1];
            Console.Write(a * b);
        }
    }
}


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

using namespace std;

typedef struct task_T
{
        long a;
        long b;
}task_t;

int main(){
        int n;
        cin >> n;
        task_t *ts = new task_t[n];
        for(int i=0;i<n;i++){
                cin >> ts[i].a >> ts[i].b;
        }

        sort(ts, ts+n, [](task_t a, task_t b){return a.b < b.b;});

        long long wa = 0;
        bool bCan = true;
        for(int i=0;i<n;i++){
                wa += ts[i].a;
                if(ts[i].b < wa){
                        bCan = false;
                        break;
                }
        }

        cout << (bCan ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3328
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();
        int dp[] = new int[N];
        for (int i=0;i<N;i++){
        dp[i] = 2147000000;
        }
      
        for(int i=0;i<N;i++){
          list.add(sc.nextInt());
        }
        dp[0] = 0;
        for(int i=0;i<N-1;i++){
          for(int j=1;j<=K;j++){
            if (i+j<=N-1){
          dp[i+j] = Math.min(dp[i]+Math.abs(list.get(i+j)-list.get(i)),dp[i+j]);
          }
          }
        }
      
        System.out.println(dp[N-1]);
    }
}

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

int main() {
  
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int count = 0;
  
  for( int i = 0; i <= a; i++){
    for( int j = 0; j <= b; j++){
      for( int k = 0; k <= c; k++){
        if ( 500 * i + 100 * j + 50 * k == x ){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  return 0;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[8]={-1,-1,-1,0,0,1,1,1},b[8]={-1,0,1,-1,1,-1,0,1},m,n;
int d[10001][10001];
void dfs(int x,int y)
{
	if(d[x][y]==-1)
	return;
	for(int i=0;i<=7;i++)
	{
		int x1=x+a[i],y1=y+b[i];
	    if(x1>=1&&x1<=n&&y1>=1&&y1<=m)
	    {
	    	if(d[x1][y1]==-1)
	    	d[x][y]++;
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		char q;
		cin>>q;
		if(q=='#')
		d[i][j]=-1;
		else
		d[i][j]=0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	dfs(i,j);
	for(int i=1;i<=n;i++)
	{
	for(int j=1;j<=m;j++)
	{
		if(d[i][j]==-1)
		cout<<"#";
		else
		cout<<d[i][j];
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
import numpy as np
MOD = 10**9 + 7
def solve(s):
    a = np.zeros(4, dtype=int)
    a[0] = 1
    for c in s:
        t = 2 * int(c == "?") + 1
        b = t * a % MOD
        if c == "A":
            b[1] += a[0]
        elif c == "B":
            b[2] += a[1]
        elif c == "C":
            b[3] += a[2]
        else:
            b[1:] += a[:-1]
        a = b
    return a[3] % MOD

s = input()
print(solve(s))

Measured memory_bytes: 12616
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

if np.count_nonzero(a < 0) % 2 == 0:
    print(np.abs(a).sum())
else:
    b = np.abs(a)
    m = b.min()
    print(b.sum() - 2 * m)


Measured memory_bytes: 38152
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
    ll n; cin >> n;
    ll ans = 0;

    vector<ll> data(n+1);
    rep(i,n+1) data[i] = i;
    rep(i,n) data[i+1] += data[i];

    loop(i,1,n+1) ans += i*data[n/i];
    cout << ans << endl;
}

Measured memory_bytes: 81400
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abcxy = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var a = abcxy[0];
            var b = abcxy[1];
            var c = abcxy[2];
            var x = abcxy[3];
            var y = abcxy[4];

            var min = Math.Min(x, y);
            var max = Math.Max(x, y);
            var minA = Math.Min(a, 2 * c);
            var minB = Math.Min(b, 2 * c);
            var answer = 0L;
            answer = a * x + b * y;
            answer = Math.Min(answer, 2 * c * max);
            answer = Math.Min(answer, 2 * c * min + minA * (x - min) + minB * (y - min));

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; in(N);
  string S; in(S);

  int close = 0, open = 0;
  rep(i, N) {
    if (S[i] == ')') {
      if (open == 0) ++close;
      else --open;
    } else
      ++open;
  }
  rep(i, close) cout << "(";
  cout << S;
  rep(i, open) cout << ")";
  cout << "\n";


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<int> pvec(100000);
vector<int> mvec(100000);
vector<pair<int, int>> process(100000);

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

    int N, t, p = 0, m = 0;
    cin >> N;

    rep (i, N)
    {
        cin >> t;
        if (t > 0)
        {
            pvec[p++] = t;
        }
        else
        {
            mvec[m++] = t;
        }
    }

    sort(pvec.begin(), pvec.begin() + p);
    sort(mvec.begin(), mvec.begin() + m, greater<int>());

    int ans = 0;
    int itp = 0, itm = 0, ita = 0;
    if (p == 0)
    {
        pvec[0] = mvec[0];
        ++p; ++itm;
    }
    else if (m == 0)
    {
        mvec[0] = pvec[0];
        ++m; ++itp;
    }

    ans = mvec[itm++];
    for (; itp < p - 1; ++itp)
    {
        process[ita++] = {ans, pvec[itp]};
        ans = ans - pvec[itp];
    }
    process[ita++] = {pvec[itp], ans};
    ans = pvec[itp++] - ans;
    for (; itm < m; ++itm)
    {
        process[ita++] = {ans, mvec[itm]};
        ans = ans - mvec[itm];
    }

    cout << ans << "\n";
    rep (i, N - 1)
    {
        cout << process[i].first << " " << process[i].second << "\n";
    }

    return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int A, B, C;
  cin >> A >> B>> C;
  int sum = A + B;

  if (C <= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
 
  int N,count;
int dmin = 100; //問題文では、N個の最大数は200個　全て偶数としたら、１回は割るので、100個分は割ることになる
    cin>>N;
    
    for(int i=0;i<N;i++)
    {
        count = 0;
        int X;
        cin>>X;
       
    
    while(X%2 == 0)
     {
      X/=2;
count++;     
      
       
     }
     dmin = min(dmin, count);// それぞれの数の内最低回数を導く
    }

     cout<<dmin<<endl;
}


Measured memory_bytes: 256
local n=io.read("n")
local a={}
for i=1,n do
    local hat=io.read("n")
    a[hat]=(a[hat] or 0)+1
end

if a[0]==n then
    print("Yes")
elseif n%3==0 then
    local b={}
    local thirds=true
    for hat,number in pairs(a) do
        if number~=n//3 then
            thirds=false
        end
        table.insert(b,hat)
    end
    if a[0]==n//3 and #b==2 then
        print("Yes")
    elseif #b==3 then
        if thirds and b[1]~b[2]~b[3]==0 then
            print("Yes")
        else
            print("No")
        end
    else
        print("No")
    end
else
    print("No")
end

Measured memory_bytes: 6508
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);
  Cin(string, s);

  int ans = 0;
  for (int i = 1; i < n; ++i) {
    string l = s.substr(0, i);
    string r = s.substr(i);

    set<char> sl, sr;
    for (auto e : l) sl.insert(e);
    for (auto e : r) sr.insert(e);

    int cnt = 0;
    for (char c = 'a'; c <= 'z'; ++c) {
      if (sl.count(c) && sr.count(c)) cnt++;
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
ans = 100000000

for i in range(n+1):
  # print(sum(w[:i]), sum(w[i:]))
  tmp = abs(sum(w[:i])-sum(w[i:]))
  if ans > tmp:
    ans = tmp
print(ans)

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

int k, n;
bool D[10];
bool valid(int x){
	while(x>0){
		if(D[x%10]) return false;
		x/=10;
	}
	return true;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<k; i++){
		int d; cin>>d; D[d]=true;
	}
	while(true){
		if(valid(n)){ cout<<n; return 0; }
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
S = input()

c = 0
cum = [c]
for s in S:
    if s == "1":
        c += 1
    else:
        c -= 1
    cum.append(c)
max_cum = [None] * (len(S) + 1)
max_cum[-1] = cum[-1]
for i in reversed(range(len(S))):
    max_cum[i] = max(cum[i], max_cum[i + 1])
z = max_cum[0]


def f(m):
    c = 0
    fz = c
    add = 0
    for i, s in enumerate(S):
        if s == "1":
            c += 1
        elif s == "0":
            c -= 1
            fz = min(fz, c)
        elif add + max_cum[i + 1] + 2 <= m:
            c += 1
            add += 2
        else:
            c -= 1
            fz = min(fz, c)
    return fz


fz = f(z)
fz1 = f(z + 1)

ans = min(z - fz, z + 1 - fz1)
print(ans)

Measured memory_bytes: 158784
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int, int>> v;
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	for(int i=-5200; i<=5200; i++) {
		v.push_back({i*i*i*i*i, i});
	}
	int x;
	cin >> x;
	for(auto [t, i]: v) {
		auto it = lower_bound(v.begin(), v.end(), make_pair(t-x, (int)INT_MIN));
		if(it->first != t-x) continue;
		cout << i << ' '<< it->second;
		break;
	}
}

Measured memory_bytes: 3776
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char w[120],ans[27]="abcdefghijklmnopqrstuvwxyz" ;
    scanf ("%s",w) ;
    for (int i=0; i<strlen(ans); i++){
        int count=0;
        for (int j=0; j<strlen(w); j++){
            if (w[j]==ans[i]){
                count++ ;
            }
        }
        if (count%2!=0){
            printf ("No\n") ;
            exit (0) ;
        }
    }
    printf ("Yes\n") ;
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  bool ans=0;
  cin>>n;
  for(int i=1;i<10;i++){
    for(int j=i;j<10;j++){
      if(n==i*j)
	ans=1;
    }
  }
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
    string a, b;
    cin >> a >> b;

    int n = a.size();
    int m = b.size();

    vector<vector<int> > dp(n + 1, vector<int>(m + 1));

    for(int i = 1; i < n + 1; ++i) {
        for(int j = 1; j < m + 1; ++j) {
            dp[i][j] = max({dp[i - 1][j - 1] + (a[i - 1] == b[j - 1]),
                            dp[i][j - 1],
                            dp[i - 1][j]});
        }
    }

    string out;

    int x = n, y = m;
    while(x > 0 && y > 0) {
        if(a[x - 1] == b[y - 1] && dp[x - 1][y - 1] + 1 == dp[x][y]) {
            out.push_back(a[x - 1]);
            --x;
            --y;
        } else if(dp[x - 1][y] == dp[x][y]) {
            --x;
        } else {
            --y;
        }
    }

    reverse(out.begin(), out.end());

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
#define ite iterator
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
 	return x * f;
}
using namespace std;
const int mod = 1e9 + 7;

const int N = 3e5 + 10;
int *s1[N],*s2[N],s[N],tot[N],cnt;
int id[N],pos[N];
int a[N],sum[N],val[N],inv[N];
int n,num,ans;void inc(int &x,const int &y)
{
	if((x += y) >= mod) x -= mod;
}
 
void ins(int *sum,int n,int p,int v)
{
	while(p <= n) inc(sum[p], v), p += p & -p;
}
 
int qry(int *sum,int p)
{
	int ans = 0;
	while(p) inc(ans,sum[p]), p -= p & -p;
	return ans;
}
 
int qry2(int *sum,int n,int p)
{
	return (qry(sum, n) - qry(sum, p - 1) + mod) % mod;
}
 
il ll qpow(ll x,int y)
{
	ll ans = 1;
	while(y)
	{
		if(y & 1) ans = ans * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return ans;
}
 
int main()
{
	n = read();
	rep(i, 1, n)
	{
		a[i] = read();
		sum[a[i]] ++;
	}
	rrep(i, n - 1, 1) sum[i] += sum[i + 1];
	int lst = 0;
	num = 1;
	rep(i, 1, n)
	{
		int v = sum[i] - n + i;
		if(!v) return puts("0"), 0;
		num = (ll)num * v % mod;
		val[i] = (v - 1) * qpow(v, mod - 2) % mod;
		if(val[i - 1]) val[i] = (ll)val[i] * val[i - 1] % mod;
		inv[i] = qpow(val[i], mod - 2);
		if(!val[i])
		{
			tot[++ cnt] = i - lst;
			rep(j, lst, i - 1) id[j] = cnt, pos[j] = j - lst + 1;
			lst = i;
			val[i] = inv[i] = 1;
		}
	}
	tot[++ cnt] = n + 1 - lst;
	rep(i, 1, cnt)
	{
		s1[i] = new int[tot[i] + 1];
		s2[i] = new int[tot[i] + 1];
		memset(s1[i], 0, sizeof(int)*(tot[i]+1));
		memset(s2[i], 0, sizeof(int)*(tot[i]+1));
	}
	rep(j, lst, n) id[j] = cnt, pos[j] = j - lst + 1;
	ll inv2 = qpow(2, mod - 2);
	rep(i, 1, n)
	 {
		int v=a[i],j=id[v],p=pos[v];
		inc(ans,(ll)num*qry(s2[j],p)%mod*val[v]%mod*inv2%mod);
		inc(ans,(ll)num*((ll)qry2(s,n,v+1)+mod-(ll)qry2(s1[j],tot[j],p+1)*inv[v]%mod*inv2%mod)%mod);
		ins(s1[j],tot[j],p,val[v]);
		ins(s2[j],tot[j],p,inv[v]);
		ins(s,n,v,1);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 25600
#include <iostream>
#include <stdio.h>
#define N 101
#define MAX 1 << 21
using namespace std;

int main(int argc, char *argv[])
{
    int n, q;
    scanf("%d", &n);
    int p[N], m[N][N];
    for (int i = 1; i <= n; i++)
    {
        scanf("%d %d", &p[i - 1], &p[i]);
    }

    for (int i = 1; i <= n; i++)
    {
        m[i][i] = 0;
    }

    for (int l = 2; l <= n; l++)
    {
        for (int i = 1; i <= n - l + 1; i++)
        {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k < j; k++)
            {
                q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
                if (q < m[i][j])
                {
                    m[i][j] = q;
                }
            }
        }
    }

    printf("%d\n", m[1][n]);
    return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int a,b;
    cin >> a >> b;
    int ans = 1;
    int count = 0;
    for (int i = 0; i < a; i++) {
        int y;
        cin >> y;
        count += y;
        if (count <= b)ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
N = int(input())



def check(num):

    if num > N:
        return 0

    # check 753
    str_num =  str(num)

    count = 0

    if "7" in str_num and "5" in str_num and "3" in str_num:
        count += 1

    count += check(num*10 + 7)
    count += check(num*10 + 5)
    count += check(num*10 + 3)
    return count

    
ret = 0
ret += check(7)
ret += check(5)
ret += check(3)
print(ret)


Measured memory_bytes: 46680
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    ll X; cin>> X;
    
    for(ll i=-200;i<200;i++){
        for(ll j=-200;j<200;j++){
            ll temp = pow(i,5) - pow(j,5);
            if(temp == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    
    return 0;
}


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


int solve(int a, int b) {
	if(a<b) swap(a,b);
	int r;
	while(b>0) {
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}

int main() {
	int x,y;
	cin >> x >> y;
	cout << solve(x,y) << endl;
	}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
typedef pair<double,double> Pd;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

struct edge{
	ll to,id;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<vector<edge>> g(n);
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back({b,i});
		g[b].push_back({a,i});
	}
	vector<ll> cnt;
	function<bool(int,int,int)> dfs=[&](int v,int go,int pre){
		if(v==go) return true;
		for(auto itr:g[v]){
			if(itr.to==pre) continue;
			if(dfs(itr.to,go,v)){
				cnt.push_back(itr.id);
				return true;
			}
		}
		return false;
	};
	int m;
	cin>>m;
	vector<ll> num(m,0);
	rep(i,m){
		int u,v;
		cin>>u>>v;
		u--,v--;
		cnt.clear();
		dfs(u,v,-1);
		rep(j,cnt.size()){//u→vと進むときに用いる辺をbitで管理
			num[i]|=(1ll<<cnt[j]);
		}
	}
	ll ans=0;
	rep(i,1ll<<m){
		ll mask=0;
		rep(j,m){
			if(i & 1ll<<j){
				mask|=num[j];
			}
		}
		ll white=__builtin_popcountll(mask);
		ll now=1ll<<(n-1-white);
		if(__builtin_popcountll(i)%2==0) ans+=now;
		else ans-=now;
	}
	cout<<ans<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];

const int mod=1000000007;
int fact[222222],inv[222222];
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int cnt[222222];
int ans[222222];

int C(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

signed main(){
    fact[0]=1;
    for(int i=1;i<222222;i++)fact[i]=fact[i-1]*i%mod;
    inv[222222-1]=mpow(fact[222222-1],mod-2);
    for(int i=222222-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

    cin>>N;
    rep(i,N+1)cin>>A[i],A[i]--;

    rep(i,N+1)cnt[A[i]]++;
    int K=find(cnt,cnt+N,2)-cnt;
    int a=-1,b;
    rep(i,N+1){
        if(A[i]!=K)continue;
        if(a==-1)a=i;
        else b=i;
    }

    for(int i=1;i<=N+1;i++)ans[i]=C(N+1,i);
    int n=a+(N+1-b-1);
    for(int i=1;i<=1+n;i++){
        ans[i]=(ans[i]-C(n,i-1)+mod)%mod;
    }

    for(int i=1;i<=N+1;i++)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 7936
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int N=sc.nextInt();
	int[] buf=new int[N];
	for(int i=0;i<buf.length;i++){
		buf[i]=sc.nextInt();
	}


	int max=buf[0];
	int second=0;
	int num=0;

		for(int i=1;i<N;i++) {
			if(max<buf[i]) {
				second=max;
				max=buf[i];
				num=i;
			}else if(second<buf[i]){
				second=buf[i];
			}


		}
		for(int i=0;i<N;i++) {
			if(i==num) {
				System.out.println(second);
			}else {
				System.out.println(max);
			}
		}
	}

}

Measured memory_bytes: 109800
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main() {

    string S,T; cin>>S>>T;
    int A,B; cin>>A>>B;
    string U; cin>>U;

    if(S == U) A--;
    else B--;

    cout<<A<<" "<<B<<endl;

    return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split());

A = list(map(int, input().split()));


answer = 0;
check = 1;

while(check == 1):
    min = 5000000000000000;
    for i in A:
        if(i < min):
            min = i;

    if(x >= min):
        x -= min;
        answer += 1;
        A.remove(min);
    else:
        check = 0;

if(x > 0 and A == []):
    answer -= 1;

print(answer);


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

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

int N, K;

int main()
{
    int i, j;

    scanf("%d%d", &N, &K);
    if(K==1) printf("0");
    else printf("%d", N-K);
}


Measured memory_bytes: 256
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
//    freopen(NAME".out", "w", stdout);

    int n;
    scanf("%d", &n);
    ll ans = 0LL;

    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += (ll) i;
        }
    }

    printf(lld"\n", ans);

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3828
# Binary search trees - Binary Search Tree I
class Tree:
    def __init__(self):
        self.root = None
        self.size = 0
    
    def printorder(self):
        self._preorder_walk(self.root)
        print()
        self._inorder_walk(self.root)
        print()

    def _inorder_walk(self, nd):
        print(' {0}'.format(nd.key), end='')
        if nd.left: self._inorder_walk(nd.left)
        if nd.right: self._inorder_walk(nd.right)

    def _preorder_walk(self, nd):
        if nd.left: self._preorder_walk(nd.left)
        print(' {0}'.format(nd.key), end='')
        if nd.right: self._preorder_walk(nd.right)

class Node:
    def num_child(self):
        d = 1 if self.left else 0
        d += 1 if self.right else 0
        return d
    def __init__(self, key):
        self.key = key
        self.right,self.left = None,None
        self.parent = None
    def __str__(self):
        return 'node key: ' + str(self.key)

def insert(T, z):
    y = None
    x = T.root
    while not x == None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if z.parent == None:
        T.root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    T.size += 1

m = int(input())
T = Tree()
for _ in range(m):
    ss = input().split()
    op = ss[0]
    if op == 'insert':
        v = int(ss[1])
        insert(T, Node(v))
    if op == 'print':
        T.printorder()


Measured memory_bytes: 153816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   bool isbad = false;
   if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) isbad = true;

   if (isbad) cout << "Bad" << endl;
   else
      cout << "Good" << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main(){
    int N, M, ans = 0;
    cin >> N >> M;
    if (N > 1) {
        ans += comb(N, 2)[N][2];
    }
    if (M > 1) {
        ans += comb(M, 2)[M][2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans=0;
	string s1[100],s2[100];
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>s1[i];
	}
	cin>>b;
	for(int i=0;i<b;i++){
		cin>>s2[i];
	}
	for(int i=0;i<a;i++){
		int sum=0;
		for(int j=0;j<a;j++){
			if(s1[i]==s1[j])
				sum++;
		}
		for(int j=0;j<b;j++){
			if(s1[i]==s2[j])
				sum--;
		}
		if(sum>ans)
			ans=sum;
	}
	cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


L = int(input())


def sanshin(x):
    res = []
    while x > 0:
        res.append(x % 3)
        x = x // 3
    return res


a = sanshin(L)
b = []
L_ = L
for i in range(len(a)):
    L_ -= a[i] * 3**i
    b.append(L_)

N = 14
result = []

for i in range(N-1):
    result.append((i, i+1, 0))
    result.append((i, i+1, 3**i))
    if 2*(3**i) < 10**6:
        result.append((i, i+1, 2*(3**i)))


for i in range(N):
    if i >= len(a):
        break
    if a[i] == 1:
        result.append((i, N, b[i]))
    elif a[i] == 2:
        result.append((i, N, b[i]))
        result.append((i, N, b[i] + 3**i))


M = len(result)
print(N+1, M)
for res in result:
    print(res[0]+1, res[1]+1, res[2])


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 50 + 10;

int n, k;
int a[MAXN];
ll dp[2*MAXN][MAXN][MAXN];

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for(int i=1; i<=n; i++) cin >> a[i];

	for(int i=0; i<2*MAXN; i++)
		for(int x=0; x<MAXN; x++)
			for(int y=0; y<MAXN; y++)
				dp[i][x][y] = -1e15;
	
	dp[0][1][n] = 0;

	ll ans = 0;

	for(int i=0; i<=k; i++){
		for(int x=1; x<=n; x++){
			for(int y=n; y>=x-1; y--){
				//cout << i << " " << x << " " << y << " " << dp[i][x][y] << endl;

				ans = max(ans, dp[i][x][y]);
				dp[i+1][x][y] = max(dp[i+1][x][y], dp[i][x][y]);
				dp[i+1][x+1][y] = max(dp[i+1][x+1][y], dp[i][x][y] + a[x]);
				dp[i+1][x][y-1] = max(dp[i+1][x][y-1], dp[i][x][y] + a[y]);
				dp[i+2][x+1][y] = max(dp[i+2][x+1][y], dp[i][x][y]);
				dp[i+2][x][y-1] = max(dp[i+2][x][y-1], dp[i][x][y]);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3584