akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    string s;
    cin>>s;
    int x=0,y=0,z=0;
    REP(i,s.length())
    {
        if(s[i]=='a')x++;
        else if(s[i]=='b')y++;
        else z++;
    }
    if(max(x,max(y,z)) <= min(x,min(y,z)) + 1)
    cout<<"YES";
    else cout<<"NO";

  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> p;
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    p.push_back(d);
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=p[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

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

    int defence = 2 * d + 1;

    for (int i = 1; i <= n; i++) {
        if (defence * i >= n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] < xx) {//未満では<, 以下では<=
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { 
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
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;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
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;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx<=1) {
		return 0;
	}
	double d = sqrt(xx);
	for (int i = 2; i <= d; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n;
	cin >> n;
	cout << 1000*krag((n + 0.0) / 1000) - n << endl;
}


Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=55;
const int mod7=1e9+7;
const int mod=998244353;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
struct note {int v,a,b;};
vector <note> G[N];
int c[N],d[N];
ll f[N][N*N];
int main()
{
    int n,m,s;
    read(n),read(m),read(s);
    s=min(s,2500);
    for(re int i=1,u,v,a,b;i<=m;i++)
    {
        read(u),read(v),read(a),read(b);
        G[u].pb({v,a,b});G[v].pb({u,a,b});
    }
    for(re int i=1;i<=n;i++) read(c[i]),read(d[i]);
    for(re int i=0;i<N;i++) for(re int j=0;j<N*N;j++) f[i][j]=1e18;
    f[1][s]=0;
    typedef tuple <ll,int,int> T;
    priority_queue <T,vector <T>,greater<T>> q;
    q.push(T(0,1,s));
    while(!q.empty())
    {
        ll t=get<0>(q.top());
        int u=get<1>(q.top()),w=get<2>(q.top());
        q.pop();
        if(f[u][w]>t) continue;
        for(auto i:G[u])
        {
            int v=i.v,a=i.a,b=i.b;
            if(w>=a&&f[v][w-a]>t+b)
            {
                f[v][w-a]=t+b;
                q.push(T(t+b,v,w-a));
            }
        }
        if(f[u][min(w+c[u],2500)]>t+d[u])
        {
            f[u][min(w+c[u],2500)]=t+d[u];
            q.push(T(t+d[u],u,min(w+c[u],2500)));
        }
    }
    for(re int i=2;i<=n;i++)
    {
        ll ans=1e18;
        for(re int j=0;j<=2500;j++) ans=min(ans,f[i][j]);
        printf("%lld\n",ans);
    }
    return 0;
}

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

using namespace std;
using ll = long long int;

int main(){

    ll t;
    cin >> t;

    vector<ll> val = {0, 0, 0, 0};

    while(t--){
        string s;
        cin >> s;

        if (s == "AC") val[0]++;
        if (s == "WA") val[1]++;
        if (s == "TLE") val[2]++;
        if (s == "RE") val[3]++;

    }

    cout << "AC x " << val[0] << endl;
    cout << "WA x " << val[1] << endl;
    cout << "TLE x " << val[2] << endl;
    cout << "RE x " << val[3] << endl;

    return 0;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	int H, W;
	cin >> H >> W;

	vector<vector<char>> table(H, vector<char>(W));
	vector<bool> removed_H(H, false);
	vector<bool> removed_W(W, false);

	// initialize vector array
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> table.at(i).at(j);
		}
	}

	// make index for height
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (table.at(i).at(j) == '#') {
				removed_H.at(i) = false;
				break;
			}
			else if (j == (W-1)) {
				removed_H.at(i) = true;
			}
		}
	}

	// make index for width
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (table.at(i).at(j) == '#') {
				removed_W.at(j) = false;
				break;
			}
			else if (i == (H-1)) {
				removed_W.at(j) = true;
			}
		}
	}

	// check vector array and output them to stdout
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (removed_H.at(i) == false && removed_W.at(j) == false) {
				cout << table.at(i).at(j);
			}
			if (removed_H.at(i) == false && j == W-1) {
				cout << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define ll              long long int
#define vll             vector<ll>
#define vs              vector <string>                                    
#define mll             map<ll,ll>
#define pll             pair<ll, ll>
#define vpll            vector < pair<ll,ll> >
#define itr             vll::iterator
#define all(c)          c.begin(),c.end()
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pb              push_back
#define mb              make_pair
#define ff              first
#define ss              second
#define max3(a,b,c)     max(max(a,b),c)                                    
#define min3(a,b,c)     min(min(a,b),c)  
#define mod             1000000007
#define inf             1000000000000000001
#define from(i, n)      for(__typeof(n) i = 0; i <  n; ++i)
#define fromj(i, j, n)  for(__typeof(n) i = j; i <  n; ++i)
#define printv(v)       from(i,v.size())cout<<v[i]<<" ";cout<<"\n";
#define w(x)            int x; cin>>x; while(x--)

using namespace std;
using namespace __gnu_pbds; 

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}
 
bool func(const pll &a, const pll &b){
    if(a.ss==b.ss)return a.ff<b.ff;
    return a.ss < b.ss;
}

typedef tree<int, null_type, less<int >, rb_tree_tag, 
             tree_order_statistics_node_update> pbds; 
list<int>*l;
int solve(int src,vector<int>&maxdepth){
	if(maxdepth[src]!=-1)return maxdepth[src];
	if(l[src].size()==0){
		maxdepth[src]=0;
		return 0;
	}
	for(int i:l[src]){
		maxdepth[src]=max(maxdepth[src],1 + solve(i,maxdepth));
	}
	return maxdepth[src];
}
int main(){
    c_p_c();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    l = new list<int>[n];
    from(i,m){
    	int x,y;
    	cin>>x>>y;
    	l[x-1].push_back(y-1);
    }
    vector<int>maxdepth(n,-1);
    int ans=0;
    from(i,n)ans=max(ans,solve(i,maxdepth));
    cout<<ans;
}    


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

#define endl "\n"
#define ll long long int

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x;
	cin>>x;
	ll happiness= (x/500)*1000;
	x= x%500;
	happiness += (x/5)*5;
	cout<<happiness<<endl;

	return 0;
}


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

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    map<int, int> mmp;
    for (int i = 1; i <= n; i++) {
        int w;
        cin >> w;
        mmp[w]++;
    }
    for (int i = 0; i <=100; i++) {
        int w = x - i;
        if (mmp.count(w) == 0) {
            cout << w << endl;
            return 0;
        }
        w = x + i;
        if (mmp.count(w) == 0) {
            cout << w << endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

int main() {
	int num;
	cin >> num;
	vector<int> a(num);
	for( int i=0; i<num; i++ ) {
		cin >> a[i];
	}
	std::reverse( a.begin(), a.end() );
	for( vector<int>::iterator it=a.begin() ; it!=a.end() ; ++it ) {
		if( it != a.begin() ) { cout << " "; }
		cout << *it;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3112
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Input:
6
D 3
H 2
D 1
S 3
D 2
C 1

Output:
Not stable / Stable
D 1
C 1
D 2
H 2
D 3
S 3
"""
import sys
import copy


def partition(array, start, end):
    x = int(array[end][2:])
    i = start - 1
    assert start <= end
    for j in range(start, end):
        if int(array[j][2:]) <= x:
            i += 1
            array[i], array[j] = array[j], array[i]
    array[i + 1], array[end] = array[end], array[i + 1]
    return i + 1


def quick_sort(array, start, end):
    if start < end:
        cursor = partition(array, start, end)
        quick_sort(array, start, cursor - 1)
        quick_sort(array, cursor + 1, end)
    return array


def merge(A, left, mid, right):
    L = A[left:mid] + ['N ' + str(int(1e9 + 1))]
    R = A[mid:right] + ['N ' + str(int(1e9 + 1))]

    i, j = 0, 0

    for k in range(left, right):
        if int(L[i][2:]) <= int(R[j][2:]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return None


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.strip('\n'), _input[1:]))
    assert len(array) == array_length

    merge_array = copy.deepcopy(array)

    # print('merge',merge_array)
    merge_result = merge_sort(A=merge_array, left=0, right=array_length)
    # print(*merge_result, sep='\n')

    # print('quick',array)
    quick_result = quick_sort(array=array, start=0, end=array_length - 1)
    if quick_result != merge_result:
        print('Not stable')
    else:
        print('Stable')
    print(*quick_result, sep='\n')

Measured memory_bytes: 23996
#import math
import fractions
from functools import reduce

def gcdList(ls):
#    return reduce(math.gcd, ls)
    return reduce(fractions.gcd, ls)

n,y = map(int,input().split())
x = sorted([int(i) for i in input().split()])
x_ = [0 for _ in range(n)]
for i in range(n):
    x_[i] = abs(y-x[i])
print(gcdList(x_))

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

int main() 
{
    int h,m,h1,m1,k;
    cin>>h>>m>>h1>>m1>>k;
    int l,n;
    l=h*60+m;
    n=h1*60+m1;
    
    cout<<(abs(l-n))-k;
	return 0;
}

Measured memory_bytes: 3632
n=int(input())
e=[0]*(n-1)
for i in range(2,n+1):
  a=i
  for j in range(2,i+1):
    while a%j==0:
      e[j-2]+=1
      a//=j
ans=1
for k in e:
  ans*=k+1
print(ans%1000000007)

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

int main() {
  int n;
  cin>>n;
  pair<int,int> red[n];
  pair<int,int> blue[n];
  for(int i=0;i<n;i++) cin>>red[i].first>>red[i].second;
  for(int i=0;i<n;i++) cin>>blue[i].first>>blue[i].second;
  sort(blue,blue+n);
  int ans=0;
  bool c[n];
  for(int i=0;i<n;i++) c[i]=false;
  for(int i=0;i<n;i++){
    int temp_y=-1;
    int temp=-1;
    for(int j=0;j<n;j++){
      if(c[j]) continue;
      if(red[j].first<blue[i].first && red[j].second<blue[i].second){
        temp_y=max(temp_y,red[j].second);
        if(temp_y==red[j].second) temp=j;
      }
    }
    if(temp!=-1){
      ans++;
      c[temp]=true;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
program speedrun
   implicit none
   integer::N
   integer,allocatable,dimension(:)::A

   integer::i
   logical::C=.true.
   read*,N
   allocate(A(N))
   read*,A
   do i=1,N
      if(mod(A(i),2)==1)cycle
      if(mod(A(i),3)==0)cycle
      if(mod(A(i),5)==0)cycle
      C=.false.
   end do
   print"(A)",trim(merge("APPROVED","DENIED  ",C))
end program speedrun

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
typedef long long int ll;

int nextsmallest(vector<int> &v, int sidx) {
    int l = 0, u = v.size()-1;
    if (v[0] > sidx) {
        u = 0;
    } else if (v[u] > sidx) {
        while (u - l > 1) {
            int b = (l+u+1)/2;
            ll h = v[b];
            if (h > sidx) u = b;
            else if (h < sidx) l = b;
            else u = l = b+1;
        }
    } else u = u + 1;
    
    u = u%v.size();
    return u;
}

int main(int argc, const char * argv[]) {
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    REP(i, N) {
        cin >> V[i];
    }
    
    ll score = 0;
    REP(kk, K+1) {
        REP(k, kk+1) {
            ll take = kk - k;
            ll give = k;
            
            if (give > take || take > N) continue;
            REP(l, take+1) {
                ll r = take-l;
                vector<ll> s;
                ll q = 0;
                REP(i, N) {
                    if (i < l || N-r-1 < i) {
                        s.push_back(V[i]);
                    }
                }
                sort(s.begin(), s.end());
                REP(i, s.size()) {
                    if (i >= give)
                        q += s[i];
                }
                score = max(score, q);
            }
            
        }
    }

    cout << score << endl;
}


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

int main() {
  int n,ans;
  cin >> n;
  if (n <= 111) ans = 111;
  else if (n <= 222) ans = 222;
  else if (n <= 333) ans = 333;
  else if (n <= 444) ans = 444;
  else if (n <= 555) ans = 555;
  else if (n <= 666) ans = 666;
  else if (n <= 777) ans = 777;
  else if (n <= 888) ans = 888;
  else ans = 999;

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3624
from collections import deque
n = int(input())

num_to_alp = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f', 6:'g', 7:'h', 8:'i', 9:'j'}
alp_to_num = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8, 'j':9}
words = deque([[0]])

def next_letters(x):
    letters = deque([])
    for i in range(x + 2):
        letters.append(i)
    return letters

while len(words[0]) < n:
    word = words.popleft()
    letters = next_letters(max(word))
    for l in letters:
        l = [l]
        words.append(word + l)

for word in words:
    word = [num_to_alp[i] for i in word]
    print(''.join(word))


Measured memory_bytes: 23952
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans;
  rep(i, 101){
    bool flag = true;
    rep(j, n){
      if (x - i == p[j]){
        flag = false;
        break;
      }
    }
    if (flag){
      ans = x - i;
      break;
    }
    
    flag = true;
    rep(j, n){
      if (x + i == p[j]){
        flag = false;
        break;
      }
    }
    if (flag){
      ans = x + i;
      break;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3600
#D WA
s = list(input())
n = len(s)

for i in range(n - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit()

alp = [chr(i) for i in range(97, 97+26)]

for j in range(26):
    num = [0] * n

    for i in range(n):
        if s[i] == alp[j]:
            num[i] += 1

    start = 0
    end = 3

    while True:
        #print(start, end, n)
        #print(sum(num[start:end]),(end - start) / 2)

        if start >= n or end > n:
            break

        if num[start] == 0:
            start += 1
            end += 1
            continue

        if sum(num[start:end]) > (end - start) / 2:
            print(start + 1, end)
            exit()

        if sum(num[start:end]) > (end - start) / 2 - 1:
            end += 1

        else:
            start += 1
            if end - start < 3:
                end += 1

print(-1, -1)


Measured memory_bytes: 72440
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  int sum = std::accumulate(A.begin(), A.end(), 0);
  int need = (sum - 1) / (4 * M);
  int cnt = 0;
  for (int x: A) {
    if (x > need) {
      ++cnt;
    }
  }
  std::cout << (cnt >= M ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

n = I()
a = Intl()
cnt = 0
if not 1 in a:
    print(-1)
    exit()
now = 1
for i in range(n):
    if now == a[i]:
        now += 1
    else:
        cnt += 1
print(cnt)

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#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 REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

class UnionFind{
private:
	vector<int> rank; // 木の深さ
	int count_;

public:
	vector<int> data; // 親>0, サイズ<0

	UnionFind(int n):data(n,-1), rank(n,0), count_(n){}

	int root(int x){
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}

	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y) return;

		count_--;
		if(rank[x] < rank[y]){
			data[y] += data[x];
			data[x] = y;
		} else {
			data[x] += data[y];
			data[y] = x;
			if(rank[x] == rank[y])
				rank[x]++;
		}
	}

	bool same(int x, int y){
		return root(x) == root(y);
	}

	int size(int x){
		return -data[root(x)];
	}

	int groups(){
		return count_;
	}
};

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  int A[100000+5], B[100000+5];
  int count[100000+5] = {};

  rep(i, M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    A[i] = a;
    B[i] = b;
    uf.unite(a, b);
  }

  rep(i, M){
    int a, b;
    a = A[i];
    b = B[i];
    if(uf.same(a, b)){
      count[a]++;
      count[b]++;
    }
  }

  rep(i, K){
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    if(uf.same(c, d)){
      count[c]++;
      count[d]++;
    }
  }

  rep(i, N){
    cout << uf.size(i) - count[i] - 1 << " ";
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
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...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

using P = pair<ll, ll>;
int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> t(N), d(N);
    priority_queue<P> que;
    set<int> s;
    for (int i = 0; i < N; i++) {
        cin >> t.at(i) >> d.at(i);
        t[i]--;
        que.push(P(d[i], t[i]));
    }

    ll sum = 0;
    priority_queue<P, vector<P>, greater<P>> used;
    for (int i = 0; i < K; i++) {
        P p = que.top();
        que.pop();
        sum += p.first;
        if (s.count(p.second) == 1) { used.push(p); }
        s.insert(p.second);
    }
    ll ans = sum + ((ll)s.size() * (ll)s.size());

    while (!que.empty() && !used.empty()) {
        P p = que.top();
        que.pop();
        if (s.count(p.second)) {
            continue;
        } else {
            P q = used.top();
            used.pop();
            sum = sum - q.first + p.first;
            s.insert(p.second);
            chmax(ans, sum + ((ll)s.size() * (ll)s.size()));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7280
x1, y1, x2, y2 = map(int, input().split())

dx1, dy1 = x1-x2, y1-y2
x3 = dy1 + x2
y3 = -dx1 + y2

dx2, dy2 = x2-x1, y2-y1
x4 = -dy2 + x1
y4 = dx2 + y1

print(x3, y3, x4, y4)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int sum[2][114];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a[2][114];
	cin>>n;
	REP(i, 2){
		REP(j, n){
			cin>>a[i][j];
			sum[i][j+1]=sum[i][j]+a[i][j];
		}
	}
	int ans=0;
	REP(i, n){
		ans=max(ans, sum[0][i+1]+sum[1][n]-sum[1][i]);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
E=[]
for i in range(M):
  a,b=map(int,input().split())
  E.append((a-1,b-1))
Q=int(input())
dp=[[-1]*11 for i in range(N)]
C=[]
for i in range(Q):
  v,d,c=map(int,input().split())
  dp[v-1][d]=i
  C.append(c)
for d in range(1,11)[::-1]:
  for n in range(N):
    dp[n][d-1]=max(dp[n][d],dp[n][d-1])
  for a,b in E:
    dp[a][d-1]=max(dp[a][d-1],dp[b][d])
    dp[b][d-1]=max(dp[b][d-1],dp[a][d])
for i in range(N):
  if dp[i][0]>=0:
    print(C[dp[i][0]])
  else:
    print(0)


Measured memory_bytes: 91224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=30000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	#ifdef LOCAL
		freopen("B.txt","r",stdin);
	#endif
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
int a[100003],b[100003];
int main(){
	init();
	int n=readint();
	for(int i=1;i<=n;i++)
		a[i]=readint();
	sort(a+1,a+n+1);
	int cnt=0,mmax=0,secmax=0;
	long long ans=0;
	for(int i=n;i;i--){
		if (a[i]!=a[i+1]){
			if (cnt>=2){
				if (!mmax)
					mmax=a[i+1];
				else if (!secmax)
					secmax=a[i+1];
			}
			if (cnt>=4)
				ans=max(ans,1LL*a[i+1]*a[i+1]);
			cnt=0;
		}
		cnt++;
	}
	if (cnt>=2){
		if (!mmax)
			mmax=a[1];
		else if (!secmax)
			secmax=a[1];
	}
	if (cnt>=4)
		ans=max(ans,1LL*a[1]*a[1]);
	cnt=0;
	printf("%lld",max(1LL*mmax*secmax,ans));
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	char ch;
	int i , x , y , total[26]={0};
	while( cin >> ch ){
		if( isupper(ch) )
			ch = tolower(ch);
		x = ch - 'a';
		total[x] ++;
	}
	for( i=97 ; i<=122 ; i++ ){
		printf("%c : %d\n" , i , total[i-97] );
	}
}

Measured memory_bytes: 3220
S = input()
result = 0
for i in range(len(S)):
    for j in range(1, len(S) - i + 1):
        flg = True
        for c in tuple(S[i:i + j]):
            if not (c == 'A' or c == 'C' or c == 'G' or c == 'T'):
                flg = False
            if not flg:
                break
        if flg:
            if result < len(S[i:i + j]):
                result = len(S[i:i + j])
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define print(x) cout<<(x)<<'\n'
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;

void solve() {
    vs strs(3);
    rng(i,0,3){
        cin >> strs[i];
    }
    vl idx(3, 0);
    ll turn = 0;
    while(idx[turn] != strs[turn].size()){
        ll i = idx[turn];
        idx[turn]++;
        turn = strs[turn][i] - 'a';
    }
    print((char)(turn+'A'));
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3576
N = int(input())
X = [0]*N
X = list(map(int, input().split()))
Y = X[:]
hoge = 0

X.sort()
for i in range(N):
    if Y[i]<X[int(N/2)]:
        print(X[int(N/2)])
    else:
        print(X[int(N/2)-1])



Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int in;
    bool s=true;
    vector<vector<int>> tl(3,vector<int>(3,0));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>in;
            tl[i][j]=in;
        }
    }
    if(!((tl[1][0]-tl[0][0]==tl[1][1]-tl[0][1])&&(tl[1][2]-tl[0][2]==tl[1][1]-tl[0][1])))s=false;
    if(!((tl[2][0]-tl[1][0]==tl[2][1]-tl[1][1])&&(tl[2][2]-tl[1][2]==tl[2][1]-tl[1][1])))s=false;
    if(!((tl[0][1]-tl[0][0]==tl[1][1]-tl[1][0])&&(tl[2][1]-tl[2][0]==tl[1][1]-tl[1][0])))s=false;
    if(!((tl[0][2]-tl[0][1]==tl[1][2]-tl[1][1])&&(tl[2][2]-tl[2][1]==tl[1][2]-tl[1][1])))s=false;
    cout<<(s?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            
           if(op.equals("?")){
               break;
           }


            
            int x = 0;
            
            switch(op){
            case "+":
                x = a + b;
                break;
            case "-":
                x = a - b;
                break;
            case "*":
                x = a * b;
                break;
            case "/":
                x = a / b;
                break;
            }
            
            System.out.println(x);
            
        }   
        
    }
}


Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;
  
int n;
string s;

map<char, int> m;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> s;
    
    for (auto& i : s) {
        m[i]++;
    }

    ll ans = 1;
    for (auto& i : m) {
        ans = modMul(ans, i.second + 1);
    }
    ans--;
    cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 55;

int n;
long double a[N];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    long double ans = (a[1] + a[2]) / 2;
    for (int i = 3; i <= n; ++i)
        ans = (ans + a[i]) / 2;
    cout << ans << endl;
    return 0;
}


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

int M = 10000001;


int main()
{
	int n; cin >> n;
	vector<int> a(n);
	map<int, int> mp;
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
		sum += a[i];
	}
	int q; cin >> q;
	vector<pair<int, int>> pp(q);
	rep(i, q) cin >> pp[i].first >> pp[i].second;
	rep(i, q) {
		mp[pp[i].second] += mp[pp[i].first];
		sum += (pp[i].second - pp[i].first) * mp[pp[i].first];
		mp[pp[i].first] = 0;
		cout << sum << endl;
	}
	

}

Measured memory_bytes: 8764
#include<cstdio>

const int p = 998244353;
const int K_MAX = 2000;
const int N_MAX = 2000;

long long fact[K_MAX+N_MAX+1];
long long ans[(K_MAX+1)/2+1];

long long inv(long long x) {
	long long r0 = x, r1 = p;
	long long a0 = 1, a1 = 0;
	long long b0 = 0, b1 = 1;
	while(r1 > 0) {
		long long q1 = r0 / r1;
		long long r2 = r0 % r1;
		long long a2 = a0 - q1 * a1;
		long long b2 = b0 - q1 * b1;
		r0 = r1; r1 = r2;
		a0 = a1; a1 = a2;
		b0 = b1; b1 = b2;
	}
	a0 %= p;
	if(a0 < 0) a0 += p;
	return a0;
}

int main() {
	int k, n;
	scanf("%d %d", &k, &n);
	fact[0] = 1;
	for(int i=1;i<=k+n;i++) {
		fact[i] = (i * fact[i-1]) % p;
	}
	for(int i=1;i<=(k+1)/2;i++) {
		ans[i] = 0;
		for(int j=0;j<=i;j++) {
			long long c = (((fact[i] * inv(fact[j])) % p) * inv(fact[i-j])) % p;
			long long h = 0;
			if(2*j <= n) h = (((fact[k+n-2*j-1] * inv(fact[n-2*j])) % p) * inv(fact[k-1])) % p;
			long long ch = (c * h) % p;
			if(j % 2 == 1) ch = (p - ch) % p;
			ans[i] = (ans[i] + ch) % p;
		}
	}
	for(int i=2;i<=2*k;i++) {
		if(i <= k+1) {
			printf("%lld\n", ans[i/2]);
		} else {
			printf("%lld\n", ans[k+1-(i-i/2)]);
		}
	}
	return 0;
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

data = getInputListInt()
data.sort()

print(*data, sep=" ")



Measured memory_bytes: 6880
#include<stdio.h>

int main(void){
  
  int N,H,W;
  int x,y;
  int result = 0;
  
  scanf("%d",&N);
  scanf("%d",&H);
  scanf("%d",&W);
  
  for(x = 0;x <= N - W;x++){
    for(y = 0;y <= N - H;y++){
      result++;
    }
  }
  
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll cnt=0,n,k;
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		ll x,y;
		cin >> x >> y;
		if(x*x+y*y<=k*k)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3604
using System;
class Program
{
    static void Main(string[] args)
    {
        //入力
        string[] input1 = Console.ReadLine().Split(' ');
        string[] input2 = Console.ReadLine().Split(' ');
        int H = int.Parse(input1[0]);
        int W = int.Parse(input1[1]);
        int h = int.Parse(input2[0]);
        int w = int.Parse(input2[1]);
        
        //出力
        Console.WriteLine((H-h)*(W-w));
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

const int INF = 1000000000;
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> dp(10, vector<int>(10, INF));
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, 10)rep(j, 10) cin >> dp[i][j];
  rep(i, h)rep(j, w) cin >> a[i][j];
  rep(i, 10) dp[i][i] = 0;
  
  rep(k, 10)rep(i, 10)rep(j, 10){
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  }
  int ans = 0;
  rep(i, h)rep(j, w){
    if (a[i][j] == -1) continue;
    ans += dp[a[i][j]][1];
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)

	a := make(map[int]bool)
	a[s] = true
	for i := 2; ; i++ {
		if s%2 == 0 {
			s = s / 2
		} else {
			s = 3*s + 1
		}

		if a[s] {
			fmt.Println(i)
			return
		}
		a[s] = true
	}
}


Measured memory_bytes: 512
s = input()
t = input()
max_cover = 0
for i in range(len(s) - len(t) + 1):
    temp_cover = 0
    for j in range(len(t)):
        if s[j + i] == t[j]:
            temp_cover += 1
    max_cover = max(max_cover, temp_cover)
print(len(t) - max_cover)

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
string s, t, B = "~";
bool isOK(string ss,string t)
{//sをi文字目からtと同じ文字数で切り取ったものがssとして届く
 //cout << ss<<":"<<t<<endl;
 rep(i,ss.size())
 { 
   if(ss[i]!='?'&&ss[i]!=t[i])
   {return false;}
 }
 //cout<<"true!"<<endl;
 return true;

}
int main() {
	cin >> s >> t;
	//for (int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
	for (int i = 0; i <= (int)s.size()-(int)t.size(); i++){
		/*string U = s.substr(i, t.size());
		if (isOK(U, t) == true) {*/
		if(isOK(s.substr(i,t.size()),t)){
			string v = s;
			//for (int j = i; j < i + t.size(); j++)v[j] = t[j - i];
			for(int j=0; j<t.size(); j++)
	    	{v[j+i]=t[j];}
	 		rep(j,i)//i(挿入開始地点)まで見る
	 		{if(v[j]=='?')v[j]='a';}
	 		for(int j=i+t.size(); j <s.size();j++)
	 		{if(v[j]=='?')v[j]='a';}
			B = min(B, v);

	  		/*string v=s;
	    	for(int j=0; j<t.size(); j++)
	    	{v[j+i]=t[j];}
	    	//?を置き換え
	 		rep(j,i)//i(挿入開始地点)まで見る
	 		{if(v[j]=='?')v[j]='a';}
	 		for(int j=i+t.size(); j <s.size();j++)
	 		{if(v[j]=='?')v[j]='a';}*/
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int a = 0;
  FOR(i,0,s.length()) {
    if(s[i] == 'A') a++;
  }
  string t = "AKIHABARA";
  int si, ti = 0;
  while(si < s.length() && ti < t.length()) {
    if(s[si] == t[ti]) {
      si++;
      ti++;
    } else if(t[ti] == 'A'){
      ti++;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  if(si == s.length() && s.length() >= 5 + a) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
participants = sorted([ int(v) for v in input().split(" ") ], reverse=True)

# 1 2 4 5 5 5 7 8 9 
# 1 2 5 5 5 8

sum = 0
for i in range(0, N):
  #print(participants)
  #c_max = participants.pop(0)
  #n_max = participants.pop(0)
  #c_min = participants.pop(-1)
  sum += participants[2*i+1]

print(sum)


Measured memory_bytes: 42608
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total = 0
for i in range(len(B)):
    num_of_defeated = min(A[i], B[i])
    A[i] -= num_of_defeated
    total += num_of_defeated

    remainder = B[i] - num_of_defeated
    num_of_defeated = min(A[i + 1], remainder)
    A[i + 1] -= num_of_defeated
    total += num_of_defeated

print(total)


Measured memory_bytes: 19116
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>


using lli = long long int;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int inf = 1000000007;
int N;

int main() {
	cin >> N;
	map<int, int> d;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		d[A]++;
	}
	int ans = 0;
	for (auto e : d)ans += (e.second % 2);
	cout << ans << endl;
}

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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)
#define PI 3.14159265358979323846264338327950L

// -----



int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    if(x != 0)
    {
        ll aux=k;
        k-=abs(x/d);
        ll temp1 = min(abs(x-d*aux), abs(x+d*aux)), temp2=min(abs(x-x/d*d), abs(x+x/d*d));
        x=(k <= 0 ? temp1 : temp2);
    }
    
    if(k%2 == 1)
    {
        if(x > 0) x-=d;
        else x+=d;
    }
    pl(abs(x));
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <ctype.h>
	int main(void){
		char str;

		while(1){
			scanf("%c",&str);
			if(str=='\n') break;
			if(isupper(str)){
				str=tolower(str);
			}else if(islower(str)){
				str=toupper(str);
			}
			printf("%c",str);
		}
		printf("\n");
		return 0;
}

Measured memory_bytes: 524