akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        int n = rint();
        var dic = new Dictionary<string,bool>();
        int ct = 0;
        for (int i = 0; i < n; i++)
        {
            string s = rstr();
            if (!dic.ContainsKey(s))
            {
                dic.Add(s,true);
                ct++;
            }
        }
        Write(ct);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


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

int main()
{
	int n;
	cin >> n;
	int Ai[n];
	map<int, int> countMap;
	rep(i, n) {
		int a;
		cin >> a;
		countMap[a] = countMap[a] + 1;
	}

	int ans = 0;
	for (auto itr = countMap.begin(); itr != countMap.end(); itr++) {
		int k = itr->first;
		int v = itr->second;

		if (k > v) {
			ans += v;
		} else if (k < v) {
			ans += (v - k);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>
#include <string>
#include <map>
using namespace std;

int main(void){
	map<string,int> m;
	int a;
	char str[100];
	while(scanf("%d,%s",&a,str)!=EOF) m[string(str)]++;
	printf("%d\n",m["A"]);
	printf("%d\n",m["B"]);
	printf("%d\n",m["AB"]);
	printf("%d\n",m["O"]);
	return 0;
}

Measured memory_bytes: 2824
if __name__=='__main__':
  n=int(input())
  h=[2,4,5,7,9]
  p=[0,1,6,8]
  b=[3]
  one=n%10
  if one in h:
    print('hon')
  elif one in p:
    print('pon')
  elif one in b:
    print('bon')

Measured memory_bytes: 9180
#include<stdio.h>
int main()
{
    char A,B,C,D;
    int a,b,c,d;
    scanf("%c%c%c%c",&A,&B,&C,&D);
    a=A-'0';b=B-'0';c=C-'0';d=D-'0';
    if(a+b+c+d==7)
        printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a+b+c-d==7)
        printf("%d+%d+%d-%d=7",a,b,c,d);
    else if(a+b-c+d==7)
        printf("%d+%d-%d+%d=7",a,b,c,d);
    else if(a-b+c+d==7)
        printf("%d-%d+%d+%d=7",a,b,c,d);
    else if(a+b-c-d==7)
        printf("%d+%d-%d-%d=7",a,b,c,d);
    else if(a-b+c-d==7)
        printf("%d-%d+%d-%d=7",a,b,c,d);
    else if(a-b-c+d==7)
        printf("%d-%d-%d+%d=7",a,b,c,d);
    else if(a-b-c-d==7)
        printf("%d-%d-%d-%d=7",a,b,c,d);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int N, A, B;
	cin >> N;
	if (N == 1)
	{
		cout << "Hello World" << endl;
	}
	else
	{
		cin >> A >> B;
		cout << A + B << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

double distof(const vector<double> &v1, const vector<double> &v2) {
    double ans = 0;
    for(int i = 0; i < 3; ++i) ans += pow(v1[i]-v2[i], 2);
    return ans;
}

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

    vector<vector<double> > v(N);
    for(int i = 0; i < N; ++i) {
        v[i].resize(3);
        for(int j = 0; j < 3; ++j) {
            cin >> v[i][j];
        }
    }

    vector<vector<double> > dist(N, vector<double>(N, 0));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < i; ++j) {
            dist[i][j] = dist[j][i] = distof(v[i], v[j]);
        }
    }

    double ans = 0;
    for(int pat = 0; pat < (1<<N); ++pat) {
        if(__builtin_popcount(pat) != M) continue;

        double tmpcnt = 0;
        vector<int> vs;
        for(int i = 0; i < N; ++i) {
            if(pat & (1<<i)) vs.push_back(i);
        }
        for(int i = 0; i < M; ++i) {
            for(int j = 0; j < i; ++j) {
                tmpcnt += dist[vs[i]][vs[j]];
            }
        }
        ans = max(ans, tmpcnt);
    }

    printf("%.6f\n", ans);
    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  sort(all(v));
  dump(v);
  int ans = 0;
  int m = N / 2;
  dump(m);
  if (N & 1) {
    int tmp = 0;
    rep(i, 0, m) {
      tmp -= v[i] * 2;
      dump(i, v[i], tmp);
    }
    rep(i, m + 2, N) {
      tmp += v[i] * 2;
      dump(i, v[i], tmp);
    }
    tmp += v[m] + v[m + 1];
    dump(m, v[m], v[m + 1]);
    dump(tmp);
    chmax(ans, tmp);
    tmp += -v[m] * 2 + v[m + 1] + v[m - 1];
    dump(tmp);
    chmax(ans, tmp);
  } else {
    rep(i, 0, m - 1) { ans -= v[i] * 2; }
    ans -= v[m - 1];
    rep(i, m + 1, N) { ans += v[i] * 2; }
    ans += v[m];
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
    int n;cin>>n;
    vector<string>vs(n);
    for(int i=0;i<n;++i){
        cin>>vs[i];
    }
    sort(vs.begin(),vs.end());
    int m;cin>>m;
    bool lock=0;
    for(int i=0;i<m;++i){
        string s;cin>>s;
        auto it1=lower_bound(vs.begin(),vs.end(),s);
        auto it2=upper_bound(vs.begin(),vs.end(),s);
        if(it1==it2){
            cout<<"Unknown "<<s<<endl;
            continue;
        }
        else{
            if(lock)lock=false;
            else lock=true;
            if(lock)cout<<"Opened by "<<s<<endl;
            else cout<<"Closed by "<<s<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3232
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(N)]
AB.sort()
answer = 0
for cost, num in AB:
    if M - num > 0:
        answer += cost * num
        M -= num
    else:
        answer += cost * M
        break

print(answer)


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

string to_string(string s) {
	return '"' + s + '"';
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
	int x;
	cin >> x;
	cout << (x == 7 || x == 3 || x == 5 ? "YES\n" : "NO\n");
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e6+10;
int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   swap(a,b);
   swap(a,c);
   cout<<a<<" "<<b<<" "<<c;
   //system("pause");
   return 0;
}


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

int N;
vector<int> A,B,C;

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        A.push_back(x);
    }

    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        B.push_back(x);
    }

    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        C.push_back(x);
    }

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

    long long ans=0;

    for(int i=0;i<N;i++){
        int b=B.at(i);
        ans+=(lower_bound(A.begin(),A.end(),b)-A.begin())*(C.end()-upper_bound(C.begin(),C.end(),b));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1784
#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000000;

int main()
{
    int t;
    cin >> t;
    while(t--){
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        ll ans = INF;
        map<ll, ll> dp;
        map<ll, bool> f;
        priority_queue<ll> que;
        que.push(n);
        while(que.size()){
            ll m = que.top();
            que.pop();
            if(m == 1){
                ans = min(ans, dp[m] + d);
                break;
            }
            if(f[m]) continue;
            f[m] = true;
            if(m < INF / d) ans = min(ans, dp[m] + d * m);
            if(m % 2 == 0){
                if(dp[m / 2]) dp[m / 2] = min(dp[m / 2], dp[m] + a);
                else dp[m / 2] = dp[m] + a;
                que.push(m / 2);
            }
            else{
                if(dp[m / 2]) dp[m / 2] = min(dp[m / 2], dp[m] + a + d);
                else dp[m / 2] = dp[m] + a + d;
                que.push(m / 2);
                if(dp[m / 2 + 1]) dp[m / 2 + 1] = min(dp[m / 2 + 1], dp[m] + a + d);
                else dp[m / 2 + 1] = dp[m] + a + d;
                que.push(m / 2 + 1);
            }
            if(m % 3 == 0){
                if(dp[m / 3]) dp[m / 3] = min(dp[m / 3], dp[m] + b);
                else dp[m / 3] = dp[m] + b;
                que.push(m / 3);
            }
            else if(m % 3 <= 1){
                if(dp[m / 3]) dp[m / 3] = min(dp[m / 3], dp[m] + b + d);
                else dp[m / 3] = dp[m] + b + d;
                que.push(m / 3);
            }
            else{
                if(dp[m / 3 + 1]) dp[m / 3 + 1] = min(dp[m / 3 + 1], dp[m] + b + d);
                else dp[m / 3 + 1] = dp[m] + b + d;
                que.push(m / 3 + 1);
            }
            if(m % 5 == 0){
                if(dp[m / 5]) dp[m / 5] = min(dp[m / 5], dp[m] + c);
                else dp[m / 5] = dp[m] + c;
                que.push(m / 5);
            }
            else if(m % 5 <= 2){
                if(dp[m / 5]) dp[m / 5] = min(dp[m / 5], dp[m] + c + d * (m % 5));
                else dp[m / 5] = dp[m] + c + d * (m % 5);
                que.push(m / 5);
            }
            else{
                if(dp[m / 5 + 1]) dp[m / 5 + 1] = min(dp[m / 5 + 1], dp[m] + c + d * (5 - m % 5));
                else dp[m / 5 + 1] = dp[m] + c + d * (5 - m % 5);
                que.push(m / 5 + 1);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 5160
#include<cstdio>
#include<cstdlib>
#include<iostream>
#define llong long long
using namespace std;

void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

const int N = 50;
int f[N+3][N+3];
int a[N+3];
int b[N+3];
int n;

bool check(llong sta)
{
	for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) f[i][j] = i==j?1:0;
	for(int i=0; i<=N; i++)
	{
		for(int j=1; j<=i; j++)
		{
			if(sta&(1ll<<j)) {f[i][i%j] = 1;}
		}
	}
	for(int k=0; k<=N; k++)
	{
		for(int i=0; i<=N; i++)
		{
			for(int j=0; j<=i; j++)
			{
				f[i][j] |= (f[i][k]&f[k][j]);
			}
		}
	}
	bool ret = true;
	for(int i=1; i<=n; i++)
	{
		if(!f[a[i]][b[i]]) {ret = false; break;}
	}
	return ret;
}

int main()
{
	scanf("%d",&n); for(int i=1; i<=n; i++) scanf("%d",&a[i]); for(int i=1; i<=n; i++) scanf("%d",&b[i]);
	llong sta = (1ll<<38)-2;
	if(!check(sta)) {puts("-1"); return 0;}
	for(int i=37; i>=1; i--)
	{
		llong tmp = sta^(1ll<<i);
		if(check(tmp)) {sta = tmp;}
	}
	printf("%lld\n",sta);
	return 0;
}

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

int main(){
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	
    bool A = true;
	if((e -a) > k){
		A = false;
	}
  
   
    if(A){
    cout << "Yay!" << endl;	
}
else{
	cout << ":(" << endl;
}

}

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

int main() {
 int n,cnt=0;
 cin >> n;
 vector<int> price(n);
 vector<int> cost(n);
 vector<int> diff(n);
 for(int i=0;i<n;i++){
   cin >> price[i];
 }
   for(int i=0;i<n;i++){
   cin >> cost[i];
   diff[i]= price[i]-cost[i];
     if(diff[i]>0){
     cnt = cnt + diff[i];
     }
 }
 cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    int d[n];
    int ans=0;
    int min = 100000;
    rep(i,0,n-1) cin>>d[i];
    sort(d,d+n);
    drep(i,n-1,0){
        if(d[i]<min){
            ans++;
            min = d[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //日付を入力する
            string[] input= Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long a = long.Parse(input[1]);
            long b = long.Parse(input[2]);

            //月が同じなら月末、それ以外は別
            if((a-b)% 2 == 0)
                Console.WriteLine(Math.Abs(a-b)/2);
            else
            {
                long ans1 = a + b - 1;
                long ans2 = 2 *n - b - a + 1;

                if(ans1 < ans2)
                    Console.WriteLine(ans1 / 2);
                else
                {
                    Console.WriteLine(ans2 /2);
                }

                
            }
                
        }
    }

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

ans = [0]*80100
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            ans[x**2+y**2+z**2+x*y+y*z+z*x] += 1

for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 74552
N =int(input())
import math
def digits(n):
    digits = "abcdefghijklmnopqrstuvwxyz"
    return digits[n%26-1]

def alph(X):
    if int(X/27) >= 1:
        return alph(math.ceil(X/26)-1) + digits(X)
    else:
        return digits(X)
print(alph(N))

Measured memory_bytes: 9172
import sys
input = sys.stdin.readline

def judge():
    l = [10*i+d[i] for i in range(N)]
    
    for i in range(1, N):
        l[i] = max(l[i], l[i-1])
    
    now = 0
    
    for _ in range(N-1):
        now = l[now//10]
        
        if now>=10*(N-1):
            return True
    
    return False

N = int(input())
d = [int(input()) for _ in range(N)]

if judge():
    d.reverse()
    
    if judge():
        print('yes')
        exit()

print('no')


Measured memory_bytes: 29360
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n)
	{
		if(n % 39 == 0)
		{
			printf("3C39\n");
		}
		else
		{
			printf("3C%02d\n", n % 39);
		}
	}
}

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

Measured memory_bytes: 0
function main()
  
  S = split(chomp(readline()),"")
  
  c0 = 0
  c1 = 0
  
  for i in 1:length(S)
    
    if S[i] == "0"
      c0 += 1
    else
      c1 += 1
    end
    
  end
  
  println(2 * min(c0,c1))
      
end

main()

Measured memory_bytes: 121844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main() {
  ll N, T;
  cin >> N >> T;
  ll out = 0;
  vector<ll> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  for (int i = 1; i<N; i++){
    ll tmp = 0;
    if (t[i] - t[i - 1] >= T) {
      tmp = T;
      out += tmp;
    } else {
      tmp = t[i] - t[i - 1];
      out += tmp;
    }
  }
  cout << out+T << endl;
  return 0;
}

Measured memory_bytes: 4728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;

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

const int kMaxN = 2005, kMaxM = 10005, kMaxS = 1e6 + 5;

int n, k, cnt, len[kMaxN];
char str[kMaxN][kMaxM];
bitset<kMaxM> dp[kMaxN];
pii ch[2][kMaxM];

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str[i]);
    len[i] = strlen(str[i]);
  }
  dp[n + 1][0] = 1;
  for (int i = n; i; --i) {
    dp[i] = dp[i + 1] | (dp[i + 1] << len[i]);
  }
  for (int i = 1; i <= n; ++i) {
    if (dp[i + 1][k - len[i]])
      ch[0][cnt++] = make_pair(i, 0);
  }
  for (int now = 1, i = 1; i <= k; ++i, now ^= 1) {
    int ncnt = 0;
    char minc = 'z';
    for (int j = 0; j < cnt; ++j)
      minc = min(minc, str[ch[now ^ 1][j].first][ch[now ^ 1][j].second]);
    putchar(minc);
    int minid = n + 1;
    for (int j = 0; j < cnt; ++j) {
      int id = ch[now ^ 1][j].first, pos = ch[now ^ 1][j].second;
      if (str[id][pos] != minc)
        continue;
      if (pos < len[id] - 1)
        ch[now][ncnt++] = make_pair(id, pos + 1);
      else
        minid = min(minid, id);
    }
    for (int j = minid + 1; j <= n; ++j) {
      if (k - i - len[j] >= 0 && dp[j + 1][k - i - len[j]])
        ch[now][ncnt++] = make_pair(j, 0);
    }
    cnt = ncnt;
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 21504
#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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll	n;
	cin >> n;
	ll	sum;
	sum = 0;
	rep (i, n + 1)
	{
		if (i % 3 != 0 && i%5 != 0)
			sum += i;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	string s,t;
	cin>>s>>t;
	ll a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)
	{
		cout<<a-1<<" "<<b;
	}
	else
	{
		cout<<a<<" "<<b-1;
	}
	return 0;
}




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

int main(void){

    long long N, M;

    scanf("%lld%lld", &N, &M);

    if(2 * N > M){
        printf("%lld\n", M / 2);
    }else{
        printf("%lld\n", (2*N + M) / 4);
    }

    return 0;
}

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

#define N 100000
#define Q
#define INF 1000000007
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define ABS(X) ((X)<0?-(X):(X))

int dp[N+1][3];

int main(void){
  int n;
  int hap[N+1][3];
  
  cin >> n;
  for (int i=1; i<=n; i++)
    for (int j=0; j<3; j++)
      cin >> hap[i][j];
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i=1; i<=n; i++){
    dp[i][0] = MAX(dp[i-1][1], dp[i-1][2]) + hap[i][0];
    dp[i][1] = MAX(dp[i-1][2], dp[i-1][0]) + hap[i][1];
    dp[i][2] = MAX(dp[i-1][0], dp[i-1][1]) + hap[i][2];
  }
  
  cout << MAX(MAX(dp[n][0],dp[n][1]), dp[n][2]) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long dp[N][3];
long long c[N][3] ;
int n;


int32_t main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i ++){
		for(int j = 0 ; j < 3 ; j ++) scanf("%lld" , &c[i][j]);
	}
	for(int i = 0 ; i <= n ;i ++)
		for(int j = 0 ; j < 3 ; j ++)
			dp[i][j] = -(long long) 1e18;
	dp[1][0] = c[1][0] , dp[1][1] = c[1][1] , dp[1][2] = c[1][2];
	for(int i = 2 ; i <= n; i ++)
		for(int j = 0 ; j < 3 ; j ++){
			if(j == 0){
				dp[i][j] = max(dp[i-1][1] , dp[i-1][2]) + c[i][j];
			}
			if(j == 1){
				dp[i][j] = max(dp[i-1][0] , dp[i-1][2]) + c[i][j];
			}
			if(j == 2){
				dp[i][j] = max(dp[i-1][0] , dp[i-1][1]) + c[i][j];
			}
		}
	long long ans = -1;
	for(int j = 0 ; j  < 3 ; j ++) ans = max(ans , dp[n][j]);
	printf("%lld\n" , ans);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {

	int n;
	cin >> n;
	vi a(n);
	vector<ll> b(n);
	rep(i, n)cin >> a[i];

	int i = 0, k = 1;
	ll hoge = 0;
	while (i < n) {
		hoge += (ll)a[i] * k;
		k *= -1;
		i++;
	}
	b[0] = hoge;
	rep1(i, n - 1) {
		b[i] = 2 * a[i - 1] - b[i - 1];
	}

	rep(i, n)cout << b[i] <<" ";
	cout <<endl;
}

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

def main(N, M, lst_sc):
    
    numbers = [''] * N
    for sc in lst_sc:

        [s, c] = sc

        if s > N: return -1

        if numbers[s-1] == '':
            numbers[s-1] = str(c)
        elif not numbers[s-1] == str(c):
            return -1
            
    if N > 1 and numbers[0] == '0': return -1
    if N == 1 and numbers[0] == '': return 0
    
    answer = ''
    for i in range(N):
        if numbers[i] == '':
            if i == 0: numbers[i] = '1'
            else     : numbers[i] = '0'
        answer += numbers[i]
    return int(answer)
    

if __name__ == "__main__":

    answer = main(N, M, lst_sc)
    print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

using Graph = vector<vector<int>>;

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

	Graph G(N);
	for(int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<int> from(N, -1);
	queue<int> que;
	from[0] = 0;
	que.push(0);

	while(!que.empty()) {
		int v = que.front();
		que.pop();

		for(int nv : G[v]) {
			if(from[nv] != -1) continue;
			from[nv] = v;
			que.push(nv);
		}
	}
	cout << "Yes\n";
	for(int v = 1; v < N; ++v) cout << from[v] + 1 << "\n";
}

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

int main( void )
{
    string s;
    cin >> s;
    
    int ans = 0;
    rep(i,4)
    {
        if ( s[i] == '+')
            ans++;
        else if ( s[i] == '-')
            ans--;
    }
        cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
import math
if abs(N-M) >= 2:
    p = 0
elif N == M:
    p = (math.factorial(N)*math.factorial(M)*2) % (10**9+7)
else:
    p = (math.factorial(N)*math.factorial(M)) % (10**9+7)
print(p)


Measured memory_bytes: 5192
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    string S, T;
    cin >> S >> T;
    map<char, char> dictionary1, dictionary2;
    int size = S.size();

    for (int i = 0; i < size; i++) {
        auto itr = dictionary1.find(T[i]);
        if (itr == dictionary1.end()) {
            if (T[i] != S[i]) {
                dictionary1[T[i]] = S[i];
            }         
        } else {
            if (dictionary1[T[i]] != S[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        itr = dictionary2.find(S[i]);
        if (itr == dictionary2.end()) {
            if (T[i] != S[i]) {
                dictionary2[S[i]] = T[i];
            }         
        } else {
            if (dictionary2[S[i]] != T[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e4;

int main()
{
  FastIO();
  int tc, ca = 0;
  int k;
  string s;
  cin >> k >> s;
  string ans;
  for (int i = 0;i < min(k, int(s.size()));i++){
    ans += s[i];
  }
  if (k < s.size())ans += "...";
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3644
//Author - Sanket Mundra
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back 
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fin cin
#define PI 3.14159265358979323846
#define M 1000000007;
 
int main()
{
    
    fastIO;
    ll t; cin>>t;
    cout<<2*PI*t<<endl;
    return 0;
}

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

int main(){

  string s;
  cin>>s;

  int ans=105;
  
  for(int i=0;i<s.size();i++){

    int cnt=0, maxcnt=0;
    
    for(int j=s.size()-1;j>=0;j--){
      
      if(s[i]==s[j]) cnt=0;
      else cnt++;
      
      maxcnt=max(maxcnt,cnt);
      
    }    
    
    ans=min(ans,maxcnt);
    
  }

  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
n, x, y = gets.split.map(&:to_i)
x -= 1
y -= 1
a = Array.new(n){0}
(n - 1).times do |i|
  i.next.upto(n - 1) do |j|
    a[[j - i, (i - x).abs + 1 + (j - y).abs].min] += 1
  end
end
1.upto(n - 1) do |i|
  puts a[i]
end

Measured memory_bytes: 1916
#include <stdio.h>

int main(void)
{
  int a,b,i;
  scanf("%d %d",&a,&b);
  if(a<b){
    for(i=1;i<=b;i++){
      printf("%d",a);
    }
  }else{
      for(i=1;i<=a;i++){
        printf("%d",b);
      }
  }
  return 0;
} 


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N;
	LL tmp = 0;
	LL ans = 0;
	for(int i=0; i<N; i++){
		LL A;
		cin >> A;
		if(A >= tmp){
			ans += tmp;
			tmp = A - tmp;
		}
		else{
			ans += A;
			tmp = 0;
		}
		if(tmp / 2 > 0){
			ans += tmp / 2;
			tmp = tmp - (tmp/2)*2;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	// degree of vertices
	d := make([]int, 4)
	var a, b int
	for i := 0; i < 3; i++ {
		fmt.Scan(&a, &b)
		d[a-1]++
		d[b-1]++
	}
	c := 0
	for _, v := range d {
		if v%2 == 1 {
			c++
		}
	}
	if c == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	printf((a&1)!=(b&1)?"IMPOSSIBLE\n":"%d\n",a+b>>1);
	return 0;
}
/*1
2 16
*/
/*2
0 3
*/
/*3
998244353 99824435
*/

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

int main()
{
	int ary[101][101] = { 0 };

	int r, c;
	cin >> r >> c;
	
	for (int j = 0; j < r; j++)
	{
		for (int i = 0; i < c; i++)
		{
			cin >> ary[j][i];
		}
	}

	//?¨?????????°???
	for (int j = 0; j < r; j++)
	{
		for (int i = 0; i < c; i++)
		{
			ary[j][c] += ary[j][i];
		}
	}

	//???????????°???
	for (int i = 0; i < c + 1; i++)
	{
		for (int j = 0; j < r; j++)
		{
			ary[r][i] += ary[j][i];
		}
	}

	//??????
	for (int j = 0; j < r + 1; j++)
	{
		for (int i = 0; i < c + 1; i++)
		{
			cout << ary[j][i];

			if (i != c)
			cout << " ";
		}
		cout << "\n";
	}



	

	return 0;
}

Measured memory_bytes: 1208
m,k=map(int,input().split())

n=300005

def init_max(init_max_val):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]    
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = 0

#num_max:n以上の最小の2のべき乗
num_max =2**(n-1).bit_length()
seg_max=[ide_ele_max]*2*num_max

for _ in range(m):
    a=int(input())
    maxl=query_max(max(0,a-k),min(n-1,a+k)+1)
    update_max(a,maxl+1)

print(query_max(0,n+1))

Measured memory_bytes: 99084
# ABC043 B

s = input()
word = ''

for i in range(len(s)):
    if s[i] == '0':
        word = word + '0'
    elif s[i] == '1':
        word = word + '1'
    else:
        if len(word) != 0:
            word = word[:-1]

print(word)


Measured memory_bytes: 2940
def d_all_your_paths_are_different_lengths(L):
    do = []
    while L > 2:
        if L % 2 == 0:
            do.append('*2')
            L >>= 1
        else:
            do.append('+1')
            L -= 1
    do.reverse()

    vertex = 2
    l = 2
    edge = [[1, 2, 0], [1, 2, 1]]
    for op in do:
        if op == '*2':
            edge = [[v1, v2, c * 2] for v1, v2, c in edge]
            edge.append([vertex, vertex + 1, 0])
            edge.append([vertex, vertex + 1, 1])
            vertex += 1
            l *= 2
        elif op == '+1':
            edge.append([1, vertex, l])
            l += 1

    ans = '{} {}\n'.format(vertex, len(edge))
    ans += '\n'.join([' '.join(map(str, row)) for row in edge])
    return ans

L = int(input())
print(d_all_your_paths_are_different_lengths(L))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x <= 3) ans += 4 - x;
  if (y <= 3) ans += 4 - y;
  if (x == 1 & y == 1) ans += 4;
  cout << (ans * (int)1e5);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
/**
 * Write a description of class password here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Main
{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String s = sc.next();
        s += sc.nextLine();
        char current;
        int count = 0;
        for(int i = 0;i<s.length()-1;i++)
        {
            current = s.charAt(i);
            if(current != s.charAt(i+1))
            {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 27628
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pii make_pair
#define pb push_back
#define ff first
#define ss second
int ceil(int a, int b) { if(a%b==0) return a/b; else return a/b+1; }
bool checkbit(int pos, int mask) { return mask&(1<<pos); }
int turnon(int pos, int mask) { return mask|(1<<pos); }

main()
{
    fastio;
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s') cout<<s+"es";
    else cout<<s+"s";
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
#define repM1(i, n) for(ll i = (ll)(n - 1); i > 0; i--)
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; }

int main()
{
	cout << fixed << setprecision(18);

	ll n, k;
	cin >> n >> k;

	vector<ll> p(n);

	rep(i, n)
		cin >> p[i];

	sort(p.begin(), p.end());

	ll ans = 0;
	rep(i, k)
		ans += p[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
A,B,C,D = gets.chomp.chars.map(&:to_i)

op = [?+,?-]

op.each do |i|
  op.each do |j|
    op.each do |k|
      if eval "#{A}#{i}#{B}#{j}#{C}#{k}#{D}==7"
        puts "#{A}#{i}#{B}#{j}#{C}#{k}#{D}=7"
        exit
      end
    end
  end
end

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=3005;
//ll fact[N];

ll dp[N][N];

void solve()
{
    int n;
    cin>>n;
    vll a(n);
    cin>>a;

    for(int l=n-1; l>=0 ; l--)
    {
        for(int r = l; r<n; r++)
        {
            if(l==r) dp[l][r] = a[l];
            else dp[l][r] = max(a[l]-dp[l+1][r], a[r]-dp[l][r-1]);
        }
    }


    cout<<dp[0][n-1];
}

int main()
{
    fastio;
    
    int t=1;
    //cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 49780
#include "bits/stdc++.h"
#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    speed;
    int a, b;
    cin >> a >> b;
    if (a <= b)
        cout << a;
    else
        cout << a - 1;
    ed;
    return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int a[n],b[n],c[m],d[m];
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i] >> d[i];

    int l,min,ans;
    for(int i = 0; i < n; i++){
        min = 1e9;
        for(int j = 0; j < m; j++){
            l = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(l < min){
                min = l;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

int main() {
    LL n,m;
    read(n);read(m);
    if(n*2>m) {
        printf("%lld\n",m/2);
    } else {
        printf("%lld\n",n+((m-2*n)/4));
    }
    return 0;
}

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

const int INF =1e9;
const int MOD =1e9+7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

ll powmod(ll n, ll x)
{
    vector<ll> vll(32);
    vll[0] = n;
    FOR(i, 1, 32)
    {
        vll[i] = (vll[i - 1] * vll[i - 1]) % MOD;
    }
    ll ret = 1;
    int cnt = 0;
    while (x > 0) {
        if (x & 1) {
            ret = (ret * vll[cnt]) % MOD;
        }
        x >>= 1;
        cnt++;
    }
    return ret;
}

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

cout<<(powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n)+MOD+MOD)%MOD<<endl;;
}

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

int main() {
    int n,l;
    long long cnt = 0;
    cin >> n;
    vector<int>wa(n);
    vector<int>table(3000000,0);

    for (int i = 1; i < n+1; i++) {
      cin >> l;
      wa.at(i-1) = l + i;

      if (i-l >= 0) {
        table.at(i-l)++;
      }

    }

    for (int i = 0; i < n; i++) {
      if (wa.at(i) <= 2100000) {
        cnt += table.at(wa.at(i));
      }
    }
    cout << cnt << endl;
}


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

int main(){
 	int min=1000000, max=-1000000, n, tmp, i;
 	long sum=0;
 
 	cin >> n;
 
 	for(i = 0; i < n; i++) {
 		cin >> tmp;
	
		if ( tmp < min) {
			min = tmp;
		}
		
		if ( tmp > max) {
			max = tmp;
		}
		sum += tmp;
 	}
  	cout << min << " " << max << " " << sum <<endl;

 	return 0;
}

Measured memory_bytes: 3104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>




#include <ostream>
#include <sstream>


using namespace std;

class C {
public:

  int sgn(long long int val) {
    if (val == 0) {
      return 0;
    }
    if (val < 0) {
      return -1;
    }
    return 1;
  }

  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    int n;
    in >> n;
    vector<long long int> a(n), p(n);
    for (int i = 0; i < n; ++i) {
      in >> a[i];
    }
//    int res = 0;
    long long int steps = 0;
    long long int steps2 = 0;
    p[0] = a[0];
    if (a[0] != 0) {
      for (int i = 0; i < n - 1; ++i) {
        p[i + 1] = p[i] + a[i + 1];
        if (sgn(p[i]) != -sgn(p[i + 1])) {
          steps += abs(p[i + 1]) + 1;
          p[i + 1] = -sgn(p[i]);
        }
      }
      steps2 = abs(a[0]) + 1;
      p[0] = -sgn(p[0]);
      for (int i = 0; i < n - 1; ++i) {
        p[i + 1] = p[i] + a[i + 1];
        if (sgn(p[i]) != -sgn(p[i + 1])) {
          steps2 += abs(p[i + 1]) + 1;
          p[i + 1] = -sgn(p[i]);
        }
      }
    } else {
      p[0] = 1;
      for (int i = 0; i < n - 1; ++i) {
        p[i + 1] = p[i] + a[i + 1];
        if (sgn(p[i]) != -sgn(p[i + 1])) {
          steps += abs(p[i + 1]) + 1;
          p[i + 1] = -sgn(p[i]);
        }
      }
      p[0] = -1;
      for (int i = 0; i < n - 1; ++i) {
        p[i + 1] = p[i] + a[i + 1];
        if (sgn(p[i]) != -sgn(p[i + 1])) {
          steps2 += abs(p[i + 1]) + 1;
          p[i + 1] = -sgn(p[i]);
        }
      }
      ++steps;
      ++steps2;
    }
    steps = min(steps, steps2);
    out << steps << endl;
  }

};


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


Measured memory_bytes: 1792