akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
import string

S = input().rstrip('\r')
alph = string.ascii_lowercase
S_map = {}
for c in alph:
    S_map[c] = False
for s in S:
    S_map[s] = True
ans = 'None'
for c in alph:
    if not S_map[c]:
        ans = c
        break
print(ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n;
    cin >> n;
    cout << ce(n, 2) << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin >> s;
	int n = s.size(), numb = 0;
	ll ans = 0;
	for(int i = n - 1;i >= 0;i--){
		if(s[i] == 'B'){
			ans += n - 1 - i - numb;
			numb++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 720
#include <iostream> 
using namespace std;
int main() {
    long long N;
    long long list[100];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> list[i];
    }
    for (int j = N - 1; j > 0; j--) {
        cout << list[j] << ' ';
    }
    cout << list[0] << '\n';
}


Measured memory_bytes: 3104
# ordinary number
n = int(input())
list = [int(i) for i in input().split(' ')]
# print(n,list)
ans = 0
for i in range(1,n-1):
	tmp = list[i-1:i+2]
	tmp.sort()
	# print(tmp)
	if tmp[0] != list[i] and  tmp[1] == list[i]:
		ans = ans + 1
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    vector<int> cnt(n);
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    bool flag = true;
    REP(i,n){
        if(cnt[i]%2!=0)flag = false;
    }
    if(flag){
        put("YES");
    }else{
        put("NO");
    }
    return 0;
}


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

int main() {
	int n, k;
	cin >> n;
	int arr[n][3];
	int dp[n][3];
	int maxm[n][3];
	for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin >> arr[i][j];
        }
	}
// 	for(int i=0; i<n; i++){
// 	    int max_row = 0;
// 	    for(int j=0; j<3; j++){
// 	        max_row = max(max_row, arr[i][j]);
// 	    }
// 	    for(int j=0; j<3; j++){
// 	        maxm[i][j]
// 	    }
// 	}
	for(int j=0; j<3; j++){
	    dp[n-1][j] = arr[n-1][j];
	}
	for(int i=n-2; i>=0; i--){
	    for(int j=0; j<3; j++){
	        int max_row=0;
	        for(int k=0; k<3; k++){
	            if(j==k){continue;}
	            max_row = max(max_row, dp[i+1][k]);
	        }
	        dp[i][j] = arr[i][j]+max_row;
	    }
	}
	int max_row=0;
	for(int i=0; i<n; i++){
	    max_row=max(max_row, dp[0][i]);
	}
	cout << max_row << "\n";
	return 0;
}


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

using namespace std;

#define EPS (1e-7)
#define INF (1e9)


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rep2(i, n) for(int i = 1; i <= (n); i++)
#define all(a) begin(a),end(a)
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

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


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

inline void init(vector<int>& uf) {

    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {

    if(uf[x] == x) {

        return x;
    }
    else {

        return uf[x] = root(uf, uf[x]);
    }
}

inline bool same(vector<int>& uf, int x, int y) {

    return root(uf, x) == root(uf, y);
}

inline void unite(vector<int>& uf, int x, int y) {

    x = root(uf, x);
    y = root(uf, y);

    if(x == y) return;

    uf[x] = y;
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

int N;

void Input() {

    cin >> N;
}



void Solve() {


    vector< pair<int, int> > blue;
    vector< pair<int, int> > red;



    for(int i = 0; i < N; i++) {

        int x, y;
        cin >> x >> y;
        red.push_back(make_pair(x,y));
    }

    for(int i = 0; i < N; i++) {

        int x, y;
        cin >> x >> y;
        blue.push_back(make_pair(x,y));
    }

    sort(blue.begin(), blue.end(),
            [](pair<int, int> l, pair<int, int> r) { return l.first < r.first; });
    sort(red.begin(), red.end(),
            [](pair<int, int> l, pair<int, int> r) { return l.second < r.second; });
    reverse(red.begin(), red.end());

    int cnt = 0;
    for(auto b : blue) {

        for(auto it = red.begin(); it != red.end(); ++it) {

            if(it->first < b.first && it->second < b.second) {

                cnt++;
                it->first = it->second = 300;
                break;
            }
        }
    }
    cout << cnt << endl;




}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    cin>>a>>b;
    bool flag=false;
    if(a>8||b>8){
        flag=true;
    }

    
    cout<< (flag?":(":"Yay!") <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

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

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

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	long long H,K,ans=0; cin >> H>>K;
	VLL N(H);
	for (int i = 0;i < H;i++)cin >> N[i];
	sort(all(N));
	for (int i = 0;i < H-K;i ++ ) {
		ans += N[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;
s64 k;
int dp[1 << 9][100001];
vector< P > vw;

int rec(int v, int l)
{
    if (v == 0) return 0;
    if ((1 << k) > v && dp[v][l] >= 0)
    {
        return dp[v][l];
    }

    int ret = rec(v / 2, l);
    if (l >= vw[v - 1].second) ret = max(ret, rec(v / 2, l - vw[v - 1].second) + vw[v - 1].first);

    if ((1 << k) > v) dp[v][l] = max(dp[v][l], ret);
    return ret;
}


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

    int n;
    cin >> n;

    vw.resize(n);
    rep (i, n)
    {
        cin >> vw[i].first >> vw[i].second;
    }

    while ((1ll << (2 * k)) < n) ++k;
    for (int v = 1; v < (1 << k); ++v)
    {
        rep (l, 100000 + 1)
        {
            dp[v][l] = -1;
        }
    }
    for (int v = 1; v < (1 << k); ++v)
    {
        rep (l, 100000 + 1)
        {
            rec(v, l);
        }
    }

    int q;
    cin >> q;
    while (q--)
    {
        int v, l;
        cin >> v >> l;
        cout << rec(v, l) << "\n";
    }

    return 0;
}



Measured memory_bytes: 204868
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,d;
	cin>>n>>d;
	int ans=(n+2*d)/(2*d+1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL N,i;
	cin>>N;
	vector<LL> A(N+1),X(N+1);
	LL S=0;
	LL S2=0;
	for (i=1;i<=N;i++){
		cin>>A[i];
		S+=A[i];
		if (i%2==0){
			S2+=A[i];
		}
	}
	X[1]=S-2*S2;
	for (i=1;i<N;i++){
		X[i+1]=2*A[i]-X[i];
	}
	for (i=1;i<=N;i++){
		if (i>1){
			cout<<" ";
		}
		cout<<X[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 2944
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

void sputs(){}
template <class Head, class... Tail>
void sputs(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) == 0) { cout << endl; }
  else { cout << " "; }
  sputs(std::move(tail)...);
}

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

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

  vector<pii> ans;
  int s = n%2?n:n+1;
  rep(i, 1, n+1){
    rep(j, i+1, n+1){
      if (i+j!=s) ans.pb(mp(i, j));
    }
  }
  cout << sz(ans) << endl;
  rep(i,sz(ans)){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#define K 21000
using namespace std;
int a[20100],b[20100],p[20100],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)a[i]=i*K;
	for(int i=n;i>=1;i--)b[i]=a[n-i+1];
	for(int i=1;i<=n;i++)
	{
		a[p[i]]-=(n-i+1);b[p[i]]-=(n-i+1);
	}
	for(int i=1;i<=n;i++)printf("%d ",a[i]);cout<<endl;
	for(int i=1;i<=n;i++)printf("%d ",b[i]);return 0;
 } 

Measured memory_bytes: 896
#![allow(dead_code, unused_variables)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        s:Chars,
        t:Chars,
    }
    let n = s.len();
    let m = t.len();
    let mut dp = vec![vec![0;m+1];n+1];

    for i in 0..n{
        for j in 0..m{
            if s[i] == t[j]{
                dp[i+1][j+1] = max(dp[i][j] + 1,dp[i+1][j+1]);
                // println!("{} {}",dp[i][j] + 1,dp[i+1][j+1]);
            }else{
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }
            
        }
    }
    // println!("{:?}",&dp);
    let mut i = n;
    let mut j = m;
    let mut ans = String::new();

    while i > 0 && j > 0{
        if dp[i][j] == dp[i-1][j]{
            i -= 1;
        }else if dp[i][j] == dp[i][j-1]{
            j -= 1;
        }else{
            ans.push(s[i-1]);
            i -= 1;
            j -= 1;
        }
    }
    let res = ans.chars().rev().collect::<String>();
    println!("{}",res);

}


Measured memory_bytes: 37348
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
	IOS
	string s;
	cin>>s;

	ll i=0;
	vector<char> v;
	set<char> set;
	map<char,ll> m;
	ll n=s.size();
	for(i=0;i<n;i++)
	{
		set.insert(s[i]);
		m[s[i]]++;
	}
	if(set.size()!=2)
	{
		cout<<"No";
	}
	else
	{
		for(auto i:set)
			{
				v.pb(i);
			}
			if(m[v[0]]==m[v[1]])
			{
				return cout<<"Yes",0;
			}
			else
			{
				cout<<"No";
			}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
int d1[4] = { 1,0,-1,0 };
int d2[4] = { 0,1,0,-1 };
int panel[10][10];
int cop[10][10];
void init() {
	rep(i, 10) {
		rep(j, 10) {
			cop[i][j] = panel[i][j];
		}
	}
}
void trans(int col) {
	queue<P> q; q.push({ 1,1 });
	int used[10][10] = {}; int memo = cop[1][1];
	used[1][1] = 1; cop[1][1] = col;
	while (!q.empty()) {
		P now = q.front(); q.pop();
		rep(k, 4) {
		    int nx = now.first+d1[k]; int ny = now.second+d2[k];
			if (cop[nx][ny] == memo && used[nx][ny] == 0) {
				used[nx][ny] = 1;
				cop[nx][ny] = col;
				q.push({ nx,ny });
			}
		}
	}
}
int count(int col) {
	int res = 1;
	queue<P> q; q.push({ 1,1 });
	int used[10][10] = {}; int memo = cop[1][1];
	used[1][1] = 1;
	while (!q.empty()) {
		P now = q.front(); q.pop();
		rep(k, 4) {
			int nx = now.first + d1[k]; int ny = now.second + d2[k];
			if (cop[nx][ny] == memo && used[nx][ny] == 0) {
				used[nx][ny] = 1;
				res++;
				q.push({ nx,ny });
			}
		}
	}
	return res;
}
int main() {
	int h, w, c;
	while (cin >> h >> w >> c, h) {
		rep(i, 10) {
			rep(j, 10) {
				panel[i][j] = 0;
			}
		}
		rep1(i, h) {
			rep1(j, w) {
				cin >> panel[i][j];
			}
		}
		int ma = 1;
		rep1(i1, 6) {
			if (i1 == panel[1][1])continue;
			rep1(i2, 6) {
				if (i2 == i1)continue;
				rep1(i3, 6) {
					if (i3 == i2)continue;
					rep1(i4, 6) {
						init();
						trans(i1); trans(i2); trans(i3); trans(i4); trans(c);
						ma = max(ma, count(c));
					}
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
	int X, A, B;
	cin >> X >> A >> B;

	if (B - A <= 0) {
		cout << "delicious" << endl;
	}
	else if (B-A <= X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}

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

int main() {
    int N; cin >> N;
    int K; cin >> K;
    string S; cin >> S;

    int counter = 0;
    for (int i = 1; i < N; i++){
        if(S[i] != S[i-1]){
            counter ++;
        }
    }
    int ans = N-1 - counter;
    rep(i, K){
        if(ans == N-1)break;
        ans += 2;
        if(ans == N-1){
            break;
        } else if(ans == N){
            ans--;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m, q) = get!(usize, usize, usize);
    let mut v = vec![vec![0; n + 1]; n + 1];
    for _ in 0..m {
        let (l, r) = get!(usize, usize);
        v[l][r] += 1;
    }
    let mut query = Vec::new();
    for _ in 0..q {
        query.push(get!(usize, usize));
    }
    let mut s = vec![vec![0; n + 1]; n + 1];
    for i in 1..n + 1 {
        for j in 1..n + 1 {
            s[j][i] = s[j][i - 1] + v[j][i];
        }
    }
    //for i in 0..v.len() {
    //    eprintln!("{:?}", s[i]);
    //}
    for i in 0..q {
        let mut t = 0;
        for j in query[i].0..query[i].1 + 1 {
            t += s[j][query[i].1];
        }
        println!("{}", t);
    }
}


Measured memory_bytes: 9084
heroes = int(input())
monsters = [int(i) for i in input().split()]
slay = [int(i) for i in input().split()]

res = 0

for i in range(heroes):
    temp = 0
    if slay[i] <= monsters[i]:
        res += slay[i]
    else:
        res += monsters[i]
        temp = slay[i] - monsters[i]
        if temp <= monsters[i+1]:
            res += temp
            monsters[i+1] -= temp
        else:
            res += monsters[i+1]
            monsters[i+1] = 0

print(res)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define sort(v)	sort(v.begin(),v.end());
#define rsort(v) sort(v.rbegin(),v.rend());
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

/******************************START********************************/
int main()
{
	char ch1,ch2,ch3;
	string s1,s2,s3;
    lli i,j,k,a,t,b,c,n,m,x,sum=0,ans=0,temp;
    cin >> n >> k;
    vector<lli>v(n);
    rep(i,0,n)	cin >> v[i];
    sort(v);
    if(k>=n){
    	cout << "0" << endl;
	}
	else{
		for(i=0;i<n-k;i++){
			sum+=v[i];
		}
		cout << sum << endl;
	}
    
    
    
    
    
    return 0;
}





















/* UJJWAL KESHRI */

Measured memory_bytes: 1792
N, K = map(int, input().split())

data_dict = {}

for k in range(K):
    data_dict[k] = 0

for n in range(N):
    if n in data_dict:
        if data_dict[n] == 0:
            data_dict[n] = 1
    else:
        data_dict[0] += 1

print(data_dict[0] - data_dict[K - 1])

Measured memory_bytes: 38460
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    double res = 0;
    for (int i = 1; i <= n; i++) {
        int dice = i;
        double coin = (double)1 / n;
        while (dice < k) {
            coin /= 2;
            dice *= 2;
        }
        res += coin;
    }
    
    printf("%.12f\n", res);
}


Measured memory_bytes: 256
#include<stdio.h>
#define INF 1000000000
#define N 100000000
void maxheapinsert(int *,int);

void heapincreasekey(int *,int,int);

int heapextractmax(int *);

void maxheapify(int *,int);

int heapsize;

int heap[N];

int main(){
  char command[10];
  int key;

  int max;

  while(1){
  scanf("%s",command);

  if(command[0] == 'i') {
    scanf("%d",&key);
    maxheapinsert(heap,key);
  }

  else if(command[0] == 'e' && command[1] == 'x'){
    max = heapextractmax(heap);
    printf("%d\n",max);
  }

  else break;

  }
  return 0;

}


void maxheapify(int *A,int i){
  int l,r;
  int temp;
  int largest;

  
  l = 2*i;
  r = 2*i+1;
  //左の子、自分、右の子で値が最大のノードを選ぶ
  if (l <= heapsize && A[l] > A[i])
    largest = l;
  else 
    largest = i;
  if (r <= heapsize && A[r] > A[largest])
    largest = r;

  //printf("largest %d\n",largest);

  if (largest != i){
    //iの子の方が値が大きい場合
    //A[i] と A[largest] を交換
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    
    maxheapify(A, largest); // 再帰的に呼び出し
  }
}

  
int heapextractmax(int *A){
  int max;
  
  if(heapsize < 1){
    printf("heap underflow\n");
  }

  max = A[1];

  A[1] = A[heapsize];

  heapsize--;

  maxheapify(A,1);

  return max;

}

void maxheapinsert(int *A,int key){

  heapsize += 1;
  A[heapsize] = -INF;
  heapincreasekey(A,heapsize,key);

}

void heapincreasekey(int *A,int i,int key){
  int temp;
  
  if(key < A[i]) printf("new key is smaller than current key\n");

  A[i] = key;

  while(i > 1 && A[i/2] < A[i]){
    //exchange A[i] and A[parent(i)]
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;

    i = i/2;
  }

}

    

    



Measured memory_bytes: 6472
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := n / 500
	n %= 500
	b := n / 5
	fmt.Println(a*1000 + b*5)
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    int x, y;
    cin >> x >> y;

    int tot = y - 2 * x;
    if(tot >= 0 && tot % 2 == 0 && (x - tot / 2) >= 0) cout << "Yes";
    else cout << "No";

}








Measured memory_bytes: 3652
use std::io::*;
fn read(s: &mut StdinLock, num: usize) -> Vec<usize> {
    let stdin_iter = &mut s.by_ref().bytes().map(|c| c.unwrap() as char);
    (0..num).map(|_| 
        stdin_iter
            .take_while(|c| !c.is_whitespace())
            .skip_while(|c| c.is_whitespace())
            .fold(0, |a, x| (x as u8 - b'0') as usize + a * 10)
    ).collect()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let hw: Vec<usize> = read(&mut s, 2);
    let h = hw[0];
    let w = hw[1];
    let squares: Vec<Vec<char>> = {
        let mut squares: Vec<Vec<char>> = Vec::new();
        for _ in 0..h {
            squares.push(
                s.by_ref().bytes().map(|c| c.unwrap() as char)
                    .take_while(|c| !c.is_whitespace())
                    .skip_while(|c| c.is_whitespace())
                    .collect::<Vec<char>>());
        }
        squares
    };
    let mut ans: u64 = 0;
    let mut h_cnts: Vec<u64> = vec![0; w];
    for i in (0..h).rev() {
        let mut o_cnt: u64 = 0;
        for j in (0..w).rev() {
            if squares[i][j] == 'I' {
                h_cnts[j] += 1;
            } else if squares[i][j] == 'O' {
                o_cnt += 1;
            } else {
                ans += h_cnts[j] * o_cnt;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 66472
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> Li(n);
  for(int i=0; i<n; i++) cin >> Li[i];

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

  long long ans = 0;
  for(int b=0; b<n; b++){
    for(int a=0; a<b; a++){
      int r = lower_bound(Li.begin(), Li.end(), Li[a]+Li[b]) - Li.begin();
      int l = b + 1;
      ans += r - l;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXN = 100 + 1;
const LL MAXS = 100 + 1;
const LL MAXT = 100 + 1;

void ok()
{
	cout << "YES";
	exit(0);
}

void bad()
{
	cout << "NO";
	exit(0);
}

LL n, a, b, c, d;

bool intersect(LL x, LL y, LL z, LL t)
{
	return z <= y;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n >> a >> b >> c >> d;
	b -= a;
	b = abs(b);
	--n;
	a = b;

	for(LL pos = 0; pos <= n; ++pos)
	{
		bool can = 0;
		LL neg = n - pos;

		LL mi = -neg * d;
		LL ma = -neg * c;

		LL mi1 = pos * c;
		LL ma1 = pos * d;

		if (mi + mi1 <= a && ma + ma1 >= a)
			can = 1;

		if (can)
			ok();
	}

	bad();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int count=0;
    for(int i=a;i<b+1;i++){
        if(i<0){count++;}
        else if(i==0){count=-1; break;}
    }
    if(count%2==0){cout<<"Positive"<<endl;}
    else if(count==-1){cout<<"Zero"<<endl;}
    else{cout<<"Negative"<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    VSORT(a);

    ll start = a[0];
    ll cnt = 0;
    ll ans = 1;

    REP(i,n){

        if(cnt < c && a[i] <= start + k){
            //定員に達していないかつ時刻も満たす
            cnt++;
        }else{
            start = a[i];
            cnt = 1;
            ans++;
        }
        //cout << i << " " << cnt << " " << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    string s;
    cin >> s;
    cout << string(s.size(), 'x') << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

typedef long long ll;
typedef std::pair<ll,ll> llp;

const ll MOD = 1000000007; // 1e9 + 7
const ll MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modinv(ll a, ll modVal) {
    ll b = modVal, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= modVal; 
    if (u < 0) u += modVal;
    return u;
}

ll frac(ll n)
{
    ll v = 1;

    while(n > 1) {
        v *= n;
        v %= MOD;
        n--;
    }

    return v;
}

ll nCr(const ll n, const ll r)
{
    //return (frac(n) * modinv((frac(r) * frac(n - r)) % MOD, MOD)) % MOD;
    return COM(n, r);
}

ll solve(const ll n, const ll k, const std::vector<llp> ap)
{
    ll sum = 0;
    if (k == 1) {return 0LL;}

    // 上のパターン
    ll elemSum = 0;
    for (int i = 0; i < ap.size(); i++) {
        const ll elemNum = ap[i].first;
        const ll elemCount = ap[i].second;
        if (elemSum + elemCount < k) {
            elemSum += elemCount;
            continue;
        }

        for (int j = 1; j <= elemCount; j++) {
            sum += (((elemNum * nCr(elemCount, j)) % MOD) * nCr(elemSum, k - j)) % MOD;
            sum %= MOD;
        }
        elemSum += ap[i].second;
    }
    
    // 下のパターン
    elemSum = 0;
    for (int i = ap.size() - 1; i > 0; i--) {
        const ll elemNum = ap[i].first;
        const ll elemCount = ap[i].second;
        if (elemSum + elemCount < k) {
            elemSum += elemCount;
            continue;
        }

        for (int j = 1; j <= elemCount; j++) {
            sum -= (((elemNum * nCr(elemCount, j)) % MOD) * nCr(elemSum, k - j)) % MOD;
            sum %= MOD;
            if (sum < 0) {sum += MOD;}
        }

        elemSum += ap[i].second;
    }

    return sum;
}

int main(int argc, char *argv[])
{
    ll n, k;
    std::vector<ll> a;
    std::vector<llp> ap;
    ll ans;

    COMinit();

    std::cin >> n >> k;

    a.resize(n);

    ll min = std::numeric_limits<ll>::max();
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        min = std::min(min, a[i]);
    }
    for (int i = 0; i < n; i++) {
        a[i] -= min;
    }

    std::sort(a.begin(), a.end());

    ap.push_back({a[0], 1});
    for (int i = 1; i < n; i++) {
        const ll num = a[i];
        if (ap.back().first != num) {
            ap.push_back({num, 1});
        } else {
            ap.back().second++;
        }
    }

    ans = solve(n, k, ap);

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

    return 0;
}


Measured memory_bytes: 15984
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int s[50][26]={0};
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        for(int j=0;j<a.size();j++){
            s[i][a[j]-'a']++;
        }
    }
    string tmp="";
    for(int j=0;j<26;j++){
        int k=10000;
        for(int i=0;i<n;i++){
            k=min(k,s[i][j]);
        }
        for(int i=0;i<k;i++){
            tmp+='a'+j;
        }
    }
    cout<<tmp<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
 
typedef long long int ll;
typedef unsigned long long int llu;


ll max(ll a,ll b){
	return a>b?a:b;
}
#define N 1000000000000000000
int main()
{
	ll a; cin>>a;
  long double b; cin>>b;
  ll bb=(ll)b;
  long double xx=b-bb;
  ll ans=bb*a;
  ans=ans+(xx*a);
  cout<<ans;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>

using namespace std;

int borrow, a, b, k, ans, A[10], B[10], C[10], as, bs;

void solve(int p, int cnt){
  if(p == as){
    int tmp = 0;
    for(int i=0, r=1;i<as;i++,r*=10) tmp += C[i] * r;
    ans = max(ans, tmp);
    return;
  }
  if(A[p] - borrow >= B[p]){
    C[p] = A[p] - borrow - B[p];
    borrow = 0;
    solve(p+1, cnt);
  }else{
    C[p] = A[p] - borrow + 10 - B[p];
    borrow = 1;
    solve(p+1, cnt);
    if(cnt < k){
      borrow = 0;
      solve(p+1, cnt+1);
    }
  }
  C[p] = 0;
}

main(){
  cin >> a >> b >> k;
  fill(C, C+10, 0);
  for(as=0;;as++){
    A[as] = a % 10;
    if(a == 0) break;
    a /= 10;
  }
  for(bs=0;;bs++){
    B[bs] = b % 10;
    if(b == 0) break;
    b /= 10;
  }
  for(int i=bs;i<as;i++) B[i] = 0;
  ans = borrow = 0;
  solve(0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 1164
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char C[2200010];
char *ci = C, ct;
char D[2200010];
char *di = D;
void pakuri_sort(int N, ll A[], int ichi[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = ichi[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			ichi[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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

	fread(C, 1, 2200010, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	ll S[200000];
	int ichi[200001];
	rep(i, N) {
		ll s = 0;
		ichi[i] = ci - C;
		int k = 10;
		while ((ct = *ci++) >= 'a') {
			s = s * 27 + ct - '`';
			k--;
		}
		rep(i, k) s *= 27;
		S[i] = s;
	}
	pakuri_sort(N, S, ichi);
	int kazu = 0;
	int saidai = 0;
	ll mae = 0;
	rep(i, N) {
		if (S[i] != mae) {
			if (saidai < kazu) {
				saidai = kazu;
				di = D;
			}
			if (saidai == kazu) {
				char* tmp = C + ichi[i - 1];
				while (*tmp >= 'a')* di++ = *tmp++;
				*di++ = '\n';
			}
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	if (saidai < kazu) {
		saidai = kazu;
		di = D;
	}
	if (saidai == kazu) {
		char* tmp = C + ichi[N - 1];
		while (*tmp >= 'a')* di++ = *tmp++;
		*di++ = '\n';
	}
	fwrite(D, 1, di - D, stdout);

	Would you please return 0;
}

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

int j, y;
string s;
void solve(int t, int k) {
	if (!t && !k) {
		int a = 0, b = 0;
		rep(i, s.size()) {
			if (s[i] == 'A')a++; else b++;
			if (a <= 3 && b == 5 && i != s.size() - 1)return;
			if (a == 5 && b <= 3 && i != s.size() - 1)return;
			if (a == 4 && b == 4 && i < s.size() - 3 && s[i + 1] == s[i + 2])return;
			if (a == 4 && b == 4 && i < s.size() - 3 && s[i + 1] != s[i + 2])return;
		}
		cout << s << endl;
	}
	if (t) {
		s += 'A'; solve(t - 1, k); s.pop_back();
	}
	if (k) {
		s += 'B'; solve(t, k - 1); s.pop_back();
	}
}
int main() {
	scanf("%d%d", &j, &y);
	solve(j, y);
}

Measured memory_bytes: 3228
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_B
  * Array - Finding Missing Cards
  */
object Main {
  def main(args: Array[String]): Unit = {
    val suits = Seq("S", "H", "C", "D")
    val ranks = 1 to 13
    val cards = for (suit <- suits; rank <- ranks) yield Card(suit, rank)
    val n = io.StdIn.readInt()
    val tarosCards = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(n).map(_.split(" "))
      .map { case Array(s, r) => Card(s, r.toInt) }
      .toSeq
    cards.diff(tarosCards).sorted.foreach {
      case Card(suite, rank) => println(s"$suite $rank")
    }
  }

  case class Card(suite: String, rank: Int) extends Ordered[Card] {
    val suitOrders = Map("S" -> 1, "H" -> 2, "C" -> 3, "D" -> 4)

    def compare(that: Card): Int = {
      import scala.math.Ordered._
      (suitOrders(this.suite), this.rank).compare((suitOrders(that.suite), that.rank))
    }
  }

}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string temp = "";
            while ((temp = Console.ReadLine()) != "0 0")
            {
                int[] date = temp.Split().Select(int.Parse).ToArray();

                DateTime dt = new DateTime(2004, date[0], date[1]);
                DayOfWeek week = dt.DayOfWeek;

                Console.WriteLine(week);
            }
        }
    }
}



Measured memory_bytes: 18428
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
using namespace std;

int main(void){
    string target,s;
    int n;
    cin>>target>>n;
    int ans=0;
    rep(i,0,n){
        cin>>s;
        s+=s;
        rep(i,0,2*s.size()-target.size()){
            bool ok=true;
            rep(j,0,target.size()){
                if(target[j]!=s[i+j])ok=false;
            }
            if(ok){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3176
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(n, m) = sc.nextLine.split(" ").map(_.toInt)
    val nPoints = List.fill(n)(sc.nextLine.split(" ").map(_.toInt))
    val mPoints = List.fill(m)(sc.nextLine.split(" ").map(_.toInt))
    nPoints.map {
      nPoint => mPoints.map { mPoint => math.abs(mPoint(0) - nPoint(0)) + math.abs(mPoint(1) - nPoint(1)) }.zipWithIndex.minBy(item => item._1)._2 + 1
    }.foreach(println)
  }
}


Measured memory_bytes: 27584
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

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

Measured memory_bytes: 3636
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    int[] VS = [0], WS = [0];
    foreach (_; 0..N) {
        auto vw = readln.split.to!(int[]);
        VS ~= vw[0];
        WS ~= vw[1];
    }
    auto Q = readln.chomp.to!int;

    auto len = min(2^^9+1, N+1);
    auto MAX_L = 10^^5;
    auto DP = new int[][](len, MAX_L+1);
    foreach (i; 1..len) {
        foreach (w; 0..MAX_L+1) {
            DP[i][w] = max(DP[i][w], DP[i/2][w]);
            if (w - WS[i] >= 0) DP[i][w] = max(DP[i][w], DP[i/2][w-WS[i]] + VS[i]);
        }
    }

    foreach (_; 0..Q) {
        auto vl = readln.split.to!(int[]);
        auto v = vl[0];
        auto L = vl[1];

        if (v < len) {
            writeln(DP[v][L]);
        } else {
            int solve(int i, int l) {
                if (i < len) return DP[i][l];
                auto r1 = solve(i/2, l);
                int r2;
                if (l - WS[i] >= 0) r2 = solve(i/2, l - WS[i]) + VS[i];
                return max(r1, r2);
            }
            writeln(solve(v, L));
        }
    }
}

Measured memory_bytes: 207524
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    for(int i=0; i<n; ++i){
        if((i % 2 == 0 && s[i] == 'L') || (i % 2 != 0 && s[i] == 'R')){
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256