akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        System.out.println(CapitalHead(a) + CapitalHead(b) + CapitalHead(c));
    }

    public static String CapitalHead(String s) {
        return s.toUpperCase().substring(0, 1);
    }
}

Measured memory_bytes: 22356
a, b, c, d = map(int, input().split())
import fractions
f = fractions.gcd(c, d)
e = c * d // f

c_a, c_b = (a-1)//c, b//c
c_ab = c_b - c_a 

d_a, d_b = (a-1)//d, b//d
d_ab = d_b - d_a 

e_a, e_b = (a-1)//e, b//e
e_ab = e_b - e_a

ans = (b - a + 1) - (c_ab + d_ab - e_ab)
print(ans)

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

int main(){
	int h,w;
	cin >> h >> w;
	string s[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s[i][j];
			if(s[i][j]=="snuke"){
				cout << (char)(j+'A') << i+1 << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    int MAX;
    MAX = min(a, b);
    int MIN;
    MIN = max(0, (a + b) - n);
    cout << MAX << ' ' << MIN << endl;
}

Measured memory_bytes: 256
def main():
    x = int(input())

    a_100 = x // 100
    b_100 = x % 100
    a_5 = b_100 // 5
    b_5 = b_100 % 5
    a_4 = b_5 // 4
    b_4 = b_5 % 4
    a_3 = b_4 // 3
    b_3 = b_4 % 3
    a_2 = b_3 // 2
    b_2 = b_3 % 2
    a_1 = b_2 // 1
    b_1 = b_2 % 1

    if a_5 + a_4 + a_3 + a_2 + a_1 > a_100:
        ans = 0
    else:
        ans = 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61928
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(ll i=m ; i<n ; i++)
#define forr(i, m, n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 2e5 + 5;
const ll OO = 1e15;
using namespace std;

int main() {
    IO;
    ll n, k;
    cin >> n >> k;
    vll a(n + 1);

    forr(i, 1, n)cin >> a[i];

    vll no;
    no.pb(1);
    vector<bool> check(n + 1);
    check[1] = 1;
    int i = 1;
    while (check[a[i]] != 1) {
        i = a[i];
        no.pb(i);
        check[i] = 1;
    }


    ll start = find(all(no), a[i]) - no.begin();
    if (k <= start) {
        cout << no[k];
    } else {
        cout << no[start + (k - start) % (no.size() - start)];
    }
}

Measured memory_bytes: 6920
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

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

    int x = 1;
    int minx;
    int cx;
    rep(i, N) {
        cx = x;
        minx = min(cx * 2, cx + K);
        if (minx == cx * 2)x *= 2;
        else x += K;
    }
    cout << minx << endl;
}

Measured memory_bytes: 256
def load_input():
    a, b = list(map(int, input().split()))
    return a, b


def main():
    a, b = load_input()

    coin = 0
    for i in range(2):
        if a > b:
            coin += a
            a -= 1
        else:
            coin += b
            b -= 1
    print(coin)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
int h,w;
int l[1001][1001];
ll dp1[50]={3};
ll dp2[50]={5};
int g=1;
bool b[1001][1001]={};
int d[1001][1001]={};
ll calc(ll y,int m){
	if(y==0)return 0;
	if(m==0){
		return min(y-1,(ll)3);
	}
	if(y==dp2[m]/2){
		return dp1[m-1];
	}
	if(y<dp2[m]/2){
		return calc(y-1,m-1);
	}
	if(y>dp2[m]/2){
		return dp1[m-1]+1+calc(y-dp2[m]/2-1,m-1);
	}
	return 0;
}
int main() {
	int n;
	ll x;
	cin>>n>>x;
	rep(i,1,50){
		dp1[i]=dp1[i-1]*2+1;
	}
	rep(i,1,50){
		dp2[i]=dp2[i-1]*2+3;
	}
	cout<<calc(x,n-1)<<endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL M = 998244353;
	static const UL MAX = 1000000;

	ULL D[MAX + 1];
	ULL S[MAX + 1];
	vector<UL> E[MAX + 1];
	ULL V[MAX + 1] = {};

	void Solve() {
		UL N; cin >> N;
		D[0] = 0; D[1] = 1;
		for (UL i = 2; i <= MAX; i++) D[i] = M - M / i * D[M % i] % M;
		for (UL i = 1; i <= MAX; i++) {
			E[i].push_back(i);
			D[i] %= M;
			for (UL j = i * 2; j <= MAX; j += i) {
				D[j] += M - D[i];
				E[j].push_back(i);
			}
			D[i] %= M;
		}

		ULL ans = 0;
		rep(i, N) {
			UL a; cin >> a;
			ULL tmp = 0;
			for (UL j : E[a]) {
				tmp += V[j];
				V[j] += a * D[j];
				V[j] %= M;
			}
			tmp %= M;
			ans += tmp * a;
			ans %= M;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    string s;
    cin>>s;

    if(s.size()>=4&&s.substr(0,4)=="YAKI")
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int d = b - a;
	if (d % 2 == 0) {
		cout << d / 2 << endl;
	}
	else {
		int res1 = a + (b - a - 1) / 2;
		int res2 = n - b + 1 + (b - a - 1) / 2;
		cout << min(res1, res2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <map>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;

int main(){
  int n;
  cin >> n;
  long long a[n];
  long long tmp=0;
  rep(i,n) cin >> a[i];
  long long result=0;
  for(int i=1;i<n;i++){
    tmp = (tmp+a[i-1])%1000000007;
    result = (result+a[i]*tmp)%1000000007;
  }

  cout << result << endl;
    
}

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

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());

        var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        Output(A);

        for (var i = 1; i < N; i++)
        {
            var v = A[i];
            var j = i - 1;

            while(j >= 0 && A[j] > v)
            {
                A[j + 1] = A[j];
                j--;
            }

            A[j + 1] = v;

            Output(A);
        }
    }

    private static void Output(int[] A)
    {
        var s = string.Join(" ", A);
        Console.WriteLine(s);
    }
}



Measured memory_bytes: 18216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl v(n,inf);
    rep(i,n){
        ll a;cin >> a;
        ll x=lower_bound(all(v),a)-v.begin();
        v[x]=a;
    }
    ll ans=0;
    rep(i,n){
        if(v[i]<inf)ans++;
        else break;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e9;
const int INF=0x3f3f3f3f;
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	cout<<s;
	if(s[s.length()-1]=='s') cout<<"es"<<endl;
	else cout<<'s'<<endl;
	return 0;
}


Measured memory_bytes: 3660
import math
import sys

a, b = map(str, input().split())
if a == "0" or b == "0.00":
  print(0)
  exit()
ans = 0
ans += int(a) * int(b[0]) * 100
ans += int(a) * int(b[2]) * 10
ans += int(a) * int(b[3])
tmp = list(str(ans))
if len(tmp) == 1 or len(tmp) == 2:
  print(0)
  exit()
tmp.pop(-1)
tmp.pop(-1)
print(int("".join(tmp)))


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a < b){
	  if(b < c){
		cout << a << " " << b << " " << c << endl;
	  }else if(a < c){
		cout << a << " " << c << " " << b << endl;
	  }else{
		cout << c << " " << a << " " << b << endl;
	  }
	}else if(a < c){
		cout << b << " " << a << " " << c << endl;
	}else if(b < c){
		cout << b << " " << c << " " << a << endl;
	}else{
		cout << c << " " << b << " " << a << endl;
	}
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll d;
    cin>>d;
    if(d==25) cout<<"Christmas"<<endl;
    else if(d==24) cout<<"Christmas Eve"<<endl;
    else if(d==23) cout<<"Christmas Eve Eve"<<endl;
    else cout<<"Christmas Eve Eve Eve"<<endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] nkl = Console.ReadLine().Split().Select(int.Parse).ToArray();
        UnionFind road = new UnionFind(nkl[0]);
        UnionFind train = new UnionFind(nkl[0]);
        for (int i = 0; i < nkl[1]; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            road.Union(ab[0], ab[1]);
        }
        for (int i = 0; i < nkl[2]; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            train.Union(ab[0], ab[1]);
        }

        int[] roadd = road.formatData();
        int[] traind = train.formatData();
        //<道路グループindex,<電車グループインデックス,属してるインデックス>>
        Dictionary<int, Dictionary<int, int>> dict = new Dictionary<int, Dictionary<int, int>>();
        for (int i = 0; i < roadd.Length; i++)
        {
            if (!dict.ContainsKey(roadd[i])) dict.Add(roadd[i], new Dictionary<int, int>());
            if (!dict[roadd[i]].ContainsKey(traind[i])) dict[roadd[i]].Add(traind[i], 0);
            dict[roadd[i]][traind[i]]++;
        }
        Console.WriteLine(string.Join(" ", Enumerable.Range(0, nkl[0]).Select(x => dict[roadd[x]][traind[x]]).ToArray()));
    }
}
class UnionFind
{
    int[] data;
    public UnionFind(int count)
    {
        data = Enumerable.Range(0, count).ToArray();
    }
    public void Union(int x, int y)
    {
        int xp = Parent(x);
        int yp = Parent(y);
        if (xp != yp)
        {
            data[yp] = xp;
        }
    }
    public bool IsSameGroup(int x, int y) => Parent(x) == Parent(y);
    public int[] AllParents() => data.Where((x, y) => x == y).ToArray();
    public int[] formatData() => data.Select(x => Parent(x)).ToArray();
    public int Parent(int x)
    {
        form(x);
        return data[x];
    }
    private void form(int x)
    {
        while (data[x] != data[data[x]])
        {
            data[x] = data[data[x]];
        }
    }
}

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

int main(){
  string S;
  cin>>S;
  if(S=="Sunny") cout<<"Cloudy"<<endl;
  else if(S=="Cloudy") cout<<"Rainy"<<endl;
  else if(S=="Rainy")cout<<"Sunny"<<endl;
return 0;
}


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

C0, C1, C2, C3=0, 0, 0, 0
for i in range(N):
    s=input()
    if s=="AC":
        C0+=1
    elif s=="WA":
        C1+=1
    elif s=="TLE":
        C2+=1
    elif s=="RE":
        C3+=1
        
print("AC x "+str(C0))
print("WA x "+str(C1))
print("TLE x "+str(C2))
print("RE x "+str(C3))

Measured memory_bytes: 9048
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, D = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in [0] * N]

    ans = 0
    for x, y in XY:
        if x * x + y * y <= D * D:
            ans += 1
    print(ans)


main()


Measured memory_bytes: 37508
import java.util.Scanner;

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

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		if(a!=b && a!=c && b==c) {
			System.out.println(a);
		}

		else if(b!=a && b!=c && a==c) {
			System.out.println(b);
		}

		else if(c!=b && c!=a && a==b) {
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 21716
import bisect
from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]
H = defaultdict(lambda: [])
Ad = defaultdict(lambda: 0)
N = int(input())
A = inpl()
for i in A:
    Ad[i] += 1
A = list(set(A))
A.sort()
ans = 0
for j in range(30,0,-1):
    k = 2**j
    H = defaultdict(lambda: [])
    ml = bisect.bisect_left(A, k) 
    for i in A[:ml]:
        if 2*i == k:
            ans += Ad[i]//2
            del Ad[i]
            continue
        if H[k-i]:
            m = min(Ad[k-i], Ad[i])
            Ad[k-i] -= m
            del Ad[i]
            ans += m
        else:
            H[i] = j
print(ans)


Measured memory_bytes: 91232
/*
By Tianyi Chen. All rights reserved.
Date: 2016-09-04
*/
#include<bits/stdc++.h>
using namespace std;
int64_t a,b,c,ans=LLONG_MAX;
int main() {
 cin>>a>>b>>c;
 ans=min(ans,(a&1)*b*c);
 ans=min(ans,(b&1)*a*c);
 ans=min(ans,(c&1)*a*b);
 cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    int a[n];
    int tmp, cnt = 0;
    while (cnt < n)
    {
        scanf("%d", &tmp);
        a[cnt] = tmp;
        cnt++;
    }
 
    if (n % 2 == 0)
    {
        cnt = 0;
        while (cnt < n / 2)
        {
            int tmpNum = a[cnt];
            a[cnt] = a[n - cnt - 1];
            a[n - cnt - 1] = tmpNum;
            cnt++;
        }
    }
    else
    {
        cnt = 0;
        while (cnt < n / 2)
        {
            int tmpNum = a[cnt];
            a[cnt] = a[n - cnt - 1];
            a[n - cnt - 1] = tmpNum;
            cnt++;
        }
    }
 
    cnt = 0;
    while (cnt < n)
    {
        printf("%d", a[cnt]);
        cnt++;
        if (cnt < n)
        {
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
//#pragma optimize("Ofast")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int len[2005];
char s[2005][10005];
bitset<10005> can[2005];
pair<int,int> dp[2][2005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
		len[i]=strlen(s[i]);
	}
	for(int i=0;i<n;i++){
		can[i].reset();
	}
	can[n]=1;
	for(int i=n-1;i>=0;i--){
		can[i]=can[i+1]|(can[i+1]<<len[i]);
	}
	int cnt=0,ii=0;
	for(int i=0;i<n;i++){
		if(can[i+1][k-len[i]]) dp[0][cnt++]=make_pair(i,0);
	}
	string res;
	pair<int,int> *a=dp[0],*b=dp[1];
	for(int i=1;i<=k;i++){
		char mi='z';
		int cnt2=0;
		for(int j=0;j<cnt;j++){
			mi=min(s[a[j].first][a[j].second],mi);
		}
		res+=mi;
		int miid=1e9;
		for(int j=0;j<cnt;j++){
			int fi=a[j].first,se=a[j].second;
			if(s[fi][se]==mi){
				if(se+1==len[fi]) miid=min(miid,fi);
				else{
					b[cnt2++]=make_pair(fi,se+1);
				}
			}
		}
		for(int j=miid+1;j<n;j++){
			if(k-len[j]-i>=0&&can[j+1][k-len[j]-i]) b[cnt2++]=make_pair(j,0);
		}
		swap(a,b);
		cnt=cnt2;
	}
	cout<<res;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

int N;

int main() {
    cin >> N;

    int ans = N;
    if (N % 2 == 1) {
        ans *= 2;
    }

    cout << ans << endl;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

struct BipartiteMatching {
    vector<vector<int> > graph;
    vector<int> match, alive, used;
    int timestamp;

    BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

    void add_edge(int u, int v) {
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    bool dfs(int idx) {
        used[idx] = timestamp;
        for (auto &to : graph[idx]) {
            int to_match = match[to];
            if (alive[to] == 0) continue;
            if (to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
                match[idx] = to;
                match[to] = idx;
                return true;
            }
        }
        return false;
    }

    int bipartite_matching() {
        int ret = 0;
        for (int i = 0; i < graph.size(); i++) {
            if (alive[i] == 0) continue;
            if (match[i] == -1) {
                ++timestamp;
                ret += dfs(i);
            }
        }
        return ret;
    }

    void output() {
        for (int i = 0; i < graph.size(); i++) {
            if (i < match[i]) {
                cout << i << "-" << match[i] << endl;
            }
        }
    }
};

int main() {
    struct Ball {
        int i, x, y;
    };

    int n;
    cin >> n;
    vector<Ball> blues(n), reds(n);
    rep(i, n) cin >> reds[i].x >> reds[i].y;
    rep(i, n) reds[i].i = i;
    rep(i, n) cin >> blues[i].x >> blues[i].y;
    rep(i, n) blues[i].i = i;


    BipartiteMatching bm(2 * n);

    for (Ball blue: blues) {
        for (Ball red : reds) {
            if (red.x < blue.x && red.y < blue.y) {
                bm.add_edge(red.i, n + blue.i);
            }
        }
    }
    cout << bm.bipartite_matching() << endl;


}




Measured memory_bytes: 256
#include <stdio.h>

char era_name[1000][20];
int era_year[1000];
int western[1000];
int year;
int i, j;

int main(void)
{
    int N, Q;
    
    while (1){
        scanf("%d%d", &N, &Q);
        if (N == 0 && Q == 0){
            break;
        }
        
        for (i = 0; i < N; i++){
            scanf("%s%d%d", era_name[i], &era_year[i], &western[i]);
        }
        
        for (i = 0; i < Q; i++){
            scanf("%d", &year);
            for (j = 0; j <N ; j++){
                if (western[j] - era_year[j] + 1 <= year && year <= western[j]){
                    printf("%s %d\n", era_name[j],
                                      year - (western[j] - era_year[j] + 1) + 1);
                    break;
                }
            }
            if (j == N){
                printf("Unknown\n");
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 640
#include <cstdio>
#include <cctype>
using namespace std;
int main(){
  int counter[26] = {0};
  char ch;
  while(scanf("%c", &ch) != EOF){
    if(ch >= 'A' && ch <= 'Z')
      counter[ch - 'A']++;
    else if(ch >= 'a' && ch <= 'z')
      counter[ch - 'a']++;
  }
  for(int i = 0; i < 26; i++)
    printf("%c : %d\n", i + 'a', counter[i]);
}

Measured memory_bytes: 968
#include <stdio.h>
#include <string.h>
#include <algorithm>
long long int home[12345678];
long long int muki[12345678];
long long int important[123456];
long long int hit[12345678];
long long int ans[12345678];
int main(){
	long long int num;
	long long int time;
	long long int imp_num;
	long long int hit_num = 0;
	scanf("%lld%lld%lld", &num, &time, &imp_num);
	for (long long int a = 0; a < num; a++){
		scanf("%lld%lld", &home[a], &muki[a]);
	}
	for (int a = 0; a < imp_num; a++){
		scanf("%lld", &important[a]);
	}
	for (long long int a = 0; a < num - 1; a++){
		if (muki[a] == 1 &&
			muki[a + 1] == 2){
			hit[hit_num] = (home[a + 1] - home[a]) / 2 + home[a];
			hit_num++;
		}
	}
	for (long long int a = 0; a < num; a++){
		if (muki[a] == 1){
			home[a] += time;
			for (long long int b = 0; b < hit_num; b++){
				if (home[a] >= hit[b] &&
					home[a] - time <= hit[b]){
					home[a] = hit[b];
					break;
				}
			}
		}
		else{
			home[a] -= time;
			for (long long int b = hit_num - 1; 0 <= b; b--){
				if (home[a] <= hit[b] &&
					home[a] + time >= hit[b]){
					home[a] = hit[b];
					break;
				}
			}
		}
	}
	for (int a = 0; a < imp_num; a++){
		printf("%lld\n", home[important[a] - 1]);
	}
	return 0;
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int INF = 0x3f3f3f3f;
const int maxn = 20;
int p[maxn], c[maxn];

int main()
{
    int n, k;
    sc(n); sc(k);
    for(int i = 1; i <= n; i++){
        sc(p[i]); sc(c[i]);
    }
    int ans = INF;
    vector<int> vec;
    for(int i = 1; i <= n; i++)vec.pb(i);
    do{
        int now = k, tot = 0;
        for(int i = 0; i < n; i++){
            int add = min(p[vec[i]], (now-1+vec[i]*100)/(100*vec[i]));
            //printf("add=%d\n", add);
            now -= add*100*vec[i];
            tot += add;
            //printf("tot=%d\n", tot);
            if(add == p[vec[i]])now -= c[vec[i]];
            if(now < 0)break;
        }
        ans = min(ans, tot);
    }while(next_permutation(ALL(vec)));
    printf("%d\n", ans);
    return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);

		String str=in.next();
		String[] data=str.split("/");
		int[] idata=new int[3];

		for(int i=0;i<data.length;i++)idata[i]=Integer.parseInt(data[i]);
		
		if(idata[0] > 2019 ||(idata[0]>=2019 && idata[1]>4))System.out.println("TBD");
		else System.out.println("Heisei");
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)


int main(void) {
	char a, b;
	scanf("%c %c", &a, &b);
	printf("%c", a == b ? 'H' : 'D');
	return 0;
}


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

int main(){

    int N,M;
    cin >> N >> M;

    //vector<型名> 変数名(要素数,値)
    vector<int>oks(N+1,true);
    for(int i=0;i<M;i++){
        int a;
        cin >> a;
        oks[a] = false;
        //cout << oks[a] << " ";
    }
    //cout << endl;

    vector<int>dp(N+1);
    dp[0] = 1;
    for(int now=0;now<N;now++){
        for(int next=now+1;next<=min(N,now+2);next++){
            //cout << "next=" << next << " ";
            if(oks[next]){
                dp[next] += dp[now];
                dp[next] %= 1000000007;
                //cout << next << "=" << dp[next] << " ";
            }
        }
        //cout << endl;
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  string op;
  cin >> a >> op >> b;
  if (op == "-") {
    cout << (a - b) << endl;
  } else if (op == "+") {
    cout << (a + b) << endl;
  }
}

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

using namespace std;

int main() {
    
    string s;
    cin >> s;

    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[2] - '0') * 10 + (s[3] - '0');
    int c = a * 100 + b;
    set<int> yymm, mmyy, amb;

    for (int i = 13; i <= 99; ++i) 
        for (int j = 1; j <= 12; ++j) {
            yymm.insert(i * 100 + j);
            mmyy.insert(j * 100 + i);
        }
    
    for (int i = 1; i <= 12; ++i) 
        for (int j = 1; j <= 12; ++j)
            amb.insert(i * 100 + j);
    
    if(yymm.count(c) or (a == 0 and b >= 1 and b <= 12)) return puts("YYMM"),0;
    if(mmyy.count(c) or (b == 0 and a >= 1 and a <= 12)) return puts("MMYY"),0;
    if(amb.count(c)) return puts("AMBIGUOUS"),0;
    puts("NA");       
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	
	long long A, B;

	cin >> A >> B;
	cout << (A - 1)*(B - 1);

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    lists.add(new ArrayList<>());
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
		    int type = sc.nextInt();
		    if (type == 0) {
		        lists.get(sc.nextInt()).add(sc.nextInt());
		    } else if (type == 1) {
		        boolean first = true;
		        int idx = sc.nextInt();
		        for (int x : lists.get(idx)) {
		            if (!first) {
		                sb.append(" ");
		            }
		            first = false;
		            sb.append(x);
		        }
		        sb.append("\n");
		    } else {
		        lists.get(sc.nextInt()).clear();
		    }
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 310604
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define flush fflush(stdout)
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define ln '\n'
#define MAX 1000000009
#define MOD 1000000007
#define N 1005
using namespace std;
typedef long long ll;
typedef pair<int ,int > pii;
int h, w, dp[N][N];
char mat[N][N];
int DP(int x, int y){
    if(dp[x][y] != -1){
        return dp[x][y];
    }
    if(x < 0 || y < 0){
        return 0;
    }
    return dp[x][y] =(DP(x, y - 1) + DP(x - 1, y)) % MOD;
}
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    memset(dp, -1, sizeof dp); 
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            if(mat[i][j] == '#'){
                dp[i][j] = 0;
            }
        }
    }   
    dp[0][0] = 1;
    cout << DP(h - 1, w - 1);

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        int p;
        cin >> p;
        v[i] = make_pair(p, i);
    }
    sort(all(v));
    vector<int> p(n);
    rep(i, n) {
        p[i] = v[i].second;
    }
    set<int> st;
    st.insert(-1);
    st.insert(n);

    ll ans = 0;
    rep(i, n) {
        int num = i + 1;
        auto itr = st.lower_bound(p[i]);
        int right = *itr;
        itr--;
        int left = *itr;

        ll now = 1;
        now *= (ll)right - p[i];
        now *= (ll)p[i] - left;
        now *= (ll)num;
        ans += now;
        st.insert(p[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  vector<string> vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  
  ll m=0;
  ll a=0;
  ll r=0;
  ll c=0;
  ll h=0;
  rep(i,N) {
    if(vec.at(i).at(0)=='M') {
      m++;
    }
    if(vec.at(i).at(0)=='A') {
      a++;
    }
    if(vec.at(i).at(0)=='C') {
      c++;
    }
    if(vec.at(i).at(0)=='R') {
      r++;
    }
    if(vec.at(i).at(0)=='H') {
      h++;
    }
  }
  
  ll sum=0;
  sum=(m*a*r)+(m*a*c)+(m*a*h)+(m*r*c)+(m*r*h)+(m*c*h)+(a*r*c)+(a*r*h)+(a*c*h)+(r*c*h);
  
  cout<<sum<<endl;
}
  
 

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;cin>>A>>B;
  if(A<=0 && 0<=B)cout<<"Zero"<<endl;
  else if(A>0)cout<<"Positive"<<endl;
  else if((B-A)%2==1)cout<<"Positive"<<endl;
  else cout<<"Negative"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one

    struct Child {
        ll value;
        int prev;
    };
}

int main() {

    int n = inp1;
    vector<ll> a = inp(n);
    vector<Child> childs(n);
    rep(i, n) {
        childs[i].value = a[i];
        childs[i].prev = i;
    }

    // 大きいやつから左端に行くか右端に行くか選択する
    sort(allof(childs), [](Child& lhs, Child& rhs) {
        return lhs.value > rhs.value;
        });

    // dp[i][j] := i人見たときに，左にj人送った時のうれしさの最大値
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0LL));

    rep(i, n) { // i+1人目を移動
        rep(j, i + 1) { // すでにj人左に送った
            // 右に送った数
            int right = i - j;
            // 左に送る
            chmax(dp[i + 1][j + 1], dp[i][j] + childs[i].value * abs(childs[i].prev - j));
            // 右に送る
            chmax(dp[i + 1][j], dp[i][j] + childs[i].value * abs(childs[i].prev - (n - right - 1)));
        }
    }

    ll ans = 0LL;
    rep(i, n + 1) { // 左に送った人の数
        chmax(ans, dp[n][i]);
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 34624
def main():
    N,K = map(int, input().split())
    cnt = 0
    sunuke = [0]*(N+1)

    for index in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for j in (A):
            sunuke[j] += 1

    
    cnt = sunuke.count(0) - 1

    print(cnt)




if __name__ == '__main__':
    main()


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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	
	int N, M, best = 0;
	long int K;
	
	cin >> N >> M >> K;
	
	vector<int> A(N), B(M);
	
	for(int i = 0;i < N;i++){
		cin >> A[i];
	}
	for(int i = 0;i < M;i++){
		cin >> B[i];
	}
	
	vector<long long> vA, vB;
	vA.push_back( 0 );
	vB.push_back( 0 );
	for(int n = 0;n < N;n++){
		if( vA[n] + A[n] <= K ){
			vA.push_back( vA[n] + A[n] );
		}
		else{
			break;
		}
	}
	for(int m = 0;m < M;m++){
		if( vB[m] + B[m] <= K ){
			vB.push_back( vB[m] + B[m] );
		}
		else{
			break;
		}
	}
	
	int nstart = vA.size() - 1;
	for(int m = 0;m < vB.size();m++){
		for(int n = nstart;n >= 0;n--){
			if( vA[n] + vB[m] <= K ){
				if( best < ( n + m ) ){
					best = ( n + m );
				}
				nstart = n;
				break;
			}
		}
	}
	
#if(0)
	int posA = 0, posB = 0, sum1 = 0, sum2 = 0;
	long int et = 0;
	bool flagA = false, flagB = false;
	
	
	while(1){
		
		if( posA == N ){
			flagA = true;
		}
		if( posB == M ){
			flagB = true;
		}
		
		
		if( flagA && flagB ){
			break;
		}
		else if( flagA ){
			et = et + B[posB];
			sum1++;
			posB++;
		}
		else if( flagB ){
			et = et + A[posA];
			sum1++;
			posA++;
		}
		else if( A[posA] <= B[posB] ){
			et = et + A[posA];
			sum1++;
			posA++;
		}
		else{
			et = et + B[posB];
			sum1++;
			posB++;
		}
		
		if( et > K ){
			sum1--;
			break;
		}
		else if( sum1 == (M + N) ){
			break;
		}
	}
	
	
	et = 0;
	posA = 0;
	posB = 0;
	flagA = false;
	flagB = false;
	
	while(1){
		
		if( posA == N ){
			flagA = true;
		}
		if( posB == M ){
			flagB = true;
		}
		
		
		if( flagA && flagB ){
			break;
		}
		else if( flagA ){
			et = et + B[posB];
			sum2++;
			posB++;
		}
		else if( flagB ){
			et = et + A[posA];
			sum2++;
			posA++;
		}
		else if( A[posA] < B[posB] ){
			et = et + A[posA];
			sum2++;
			posA++;
		}
		else{
			et = et + B[posB];
			sum2++;
			posB++;
		}
		
		if( et > K ){
			sum2--;
			break;
		}
		else if( sum2 == (M + N) ){
			break;
		}
	}
	
	
	cout << ( (sum1 > sum2) ? sum1 : sum2 );
#endif
	
	cout << best;
	
	return 0;
	
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<M; i++){
    cin >> B.at(i);
  }
  string Ans="No";
  for(int i=0; i<N-M+1; i++){
    for(int j=0; j<N-M+1; j++){
      int k=1;
      for(int l=0; l<M; l++){
        for(int m=0; m<M; m++){
          if(B.at(l).at(m)!=A.at(i+l).at(j+m)){
            k=0;
            goto line;
          }
        }
      }
line:   if(k==1){
        Ans="Yes";
        goto lines;
      }
    }
  }
lines: cout << Ans << endl;
}


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

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

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 N = 187;

int dl[N][N][N];
int dl2[N][N][N];
int sm[2][N][N];

int n, m;
string s[N];

int get(int c, int x1, int y1, int x2, int y2) {
	return sm[c][x2][y2] - sm[c][x1][y2] - sm[c][x2][y1] + sm[c][x1][y1];
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> s[i];
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			sm[0][i][j] = sm[0][i - 1][j] + sm[0][i][j - 1] - sm[0][i - 1][j - 1] + (s[i - 1][j - 1] == '#');
			sm[1][i][j] = sm[1][i - 1][j] + sm[1][i][j - 1] - sm[1][i - 1][j - 1] + (s[i - 1][j - 1] == '.');
		}
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j <= n; ++j)
			for (int k = m - 1; k >= 0; --k) {
				if (get(0, i, k, j, k + 1) == 0 || get(1, i, k, j, k + 1) == 0) {
					if (k + 1 < m && s[i][k] == s[i][k + 1])
						dl[i][j][k] = dl[i][j][k + 1];
					else
						dl[i][j][k] = k + 1;
				}
				else
					dl[i][j][k] = k;
			}
	int ans = 0;
	while (dl[0][n][0] != m) {
		++ans;
		for (int k = 0; k < m; ++k) {
			for (int i = 0; i < n; ++i) {
				int cur = i + 1;
				for (int j = i + 1; j <= n; ++j) {
					while (cur + 1 < j && dl[i][cur + 1][k] >= dl[cur + 1][j][k])
						++cur;
					if (dl[i][j][k] != m) {
						dl2[i][j][k] = dl[i][j][dl[i][j][k]];
						if (cur > i && cur < j)
							dl2[i][j][k] = max(dl2[i][j][k], min(dl[i][cur][k], dl[cur][j][k]));
						if (cur + 1 > i && cur + 1 < j)
							dl2[i][j][k] = max(dl2[i][j][k], min(dl[i][cur + 1][k], dl[cur + 1][j][k]));
					}
					else {
						dl2[i][j][k] = m;
					}
				}
			}
		}
		memcpy(dl, dl2, sizeof(dl));
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 51712
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    int N;
    cin >> N;
    //頻度配列の型に注意
    // int -> long long
    vector<ll> MARCH(5, 0);

    for(int i=0; i<N; i++) {
        string s;
        cin >> s;
        if(s[0] == 'M') MARCH[0]++;
        if(s[0] == 'A') MARCH[1]++;
        if(s[0] == 'R') MARCH[2]++;
        if(s[0] == 'C') MARCH[3]++;
        if(s[0] == 'H') MARCH[4]++;
    }

    ll ans = 0;
    for(int i=0; i<5; i++) {
        for(int j=i+1; j<5; j++) {
            for(int k=j+1; k<5; k++) {
                ans += MARCH[i] * MARCH[j] * MARCH[k];
            }
        }
    }
    cout << ans << endl;
}

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

n = ni()
a = []

import collections

for i in range(n):
    s = ns()
    s = sorted(s)
    a.append(''.join(s))

b = collections.Counter(a)
ans = 0


for k,v in b.items():
    if v > 1:
        ans += v*(v-1)//2

print(ans)


Measured memory_bytes: 19784
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std; 
typedef long long ll;
typedef unsigned long long ull;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/


int main() {
  ll N,x,y;
  cin >> N;
  vector<ll> f0(N);
  vector<ll> f1(N);
  rep(i,N){
    cin>>x>>y;
    f0[i] = x - y;
    f1[i] = x + y;
  }
  ll max0,min0,max1,min1;
  max0 = -pow(10,9)*2;
  min0 = pow(10,9)*2;
  max1 = -pow(10,9)*2;
  min1 = pow(10,9)*2;
  rep(i,N){
    if(max0<f0[i]) max0 = f0[i];
    if(min0>f0[i]) min0 = f0[i];
    if(max1<f1[i]) max1 = f1[i];
    if(min1>f1[i]) min1 = f1[i];
  }
  ll ans = -pow(10,9)*2;
  if( (max0-min0) > (max1-min1) ){
    ans = max0 - min0;
  }else{
    ans = max1 - min1;
  }
  cout<<ans;

  return 0;
}


Measured memory_bytes: 6340
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#define mp make_pair
#define pb push_back
#define mst(a,b)  memset((a),(b),sizeof (a))
#define eps 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf=1e8;
const int maxn=1e5+100;
const int mod=1e9+7;
string u;
int main() {
#ifdef local
//    freopen("in.txt", "r", stdin);
#endif
    cin>>u;
    if((u[0]==u[1]&&u[1]==u[2])||(u[1]==u[2]&&u[2]==u[3]))cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256