akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        a: u64, b: u64
    }

    let ret = if a >= 13 {
        b
    } else if a >= 6 {
        b / 2
    } else {
        0
    };
    println!("{}", ret);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void)
{
    int d, t, s;
    scanf("%d%d%d", &d, &t, &s);
    if (t * s >= d)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
n,a,b = map(int,input().split())
ans = 0

for i in range(n+1):
    keta_wa = 0
    x = i
    while x != 0:
        keta_wa += int(x % 10)
        x /= 10
        #print(keta_wa,x)
    
    if a <= keta_wa <= b:
        ans += i 

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 367;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    map<char,int> mp;
    rep(i,n) mp[s[i]]++;
    mint ans = 1;
    for (P p : mp) {
        ans *= p.second+1;
    }
    ans -= 1;
    cout << ans << endl;
}

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

int main(){

	string str;

	cin>>str;

	int maxm = 0, count = 0;
	for(int i=0; i<str.length(); i++){
		if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T'){
			count++;
		}
		else{
			maxm = max(maxm, count);
			count = 0;
		}
	}
	maxm = max(count, maxm);
	cout<<maxm<<"\n";

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
from collections import deque

s = deque(x for x in stdin.readline().rstrip())
q = int(stdin.readline().rstrip())

direction = 1

for i in range(q):
    query = stdin.readline().rstrip().split()
    if len(query) == 1:
        direction *= -1
    else:
        if ((query[1] == '1') and (direction == 1)) or ((query[1] == '2') and (direction == -1)):
            s.appendleft(query[2])
        else:
            s.append(query[2])

sl = list(s)
if direction == 1:
    print(''.join(sl))
else:
    print(''.join(sl[::-1]))

Measured memory_bytes: 10356
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
class UnionFind{
public:
    vector<int> parent;
    UnionFind(int N){
        parent = vector<int> (N,-1);
    }
    int root(int A){
        if(parent[A]<0) return A;
        return parent[A] = root(parent[A]);
    }
    int size(int A){
        return -parent[root(A)];
    }
    bool connect(int A,int B){
        A = root(A);
        B = root(B);
        if(A==B){
            return false;
        }
        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        
        return true;
    }
};
int main(){
    ll N,M;
    cin >> N >> M;
    ll A[M],B[M];
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    vector<ll> ans(M);
    ans[M-1] = N*(N-1)/2;
    UnionFind uf(N);

    for(int i=M-1;i>=1;i--){
        ans[i-1] = ans[i];
        if(uf.root(A[i]) != uf.root(B[i])){
            ans[i-1] -= uf.size(A[i]) * uf.size(B[i]);
            uf.connect(A[i],B[i]);
        }
    }
    for(int i=0;i<M;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4096
/*

Writer: SPD_9X2
https://atcoder.jp/contests/agc030/tasks/agc030_d

Nが小さいな…
→ NC2のすべての組み合わせに関して、反転する場合は何通りあるか数える？
→クエリの数を考えたら無理じゃね？

各クエリを行った場合、全ての場合での反転数の合計はどうなるかをO(N)で求める？
→わりとありそう
→だとしたらdpっぽい

反転数 = それより右にある小さい要素の数とする

反転数をうまくdp式に縮められない…

num[i][j] = A[i] > A[j]となる通り数とする。(i < j なら反転数)

index xとyが交換される場合、全てのv(!=y)に関して

num[y][v] += num[x][v]
num[x][v] += num[y][v]

num[v][x] += num[v][y]
num[v][y] += num[v][x]

num[x][y] += num[y][x]
num[y][x] += num[x][y]

更新は高々4*3000
なので、C++なら可能？

いじらない部分は2倍する操作が必要。
最後にまとめて処理するために、いじった部分は半分にしておく


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

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;
const ll half = 500000004;

int main(){

    ll N,Q;
    cin >> N >> Q;
    vector<ll> A(N,0);

    rep(i,0,N){
        cin >> A[i];
    }

    vector<vector<ll>> lis(N,vector<ll> (N,0));
    rep(i,0,N){
        rep(j,0,N){
            if (A[i] > A[j]) lis[i][j] = 1;
        }
    }

    vector<vector<ll>> q(5*N,vector<ll> (3,0));
    rep(loop,0,Q){

        ll qind = 0;
        ll x,y;
        cin >> x >> y;
        x--;
        y--;

        rep(v,0,N){
            if ((v != x) && (v != y)){
                q[qind++] = {y,v,lis[x][v]};
                q[qind++] = {x,v,lis[y][v]};
                q[qind++] = {v,y,lis[v][x]};
                q[qind++] = {v,x,lis[v][y]}; 
            }
        }

        q[qind++] = {x,y,lis[y][x]};
        q[qind++] = {y,x,lis[x][y]};



        rep(t,0,qind){
            ll i,j,n;
            i = q[t][0];
            j = q[t][1];
            n = q[t][2];

            lis[i][j] += n;
            lis[i][j] *= half;
            lis[i][j] %= mod;
        }
    }

    ll ans = 0;
    rep(j,0,N){
        rep(i,0,j){
            ans += lis[i][j];
            ans %= mod;
        }
    }

    rep(i,0,Q){
        ans *= 2;
        ans %= mod;
    }

    cout << ans << endl;

}


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

LL minima(LL a, LL b)
{
    return (a < b) ? a : b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n, total, i, j, k, temp, sum = 0;
    cin >> n >> total;
    LL weight[n + 1], value[n + 1];

    for (i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
        sum += value[i];
    }

    LL dp[sum + 1][n + 1];
    for (i = 1; i <= sum; i++)
    {
        for (j = 0; j <= n; j++)
        {
            dp[i][j] = 1e16;
        }
    }

    for (j = 0; j <= n; j++)
    {
        dp[0][j] = 0;
    }

    for (i=0;i<=sum;i++)
    {
        for (j=0;j<= n;j++)
        {
            if (dp[i][j] != 1e16)
            {
                for (k=j+1;k<=n;k++)
                {
                    dp[i][k]=minima(dp[i][k],dp[i][j]);
                    if (i+value[k]<=sum)
                    {
                        dp[i+value[k]][k] = minima(dp[i + value[k]][k], dp[i][j] + weight[k]);
                        //cout<<"dp["<<i+value[k]<<"]["<<k<<"] is "<<dp[i+value[k]][k]<<endl;
                    }
                }
            }
        }
    }

    LL ans = -1;

    for (i = sum; i >= 0; i--)
    {
        if (dp[i][n] <= total)
        {
            ans = i;

            break;
        }
    }
    //cout<<dp[17][n]<<endl;
    //cout << dp[ans][n] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 79232
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2

*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  105
#define W 100405
lld dp[N][W];
lld n,wtt;
lld w[N],v[N];
void init()
{
	rep(i,0,N)
	{
		w[i]=0;
		v[i]=0;
		rep(j,0,W)
		{
			dp[i][j]=-1;
		}
	}
}
lld func(lld pos,lld wt)
{
	if(wt<0)
	{
		return -1e14;
	}
	if(pos==n && wt>=0)
	{
		return 0;
	}
	if(dp[pos][wt]!=-1)
	{
		return dp[pos][wt];
	}
	lld ans=0;
	ans=max(ans,v[pos]+func(pos+1,wt-w[pos]));
	ans=max(ans,func(pos+1,wt));
	dp[pos][wt]=ans;
	return dp[pos][wt];
}
inline void solve()
{
	init();
	cin >> n >> wtt;
	rep(i,0,n)
	{
		cin >> w[i] >> v[i];
	}	
	cout << func(0,wtt) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

int main() {
    int x, n;
    cin >> x >> n;
    if(n == 0) {
        cout << x << endl;
        return 0;
    }
    int p[101];
    rep(i,101) p[i] = 0;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        p[tmp] = 1;
    }
    rep(i,105) {
        if(x - i >= 1) {
            if(p[x-i] == 0) {
                cout << x-i << endl;
                break;
            }
        } else {
            cout << 0 << endl;
            break;
        }
        if(x + i <= 100) {
            if(p[x+i] == 0) {
                cout << x+i << endl;
                break;
            }
        } else {
            cout << 101 << endl;
            break;
        }
    }
}

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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    cout << fixed << setprecision(16);

    ll n, m;
    cin >> n >> m;
    vector<ll> v;

    for(ll a=2; a*a<=m; a++) {
        ll t = 0;
        while(m % a == 0)
            m /= a, t++;
        if(t) v.push_back(t);
    }
    if(m > 1) v.push_back(1);

    ll r = 1;

    auto inv = [&](ll x) {
        ll r = 1, b = MOD-2;
        while(b) {
            if(b&1) (r *= x) %= MOD;
            (x *= x) %= MOD;
            b >>= 1;
        }
        return r;
    };

    for(auto &x: v) {
        // x+n-1 C x
        for(ll i=0; i<x; i++)
            (r *= x+n-1-i) %= MOD, (r *= inv(i+1)) %= MOD;
    }
    cout << r << endl;

}


Measured memory_bytes: 256
def f(a, b, c):
    from itertools import product
    return sum(i + j in a for i, j in product(b, c))


def solve(string):
    n, s = string.split()
    r, g, b, r2, g2, b2 = [], [], [], set([]), set([]), set([])
    for i, _s in enumerate(s):
        if _s == "R":
            r.append(i)
            r2.add(2 * i)
        if _s == "G":
            g.append(i)
            g2.add(2 * i)
        if _s == "B":
            b.append(i)
            b2.add(2 * i)
    return str(len(r) * len(g) * len(b) - f(r2, g, b) - f(g2, b, r) - f(b2, r, g))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    string S, T;
    cin >> S >> T;

    ll ans = 0;
    for(i = 0; i < S.length(); i++) {
        if(S[i] != T[i]) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    string S, T;
    cin >> S >> T;
    bool res = false;
    rep0(slide, S.length())
    {
        bool tmpRes = true;
        for (int pos = slide; pos < slide + S.length(); pos++)
        {

            if (S[pos % S.length()] != T[(pos - slide) % S.length()])
            {
                tmpRes = false;
                break;
            }
        }
        if (tmpRes)
        {
            res = true;
        }
    }
    if (res)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            cout<<n*n*n<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
bool BSearch(int A[] ,unsigned int sp ,unsigned int ep ,int n){ //あり、なしのみboolで返す
  int mid = (ep+sp) / 2;
  int l = sp;
  int r = ep;
  while(l <= r){
    mid = (l + r) / 2;
    if(A[mid] == n){
      return 1;
    }
    else if(A[mid] < n){
      l = mid + 1;
    }
    else{
      r = mid - 1;
    }
  }
  return 0;
}
 
int main(void){
  int n,q;
  int counter = 0;
  int S[100000];
  int T[50000];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> T[i];
  }
 
 
  for(int i=0;i<q;i++){
    if(BSearch(S,0,n,T[i])){
      counter++;
    } else {
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000000000000
int h,w,k,ans[305][305],m[305][305],s=1;
bool ex[305];
int main(void){
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char c;
			scanf(" %c",&c);
			if(c=='#')m[i][j]=1;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(m[i][j]==1){
				if(ex[i])s++;
				ex[i]=true;
			}
			ans[i][j]=s;
		}
		if(ex[i])s++;
	}
	for(int i=1;i<h;i++){
		if(ex[i])continue;
		if(!ex[i-1])continue;
		ex[i]=true;
		for(int j=0;j<w;j++){
			ans[i][j]=ans[i-1][j];
		}
	}
	for(int i=h-2;i>=0;i--){
		if(ex[i])continue;
		if(!ex[i+1])continue;
		ex[i]=true;
		for(int j=0;j<w;j++){
			ans[i][j]=ans[i+1][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<ans[i][j];
			if(j==w-1)cout<<endl;
			else cout<<' ';
		}
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string a, b;
    cin >> a >> b;
    if (len(a) > len(b)) {
        cout << "GREATER" << endl;
    }
    else if (len(a) == len(b)) {
        if (a == b) cout << "EQUAL" << endl;
        else if (a > b) cout << "GREATER" << endl;
        else cout << "LESS" << endl;
    }
    else {
        cout << "LESS" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n, z, w;
    cin >> n >> z >> w;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    // xさん結局最後2枚のどっちかになる
    if (n == 1) cout << abs(a[0] - w) << endl;
    else cout << max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << endl;
}




Measured memory_bytes: 256
h, w, n = gets.chomp.split.map(&:to_i)


# areas = Hash.new(0)

areas = Hash.new{|h, k| h[k] = Hash.new(0)}

result = [(h - 2) * (w - 2), 0, 0, 0, 0, 0, 0, 0, 0, 0]

n.times {
  i, j = gets.chomp.split.map(&:to_i)

  for y in (i-2..i) do
    if y < 1 || (h - 2) < y then
      next
    end

    for x in (j-2..j) do
      if x < 1 || (w - 2) < x then
        next
      end

      # result[areas[x.to_s + '_' + y.to_s]] -= 1
      # areas[x.to_s + '_' + y.to_s] += 1
      # result[areas[x.to_s + '_' + y.to_s]] += 1
      result[areas[x][y]] -= 1
      areas[x][y] += 1
      result[areas[x][y]] += 1

    end
  end
}


# areas.each{|key, value|
#   result[0] -= 1
#   result[value] += 1
# }

puts result


Measured memory_bytes: 108156
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
int main() {
	ll a, b,c,d;
	cin >> a >> b >> c >> d;
	ll ans;
	a--;
	ll x = a-((a / c) + (a / d) - a / (c * d / gcd(c, d)));
	ll y = b-((b / c) + (b / d) - b / (c * d / gcd(c, d)));
	ans = y - x;
	cout << ans << endl;
}


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

#define int int64_t
#define MAX 100105

#define INF LONG_LONG_MAX/2

using namespace std;

int N,K;
int input[MAX];
int dp[MAX];

int f(int index) {
    if(index > N) return INF;
    if(index == N) return 0;

    if(dp[index] != -1) return dp[index];

    dp[index] = abs(input[index+1]-input[index])+f(index+1);

    for(int i = 2; i<=K; i++){
        dp[index] = min(dp[index], abs(input[index+i]-input[index])+ f(index+i));
    }

    return dp[index];
}

signed main() {
    scanf("%lld %lld", &N, &K);

    for(int i = 1; i<=N; i++)
    {
        scanf("%lld", &(input[i]));
        dp[i] = -1;
    }

    for(int i = N; i<=N+K+1; i++) dp[i] = -1;

    printf("%lld\n",f(1));
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  ll n;
  cin >> n;
  map<ll,ll> m;
  ll ans =0;
  REP(i,n) {
    ll a;
    cin >> a;
    ans+=a;
    m[a]++;
  }
  ll q;
  cin >> q;
  REP(i,q) {
    ll b,c;
    cin >> b >> c;
    auto itr=m.find(b);
    if(itr!=m.end()) {
      ans+=m[b]*(c-b);
      m[c]+=m[b];
      m.erase(itr);
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 7544
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X = int(readline())
    A = int(readline())
    B = int(readline())
    print((X-A)%B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	cout << ab * bc / 2 << endl;

	return 0;
}

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

int dp[101][10001]; //i番目で、残りの容量がjの時の価値
int n, weight;
int v[101], w[101];

int rec(int i, int j) //i番目で、残りの容量がj
{
	if (dp[i][j] > 0)
	{
		return dp[i][j];
	}

	if (i == n)
	{
		return 0;
	}
	else if (j < w[i]) //次に入れる物の重さが容量を超えている時は「入れない」一択
	{
		dp[i][j] = rec(i + 1, j); //iは次に進み、残り容量はそのまま
	}
	else //入りそうな時は、「入れる」「入れない」を計算して、大きい方を選択
	{
		dp[i][j] = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
		//上のやつと、iは次に進み、残り容量を減らしたものに価値を足したものを比較
	}

	return dp[i][j];
}

int main()
{
	cin >> n >> weight;
	for (int i = 0; i < n; i++)
	{
		cin >> v[i] >> w[i];
	}
	memset(dp, -1, sizeof(dp));

	cout << rec(0, weight) << endl;
	return 0;
}

Measured memory_bytes: 5116
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	k := smaller(intScanner()+1, n)
	f := make([]int, n+1)
	inv := make([]int, n+1)
	f[0], inv[0] = 1, 1
	for i := 1; i < n+1; i++ {
		f[i] = f[i-1] * i % mod
		inv[i] = modinv(f[i], mod)
	}
	ans := 0
	for i := 0; i < k; i++ {
		x := f[n-1] * inv[n-i-1] % mod * inv[i] % mod
		y := f[n] * inv[i] % mod * inv[n-i] % mod
		ans += x * y % mod
		ans %= mod
	}
	fmt.Println(ans)
}
func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for {
		t := a / b
		a -= t * b
		u -= t * v
		a, b, u, v = b, a, v, u
		if b == 0 {
			break
		}
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}


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

int main()
{
	unsigned int a, b, c, x,ret;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;
	
	ret = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (x == 500 * i + 100 * j + 50 * k) {
					ret++;
				}
			}
		}
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100010];
int main()
{
int N;
cin>>N;
int num;
for(int i=1;i<=N;i++)
	{cin>>num;
	a[num]=i;}
for(int i=1;i<=N;i++)
	cout<<a[i]<<" ";
	cout<<endl;

} 

Measured memory_bytes: 1152
import java.util.*;

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

	double x = 0.0;
	double y = 0.0;
	double angle = 0.0;

	while(sc.hasNext()){
	    String[] line = (sc.next()).split(",");
	    int step = Integer.parseInt(line[0]);
	    int dir = Integer.parseInt(line[1]);
	    if(step==0 && dir==0)break;
	    x += (double)step * Math.sin(Math.toRadians(angle));
	    y += (double)step * Math.cos(Math.toRadians(angle));
	    angle += (double)dir;
	}

	System.out.println((int)x);
	System.out.println((int)y);
    }
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
int n,f[100010],x[100010];
vector<int> a[100010];
inline void dfs(int i)
{
    int j,k=0;
    for(j=0;j<a[i].size();j++)
      dfs(a[i][j]);
    for(j=0;j<a[i].size();j++)
      x[++k]=f[a[i][j]];
    if(k)
      {
       sort(x+1,x+k+1);
       for(j=1;j<=k;j++)
         f[i]=max(f[i],x[k+1-j]+j);
      }
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	scanf("%d",&n);
	for(i=2;i<=n;i++)
	  {
       scanf("%d",&j);
       a[j].push_back(i);
      }
    dfs(1);
    printf("%d\n",f[1]);
	return 0;
}


Measured memory_bytes: 10496
_ = input()
nums = [int(x) for x in input().split(" ")]
res = 0
sums = []
for n in nums[1:][::-1]:
    if sums:
        sums.append(sums[-1]+n)
    else:
        sums.append(n)
sums.reverse()
#print(sums)
for i, ni in enumerate(nums[:-1]):
    res += ni*sums[i]
    res %= 10**9 + 7
print(res)

Measured memory_bytes: 31432
/*** ?????\ ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	int N;
	while(cin>>N, N){
		int len[41]={};
		REP(i, 0, N){
			string s;
			cin >> s;
			len[i]=s.size();
		}
		
		REP(i, 0, N){
			int num=0;
			int haiku[5]={5, 7, 5, 7, 7};
			bool flag=false;
			
			REP(j, i, N){
				haiku[num]-=len[j];
				if(haiku[num]<0) break;
				if(haiku[num]==0) num++;
				if(num==5){
					flag=true;
					break;
				}
			}
			
			if(flag){
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int k;
  unordered_map<int, int> mp;
  mp[1] = 0;
  cin >> n >> k;
  vector<int> v(n+1);
  for(int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  int cur = 1;
  int stp = 0;
  while(mp.find(v[cur]) == mp.end()){
  	stp++;
  	cur = v[cur];
  	mp[cur] = stp;
  }
  int x = mp[v[cur]];
  int l = stp+1-x;
  if(k >= x) {
	k -= x;
	k %= l;
	k += x;
  }
  cur = 1;
  while(k--) {
  	cur = v[cur];
  }
  cout << cur << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb(a)            push_back(a)
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;


int main()
{
    ll n,x;
    cin>>n>>x;
    ll l[n];
    for(ll i=0;i<n;i++)
    {
        cin>>l[i];
    }
    map<ll,ll>mp;
    mp[0]=1;
    ll cur=0;
    ll ans=1;
    for(ll i=0;i<n;i++)
    {
        cur+=l[i];
        mp[cur]++;
        if(cur<=x)
        ans=i+2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from decimal import Decimal

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
EPS = 10 ** -14

a, b, c = MAP()

if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    Yes()
else:
    No()


Measured memory_bytes: 5032
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 2005;
const int maxm = 1e6 + 5;
const int maxk = 1e4 + 5;
const int sigma = 65;

int n, k, tot = 0;
int beg[maxn], l[maxn];
int dp[maxn][maxk];
char str[maxm], ans[maxk];
char s[maxn][maxk];
bitset<maxm> segt[sigma];

int query(bitset<maxm> cur){
	int u;
	for(u = 1; u < 32; ){
		if(!(cur & segt[u << 1]).none()) u <<= 1;
		else (u <<= 1) += 1;
	}
	return u - 32;
}

int main(){
	scanf("%d%d", &n, &k);
	FOR(i, 0, n){
		scanf("%s", s[i]);
		l[i] = strlen(s[i]);
	}
	dp[n][0] = 1;
	for(int i = n - 1; i >= 0; --i) FOR(j, 0, k){
		dp[i][j] |= dp[i + 1][j];
		if(l[i] <= j) dp[i][j] |= dp[i + 1][j - l[i]];
	}
	//puts("ok");
	FOR(i, 0, n){
		beg[i] = tot;
		FOR(j, 0, l[i]){
			segt[s[i][j] - 'a' + 32].set(tot);
			str[tot++] = s[i][j];
		}
		//printf("%d\n", beg[i]);
	}
	beg[n] = tot;
	for(int i = 31; i; --i) segt[i] = segt[i << 1] | segt[i << 1 | 1];
	bitset<maxm> cur;
	cur.set(0);
	//puts("ok");
	FOR(i, 0, k){
		FOR(j, 0, n) if(cur[beg[j]]) cur.set(beg[j + 1]);
		FOR(j, 0, n) if(l[j] > k - i || !dp[j + 1][k - i - l[j]]) cur.reset(beg[j]);
		int nxt = query(cur);
		//printf("nxt = %d\n", nxt);
		cur &= segt[nxt + 32];
		cur <<= 1;
		ans[i] = nxt + 'a';
	}
	puts(ans);
	return 0;
}



Measured memory_bytes: 107392
A, B, C = map(int, input().split())

l = [5, 5, 7]

def main(A=A, B=B, C=C):
    if A in l:
        l.remove(A)
        if B in l:
            l.remove(B)
            if C in l:
                return 'YES'
    return 'NO'

if __name__ == '__main__':
    result = main()
    print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main() {
  int a, b;
  cin >> a >> b;
  rep (i, max(a, b)) cout << min(a, b);
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){

	string s;
	cin>>s;

	if(s=="AAA" || s=="BBB")cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

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

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;
	if (N == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	vector<ll> ans{2, 4, 3, 9};
	N -= 4;
	for (ll i = 4;(i + 1) * 2 <= 30000 && N >= 2;i+=3) {
		N -= 2;
		ans.push_back(2 * i);
		ans.push_back(2 * (i + 1));
	}
	for (ll i = 5;(i + 2) * 3 <= 30000 && N >= 2; i += 4) {
		N -= 2;
		ans.push_back(3 * i);
		ans.push_back(3 * (i + 2));
	}
	ll i = 1;
	while (N > 0) {
		ans.push_back(i * 6);
		i++;
		N--;
	}
	for (int i = 0;i < ans.size();i++) {
		cout << ans[i];
		if (i == (ll)ans.size() - 1)
			cout << endl;
		else
			cout << " ";
	}
	return 0;
}


Measured memory_bytes: 1272
#include<iostream>

int main(void){
    char letter,ch;
    int count[26]={};
    while(std::cin>>letter){
         if(std::isalpha(letter)){
              ++count[std::tolower(letter)-'a'];
         }
    }
    for(int i=0;i<26;i++){
        ch='a'+i;
        std::cout<<ch<<" : "<<count[i]<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		bool f=0;
		for(int i=0;i<3;++i)
			if(s[i]=='7')	f=1;
			if(f) puts("Yes");
			else puts("No");
	}
	return 0;
}

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

int main() {
  
  string S;
  cin >> S;
  
  if ((S.at(0) == S.at(1)) && (S.at(1) == S.at(2))){
    cout << "No" << endl;
  }
  
  else{
    cout << "Yes" << endl;
  }
}

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

int main(){
    string s;
    cin>>s;
    int i=0,m,mm;
    while(i<s.size()){
        if(s.at(i)=='A'){ m=i;
        break;}
        i++;
        }
    i=s.size()-1;
    while(i>0){
        if(s.at(i)=='Z'){ mm=i;
        break;}
        i--;
        }
    cout<<mm-m+1<<endl;
    }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    deque<Int> ans;
    Int q; cin>>q;
    for(Int i=1; i<=q; i++ ){
        string a,b,c;
        cin>>a>>b;
        if(a=="0"){
            cin>>c;
            Int x=stoll(c);
            if(b=="0"){
                ans.push_front(x);
            }
            else{
                ans.push_back(x);
            }
        }
        else if(a=="1"){
            Int p=stoll(b);
            cout<<ans[p]<<endl;
        }
        else{
            if(b=="0"){
                ans.pop_front();
            }
            else{
                ans.pop_back();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN
 
    ll n;cin>>n;
    vll a(n), b(n), c(n);
    REP(i,n) cin>>a[i];
    REP(i,n) cin>>b[i];
    REP(i,n) cin>>c[i];
    VSORT(a);
    VSORT(b);
    VSORT(c);
    ll ans =0;
    REP(i,n){
        ll na = lower_bound(ALL(a),b[i]) - a.begin();
        ll nb = c.end() - upper_bound(ALL(c), b[i]);
        // cout<<na<<' '<<nb<<endl;
        ans += na*nb;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;
#define F first

#define S second

void solve()
{
	string str;
	cin>>str;
	vector<ll> dp(26,0);
	for(int i=0;i<str.size();i++)
	{
		dp[str[i]-'A']+=1;
	}
	ll fg=0;
	for(int i=0;i<26;i++)
	{
		if(dp[i]==2)
			fg+=1;
	}
	if(fg==2)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	
	return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int n;
  vector<ll int> a,b;
  cin >> n;
  REP(i,n){
	int aa, bb;
	cin >> aa >> bb;
	a.pb(aa); b.pb(bb);
  }
  ll int ans = 0;
  for(int i = n-1; i > -1; i--){
	ll int to = (a[i] / b[i]) * b[i];
	if(to < a[i]) to += b[i];
	ll int kai = to - a[i]; // 3
	//	cout << a[i] << b[i] << kai << endl;
	if(ans <= kai){
	  ans = kai;
	  continue;
	}else{
	  ll int tmp = b[i] * (ans / b[i]) + kai;
	  if(tmp < ans) tmp += b[i];
	  ans = tmp;
	  continue;
	}
	
  }
  cout << ans << endl;
}


Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iL = int.Parse(sS[0]);
            int iR = int.Parse(sS[1]);
            int iD = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析 
            int iOut = 0;
            int iMin = iL / iD;
            int iMax = iR / iD;
            for (int j = iMin; j <= iMax; j++)
            {
                if (iL <= iD * j && iD * j <= iR) { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27448
#include <stdio.h>
#define LL long long
int main(){
	LL n,a,b,ans=0;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a==0)printf("0\n");
	else{
		ans+=n/(a+b)*a;
		if(n%(a+b)>=a)ans+=a;
		else ans+=n%(a+b);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
def f(x):
  if x%2==0:
    return x//2
  else:
    return 3*x+1

s = int(input())
old = s
count=1
history={s}
while 1:
  new = f(old)
  count += 1
  if new in history:
    break
  history.add(new)
  old = new

print(count)

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

int main() {
    string s;
    cin >> s;
    bool ans = false;
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
        ans = true;
    if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
        ans = true;
    if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1])
        ans = true;
    if(ans)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

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

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 1e5 + 5;
 
int n;
int m;
int a[maxn];


void exec()
{
    read(n);
    read(m);
    for (int i = 1; i <= n; ++ i) read(a[i]);
    long long ret = 0;
    if (a[1] > m) ret += a[1] - m, a[1] = m;
    for (int i = 2; i <= n; ++ i) {
        if (a[i - 1] + a[i] > m) ret += a[i - 1] + a[i] - m, a[i] = m - a[i - 1];
    }
    write(ret);
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

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

	int a[14],b[14],c[14],d[14];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	memset(c,0,sizeof(c));
	memset(d,0,sizeof(d));
	rep(i,n)
	{
		char ch;
		int t;
		cin >> ch >> t;

		if(ch == 'S') a[t]++;
		else if(ch == 'H') b[t]++;
		else if(ch == 'C') c[t]++;
		else if(ch == 'D') d[t]++;
	}

	REP(i,1,14)
	{
		if(a[i] == 0)
		{
			cout << "S " << i << endl;
		}
	}

	REP(i,1,14)
	{
		if(b[i] == 0)
		{
			cout << "H " << i << endl;
		}
	}

	REP(i,1,14)
	{
		if(c[i] == 0)
		{
			cout << "C " << i << endl; 
		}
	}
	
	REP(i,1,14)
	{
		if(d[i] == 0)
		{
			cout << "D " << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160