akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();

            string[] arS = new string[3];
            arS[0] = s.Substring(0, 1);
            arS[1] = s.Substring(1, 1);
            arS[2] = s.Substring(2, 1);

            int[] flgArray = {0,0,0};

            for(int i = 0; i < 3; i++)
            {
                if(arS[i].Equals("a"))
                {
                    flgArray[0]++;
                }
                else if(arS[i].Equals("b"))
                {
                    flgArray[1]++;
                }
                else if(arS[i].Equals("c"))
                {
                    flgArray[2]++;
                }
            }

            string ans = "No";

            if ((flgArray[0] == 1)
                &&(flgArray[1] == 1)
                &&(flgArray[2] == 1))
            {
                ans = "Yes";
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        String S = sc.next();
        int AplusB = 0;
        int countB = 0;
        PrintWriter out = new PrintWriter(System.out);

        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'a' && AplusB < (A + B)) {
                AplusB++;
                out.println("Yes");
                out.flush();
            } else if (S.charAt(i) == 'b' && AplusB < (A + B) && countB < B) {
                AplusB++;
                countB++;
                out.println("Yes");
                out.flush();
            } else {
                out.println("No");
                out.flush();
            }
        }

        sc.close();
    }
}

Measured memory_bytes: 47756
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M - 1);
    cin >> X;
    sort(ALL(X));
    REP(i, M - 1) {
        Y[i] = X[i + 1] - X[i];
    }
    sort(ALL(Y));
    int ans = 0;
    REP(i, M - 1 - (N - 1)) {
        ans += Y[i];
    }
    cout << ans << endl;
    return (0^_^0);
}



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

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

Measured memory_bytes: 4224
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():

    N, Q = map(int, readline().split())
    C = list(map(int, readline().split()))
    LR = []

    for q in range(Q):
        l, r = map(int, readline().split())
        LR.append((r + 0.1, l, q))

    t = [-1] * (N + 1)
    sect = []
    for i in range(N):
        x = C[i]
        if t[x] != -1:
            sect.append((i + 1, t[x], -1))
        t[x] = i + 1

    sect += LR
    sort_index = sorted(list(range(len(sect))), key=lambda i: sect[i][0])

    bit = [0] * (N + 1)

    def add(i, val):
        while i <= N:
            bit[i] += val
            i += i & -i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i & -i
        return res

    ans = [0] * Q
    for i in sort_index:
        r, l, n = sect[i]
        r = int(r)

        if n == -1:
            add(l, 1)
        else:
            t = sum(r) - sum(l - 1)
            ans[n] = r - l + 1 - t

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 295576
ans = []
n = int(input())
w = list(map(int, input().split()))

for t in range(n):
    s1 = []
    s2 = []
    for i in range(len(w)):
        if t >= i:
            s1.append(w[i])
        elif t < i:
            s2.append(w[i])
    ans.append(abs(sum(s1) - sum(s2)))

print(min(ans))


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

old = 0

for i in range(k,n+1):
  if i == k:
    new = 1
  elif i != k:
    new = a[i-1] / a[i-k-1]
    if new > 1:
      print("Yes")
    else:
      print("No")
  old = new

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

int main(){

    int N;
    cin >> N;

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

    int c=0;//壊すレンガの数
    int cn = 1;

    for(auto x:A){
        if(x==cn)cn++;
        else{
            c++;
        }
    }

    if(c!=N){
        cout << c << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

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

#define int long long

const int N = 1e5 + 10;
int n, sum, ar[N], a[N];

int32_t main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ar[i] = a[i] - x;
	}
	sort(ar, ar + n);
	
	int tmp = 0, x = 0;
	for (int i = 0; i < n; i++)
		if (ar[i] < 0)
			tmp += -ar[i], x++;
	if (!tmp)
		return cout << 0, 0;
		
	for (int i = n - 1; i >= 0; i--) {
		sum += ar[i];
		if (sum >= tmp)
			return cout << x + n - i, 0;
	}
	cout << -1;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  char s[100000];
  scanf("%s", &s);
  int tmp;
  int i;
  int iti = 0;
  int zero = 0;
  //if(large<b){large = b;}
  for(i=0;s[i]!='\0';i++){
    if(s[i] == '0') zero++;
    if(s[i] == '1') iti++;
  }
  int smaller = zero;
  if(smaller > iti) smaller = iti;
  printf("%d", smaller*2);
  return 0;
}


Measured memory_bytes: 256
from itertools import product
S = input()
n = len(S)
bit = list(product([0, 1], repeat = n - 1))
for state in bit:
    ans = int(S[0])
    s = S[0]
    for i in range(len(state)):
        if state[i] == 1:
            s += '+' + S[i + 1]
            ans += int(S[i + 1])
        else:
            s += '-' + S[i + 1]
            ans -= int(S[i + 1])
    if ans == 7:
        print(s + '=7')
        break


Measured memory_bytes: 61840
#include<stdio.h>
int main(){
  int h,y,x,i,bx,by;
  char m[110][110]={0};
  while(scanf("%d %*d",&h),h){
    for(i=0;i<h;i++)scanf("%s",m[i+1]+1);
    y=x=1;
    while(1){
      if(m[y][x]=='#')break;
      if(m[by=y][bx=x]=='.')break;
      if     (m[y][x]=='^')y--;
      else if(m[y][x]=='>')x++;
      else if(m[y][x]=='v')y++;
      else if(m[y][x]=='<')x--;
      m[by][bx]='#';//printf("%d %d\n",y,x);
    }
    if(m[y][x]=='.')printf("%d %d\n",x-1,y-1);
    else            printf("LOOP\n");
  }
  return 0;
}
    
    

Measured memory_bytes: 632
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int main()
{
	int N = ri();
	int K = ri();

	int64_t ans = 0;
	int64_t n = N/K;
	ans += n * n * n;

	if (K % 2 == 0)
	{
		if ((N % K) >= K/2)
			n++;

		ans += n * n * n;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
char s[maxn],t[maxn];
int n,m,i,j;
int gcd(int a,int b){
    #define ctz __builtin_ctz
    int shift=ctz(a|b);
    b>>=ctz(b);
    for(;a;a-=b){
		a>>=ctz(a);
		if (a<b) swap(a,b);
	}return b<<shift;
}
int main(){
	scanf("%d%d%s%s",&n,&m,&s,&t);
	int d=gcd(n,m);
	for(i=0,j=0;i<n;i+=n/d,j+=m/d) if (s[i]!=t[j]) break;
	if (i<n) puts("-1");
	else printf("%lld\n",(ll)n*m/d);
}

Measured memory_bytes: 384
import sys
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())
V = list(map(int, input().split())) 

ans = 0
for l in range(K+1):
    left = V[:l]
    for r in range(K+1):
        if l+r > K or l+r > N:
            break
        if r != 0:
            pick = left + V[-r:]
        else:
            pick = left
        for i in range(K+1):
            if l+r+i >K:
                break
            if l+r >= i:
                pick.sort()
                ans = max(ans, sum(pick[i:]))
print(ans)

Measured memory_bytes: 43228
// A school method based C++ program to check if a 
// number is prime 
#include <bits/stdc++.h> 
using namespace std; 

bool isPrime(int n) 
{ 
	// Corner case 
	if (n <= 1) return false; 

	// Check from 2 to n-1 
	for (int i=2; i<n; i++) 
		if (n%i == 0) 
			return false; 

	return true; 
} 

// Driver Program to test above function 
int main() 
{ 
	long int n,i;
	cin>>n;
	for(i=n;;i++)
	{
		if(isPrime(i))
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0; 
} 


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

namespace B
{
    class Heap<T> : IEnumerable<T> where T : IComparable<T>
    {
        private List<T> data = new List<T>() { default(T) };
        public Heap() { }
        public Heap(T[] array) { data.AddRange(array); }

        public IEnumerator<T> GetEnumerator()
        {
            return data.Skip(1).GetEnumerator();
        }

        public void MaxHeapify()
        {
            for (int i = data.Count / 2; i > 0; i--) MaxHeapify(i);
        }

        IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }

        private void MaxHeapify(int index)
        {
            var left = index << 1;
            var right = left + 1;
            int largest = index;
            if (left < data.Count && data[left].CompareTo(data[largest]) > 0) largest = left;
            if (right < data.Count && data[right].CompareTo(data[largest]) > 0) largest = right;

            if (largest != index)
            {
                var tmp = data[largest];
                data[largest] = data[index];
                data[index] = tmp;
                MaxHeapify(largest);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var array = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var heap = new Heap<int>(array);
            heap.MaxHeapify();
            foreach (var item in heap) Console.Write(" " + item);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 69036
#include <bits/stdc++.h>
using namespace std;
#define ms(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define pr make_pair
#define fi first
#define se second
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double EPS = 1e-8;
const double PI = atan2(-1, 0);
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5 + 5;
vector<pii> mp[100];
void dfs(int n, int pos) {
    if (pos == 1) return;
    if (n == 0) {
        mp[pos - 1].pb(pr(pos, 0));
        dfs(0, pos - 1);
        return;
    }
    if (n % 2 == 0) {
        mp[1].pb(pr(pos, n));
        n--;
    }
    mp[pos - 1].pb(pr(pos, n / 2 + 1));
    mp[pos - 1].pb(pr(pos, 0));
    dfs(n / 2, pos - 1);
}
int main() {
    int n, sum = 0;
    scanf("%d", &n);
    dfs(n - 1, 20);
    for (int i = 1; i <= 20; i++) {
        sum += mp[i].size();
    }
    printf("20 %d\n", sum);
    for (int i = 1; i <= 20; i++) {
        for (auto j : mp[i]) {
            printf("%d %d %d\n", i, j.fi, j.se);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int n, k;
// 市松模様は[0,2k)*[0,2k)のどこを黒い部分の左下にするかという情報で一意に定まる（全単射）ので、そのように表す
// imos[i][j] := (i,j)が黒い部分の左下になるような市松模様を塗った時に叶えられる希望の数
vector<vector<int>> imos(4020, vector<int>(4020, 0));

// (x,y)∈[x-k+1, x]*[y-k+1, y]の範囲でimos[i][j]+=1と累積されるように値をセットする
void set_square(int x, int y){
    if(x<0 || y<0) return;
    imos[ max(0, x-k+1) ][ max(0, y-k+1) ] += 1;
    imos[ max(0, x-k+1) ][y+1] -= 1;
    imos[x+1][ max(0, y-k+1) ] -= 1;
    imos[x+1][y+1] += 1;
}

void set_imos(int x, int y, int k, vector<vector<int>> &imos){
    set_square(x, y);
    set_square(x+k, y-k);
    set_square(x-k, y-k);
    set_square(x+k, y+k);
    set_square(x-k, y+k);
    set_square(x, y+2*k);
}

int main(){
    cin >> n >> k;
    // 入力を受け取り、扱いやすいように希望を同値変形して座標を圧縮する
    // 具体的には全ての希望を、「(x,y)∈[0,2k)*[0,2k)を黒に塗りたいな」という希望に同値変形する
    vector<int> x(n), y(n);
    rep(i, 0, n){
        cin >> x[i] >> y[i];
        char c; cin >> c;
        if(c=='W') x[i] += k;
        x[i]%=2*k; y[i]%=2*k;
    }

    rep(i, 0, n){
        // (x[i],y[i])を黒に塗れるような市松模様(X, Y)について、最後に累積した時に imos[X][Y]+=1 になるように重みを加算する
        set_imos(x[i], y[i], k, imos);
    }

    // 左→右へ累積
    rep(i, 0, 2*k) rep(j, 1, 2*k) imos[i][j] += imos[i][j-1];
    // （問題文の画像で）下→上へ累積
    rep(j, 0, 2*k) rep(i, 1, 2*k) imos[i][j] += imos[i-1][j];

    // 最大値の検索
    int ans=0;
    rep(i, 0, 2*k) rep(j, 0, 2*k) chmax(ans, imos[i][j]);

    cout << ans << '\n';
    return 0;
}


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

int main() {
	long long a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	if (a < b) {
		a += v*t;
		b += w*t;
		if (b <= a) cout << "YES" << endl;
		else cout << "NO" << endl;
	} else {
		a -= v*t;
		b -= w*t;
		if (a <= b) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 3580
N,M,C = [int(x) for x in input().split(' ')]
B =  [int(x) for x in input().split(' ')]
A=[]
for n in range(N):
    A.append([int(x) for x in input().split(' ')])

valid_count = 0
for n in range(N):
    score = 0
    for m in range(M):
        score += A[n][m]*B[m]
    if score + C > 0:
        valid_count +=1
print(valid_count)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
	int i, j, k;
	int build[4][3][10];
	for(int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k <= 9; k++)
			{
				build [i][j][k]= 0;	
			}
		}
	}
	int n = 0;
	scanf("%d", &n);
	while(n--)
	{
		int b, f, r, v;
		scanf("%d %d %d %d", &b, &f, &r, &v);
		build[b-1][f-1][r-1] += v;
	}
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				printf(" %d", build[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3)
		{
			printf("####################\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2712
#include <stdio.h>
#include <stdlib.h>
#define D 1000000007
int main()
{
    long int m,n,i,j,k,l;
    long long int *x,*y;
    unsigned long long int area=0,width=0,height=0;
    scanf("%ld %ld",&n,&m);
    x=(long long int *)malloc(sizeof(x)*n);
    y=(long long int *)malloc(sizeof(y)*m);
    for(i=0;i<n;i++){
        scanf("%lld",&x[i]);
        width += i*x[i]-(n-i-1)*x[i];
    }
    width=width%D;
    for(i=0;i<m;i++){
        scanf("%lld",&y[i]);
        height += i*y[i]-(m-i-1)*y[i];
    }
    height=height%D;
    printf("%lld\n",(width*height)%D);
    return 0;
}

Measured memory_bytes: 1792
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,m,a,b,c,x,y,z,i,j:Integer;
  breakflag:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(n);
    Readln(m);
    breakflag:=false;

    a:=0;
    b:=-1;
    c:=-1;
    for i:=0 to n do begin
      for j:=0 to n do begin
        if 4000*i+9000*j=m-1000*n then begin
          b:=i;
          c:=j;
          breakflag:=true;
          break;
        end;
        if b+c>n then
          break;
      end;
      if breakflag then
        break;
    end;

    if b=-1 then begin
      a:=-1;
      c:=-1;
    end else begin
      a:=n-b-c;
    end;

    if a<0 then begin
      a:=-1;
      b:=-1;
      c:=-1;
    end;

    Write(c);
    Write(' ');
    Write(b);
    Write(' ');
    Writeln(a);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

a = {}

for i in range(n):
    a[i] = ([int(x) for x in input().split()])

b = {}

for i in range(m):
    b[i] = int(input())

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
        
    print(c)




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

const int mod = 1000000007;

int main() {
  int n,m,k;
  cin >> n>>m>>k;
  if(n==m){
      if(n!=k){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
  }else if(m==k){
      if(n!=k){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
  }else if(n==k){
      if(n!=m){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
	int n;
	cin >> n;
	vector<long> a(n,0),b(n,0);
	for(int i=0;i<n;i++){
		cin >> a[i];
		int x=a[i];
		int cnt=0;
		while(x%2==0){
			cnt++;
			x=x/2;
		}
		b[i]=cnt;
	}
	sort(b.begin(),b.end());
	cout << b[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAX=1000000007;



signed main() {
    string s;
    cin>>s;
    int t=0;
    for(int i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1]){
            t=1;
            break;
        }
    }
    if(t==1)cout<<"Bad";
    else cout<<"Good";

 
   

      return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int max = Math.max(a, Math.max(b, c));
        int middle = 0;
        int min = Math.min(a, Math.min(b, c));
        if (max == a) {
            middle = Math.max(b, c);
        } else if (max == b) {
            middle = Math.max(a, c);
        } else {
            middle = Math.max(b, a);
        }

        int d = Integer.parseInt(String.valueOf(max) + String.valueOf(middle)) + min;

        System.out.println(d);
    }
}

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

using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  
  int sum=0;
  if(n>=2)
  {
    sum+=n*(n-1)/2;
  }
  if(m>=2)
  {
  	sum+=m*(m-1)/2;
  }
  cout<<sum<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  deque<int> d;
  rep(i,n){
    auto id = lower_bound(d.begin(),d.end(),a[i]) - d.begin();
    if(id==0)d.push_front(a[i]);
    else d[id-1]=a[i];
  }
  cout << d.size() << endl;
}

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

int main() {
	int N, d[110], last=200, ans=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d, d + N);
	for (int i = 0; i < N; i++) {
		if (d[i] != last) {
			ans++;
		}
		last = d[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "./bits/stdc++.h"

#include <vector>
#include <iostream>

using namespace std;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);


bool possible(vector<long long> &a,vector<long long> &f,long long k,long long border){
    long long count = 0;
    long long n = a.size();
    vector<long long> g(n);
    for (long long i = 0; i < n; ++i){
        g[i] = border/f[i];
        if (g[i] < a[i]){
            count += a[i]-g[i];
        }
    }
    if (count <= k){
        return true;
    }else{
        return false;
    }
}

int main(void){
    long long n,k;

    cin >> n >> k;

    vector<long long> a(n);
    vector<long long> f(n);
    for (long long i = 0; i < n; ++i){
        scanf("%lld",&a[i]);
    }

    for (long long i = 0; i < n; ++i){
        scanf("%lld",&f[i]);
    }

    sort(a.begin(),a.end());
    sort(f.begin(),f.end());
    long long abo = a[n-1]*f[n-1];
    reverse(f.begin(),f.end());

    // debug(a);

    long long left = 0;
    long long right = abo;

    while (right-left >= 10){
        long long middle = (right+left)/2;
        bool mp = possible(a,f,k,middle);
        if (mp){
            right = middle;
        }else{
            left = middle+1;
        }
    }
    long long ans = 10000000000000000;
    for (long long i = right; i >= left; --i){
        if (possible(a,f,k,i)){
            ans = i;
        }
    }
    cout << ans << endl;

};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};


Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[set() for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].add(b)
  g[b].add(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      l=dfs(j)
      l.append(j)
      return l
      break
  else:
    return []
z=dfs(1)+[1]+dfs(1)[::-1]
print(len(z))
print(*z)


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

#define int long long int
#define all(x) x.begin(),x.end()
#define endl '\n'

#ifndef ONLINE_JUDGE
template<typename T>		
void __p(T a) {
  cerr<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cerr<<"[";
  __p(a.first);
  cerr<<",";
  __p(a.second);
  cerr<<"]";
}
template<typename T>
void __p(std::vector<T> a) {
  cerr<<"[";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cerr<<",]"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr<<name<<" : ";
  __p(arg1);
  cerr<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cerr.write(names,comma-names)<<" : ";
  __p(arg1);
  cerr<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cerr<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif

const int INF = 1e9+5;

void test_case(){
	int n;
	cin>>n;
	vector<int> a(n),dp(n,INF);
	for(int &x : a){
		cin>>x;
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=max(0LL,i-2);j--){
			dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
	}
	cout<<dp[n-1];
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    int T=1;
    //cin>>T;
    for(int TT=1; TT<=T; TT++){
        test_case();
    }

    cerr<<endl<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

    return 0;
}


Measured memory_bytes: 4688
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(m);
	for (int i = 0; i < m; i++) cin >> a[i];
	sort(a.begin(), a.end());
	auto it = upper_bound(a.begin(), a.end(), x);
	int y = it - a.begin();
	cout << min(y, m-y) << endl;
}


Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a;
    cin>>a;
    string s;
    cin>>s;
    for(auto &x:s)
    {
        x = 'A'+((x-'A'+a)%26);
    }
    cout<<s;
    return 0;
}



Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b = na()

print(min(n*a,b))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, A[105], ans=0, sum=0;
    in(N);
    rep(i, N) in(A[i]);
    rep(i, N-1){
        if(A[i]==A[i+1]){
            if(sum==0) sum += 2;
            else sum++;
        }
        else if(sum){
            ans += sum/2;
            sum=0;
        }
    }
    put(ans+sum/2);
    return 0;
}


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

arr = []
for i in range(N):
    arr.append(A[i]-(i+1))

arr = sorted(arr)
diff = 0
for j in range(N//2):
    diff+=abs(arr[N-j-1]-arr[j])
    
print(diff)

Measured memory_bytes: 26180
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)

const temp = (T, x) => T-x*0.006

const Main = () => {
    const N = nextInt()
    const [T, A] = nextIntArray()
    const h = nextIntArray()
    let closest = Number.POSITIVE_INFINITY
    let idx = -1
    for(let i = 0; i<h.length; i++){
        let diff = Math.abs(A-temp(T, h[i]))
        if(diff < closest){
            closest = diff
            idx = i
        }
    }
    console.log(idx+1)
}
Main()


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

int main() {
  int n;
  cin >> n;
  vector<int> s(3);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.at(a - 1)++;
  }
  vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1)));
  for (int k = 0; k <= n; k++) {
    for (int j = 0; j <= n - k; j++) {
      for (int i = 0; i <= n - k - j; i++) {
        if (i == 0 && j == 0 && k == 0) continue;
        if (i) dp[i][j][k] += i * dp[i - 1][j][k] / (i + j + k);
        if (j) dp[i][j][k] += j * dp[i + 1][j - 1][k] / (i + j + k);
        if (k) dp[i][j][k] += k * dp[i][j + 1][k - 1] / (i + j + k);
        dp[i][j][k] += 1.0 * n / (i + j + k);
      }
    }
  }
  cout << setprecision(17) << dp[s.at(0)][s.at(1)][s.at(2)] << endl;
}


Measured memory_bytes: 216832
N, M = map(int, input().split())

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

if ans[0] == 0 and N != 1:
  neg = -1

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if N == 1:
  pass

elif ans[0] == 0:
  ans[0] = 1

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))

Measured memory_bytes: 9236
import collections


k = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
s = 0
for i in c.values():
  s += i * (i - 1) / 2

for i in a:
  j = c[i] - 1
  b = j * (j - 1) // 2
  y = (j + 1) * j // 2
  d = y - b
  print(int(s - d))

Measured memory_bytes: 26780
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

ll N, X;
ll point[100005];

ll gcd(ll a, ll b)
{
    return (a % b) ? gcd(b, a % b) : b;
}


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

    for(int i = 0; i < N; i++)
        cin >> point[i];
    
    sort(point, point + N);

    for(int i = 0; i < N; i++)
        point[i] = abs(X - point[i]);

    ll gcd_max = gcd(point[1] , point[0]);

    if(N > 2)
    {
        for(int i = 2; i < N; i++){
            gcd_max = gcd(point[i] , gcd_max);
        }
    }
    cout << gcd_max << '\n';

}


    


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int n;
vector<int> a;

vector<int> result;

void input()
{
    cin >> n;
    a = vector<int>(n);
    for (int i = 0; i < n; i++) cin >> a[i];
}

void process()
{
    result = vector<int>(n);

    a.insert(a.begin(), 0);
    a.push_back(0);

    int sum = 0;
    for (int i = 0; i < a.size() - 1; i++) sum += abs(a[i + 1] - a[i]);

    for (int i = 1; i < a.size() - 1; i++){
        int ans = sum;
        ans -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
        ans += abs(a[i + 1] - a[i - 1]);

        result[i - 1] = ans;
    }
}

void draw()
{
    for (int i = 0; i < n; i++){
        printf("%d\n", result[i]);
    }
}

int main()
{
    input();
    process();
    draw();

    return 0;
}


Measured memory_bytes: 2040
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
string s;
int cnt[256];
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)cnt[s[i]]++;
	if((cnt['W']>0)==(cnt['E']>0)&&(cnt['N']>0)==(cnt['S']>0))puts("Yes");
	else puts("No");
	return 0;
}


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


using namespace std;


vector<int> CreatePrimes(int n)
{
	bool* work = new bool[n+1];

	fill(work, work+(n+1), true);
	work[0] = work[1] = false;

	vector<int> res;
	res.push_back(2);
	for (int i = 4; i <= n; i += 2)
		work[i] = false;

	for (int i = 3; i <= n; i += 2)
	{
		if (work[i])
		{
			res.push_back(i);
			for (int j = 2*i; j <= n; j += i)
				work[j] = false;
		}
	}

	delete[] work;

	return res;
}

int main()
{
	vector<int> primes = CreatePrimes(51000);
	int n;
	while (scanf("%d", &n) != EOF)
	{
		int minP = *(lower_bound(primes.begin(), primes.end(), n) - 1);
		int maxP = *upper_bound(primes.begin(), primes.end(), n);
		printf("%d %d\n", minP, maxP);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

int dp[41][401][401];
int main() {
  int in(N); int in(M_a); int in(M_b);

  rep(i, 41) rep(j, 401) rep(k, 401) {
    dp[i][j][k] = 1e9;
  }
  dp[0][0][0] = 0;
  rep(i, N) {
    int in(A); int in(B); int in(C);
    rep(a, 401) rep(b, 401) {
      chmin(dp[i+1][a][b], dp[i][a][b]);
      if (a - A >= 0 && b - B >= 0)
        chmin(dp[i+1][a][b], dp[i][a-A][b-B] + C);
    }
  }
  int ans = 1e9;
  rep(i, 100) {
    if (M_a*(i+1) > 400 || M_b*(i+1) > 400)
      break;
    chmin(ans, dp[N][M_a*(i+1)][M_b*(i+1)]);
  }
  if (ans == 1000000000)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 25984
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n,q; cin >> n >> q;
    bool finded=false;
    int x,y,z; x=y=z=-1;
    for(int i=0; i<n+1; i++){
        for(int j=0; j<n+1-i; j++){
            for(int k=0; k<n+1-j; k++){
                if(10000*i+j*5000+k*1000==q && i+j+k==n){
                    x=i;
                    y=j;
                    z=k;
                    break;
                }
            }
        }
    }
    cout << x << " " << y << " " << z << endl;

}

Measured memory_bytes: 256
n,W = map(int,input().split())
wl = []
vl = []
for i in range(n):
    w,v =  map(int,input().split())
    wl.append(w)
    vl.append(v)
s = sum(vl)

dp = [[float("inf")]*(s+1) for _ in range(n+1)]
dp[0][0]=0


for i in range(n):
    for j in range(s+1):
        if vl[i]-j>0:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j],dp[i][j-vl[i]]+wl[i])
        #[print(*dp[l]) for l in range(n+1)]
        #print("---------------")
ans = 0
for i in range(n+1):
    for j in range(s+1):
        if dp[i][j]<=W:
            ans = max(ans,j)
print(ans)

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


int main(){
  int n;
  cin >> n;
  if(n%10==3){
    cout << "bon" << endl;
  }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = __int64_t;

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

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

int dfs(int cur, int a, int b, int c){
  if(cur == N){ //8本目まで見て
    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); //cur本目の竹を使わない
  int ret1 = dfs(cur+1, a+l[cur], b, c) + 10; //cur本目の竹をAの(合成)材料とする
  int ret2 = dfs(cur+1, a, b+l[cur], c) + 10; //cur本目の竹をBの(合成)材料とする
  int ret3 = dfs(cur+1, a, b, c+l[cur]) + 10; //cur本目の竹をCの(合成)材料とする
  return min(min(ret0, ret1), min(ret2, ret3)); //全通りのうち一番小さいコストを出力
}

void solve(){
  cin >> N >> A >> B >> C;
  rep(i, N){
    cin >> l[i];
  }
  cout << dfs(0, 0, 0, 0) << endl;
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    int n;
    cin >> n;
    int count = 0;
    for(int i=1; i<=n; i+=2) {
        int tmp=0;
        for(int j=1; j<=n; j++) {
            if(i%j == 0) tmp++;
        }
        if(tmp == 8) count++;
    }
    cout << count << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int pen = 0, AC = 0;
	int n,m;
	cin >> n >> m;
	int ac[maxn] = {};
	while(m--)
	{
		int id;
		string str;
		cin >> id >> str;
		if(ac[id]==-1) continue;
		if(str=="AC")
		{
			pen += ac[id];
			ac[id] = -1;
			AC++;
		}
		else
		{
			ac[id]++;
		}
	}
	cout << AC << " " << pen << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<string> vec;
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		vec.push_back(s);
	}
	sort(vec.begin(),vec.end());
	string x= "";
	for(int i=0;i<n;i++)
		x = x+vec[i];
	cout<<x;
	return 0;
}
	 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int L[N];
  int i;
  int max = 0, max_n; //maximum, number of maximum
  int sum = 0; //sumation  
  for(i=0; i<N; i++)
    cin >> L[i];

  for(i=0; i<N; i++)
    if(max < L[i]){
      max = L[i];
      max_n = i;
    }

  for(i=0; i<N; i++)
    if(i != max_n)
      sum += L[i];

  if(max < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import queue
while 1:
    n,k=map(int,input().split())
    if n == 0:break
    r=queue.deque(int(input()) for _ in range(k))
    s=t=sum(r)
    for i in range(n-k):
        u=r.popleft()
        v=int(input())
        r.append(v)
        t+=v-u
        s=max(t,s)
    print(s)


Measured memory_bytes: 8948
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

int N;
int main()
{

	string S, T;
	cin >> S >> T;
	vector<string> mm;
	REP(i, S.size() - T.size() + 1)
	{
		bool flag = true;
		REP(j, T.size())
		{
			if(S[i+j]!='?'&&S[i+j]!=T[j]){
				flag = false;
			}
		}
		if(flag){
			string s = S;
			REP(j,s.size()){
				if(s[j]=='?'){
					s[j] = 'a';
				}
			}
			REP(j, T.size())
			{
				s[i + j] = T[j];
			}
			mm.push_back(s);
		}
	}

	if(mm.size()==0){
		cout << "UNRESTORABLE" << endl;
	}else{
		string mi=mm[0];

		REP(i,mm.size()){
			if(mm[i]<mi){
				mi = mm[i];
			}
		}

		cout << mi << endl;

	}

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
C = Counter([input() for _ in range(N)])
# print(f'{list(C)=}')

max_value = max([value for value in C.values()])
# print(f'{max_value=}')

S = [key for key, value in zip(C.keys(), C.values()) if value == max_value]
# print(f'{S=}')

for s in sorted(S):
    print(s)


Measured memory_bytes: 38880
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,n=0;
            Map<Integer,String> map=new HashMap<Integer,String>();
            boolean[][] card=new boolean[4][14];
            while ((line = br.readLine()) != null) {
            	if(first){
            		n=Integer.parseInt(line);
            		map.put(0, "S");
            		map.put(1, "H");
            		map.put(2, "C");
            		map.put(3, "D");
            		first=false;
            	}else{
            		String[] str=line.split(" ");
            		if(str[0].equals("S")){
            			card[0][Integer.parseInt(str[1])]=true;
            		}else if(str[0].equals("H")){
            			card[1][Integer.parseInt(str[1])]=true;
            		}else if(str[0].equals("C")){
            			card[2][Integer.parseInt(str[1])]=true;
            		}else if(str[0].equals("D")){
            			card[3][Integer.parseInt(str[1])]=true;
            		}
            		i++;
            		if(i==n){
            			for(int j=0;j<4;j++){
            				String a=map.get(j);
            				for(int l=1;l<14;l++){
            					if(!card[j][l]){
            						System.out.println(a+" "+l);
            					}
            				}
            			}
            			break;
            		}
                	
            	}
            }
        }
    }

}

Measured memory_bytes: 24376
from bisect import bisect_left
INF = float("inf")
N = int(input())
L = list(map(lambda x:int(x),input().split())) + [INF]
L.sort()
cnt = 0
for i in range(N-1):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        c = bisect_left(L,a+b)
        cnt += max(0,c-j-1)
print(cnt)

Measured memory_bytes: 3188