akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int d, g, ans = 10000000;
vector<int> p, c;
int func2(vector<int>& v){
  int score = 0, ret = 0;
  for(int i = 0; i < v.size(); i++){
    if(v[i] == 1){
      ret += p[i];
      score += 100 * (i + 1) * p[i] + c[i];
    }
  }
  if(score >= g) return ret;
  for(int i = p.size() - 1; i >= 0; i--){
    //cout << score << endl;
    if(v[i] == 1) continue;
    for(int j = 0; j < p[i]; j++){
      ret++;
      score += 100 * (i + 1);
      if(j == p[i] - 1) score += c[i];
      if(score >= g) return ret;
    }
  }
  return 10000000;
}

void func(vector<int>& v){
  if(v.size() == d){
    //for(int i = 0; i < v.size(); i++) cout << v[i]; cout << endl;
    ans = min(func2(v), ans);
    return;
  }
  v.push_back(0);
  func(v);
  v.pop_back();
  v.push_back(1);
  func(v);
  v.pop_back();
  return;
}

void solve(){
  cin >> d >> g;
  for(int i = 0; i < d; i++){
    int a, b; cin >> a >> b;
    p.push_back(a);
    c.push_back(b);
  }
  vector<int> v;
  func(v);
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<string> s(N);
	rep(i, N){
		cin >> s.at(i);
	}
	int ans = 0;
	int onlyB = 0;
	int onlyA = 0;
	int BandA = 0;
	rep(i, N){
		rep(j, s.at(i).size()-1){
			if(s.at(i).at(j)=='A' && s.at(i).at(j+1)=='B'){
				ans++;
			}
		}
		if(s.at(i).at(0)=='B' && s.at(i).back()!='A'){
			onlyB++;
		}
		if(s.at(i).at(0)!='B' && s.at(i).back()=='A'){
			onlyA++;
		}
		if(s.at(i).at(0)=='B' && s.at(i).back()=='A'){
			BandA++;
		}
	}
	if(BandA != 0){
		ans += BandA - 1;
		BandA = 1;
	}
	int x = min({onlyA, onlyB, BandA});
	ans += x * 2;
	int a = onlyA - x;
	int b = onlyB - x;
	int c = BandA - x;
	if(min(a, b) != 0){
		ans += min(a, b);
	}
	if(min(a, c) != 0){
		ans += min(a, c);
	}
	if(min(c, b) != 0){
		ans += min(c, b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> a, b;
int n, m;

bool check(int h, int w) {
    if (h+m-1 >= n || w+m-1 >= n)
        return false;
    
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            if (a[h+i][w+j] != b[i][j])
                return false;
        }
    }

    return true;
}

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (check(i, j)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <limits>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int64_t>> mat(n);
    for (auto &row : mat)
        row.resize(n, numeric_limits<int64_t>::max());

    int64_t ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> mat[i][j];
        }
    }

    auto minmat = mat;
    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
            {
                if (minmat[i][j] > minmat[i][k] + minmat[k][j])
                {
                    minmat[i][j] = minmat[i][k] + minmat[k][j];
                }
            }

    if (mat != minmat)
    {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
        {
            bool check = true;
            for (int k = 0; k < n; k++)
            {
                if (k == i || k == j)
                    continue;
                if (minmat[i][j] >= minmat[i][k] + minmat[k][j])
                    check = false;
            }
            if (check)
                ans += minmat[i][j];
        }

    ans /= 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int cnt_digits(long long N) {
    int digits = 0;
    while (N > 0) {
        N /= 10;
        digits++;
    }
    return digits;
}


int main()
{
    long long N;
    long long A, B;

    cin >> N;

    for (A = 1; A <= N; A++) {
        if (A*A > N)
            break;
        if (N % A == 0)
            B = A;
    }
    cout << cnt_digits(N/B) << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int( input())
A = Counter(list( map( int, input().split())))
Q = 10**9 + 7
ans = 1
for i in range(N-1, 0, -2):
    if A[i] == 2:
        ans *= 2
        ans %= Q
    else:
        ans = 0
        break
if N%2 == 1:
    if A[0] != 1:
        ans = 0
print(ans)


Measured memory_bytes: 14820
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PalindromicTree{
  struct node{
    map<char,int> nxt;
    int len,suf,app,cnt;
    node(){}
    node(int len,int suf,int app,int cnt)
      :len(len),suf(suf),app(app),cnt(cnt){}
  };
  vector<node> v;
  vector<int> ord;
  int n,ptr;
  
  PalindromicTree(){}
  PalindromicTree(const string &s)
    :v(s.size()+10),n(2),ptr(1){
    
    v[0]=node(-1,0,-1,0);
    v[1]=node( 0,0,-1,0);
    
    for(int i=0;i<(int)s.size();i++) add_char(s,i);
    calc_order();
    calc_count();    
  }
  
  bool add_char(const string &s,int pos){
    char ch=s[pos];
    int cur=ptr;
    while(1){
      if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch) break;
      cur=v[cur].suf;
    }
    if(v[cur].nxt.count(ch)){
      ptr=v[cur].nxt[ch];
      v[ptr].cnt++;
      return false;
    }
    ptr=n++;

    v[ptr]=node(v[cur].len+2,-1,pos-v[cur].len-1,1);    
    v[cur].nxt[ch]=ptr;
    
    if(v[ptr].len==1){
      v[ptr].suf=1;
      return true;
    }
    
    while(1){
      cur=v[cur].suf;
      if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch){
        v[ptr].suf=v[cur].nxt[ch];
        break;
      }
    }
    return true;
  }
  
  void calc_order(){
    ord.clear();
    ord.push_back(0);
    ord.push_back(1);
    for(int i=0;i<(int)ord.size();i++)
      for(auto &p:v[ord[i]].nxt) ord.push_back(p.second);
  }
  
  void calc_count(){
    for(int i=(int)ord.size()-1;i>=0;i--)
      v[v[ord[i]].suf].cnt+=v[ord[i]].cnt;
  }
};
//END CUT HERE

struct RollingHash{
  using ull = unsigned long long;
  vector<ull> hash,p;
  RollingHash(){}
  RollingHash(const string &s,ull B=1e9+7){
    int n=s.size();
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=hash[i]*B+s[i];
      p[i+1]=p[i]*B;
    }
  }
  //s[l, r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};
//INSERT ABOVE HERE

signed main(){
  using ll = long long;
  string s,t;
  cin>>s>>t;
  PalindromicTree p1(s),p2(t);
  RollingHash r1(s),r2(t);
  using ull = RollingHash::ull;
  
  const int MAX = 5e5+100;
  map<ull, int> m1[MAX];
  for(int i=0;i<(int)p1.n;i++){
    PalindromicTree::node& u=p1.v[i];
    if(u.app<0) continue;
    m1[u.len][r1.find(u.app,u.app+u.len)]=u.cnt;
  }
  
  ll ans=0;
  for(int i=0;i<(int)p2.n;i++){
    PalindromicTree::node& u=p2.v[i]; 
    ull x=r2.find(u.app,u.app+u.len);
    if(u.app<0||!m1[u.len].count(x)) continue;
    ans+=(ll)m1[u.len][x]*u.cnt;
  }
  
  cout<<ans<<endl;
  return 0;
}

/*
  verified on 2018/11/07
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2292
  https://yukicoder.me/problems/no/263
*/



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

struct Team{
    int solved, penalty, num;
    bool operator<(const Team &obj)const{
        if(solved == obj.solved && penalty != obj.penalty)return penalty > obj.penalty;
        if(solved != obj.solved)return solved < obj.solved;
        return num < obj.num;
    }
    bool operator==(const Team &obj)const{
        return solved == obj.solved && penalty == obj.penalty;
    }
};

int penalty[52][12]={0};

void init(){
    for(int i=0;i<=50;++i){
        for(int j=0;j<=10;++j){
            penalty[i][j] = 0;
        }
    }
}

int main(){
    int m, t, p, r;
    while(cin >> m >> t >> p >> r, m != 0){
        init();
        vector<Team> v(t);
        for(int i=0;i<t;++i)v[i].num = i+1;
        for(int i=0;i<r;++i){
            int mi, ti, pi, ji;
            cin >> mi >> ti >> pi >> ji;
            if(ji == 0){
                v[ti-1].solved++;
                v[ti-1].penalty += mi + (penalty[ti-1][pi-1]*20);
            }else{
                penalty[ti-1][pi-1]++;
            }
        }
        sort(v.rbegin(), v.rend());
        for(int i=0;i<t;++i){
            if(i){
                if(v[i] == v[i-1])cout << "=";
                else cout << ",";
            }
            cout << v[i].num;
        }
        cout << endl;
    }

    return 0;
}



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

using namespace std;

int main(void){

    string  s, t;
    int     l, i;

    cin >> s;
    cin >> t;

    l = t.length();
    for (i = 0; i < l; i++) {
        if (s[i] != t[i]) {
            break;
        }
    }

    if (i == (l - 1)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;

}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	int A;
	string S;
	cin>>A>>S;
	if(A>=3200){
		cout<<S<<endl;
	}
	else{
		cout<<"red"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, i;

    scanf("%d", &n);

    if(n >= 1 && n <= 999){

        i = n % 10;

        if(i == 2 || i == 4 || i == 5 || i == 7 || i == 9){
            printf("hon");
        }

        if(i == 0 || i == 1 || i == 6 || i == 8){
            printf("pon");
        }

        if(i == 3){
            printf("bon");
        }
    }
    return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    if(S[0] == '7' || S[1] == '7' || S[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	long long ans = 0;
	for(int i = 0; i < s.size(); i++){
		for(int j = i; j < s.size(); j++){
			long long ways = 1;
			if(i >= 1) ways *= 1<<(i - 1);
			if(s.size() - j - 1 > 1) ways *= 1<<(s.size() - j - 2);
			for(int k = i; k <= j; k++){
				long long v = s[k] - '0';
				for(int l = 0; l < j - k; l++) v *= 10;
				v *= ways;
				ans += v;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
n_list = [0]
digit_N = len(str(N))

def setDigit(N_max, sum_min, sum_max, digit):
    n_max = int(N_max / (10 ** (digit - 1)))
    for i in range(min(n_max, sum_max, 9) + 1):
        if digit == 1 and i >= sum_min:
            n_list.append(N - N_max + i)
        elif digit == 1 and i < sum_min: continue
        else:
            setDigit(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)


setDigit(N, A, B, digit_N)

print(sum(n_list))


Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	string n=":(";
	rep1(i,N){
		int val=(int)(i*1.08);
		if(val==N){
			prin(i);
			return 0;
		}
	}
	prin(n);
	return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.1**i-1)/1.1)for i in range(19,1,-1)]+[1]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


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

int main(){
	string S, ans = "No";
	cin >> S;
	if(S[0] == S[1]){
		if(S[0] != S[2]){
			if(S[2] == S[3])ans = "Yes";
		}
	}else if(S[0] == S[2]){
		if(S[1] == S[3])ans = "Yes";
	}else if(S[0] == S[3]){
		if(S[1] == S[2])ans ="Yes";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 1e9 + 7;

long long big_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) {
			res = (res * a) % mod;
		}

		b >>= 1;
		a = (a * a) % mod;
	}

	return res % mod;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	if (n & 1) {
		if (occs[0] != 1) {
			cout << "0\n";
			return 0;
		}

		for (int i = 2; i < n; i += 2) {
			if (occs[i] != 2) {
				cout << "\n";
				return 0;
			}
		}
	} else {
		for (int i = 1; i < n; i += 2) {
			if (occs[i] != 2) {
				cout << "0\n";
				return 0;
			}
		}
	}

	cout << big_pow(2, n / 2) << "\n";

	return 0;

}

Measured memory_bytes: 640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

ll a[MAXN];
ll b[MAXN];

int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	ll sum = 0;
	for (int i = 0; i < n; ++i)
		sum += a[i];
	for (int i = 0; i < n; ++i)
		sum -= b[i];
	if (sum < 0) {
		cout << -1 << "\n";
		return 0;
	}
	vector<pair<ll, int>> vv;
	for (int i = 0; i < n; ++i)
		if (a[i] > b[i])
			vv.emplace_back(a[i] - b[i], i);
	sort(ALL(vv));
	reverse(ALL(vv));
	int ans = 0;
	int now = 0;
	ll lf = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] < b[i]) {
			++ans;
			ll nd = b[i] - a[i];
			ll go = min(lf, nd);
			nd -= go;
			lf -= go;
			while (nd) {
				lf += vv[now].first;
				++now;
				go = min(lf, nd);
				nd -= go;
				lf -= go;
			}
		}
	}
	cout << ans + now << "\n";
	return 0;
}




Measured memory_bytes: 2936
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
abcs = [list(map(int, input().split())) for i in range(M)]
INF = 10**9
dist_list = [[INF if i != j else 0 for j in range(N)] for i in range(N)]

# distance[i][j]で(i, j)間の最短の移動距離を保持
for abc in abcs:
    a = abc[0]-1
    b = abc[1]-1
    c = abc[2]
    if c < dist_list[a][b]:
        dist_list[a][b] = c
        dist_list[b][a] = c
# ワーシャルフロイド
for i in range(1, N):
    for j in range(N):
        for k in range(N):
            dist_list[j][k] = min(dist_list[j][k], dist_list[j][i] + dist_list[i][k])
            dist_list[k][j] = dist_list[j][k]

# 総当たり
result = []


def permutation(data, res):
    global result
    if len(data) == 0:
        result.append(res)
        return

    for i in data:
        _res = res[::]
        _res.append(i)
        _data = data[::]
        _data.remove(i)
        permutation(_data, _res)


permutation(r, [])
min_distance = INF
for res in result:
    distance = 0
    for i in range(1, len(res)):
        x = res[i]-1
        y = res[i-1]-1
        distance += dist_list[x][y]
    if distance < min_distance:
        min_distance = distance
print(min_distance)


Measured memory_bytes: 67292
n = int(input())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
l_a_new=[0]
l_b_new=[0]
num_a=0
num_b=0
for i in range(n):
    num_a += l_a[i]
    num_b += l_b[i]
    l_a_new.append(num_a)
    l_b_new.append(num_b)
lst_ans=[]
for i in range(1,n+1):
    can = l_a_new[i]+l_b_new[n]-l_b_new[i-1]
    lst_ans.append(can)
print(max(lst_ans))

Measured memory_bytes: 3064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func checkNext(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] <= x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	t := getString()
	p := make([][]int, 26)
	n := len(s)
	for i := 0; i < n; i++ {
		a := int(s[i] - 'a')
		p[a] = append(p[a], i)
	}

	ans := 0
	pos := 0
	for i := 0; i < len(t); i++ {
		x := int(t[i] - 'a')
		if len(p[x]) == 0 {
			out(-1)
			return
		}
		po := lowerBound(p[x], pos)
		// out(po, p[x], t[i:i+1])
		if po >= len(p[x]) {
			po = 0
			ans += n
		}
		pos = p[x][po] + 1
		// out(pos)
	}
	out(ans + pos)
}


Measured memory_bytes: 5760
import sys
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
# floatをそのまま掛け算すると精度が足りずに誤差が生じるため、.を消してintにする。
if '.' in b[-2:]: 
    b = int(b.replace(".", "")) * 10
else:
    b = int(b.replace(".", ""))
output = a * b // 100
# 小数点は2桁までで確定なので、100で切り捨て除算する。
print(output)

Measured memory_bytes: 61952
let rec seq a b = if a > b then [] else a :: seq (a+1) b
let (>>=) x f = List.map f x |> List.concat
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y z -> x,y,z)) in
  ([-1;1] >>= fun s1 ->
   [-1;1] >>= fun s2 ->
   [-1;1] >>= fun s3 -> [
     let ga = Array.map (fun (x,y,z) -> (s1*x + s2*y + s3*z, (x,y,z))) a in
     Array.sort compare ga;
     let g1,g2,g3 =
       Array.init m (fun i -> snd ga.(i))
       |> Array.fold_left (fun (a,b,c) (x,y,z) -> (a+x,b+y,c+z)) (0,0,0)
     in abs g1 + abs g2 + abs g3
   ])
  |> List.fold_left max (-10101010101010)
  |> Printf.printf "%d\n"

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

#define ll long long
#define maxn 105
#define mo 1000000007
using namespace std;

int main(){
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        if ((int) floor(log10(i) + 1) % 2 == 1)
            ans++;
    }
    printf("%d", ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    string s,t;
    cin >> s >> t;
    t.erase(t.size()-1);
    if(s==t) cout << "Yes" << endl;
    else cout << "No" << endl;
}
 

Measured memory_bytes: 3632
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const n = Number(input[0])
    const as = input[1].split(" ").map(el => parseInt(el))
    let arr = new Array(n).fill(0)
    for(let a of as){
        arr[a-1] = arr[a-1] + 1
    }
    for(let el of arr){
        console.log(el)
    }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  



Measured memory_bytes: 61556
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
for j in range(q):
    i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=i[2]+pre
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = i[2]+pre
s = pre+s+nex
if c ==-1:
    s = s[::-1]
print(s)

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    ll n,all = 0;
    cin>>n;
    unordered_map<ll,ll>mp;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(auto &itr:mp){
        all += (itr.second * (itr.second - 1))/2;
    }   

    rep(i,n){
        cout<<all - (mp[a[i]] * (mp[a[i]] - 1))/2 + ((mp[a[i]] - 2) * (mp[a[i]] - 1))/2 <<endl;
    }
    return 0;
}


Measured memory_bytes: 10284
#include<stdio.h>
int main(void)
{
	int a,b,i,x,y,z,c;
	scanf("%d %d",&a,&b);
	x=0;
	z=0;
	y=100;
	if(b!=1){
		for(i=1;i<=20;i++){
			x=a*i;
			z=i;
			c=x-(z-1);
			if(c>=b){
				if(z<=y){
				y=z;
				x=0;
				z=0;
				}
			}
			else x=0;
		}
		printf("%d\n",y);
	}
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 128
s,t=input().split()
s_num,t_num=input().split()
s_num,t_num=int(s_num),int(t_num)
string=input()
if s==string:
    s_num-=1
else :
    t_num-=1

print(str(s_num) + ' ' + str(t_num))

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC156
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }
        
        public static void b()
        {
            int[] nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int l = nk[0];
            int k = nk[1];
            int a = 0;
            bool flg = true;
            string n = "";
            if (nk[1] == 2 || nk[1] == 8 || nk[1] == 10 || nk[1] == 16)
                n = Convert.ToString(nk[0], nk[1]);
            else
            {
                while (flg)
                {
                    n += l % k;
                    a = l / k;
                    l = a;
                    if (a == 0)
                    {
                        flg = false;
                    }
                }
            }
            Console.WriteLine(n.Length);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int n;
    cin >> n;
    string S[n];
    rep(i,n) cin >> S[i];
    string ans={};
    
    for(char i='a';i<='z';i++){
        int sum=INF;
        rep(k,n){
            int cou=0;
            rep(j,S[k].size()){
                if(i==S[k].at(j)){
                    cou++;
                }
            }
            sum=min(cou,sum);
        }
        rep(j,sum){
            ans+=i;
        }
    }
    cout << ans << endl;



}


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

int main()
{
  int X;
  std::cin >> X;

  int ret = -1;
  for(int b=1; b<=std::sqrt(X); b++) {
    int t = b;
    for(int p=2; p<=10; p++) { // 2^10 = 1024
      t *= b;
      if(X < t) {
        continue;
      } else if(ret < t) {
        ret = t;
      }
    }
  }

  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int n; cin >> n;
	
	vector<int> a(n), ans(n,0); rep(i,n) cin >> a[i];
	
	int sum = 0;
	
	rep(i,n){
		sum = sum ^ a[i];
	}
	
	rep(i,n){
		int ans = sum ^ a[i];
		cout << ans << " ";
	}
	
	cout << endl;
	
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;
int n, t;
int a[N], b[N], ACnt[N], BCnt[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        a[i] = t;
        ++ACnt[t];
    }
    for (int i = 0; i < n; ++i) {
        cin >> t;
        b[i] = t;
        ++BCnt[t];
    }
    for (int i = 0; i < N; ++i) {
        if (ACnt[i] + BCnt[i] > n) {
            cout << "No" << endl;
            exit(0);
        }
    }
    reverse(b, b + n);
    int left = 0, right = n - 1;
    for (int i = 0; i < n; ++i) {
        if (b[i] == a[i]) {
            if (i - left >= right - i) {
                swap(b[i], b[left]);
                left++;
            } else {
                swap(b[i], b[right]);
                --right;
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 6692
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        //t=太郎、h=花子
        String t,h;
        int score_t=0;
        int score_h=0;

        for(int i=0; i<n; i++){
            t = sc.next();
            h = sc.next();
            
            //同値
            if(t.compareTo(h) == 0){
                score_t += 1;
                score_h += 1;
            }
            //t>h
            else if(t.compareTo(h) > 0){
                score_t += 3;
            }
            //t<h
            else{
                score_h += 3;
            }
        }
        System.out.println(String.format("%d %d",score_t,score_h));

    }

}



Measured memory_bytes: 30204
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define int long long
#define PB push_back

int gcd(int a, int b)
{
    int tmp;
    while (b) {
        tmp = a;
        a = b;
        b = tmp % b;
    }
    return a;
}

inline int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}

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

    int L;
    
    while (cin >> L, L) {
        vector<int> divisors;

        for (int i = 1; i * i <= L; ++i) {
            if (L % i == 0) {
                divisors.PB(i);
                if (i * i != L) divisors.PB(L / i);
            }
        }

        sort(begin(divisors), end(divisors));

        int ans = 0;

        for (int i = 0; i < (int)divisors.size(); ++i) {
            for (int j = 0; j <= i; ++j) {
                int ii = divisors[i], jj = divisors[j];

                if (lcm(ii, jj) == L) {
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }
}

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

using namespace std;

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

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

const int MAXN = 1e5 + 5;

int N, M;

vector<int> avail[MAXN];
int dsu[MAXN];

int find(int x){
    return dsu[x] == x ? x : dsu[x] = find(dsu[x]);
}

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

    cin >> N >> M;

    for(int a = 1; a <= N; a++){
        dsu[a] = a;
        int x;
        cin >> x;
        avail[a].push_back(x);
    }

    while(M--){
        int u, v;
        cin >> u >> v;
        int fu = find(u);
        int fv = find(v);

        if(fu != fv){
            if(avail[fv].size() > avail[fu].size()){
                swap(fu, fv);
            }

            dsu[fv] = fu;
            while(!avail[fv].empty()){
                avail[fu].push_back(avail[fv].back());
                avail[fv].pop_back();
            }
        }
    }

    for(int a = 1; a <= N; a++){
        sort(allof(avail[a]));
    }

    int ans = 0;
    for(int a = 1; a <= N; a++){
        int root = find(a);

        if(binary_search(allof(avail[root]), a)){
            ans++;
        }
    }

    cout << ans;
}


Measured memory_bytes: 9848
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		long H[]=new long[N];
		long ans=0;
		for(int i=0;i<N;i++){
			H[i]=stdIn.nextInt();
		}
		Arrays.sort(H);
		for(int i=0;i<N-K;i++){
			ans+=H[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 89128
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0])
        cout<<"YES\n";
    else
        cout<<"NO\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	bool flag = true;
	if (a < c && c < b) {
		flag = false;
	}
    if (c > b && c < a) {
		flag = false;
	}
	if (flag) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


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

int main()
{
	int A, B;

	cin >> A >> B;

	for (int i = 0;; i++)
	{
		if ((A - 1) * i + 1 >= B)
		{
			cout << i << endl;

			return 0;
		}
	}
}


Measured memory_bytes: 256
def ans():
  N, T = map(int,input().split())
  cost = 1e9
  for _ in range(N):
    c, t = map(int,input().split())
    if(t <= T):
      if(cost > c):
        cost = c
  if(cost == 1e9):
    print("TLE")
  else:
    print(cost)
ans()

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

using namespace std;
using ll=long long;

int main(){
    string s;
    cin>>s;
    int q;
    cin>>q;
    int vec=0;
    string m="";
    for(int Q = 0;Q < q; ++Q) {
        int t;
        cin>>t;
        if(t==1) {
            ++vec;
            vec%=2;
        }
        else {
            int f;
            char c;
            cin>>f>>c;
            f+=vec;
            f%=2;
            if(f==0) {
                s.push_back(c);
            }
            else {
                m.push_back(c);
            }
        }
    }
    reverse(m.rbegin(),m.rend());
    string ans=m+s;
    if(vec==1)reverse(ans.rbegin(),ans.rend());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1248
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
            // main
        Scanner sc = new Scanner(System.in);
        String S = getLine(sc);

        show(calc(S));
    }

    private static String calc(String S) {
        int front = Integer.parseInt(S.substring(0, 2));
        int back = Integer.parseInt(S.substring(2, 4));

        if (isMonth(front)) {
            if (isMonth(back)) return "AMBIGUOUS";
            else return "MMYY";
        } else {
            if (isMonth(back)) return "YYMM";
            else return "NA";
        }
    }

    private static boolean isMonth(int n) {
        return 0 < n && n < 13;
    }

    private static String getLine(Scanner sc) { return sc.next(); }
    private static void show(String answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 21712
N = int(input())
H = list(map(int, input().split()))

ans = 0
while(max(H)>=0):
    ans +=1
    for i in range(N):
        H[i] -= 1
        if (H[i] >= 0):
            if (i>=1):
                if (H[i-1] < 0 and max(H[:i])>=0):
                    ans += 1

print(ans-1)

Measured memory_bytes: 3064
def fu(n):
    if n<0:
        return (n*(-1))
    return n
n = int(input())
h = list(map(int,input().split()))

l1 = [0 for i in range(n)]
l1[n-1] = 0
l1[n-2] = abs(h[n-1]-h[n-2])
for i in range(n-3,-1,-1):
    l1[i] = min(abs(h[i]-h[i+1])+l1[i+1],abs(h[i]-h[i+2])+l1[i+2])
print(l1[0])

Measured memory_bytes: 13976
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

using tl = tuple<ll, ll, ll>;

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

    ll n, m, s;
    cin>>n>>m>>s;
    vector<vector<tl>> to(n);
    rep(i, m) {
        ll u, v, a, b;
        cin>>u>>v>>a>>b; u--; v--;
        to[u].emplace_back(b, v, -a);
        to[v].emplace_back(b, u, -a);
    }
    rep(i, n) {
        ll c, d;
        cin>>c>>d;
        to[i].emplace_back(d, i, c);
    }

    vvl dist(n, vl(2501, LINF));
    priority_queue<tl, vector<tl>, greater<tl>> q;
    q.emplace(0, 0, s);
    while (!q.empty()) {
        tl t = q.top(); q.pop();
        ll d = get<0>(t);
        ll v = get<1>(t);
        ll c = get<2>(t);

        if (c < 0) continue;
        chmin(c, 2500ll);
        if (dist[v][c] != LINF) continue;
        dist[v][c] = d;
        for (auto nt : to[v]) {
            ll nd = get<0>(nt) + d;
            ll nv = get<1>(nt);
            ll nc = get<2>(nt) + c;
            q.emplace(nd, nv, nc);
        }
    }
    rep(i, n - 1) {
        ll mi = LINF;
        rep(j, 2500) {
            chmin(mi, dist[i + 1][j]);
        }
        cout<<mi<<endl;
    }
}

Measured memory_bytes: 16460
//g++  5.4.0

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll a;
    cin>>a;
    for(ll i=1;i<=9;++i)
    {
        if(a%i==0&&a/i<=9)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}

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

int main(){


    ll n;
    cin>>n;
    string s;
    while(n){
        n--;
        s+=(n%26+'a');
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s;


}


Measured memory_bytes: 3624
n1 = int(input())

m1 = 0
s1 = 0
t1 = 0

for i1 in range(n1):
    t1 = int(input())
    s1 += t1
    if m1 < t1:
        m1 = t1

s1 -= (m1 // 2)
print(s1)

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

using namespace std;
int main() {
  int k,s; 
  int count = 0;
  cin >> k >> s;

  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      int z=s-x-y;
      if(z > k || z < 0)
        continue;
      count++;
    }
  }
  
  cout << count << endl;
  
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

int main() {
  ll X,Y,Z,K;cin>>X>>Y>>Z>>K;
  vector<ll> AS(X),BS(Y),CS(Z);
  // 組み合わせ
  REP(i,X) cin>>AS[i];
  REP(i,Y) cin>>BS[i];
  REP(i,Z) cin>>CS[i];

  // X*Y*ZがKと同じなら全部
  if (X*Y*Z==K) {
    vector<ll> res;
    REP(x,X)REP(y,Y)REP(z,Z) {
      res.push_back(AS[x]+BS[y]+CS[z]);
    }
    sort(ALL(res),greater<ll>());
    REP(i,K) {
      OUT(res[i]);
    }
    return 0;
  }

  // 以下はX*Y*Z>K
  sort(ALL(AS),greater<ll>());
  sort(ALL(BS),greater<ll>());
  sort(ALL(CS),greater<ll>());

  vector<ll> res;
  tuple<ll,int,int,int> tp;
  priority_queue<tuple<ll,int,int,int>> q;
  q.push(make_tuple(AS[0]+BS[0]+CS[0],0,0,0));
  vector<vector<vector<bool>>> visited(X,vector<vector<bool>>(Y,vector<bool>(Z,false)));
  visited[0][0][0] = true;

  REP(i,K) {
    ll total;
    ll a_idx,b_idx,c_idx;
    tie(total,a_idx,b_idx,c_idx) = q.top();q.pop();
    res.push_back(total);

    if (!visited[min(X-1,a_idx+1)][b_idx][c_idx]) {
      visited[a_idx+1][b_idx][c_idx] = true;
      q.push(make_tuple(AS[a_idx+1]+BS[b_idx]+CS[c_idx],a_idx+1,b_idx,c_idx));
    }
    if (!visited[a_idx][min(Y-1,b_idx+1)][c_idx]) {
      visited[a_idx][b_idx+1][c_idx] = true;
      q.push(make_tuple(AS[a_idx]+BS[b_idx+1]+CS[c_idx],a_idx,b_idx+1,c_idx));
    }
    if (!visited[a_idx][b_idx][min(Z-1,c_idx+1)]) {
      visited[a_idx][b_idx][c_idx+1] = true;
      q.push(make_tuple(AS[a_idx]+BS[b_idx]+CS[c_idx+1],a_idx,b_idx,c_idx+1));
    }
  }

  REP(i,K) {
    OUT(res[i]);
  }

  return 0;
}

Measured memory_bytes: 180352
from collections import Counter

N = int(input())
S = input()
S_former = S[:N]
S_latter = S[N:][::-1]
ans = 0


def analyzer(St):
    n = len(St)
    A = []
    for i in range(2**n):
        red = ''
        blue = ''
        for j in range(n):
            if (i >> j) & 1 == 1:
                red += St[j]
            else:
                blue += St[j]
        A.append((red, blue))
    return Counter(A)


SC_former = analyzer(S_former)
SC_latter = analyzer(S_latter)
for ke, va in SC_former.items():
    ans += SC_latter[ke] * va

print(ans)

Measured memory_bytes: 140380
#include <iostream>
int main(void)
{
  int n;
  std::cin >> n;
  int a[n];
  int r = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  int min = 1000001, max = -1000001;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (min > a[i]) min = a[i];
    if (max < a[i]) max = a[i];
  }
  std::cout << min << " " << max << " " << sum << std::endl;
}

Measured memory_bytes: 1200
N = int(input())
a = list(map(int, input().split()))

color = [False] * 8
cnt = 0
for i in range(N):
    if a[i] <= 399:
        color[0] = True
    elif a[i] <= 799:
        color[1] = True
    elif a[i] <= 1199:
        color[2] = True
    elif a[i] <= 1599:
        color[3] = True
    elif a[i] <= 1999:
        color[4] = True
    elif a[i] <= 2399:
        color[5] = True
    elif a[i] <= 2799:
        color[6] = True
    elif a[i] <= 3199:
        color[7] = True
    elif a[i] <= 4800:
        cnt += 1

print(max(1, sum(color)), sum(color) + cnt)

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

int main(){
    long long A,B,K;
    cin >> A >> B >> K;
    if(A<K){
        if(B<K-A){
            A=0;
            B=0;
        }else{
            B=B-(K-A);
            A=0;
        }
    }else{
        A = A-K;
    }
    cout << A << " " << B << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
from itertools import groupby
from collections import deque

N, K = [int(x) for x in input().split()]
blocks = [[tp, list(people)] for tp, people in groupby(input())]

ans = 0
cur = 0
stand = 0
target = deque()

for tp, people in blocks:
    if tp == '0':
        stand += 1
        if stand > K:
            removed = target.popleft()
            cur -= len(removed[1])
            if removed[0] == '1' and len(target) > 0:
                removed = target.popleft()
                cur -= len(removed[1])

    target.append([tp, people])
    cur += len(people)
    ans = max(ans, cur)

print(ans)

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int cur=0;
  int wor=0;
  rep(i,0,n){
    if(s[i]=='(') cur++;
    else cur--;
    wor=min(cur,wor);
  }
  rep(i,0,-wor){
    cout<<'(';
  }
  cout<<s;
  rep(i,0,cur-wor){
    cout<<')';
  }
  cout<<endl;
}

Measured memory_bytes: 256
// Hovalhagh
// Ya Aziz & Hakim
// AliReza Kaboli

#include <bits/stdc++.h>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8)
		cout << ":(\n";
	else
		cout << "Yay!\n";
}


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



int main() {
	int a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	if (a > b) {
		ans = b;
	}
	else {
		ans = a;
	}
	if (c > d) {
		ans += d;
	}
	else {
		ans += c;
	}
	cout << ans;
	return 0;
	
}


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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int s = 0;
    int h[50];
    for (int i = 0; i < a; i++)
        cin >> h[i];
    sort(h, h + a);
    for (int i = a - 1; i >= a - b; i--)
        s += h[i];
    cout << s << endl;
    return 0;

}


Measured memory_bytes: 256