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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 2019;


ll n;
ll f[2100];
ll suf[SZ];



int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(s);
    n = s.size();

    p = 1;
    f[0] = 1;

    forb(i, n-1, 0) {
        x = s[i] - '0';
        suf[i] = ((x * p) + suf[i+1]) % mod;
        ans += f[suf[i]];

        f[suf[i]]++;
        p = (p*10) % mod;
    }

    cot1(ans);

    return 0;
}



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

int main(){
  char s1[3],s2[3];
  cin >> s1 >> s2;
  if(s1[0] == s2[2] && s1[2] == s2[0] && s1[1] == s2[1]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    cin >> S;
    if(S[S.size()-1] == 's') {
        S += "es";
    }
    else {
        S += "s";
    }
    cout << S << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    string s,p;
    cin>>s>>p;
    n=s.length();
    m=p.length();
    ll dp[n+1][m+1];
    mms(dp,0);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s[i-1]==p[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    i=n;j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==p[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])i--;
            else j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


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

long long a,b;

int main(){
	cin>>a>>b;
	if(a<=0&&b>=0) { cout<<"Zero"<<endl; return 0; }
	if(a<0) if((b-a)%2==0) { cout<<"Negative"<<endl; return 0; } else { cout<<"Positive"<<endl; return 0; }
	else cout<<"Positive"<<endl;
	return 0;
} 

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k, total = 0;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
    	int h;
    	cin >> h;
    	if (h >= k) total += 1;
    }
    cout << total << '\n';
}

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

int main() {
	int i;
	int x;

	i = 0;

	while (i < 10000) {
		cin >> x;
		if (x == 0) {
			break;
		}
		i = i + 1;
		cout << "Case " << i << ": " << x << endl;
	}

	return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

	int a,b;
	cin>>a>>b;
	cout<<(int(log(a)/log(b)+1));
	
	return 0;	
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<long long> v(N, 0);

    for(int i=0; i<N; i++){
        v[i] = upper_bound(C.begin(), C.end(), 1 << 30) - lower_bound(C.begin(), C.end(), B[i]+1);
    }

    vector<long long> vv(N, 0);
    int pos = 0;
    for(int i=0; i<N; i++){
        while(pos < N){
            if(B[pos] > A[i]){
                vv[i] = pos;
                break;
            }
            pos++;
        }
        if(pos == N){
            vv[i] = N;
        }
    }

    vector<long long> v2(N+1, 0);
    for(int i=N-1; i>=0; i--) v2[i] = v2[i+1] + v[i];

    long long ans = 0;
    for(int i=0; i<N; i++){
        ans += v2[vv[i]];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
int main(void){
  char a[51],b[51];
  int i;
  scanf("%s",a);
  scanf("%s",b);
  for(i=0;a[i]!='\0';i++){
    printf("%c",a[i]);
    if(b[i]!='\0') printf("%c",b[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

const long long mod=1e9+7;

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

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

    return 0;
}

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

int n, k;
string a[10];
set<string> s;

void solve(vector<int> v) {
    do {
        string t = "";
        for (int i = 0; i < k; i++) {
            t.append(a[v[i]]);
        }
        s.insert(t);
    } while (next_permutation(v.begin(), v.end()));
}

int main() {
    cin >> n >> k;
    while (n != 0 && k != 0) {
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        s.clear();
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (k == 2) {
                    solve(vector<int>{i, j});
                } else {
                    for (int l = j + 1; l < n; l++) {
                        if (k == 3) {
                            solve(vector<int>{i, j, l});
                        } else {
                            for  (int m = l + 1; m < n; m++) {
                                solve(vector<int>{i, j, l, m});
                            }
                        }
                    }
                }
            }
        }
        cout << s.size() << "\n";
        cin >> n >> k;
    }
    return 0;
}


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

using namespace std;

int n, t, a, b;
priority_queue<int> qa;
priority_queue<int, vector<int>, greater<int>> qb; 
long long x, y;

int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d%d", &a, &b);
			y += b;
			if (qa.size() <= qb.size()) {
				qa.push(a);
				x++;
				y -= a;
			} else {
				qb.push(a);
				x--;
				y += a;
			}
			while (!qa.empty() && !qb.empty() && qa.top() > qb.top()) {
				y += qa.top() * 2;
				y -= qb.top() * 2;
				int tmp = qa.top();
				qa.pop();
				qa.push(qb.top());
				qb.pop();
				qb.push(tmp);
			}
		} else
			printf("%d %lld\n", qa.top(), x * qa.top() + y);
	}
}

Measured memory_bytes: 3452
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#H, W = map(int, input().split())
#S = list(map(int, input().split()))
#N = int(input())
S = str(input())

if len(S)%2 == 1 :
  S = S[0:-1]
else :
  S = S[0:-2]

while (True) :
  if S[0:len(S)//2] == S[len(S)//2:] :
    print (len(S))
    exit()
  else :
    S = S[0:-2]

  
  
  
  

Measured memory_bytes: 38384
from collections import Counter

n,m = map(int,input().split())
s = ""
for i in range(m):
    s = s + input()
counter = Counter(s)
for i in range(n+1):
    if counter[str(i)] % 2 != 0:
        print("NO")
        break
if i == n:
    print("YES")

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

long long A, B;
long long FA, FB;
long long ans;

int main() {
    cin >> A >> B;
    if (A%2==0) {
        if ((A/2)%2==0) FA = 0;
        else FA = 1;
    } else {
        if (((A-1)/2)%2==0) FA = A-1;
        else FA = (A-1) ^ 1;
    }
    if ((B+1)%2==0) {
        if (((B+1)/2)%2==0) FB = 0;
        else FB = 1;
    } else {
        if ((B/2)%2==0) FB = B;
        else FB = B ^ 1;
    }
    ans = FA ^ FB;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
V = [0]


for i in range(N):
    if S[i:i+2] == 'AC':
        V.append(V[-1]+1)
    else:
        V.append(V[-1])

for i in range(Q):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    print(V[r]-V[l])

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define d(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ri register int
#define ll long long
#define il inline
#define _ 200005
int max(int x, int y) {return x>y?x:y;} int min(int x, int y) {return x<y?x:y;}
int n, m, k, ansl, ansr, lstl; char str[_]; int tag[_], qwq;
int main(){
  scanf("%d%d%d", &n, &m, &k);
  scanf("%s", str+1); str[0] = 'x';
  int p = n; while(p > 0) {
    while(str[p] == 'x') --p;
    ++ansr; tag[p] = 1; p = p-k-1;
  } lstl = -k; ansl = 0;
  //f(i,1,n) printf("%d ", tag[i]); puts("");
  f(i,1,n) {
    if(tag[i]) --ansr; if(lstl+k<i-1 && str[i-1] == 'o') ++ansl, lstl=i-1;
    //printf("At %d, ansl = %d, ansr = %d\n", i, ansl, ansr);
    if(ansl+ansr < m) printf("%d\n", i);
  }
  return 0;
}
// sto wyxkk orz


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int m = scan.nextInt();
			int n_min = scan.nextInt();
			int n_max = scan.nextInt();
			if (m + n_min + n_max == 0)
				break;
			int[] p = new int[m];
			for (int i = 0; i < m; i++) {
				p[i] = scan.nextInt();
			}
			int n = 0;
			int ans = 0;
			for (int i = 0; i < m; i++) {
				if (i >= n_min - 1 && i < n_max) {
					if (n <= p[i] - p[i + 1]) {
						n = p[i] - p[i + 1];
						ans = i + 1;
					}
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 57992
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



int main(){fastio
    ll h,w,k;cin>>h>>w>>k;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll ans=inf;
    rep(q,0,(1<<(h-1))-1){
        ll cn=1;
        rep(j,0,h-2){
            if((q>>j)&1)cn++;
        }
        ll a[cn][w];memset(a,0,sizeof(a));
        ll pos=0;
        rep(i,0,h-1){
            if(i>=1){
                if((q>>(i-1))&1)pos++;
            }
            rep(j,0,w-1){
                if(s[i][j]=='1')a[pos][j]++;
            }
        }
        /*
        rep(i,0,cn-1){
            rep(j,0,w-1)cout<<a[i][j]<<" ";cout<<endl;
        }
        */
        bool f=true;
        rep(i,0,cn-1){
            rep(j,0,w-1){
                if(a[i][j]>k)f=false;
            }
        }
        if(!f)continue;
        
        ll sum[cn];memset(sum,0,sizeof(sum));
        ll res=cn-1;
        rep(j,0,w-1){
            bool ok=true;
            rep(i,0,cn-1){
                if(sum[i]+a[i][j]>k){ok=false;break;}
            }
            if(ok){
                rep(i,0,cn-1)sum[i]+=a[i][j];
            }else{
                res++;
                rep(i,0,cn-1)sum[i]=a[i][j];
            }
        }
        Min(ans,res);
        //cout<<q<<" "<<res<<endl;
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> data(N);
	rep(i, N) cin >> data.at(i);
	int result = 10000000000;

	for (int i = 1; i < 101; i++) {
		int sum = 0;
		rep(j, N) {
			sum += (data.at(j) - i) * (data.at(j) - i);
		}
		result = min(result, sum);
	}
	cout << result << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int x,a,b; cin >>x>>a>>b;
  if((10*a + b) % 4== 0){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

Measured memory_bytes: 3576
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,d,a = mi()
lis = []
for  i in range(n):
    x,h = mi()
    h = (h + a - 1) // a
    lis.append([x,h])

lis.sort()
dis = []
hp = []
for i in range(n):
    dis.append(lis[i][0])
    hp.append(lis[i][1])
#imos?
from collections import deque
hiku = deque()
sums = hp[0]
ans = hp[0]
hiku.append([dis[0] + 2 * d,hp[0]])
imadis,imahp = hiku.popleft()
for i in range(1,n):
    while True:
        if dis[i] <= imadis:
            break
        else:
            sums -= imahp
            imahp = 0
            if hiku:
                imadis,imahp = hiku.popleft()
            else:
                break
    diff = hp[i] - sums
    if diff > 0:
        ans += diff
        sums += diff
        hiku.append([dis[i] + 2 * d,diff])

print(ans)


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

int main() {
  int64_t L, R;
  cin >> L >> R;
  int64_t modmin = 2019;

  for (int64_t i = L; i < R; i++) {
    if (i % 2019 == 0) {
      modmin = 0;
      break;
    }
    else {
      for (int64_t j = i + 1; j <= R; j++) {
        if (j % 2019 == 0) {
          modmin = 0;
          break;
        }
        else {
          int64_t temp = modmin;
          modmin = min(temp, i * j % 2019);
        }
      }
    if (modmin == 0)
      break;
    }
  }
  
  cout << modmin << endl;
  
}

Measured memory_bytes: 256
from itertools import combinations

inputs = []
n,x = map(int,input().split())
while n != 0 or x != 0:
     inputs.append((n,x))
     n,x = map(int,input().split())

for n,x in inputs:
    print(len([0 for c in combinations(range(1,n+1),3) if sum(c) == x]))


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

int main() {
  int n, k;
  cin >> n >> k;
  k--;
  string s;
  cin >> s;
  s[k] += 32;
  cout << s << endl;    
    return 0;
}

Measured memory_bytes: 3496
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    int M;
    cin >> N >> M;
    vecl H(N);
    REP(i,N) cin >> H[i];
    int ans = 0;
    vector<vector<int>> res(N,vector<int>());
    REP(i,M) {
        int a,b; cin >> a >> b;
        a--;
        b--;
        res[a].push_back(H[b]);
        res[b].push_back(H[a]);
    }
    REP(i,N) {
        sort(res[i].begin(),res[i].end(), greater<int>());
        if(res[i].size() == 0) ans++;
        else if(H[i] > res[i][0]) {
            // << H[i] << endl;
            ans++;
        }
    }
    cout << ans << endl;
}


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

typedef struct{
	char str[1000][100];
	int point;
} data;

int main(){
	int n, i;
	data taro, hanako;
	
	taro.point = 0;
	hanako.point = 0;
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%s%s", &taro.str[i], &hanako.str[i]);
		if(strcmp(taro.str[i], hanako.str[i]) > 0) taro.point += 3;
		else if(strcmp(hanako.str[i], taro.str[i]) > 0) hanako.point += 3;
		else if(strcmp(taro.str[i], hanako.str[i]) == 0){
			taro.point++;
			hanako.point++;
		}
	}
	printf("%d %d\n", taro.point, hanako.point);
	
	return 0;
}

Measured memory_bytes: 796
program redistribution
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: s
  integer(8) :: m(3, 3) = 0
  read(*,*) s
  if (s < 3) then
    write(*,'(i0)') 0
    stop
  end if
  m(1, 1) = 1
  m(2, 1) = 1
  m(3, 2) = 1
  m(1, 3) = 1
  m = modmatpow(m, s - 3)
  write(*,'(i0)') m(1, 1)
contains
  function modmatmul(x, y) result(res)
    integer(8), intent(in) :: x(:, :), y(:, :)
    integer(8) :: tmp, res(size(x, 1), size(y, 2))
    integer :: i, j, k
    do j = 1, size(y, 2)
      do i = 1, size(x, 1)
        res(i, j) = 0
      end do
      do k = 1, size(x, 2)
        tmp = y(k, j)
        do i = 1, size(x, 1)
          res(i, j) = mod(res(i, j) + x(i, k) * tmp, modu)
        end do
      end do
    end do
  end
  function modmatpow(x, n) result(res)
    integer(8), intent(in) :: x(:, :)
    integer, intent(in) :: n
    integer(8) :: res(size(x, 1), size(x, 2)), tmp(size(x, 1), size(x, 2))
    integer :: m, i
    res = 0
    do i = 1, size(x, 1)
      res(i, i) = 1
    end do
    tmp = x
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = modmatmul(res, tmp)
      tmp = modmatmul(tmp, tmp)
      m = rshift(m, 1)
    end do
  end
end program redistribution

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

int main()
{
	int ans = 0;

	char S[14];

	scanf("%s", S);

	int d = strlen(S);

	for (int i = 0; i < d; i++) {
		for (int j = i; j < d; j++) {
			
			if (S[j] != 'A'&&S[j] != 'C'&&S[j] != 'G'&&S[j] != 'T')break;
			//やりたい処理

			if (ans < j - i + 1)ans = j - i + 1;




			//終わり


			


		}
	}



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


	return(0);
}



Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
for i in range(1, N):
  left = S[:i]
  right = S[i:]
  cnt = 0
  both = []
  for j in range(len(right)):
    if right[j] in left and not right[j] in both:
      cnt += 1
      both.append(right[j])
  ans = max(ans, cnt)
print(ans)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  vector<int> d(4,0);
  int a,b;
  for(int i=0;i<3;i++){
    cin >> a >> b;
    a--,b--;
    d[a]++,d[b]++;
  }
  sort(all(d));
  if(d[0]==1&&d[1]==1&&d[2]==2&&d[3]==2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

distance :: Int -> Int -> Int -> Int
distance k from to =
        if from > to then to + k - from
        else to - from

distances :: Int -> [Int] -> [Int]
distances k (d:ds) = let
    firstList = d:ds
    latterList = ds ++ [d]
    in
    zipWith (distance k) firstList latterList

main = do
    (k, n) <- readTuple2
    ds <- readInts
    let nds = distances k ds
    print $ k - maximum nds





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

int main() {
int n,a[26];
cin>>n;
for(int &x:a){
    x=0;
}
string s;
cin>>s;
for(char x:s){
    a[x-'a']++;
}
for(int i=1;i<n;i++){
    string s;
    int b[26];
    cin>>s;
    for(int &x:b){
        x=0;
    }
    for(char x:s){
        b[x-'a']++;
    }
    for(int j=0;j<26;j++){
        a[j]=min(a[j],b[j]);
    }
}
for(int i=0;i<26;i++){
    char c='a'+i;
    for(int j=0;j<a[i];j++){
        cout<<c;
    }
}
cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for (int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        int max = a[0];
        int min = a[0];
        
        for(int i=1;i<N;i++){
            if (max < a[i]){
                max = a[i];
            }
            if (min > a[i]){
                min = a[i];
            }
        }
        System.out.println(max - min);
    }
    
}

Measured memory_bytes: 21844
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &bb) {
    for (int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &bb) {
    for (int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    ll n, q; cin >> n >> q;
    vector<Pii> da(q);
    rip(i,q,0) cin >> da[i].first >> da[i].second;
    vector<ll> h(n, -1), w(n, -1);
    ll ans = 0,hh = n-2, ww = n-2;
    rip(ii,q,0) {
        if(da[ii].first == 1) {
            if(h[da[ii].second] == -1) {
                rip(i,ww+2,da[ii].second) {
                    h[i] = hh;
                }
                ww = da[ii].second-2;
                ans += hh;
            }
            else {
                ans += h[da[ii].second];
            }
        }
        else {
            if(w[da[ii].second] == -1) {
                rip(i,hh+2,da[ii].second) {
                    w[i] = ww;
                }
                hh = da[ii].second-2;
                ans += ww;
            }
            else {
                ans += w[da[ii].second];
            }
        }
    }
    cout <<(n-2)*(n-2)-ans << endl;
    
}

Measured memory_bytes: 7912
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > L(N);
	rep(i, N) cin >> L[i];
	int ans = 0;
	sort(L.begin(), L.end());
	rep(i, N) rep(j, N) rep(k, N) if (i < j && j < k) {
		if (L[i] == L[j] || L[j] == L[k])
			continue;
		if (L[i] + L[j] > L[k])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    int n;
    cin>>n;
    pair<double,double> iti[n];
    for(int i=0;i<n;i++){
        cin>>iti[i].first>>iti[i].second;
    }

    int num[n];
    for(int i=0;i<n;i++) num[i] = i;

    double nkaijou = 0;
    double dis = 0;
    do{
        for(int i=0;i<n-1;i++){
            dis += sqrt( pow(iti[num[i]].first-iti[num[i+1]].first,2)
                        + pow(iti[num[i]].second-iti[num[i+1]].second,2) );
        }
        nkaijou++;
    }while(next_permutation(num, num+n));

    double ans = dis / nkaijou;
    printf("%.10f\n",ans);
}

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

int main() {
	int n;
	cin >> n;
	if(n<2){
		cout<< 1 <<endl;
	}
	else if(n<4){
		cout<< 2 <<endl;
	}
	else if(n<8){
		cout<< 4 <<endl;
	}
	else if(n<16){
		cout<< 8 <<endl;
		
	}
	else if(n<32){
		cout<< 16 <<endl;
		
	}
	else if(n<64){
		cout<< 32 <<endl;
		
	}
	else{
		cout<< 64 <<endl;
		
	}
	return 0;
}

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

void
Main() {
	int	N;	cin >> N;
	int	K;	cin >> K;
	int	Q;	cin >> Q;

	long	A[ N ];			for ( auto i = 0; i < N; i++ ) cin >> A[ i ];
	long	wSorted[ N ];	for ( auto i = 0; i < N; i++ ) wSorted[ i ] = A[ i ];

	sort( wSorted, wSorted + N );
	long	v = 1e10;

	for ( auto i = 0; i < N; i++ ) {
		vector< long > wCandidate;
		vector< long > wCurrent;
		for ( auto j = 0; j <= N; j++ ) {
			if ( j == N || A[ j ] < A[ i ] ) {
				sort( wCurrent.begin(), wCurrent.end() );
				if ( wCurrent.size() >= K ) wCandidate.insert( wCandidate.end(), wCurrent.begin(), wCurrent.end() - K + 1 );
				wCurrent.clear();
			} else {
				wCurrent.emplace_back( A[ j ] );
			}
		}
		sort( wCandidate.begin(), wCandidate.end() );
		if ( wCandidate.size() >= Q ) v = min( v, wCandidate[ Q - 1 ] - A[ i ] );
	}
	cout << v << endl;
}

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


Measured memory_bytes: 384
#include <stdio.h>
#define SIZE 5
int compare(int a[SIZE]){
  for(int i=0;i<5;i++){
    if(a[i]==0){
      return i+1;
    }
  }
}


int main(void){
  int num[SIZE];
  scanf("%d %d %d %d %d", &num[0], &num[1], &num[2],&num[3],&num[4]);
  int k =compare(num);
  printf("%d\n",k);

  return 0 ;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n;
	cin>>n;
	ll a[n+1];
	memset(a,0,sizeof(a));
	rep(i,0,n-1)
	{
		ll x;
		cin>>x;
		a[x]++;
	}
	rep(i,1,n+1)
	cout<<a[i]<<endl;
}

Measured memory_bytes: 5220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x,y;
  cin >> x >> y;
  if(abs(x - y) > 1)cout << "Alice" << endl;
  else cout << "Brown" << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
int main(){
    int height, width;
    cin >> height >> width;
    vector<vector<char> > pixel(height + 2, vector<char> (width + 2, '#'));
    rep(i, 1, height + 1){
        rep(j, 1, width + 1){
            cin >> pixel.at(i).at(j);
        }
    }
    rep(i, 0, pixel.size()){
        rep(j, 0, pixel.at(0).size()){
            cout << pixel.at(i).at(j);
        }
        cout << endl;
    }
}

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

typedef long long ll;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    
    int a=0;
    bool f=false;
    for(int i=0; i<B; i++){
        a += A;
        if(a%B==C) f=true;
    }
    
    cout << (f?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void)
{
    long long int x;
    cin >> x;

    long long count = 0;
    long long current = 100;
    while(current < x)
    {
        current = (long long)current * (1.01);
        count ++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        
        if (op =='?') break;
        if (op == '+'){
            cout << a+b << endl;
        }else if (op == '-'){
            cout << a-b << endl;
            
        }else if(op == '*'){
            cout << a*b <<endl;
        }else{
            cout << int(a/b) <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
  
int main(int argc, char* argv[])
{
  char r[]={"SHCD"}, a[52];
  int n, b[52], c[4][13];
  int i, j, k;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%*c%c %d", &a[i], &b[i]);
  }
  
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      c[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    for(j = 0; r[j] != '\0'; j++){
      if(a[i] == r[j]){
        k = j;
        break;
      }
    }
    c[k][b[i]-1] = 1;
  }
  
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(c[i][j] == 0){
        printf("%c %d\n", r[i], j+1);
      }
    }
  }
  return(0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    if(s == "RRR")cout << 3 << endl;
    else if(s == "SRR" || s == "RRS")cout << 2 << endl;
    else if(s == "SSS")cout << 0 << endl;
    else cout << 1 << endl;
    
}

Measured memory_bytes: 3588
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    V< V<int> > lcs(int(s.size()) + 1, V<int>(int(t.size()) + 1, 0));
    for (int i = 0; i < int(s.size()); i++) {
        for (int j = 0; j < int(t.size()); j++) {
            if (s[i] == t[j]) lcs[i + 1][j + 1] = lcs[i][j] + 1;
            else lcs[i + 1][j + 1] = max(lcs[i + 1][j], lcs[i][j + 1]);
        }
    }

    int i = s.size(), j = t.size();
    string ans;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
            ans.push_back(s[i - 1]);
            i--, j--;
        } else {
            if (lcs[i - 1][j] == lcs[i][j]) i--;
            else j--;
        }
    }
    reverse(ALL(ans));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 38564
#include <iostream>
#include <queue>
#include <unordered_map>
#include <utility>
#include <array>
#include <cstring>

bool isObstacle[1000][1000];
bool done[1000][1000];

int main() {
	int h, w, n;
	std::cin >> h >> w >> n;

	std::unordered_map<int, int> factories;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			char c;
			std::cin >> c;

			if (c == 'S')
				factories[0] = j * 1000 + i;
			else if ('1' <= c && c <= '9')
				factories[c - '0'] = j * 1000 + i;
			else if (c == 'X')
				isObstacle[j][i] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		const int sx = factories[i] / 1000, sy = factories[i] % 1000;
		const int gx = factories[i + 1] / 1000, gy = factories[i + 1] % 1000;

		std::memset(done, 0, sizeof(done));

		done[sx][sy] = true;

		auto candidate = [h, w](int x, int y) {
			std::array<int, 4> arr;
			arr[0] = ((x == 0 || isObstacle[x - 1][y] || done[x - 1][y]) ? -1 : (done[x - 1][y] = true, (x - 1) * 1000 + y));
			arr[1] = ((x == w - 1 || isObstacle[x + 1][y] || done[x + 1][y]) ? -1 : (done[x + 1][y] = true, (x + 1) * 1000 + y));
			arr[2] = ((y == 0 || isObstacle[x][y - 1] || done[x][y - 1]) ? -1 : (done[x][y - 1] = true, x * 1000 + y - 1));
			arr[3] = ((y == h - 1 || isObstacle[x][y + 1] || done[x][y + 1]) ? -1 : (done[x][y + 1] = true, x * 1000 + y + 1));

			return std::move(arr);
		};

		std::queue<std::pair<int, int>> q;
		q.push({ factories[i], 0 });
		while (!q.empty()) {
			const auto& top = q.front();
			const int nx = top.first / 1000, ny = top.first % 1000;
			int cost = top.second;

			auto&& c = candidate(nx, ny);
			for (auto v : c) {
				if (v != -1) {
					if (v / 1000 == gx && v % 1000 == gy) {
						ans += cost + 1;
						q.pop();
						goto end;
					}
					q.push({ v, cost + 1 });
				}
			}

			q.pop();
		}
	end:;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, su[3];
	cin>>n;
	fore(i, 0, 3) cin>>su[i];
	int ar[n];
	fore(i, 0, n) cin>>ar[i];
	int ord[] = {0, 1, 2};
	int res = MOD;
	do
	{
		int cos1 = MOD, ind1;
		fore(i, 1, 1 << n)
		{
			if(__builtin_popcount(i) < n - 1)
			{
				int parcos = (__builtin_popcount(i)-1) * 10, parsu = 0;
				fore(j, 0, n)
				{
					parsu += (((1 << j) & i) ? 1 : 0)*ar[j];
				}
				parcos += abs(parsu - su[ord[0]]);
				vector<int> segu;
				fore(j, 0, n)
				{
					if(!((1 << j) & i))
						segu.pb(ar[j]);
				}
				int ta = segu.size();
				fore(j, 1, 1 << ta)
				{
					if(__builtin_popcount(j) < ta)
					{
						int parcos2 = (__builtin_popcount(j)-1) * 10, parsu2 = 0;
						fore(k, 0, ta)
						{
							parsu2 += (((1 << k) & j) ? 1 : 0)*segu[k];
						}
						parcos2 += abs(parsu2 - su[ord[1]]);
						vector<int> ter;
						fore(k, 0, ta)
						{
							if(!((1 << k) & j))
								ter.pb(segu[k]);
						}
						int ta2 = ter.size();	
						fore(k, 1, 1 << ta2)
						{
								int parcos3 = (__builtin_popcount(k)-1) * 10, parsu3 = 0;
								fore(l, 0, ta2)
								{
									parsu3 += (((1 << l) & k) ? 1 : 0)*ter[l];
								}
								parcos3 += abs(parsu3 - su[ord[2]]);
								res = min(res, parcos + parcos2 + parcos3);
						}
					}
				}
			}
		}
	}
	while(next_permutation(ord, ord + 3));
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

int main(){
	int H, W;
	
	while(true){
		cin >> H >> W;

		if(H == 0 && W == 0) break;

		for(int i = 0; i < H; i++){
			for(int ii = 0; ii < W; ii++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
// Aizu 0262: Making Sugoroku
// 2017.10.26 bal4u@uu

#include <stdio.h>
#include <string.h>

char g[255][255];
int d[255];

int main()
{
	int m, n, i, j, k, ans;

	while (scanf("%d", &m) && m > 0) {
		memset(g, 0, sizeof(g));
		scanf("%d", &n);
		for (i = 1; i <= n; i++) scanf("%d", d+i);
		for (i = 0; i <= n; i++) for (j = 1; j <= m; j++) {
			k = i + j + d[i+j];
			if (k < 0) k = 0;
			else if (k > n+1) k = n+1;
			g[i][k] = 1;
		}

		for (k = 0; k <= n+1; k++)
			for (i = 0; i <= n+1; i++) for (j = 0; j <= n+1; j++)
				if (g[i][k] && g[k][j]) g[i][j] = 1;

		ans = 1;
		for (i = 0; i <= n; i++) {
			if (g[0][i] && !g[i][n+1]) { ans = 0; break; }
		}
		puts(ans ? "OK" : "NG");
	}
	return 0;
}

Measured memory_bytes: 1812
#include <cstdio>
#include <cmath>

int main(){
	int n, x[100], y[100];
	
	scanf(" %d", &n);
	for(int i=0; i<n; ++i)
		scanf(" %d", &x[i]); 
	for(int i=0; i<n; ++i)
		scanf(" %d", &y[i]); 
		
	for(int p=1; p<=3; ++p){
		double d=0;
		for(int i=0; i<n; ++i)
			d += pow( fabs(x[i]-y[i]), p);
		
		printf("%lf\n", pow(d,1.0/p));
	}		
	
	double max=0;	
	for(int i=0; i<n; ++i)
		if(max < fabs(x[i]-y[i])) max = fabs(x[i]-y[i]);
	
	printf("%lf\n", max);	
	
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}


int main() {
    int K,X;
    cin>>K>>X;
    if(500*K>=X){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }




}


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

int main()
{
    long values[10];
    char buf[255];

    for (int i = 0; i < 10; i++)
    {
        fgets(buf, 255, stdin);
        values[i] = strtol(buf, NULL, 10);
    }

    for (int i = 0; i < 3; i++)
    {
        int idx = -1;
        long val = -1;
        for (int j = 0; j < 10; j++)
        {
            if (val < values[j])
            {
                idx = j;
                val = values[j];
            }
        }
        printf("%ld\n", val);
        values[idx] = -1;
    }

    return 0;
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B;
    cin >> A >> B;
    cout << max({A+B,A-B,A*B}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, x[200001], x_sorted[200001];

int main() {
	cin >> n;
	for(ll i = 0; i < n; i++){cin >> x[i]; x_sorted[i] = x[i];}
	sort(x_sorted, x_sorted+n);
	
	for(ll i = 0; i < n; i++){
		if(x[i] < x_sorted[n/2]){cout << x_sorted[n/2] << endl;} 
		else{cout << x_sorted[n/2-1] << endl;}
	}
	
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;

long long int N, a = 0, largest = 0, b, ans;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		a = 0;
		b = i;
		while (b % 2 == 0) {
			b /= 2;
			a++;
		}
		if (largest <= a) {
			largest = a;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N=int(input())
S=[input() for _ in range(N)]
M=int(input())
T=[input() for _ in range(M)]

cs=Counter(S)
ct=Counter(T).most_common()

for i in range(len(ct)):
    cs[ct[i][0]]-=ct[i][1]

print(max(0,cs.most_common()[0][1]))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i< n; i++){
        cin >> p.at(i);
    }
    
    int count = 0;
    int min= 10000000;
    for(int i = 0; i< n; i++){
        if(min >= p.at(i)){
            count++;
            min = p.at(i);
        }
    }
        

    cout << count << endl;
}

    

Measured memory_bytes: 1024