akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    int a,b;
    cin>>a>>b;
    bool ok=0;
    int ans=100000;
    for(int i=1;i<=10000;i++){
        double aa,bb;
        aa=(double)i*0.08;
        bb=(double)i*1.1;
        int s,t;
        s=(int)i*0.08;
        t=(int)i*0.1;
        if(s==a&&t==b){
            ok=1;
            chmin(ans,i);
        }
    }
    if(ok) cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
/**
 *      ABC 61 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 02:09:43
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;
    (C >= A && C <= B) ? cout << "Yes" : cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define ll long long
typedef pair<int,int> pii;
string s,rez,glob,cs[3];
int n,k,br;
vector<pii>candidates;
void do1(){

    string p=s+s;
    reverse(p.begin()+s.size(),p.end());

    for(int i=0;i<=s.size();i++){
        rez=min(rez,p.substr(i,n));
    }
}
void do13(){

    char minel='z';
    for(int i=0;i<n;i++)minel=min(minel,s[i]);
    for(int i=0;i<n;i++)rez[i]=minel;
}
void radi(pii x,int pcnt){

    int sz=x.ss;

    for(int j=1+pcnt;j<=k;j++){


        string p=glob+glob;
        reverse(p.begin()+s.size(),p.end());

        if(j!=k){
            int pos=n-1+sz;
            if(pos>=(int)p.size())break;

            glob=p.substr(pos-n+1,n);

            sz*=2;
        }
        else{
            if(n-1-sz+1<0)break;
            glob=p.substr(n-1-sz+1,n);
        }
    }
}
void go(){

    char minel='z';
    for(int i=0;i<n;i++)minel=min(minel,s[i]);

    if(s[n-1]==minel){
        int sz=1;
        while(n-sz-1>=0 && s[n-sz-1]==minel)sz++;
        candidates.pb({n-1,sz});

        cs[br++]=s;
    }

    string p=s+s;
    string prez="";
    for(int i=0;i<n;i++)prez.pb('z'+1);
    reverse(p.begin()+s.size(),p.end());
    for(int i=s.size()-1;i<p.size();i++){
        string bla=p.substr(i-n+1,n);
        reverse(bla.begin(),bla.end());

        prez=min(prez,bla);
    }
    reverse(prez.begin(),prez.end());

    int sz=1;
    cs[br++]=prez;
    while(n-sz-1>=0 && prez[n-sz-1]==minel)sz++;
    candidates.pb({n-2,sz});


    for(int i=0;i<candidates.size();i++){

        glob=cs[i];

        if(candidates[i].ff==n-1){
            radi(candidates[i],0);
        }
        else{
            radi(candidates[i],1);
        }
        rez=min(rez,glob);
    }
}
int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d %d",&n,&k);
    cin>>s;

    for(int i=1;i<=n;i++)rez.pb('z'+1);

    if(k==1)do1();
    else if(k>=13)do13();
    else go();

    cout<<rez<<endl;

	return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B; cin>>A>>B;
	bool ans = true;
	if(A>8) ans = false;
	if(B>8) ans = false;
	ote(ans?"Yay!":":(");
}


Measured memory_bytes: 256
import itertools
import sys
import math
input = sys.stdin.readline

N = int(input())
x = []
y = []

for i in range(N):
    p, q = map(int, input().split())
    x.append(p)
    y.append(q)

ans = 0
j = 0
num_old = 0

lis = [x for x in range(N)] # 0からn-1までのリスト
permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成
# 以下出力
for one_case in permutations_lis:
    i = 0
    j += 1
    for num in one_case:
#        print(num, end=" ")
        if i != 0:
            ans += math.sqrt((x[int(num_old)]-x[int(num)])**2+(y[int(num_old)]-y[int(num)])**2)
#            print(ans)
        i += 1
        num_old = num
#    print("")

#print (j)
ans = ans / j
print (ans)


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

int main(){

	// std::vector<int> a = 
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 
						5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15,
						 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	std::cin >>k;
	std::cout << a[k-1] <<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    VI c(3);
    string s;
    cin >> s;
    int len = s.size();
    REP(i,0,s.size()) {
        c[s[i] - 'a']++;
    }
    sort(all(c));
    reverse(all(c));
    if (len == 1) {
        cout << "YES" << endl;
        return;
    }
    if (c[0] - 1 >= len / 2) {
        cout << "NO" << endl;
        return;
    }
    if (c[0] > (len + 2 / 3)) {
        cout << "NO" << endl;
        return;
    }
    if (c[0] - 1 > c[2]) {
        cout << "NO" << endl;
        return;
    }
    cout << "YES" << endl;
    
}

int main() {
    resolve();
    
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 200000;
const int MAXA = 100000;
const int MAXB = 100000;

int n, ma, mb;
int ahead[MAXN], anxt[2 * MAXA], ato[2 * MAXA];
int bhead[MAXN], bnxt[2 * MAXB], bto[2 * MAXB];

int par[MAXN], rnk[MAXN];
int find(int p) { if (par[p] == p) return p; return par[p] = find(par[p]); }
void unite(int p, int q) {
	p = find(p), q = find(q);
	if (p == q) return;
	if (rnk[q] > rnk[p]) swap(p, q);
	par[q] = p; if (rnk[p] == rnk[q]) ++rnk[p];
}

bool done[MAXN];
int q[MAXN], qhead, qtail;
int cnt[MAXN], mark[MAXN], curmark;
int ret[MAXN];

void run() {
	scanf("%d%d%d", &n, &ma, &mb);
	REP(i, n) ahead[i] = bhead[i]= -1;
	REP(i, ma) {
		int a, b; scanf("%d%d", &a, &b); --a, --b;
		anxt[2 * i + 0] = ahead[a]; ahead[a] = 2 * i + 0; ato[2 * i + 0] = b;
		anxt[2 * i + 1] = ahead[b]; ahead[b] = 2 * i + 1; ato[2 * i + 1] = a;
	}
	REP(i, mb) {
		int a, b; scanf("%d%d", &a, &b); --a, --b;
		bnxt[2 * i + 0] = bhead[a]; bhead[a] = 2 * i + 0; bto[2 * i + 0] = b;
		bnxt[2 * i + 1] = bhead[b]; bhead[b] = 2 * i + 1; bto[2 * i + 1] = a;
	}
	REP(i, n) par[i] = i, rnk[i] = 0;
	REP(i, ma) {
		int p = ato[2 * i + 1], q = ato[2 * i + 0];
		unite(p, q);
	}
	REP(i, n) done[i] = false, mark[i] = -1; curmark = -1;
	REP(s, n) if (!done[s]) {
		//printf("start at %d\n", s);
		qhead = qtail = 0; ++curmark; q[qhead++] = s; done[s] = true;
		while (qtail < qhead) {
			int at = q[qtail++];
			for (int x = bhead[at]; x != -1; x = bnxt[x]) {
				int to = bto[x];
				if (!done[to]) q[qhead++] = to, done[to] = true;
			}
		}
		int nq = qhead;
		REP(i, nq) {
			int at = q[i], x = find(at);
			if (mark[x] != curmark) mark[x] = curmark, cnt[x] = 0;
			++cnt[x];
		}
		REP(i, nq) {
			int at = q[i], x = find(at);
			//printf("\t%d = %d (%d)\n", at, cnt[x], x);
			ret[at] = cnt[x];
		}
	}
	REP(i, n) { if (i != 0) printf(" "); printf("%d", ret[i]); } puts("");
}


int main() {
	run();
	return 0;
}


Measured memory_bytes: 9856
<?php
    $arr = explode(" ", trim(fgets(STDIN)));
    $g = array(4,6,9,11);
    $chk = array(0,0);
    for($i=0;$i<2;$i++){
        if($arr[$i] == 2){
            $chk[$i] = 2;
            continue;
        }else{
            foreach($g as $val){
                if($val == $arr[$i]){
                    $chk[$i] = 1;
                    break;
                }
            }
        }
    }
    if($chk[0] == $chk[1]) echo "Yes";
    else echo "No";

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

const LLI INF = 1LL << 60;

vector<vector<int>> tree;
vector<LLI> a;
LLI dp[5100][5100][2];
LLI dp2[5100][2];

int subtree[5100];

void rec(int cur, int par){
  for(auto &e : tree[cur]){
    if(e == par) continue;
    rec(e,cur);
  }

  subtree[cur] = 1;
  
  fill_array(dp2, INF);

  dp[cur][0][a[cur] < 0] = a[cur];

  for(auto &e : tree[cur]){
    if(e == par) continue;

    REP(n1,subtree[cur]){
      REP(n2,subtree[e]){
        REP(k1,2){
          REP(k2,2){
            chmin(dp2[n1+n2][k1|k2], dp[cur][n1][k1]+dp[e][n2][k2]);

            if((k2 == 0 and dp[e][n2][k2] < INF) or (k2 == 1 and dp[e][n2][k2] < 0)){
              chmin(dp2[n1+n2+1][k1], dp[cur][n1][k1]);
            }
          }
        }
      }
    }

    subtree[cur] += subtree[e];

    REP(i,subtree[cur]){
      REP(j,2){
        dp[cur][i][j] = dp2[i][j];
        dp2[i][j] = INF;
      }
    }
  }
}


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

  int n;
  while(cin >> n){
    a = vector<LLI>(n); cin >> a;

    tree = vector<vector<int>>(n);
    REP(i,n-1){
      int u, v; cin >> u >> v;
      --u, --v;
      tree[u].push_back(v);
      tree[v].push_back(u);
    }

    fill_array(dp, INF);
    fill_array(subtree, 0);

    rec(0,-1);

    int ans = INT_MAX;

    REP(i,n){
      if(dp[0][i][0] < INF or dp[0][i][1] < 0) chmin(ans, i);
    }

    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 407680
def func(n, t, q, s):
    matchN = 0
    for x in s:
        left = 0
        right = n
        while left < right:
            mid = int((left + right) / 2)
            if x == t[mid]:
                matchN += 1
                break
            elif x < t[mid]:
                right = mid
            else:
                left = mid + 1
    return matchN

n = int(input())
t = list(map(int, input().split(" ")))
q = int(input())
s = list(map(int, input().split(" ")))
print (func(n, t, q, s))


Measured memory_bytes: 16708
n = gets.chomp.to_i
ary = gets.chomp.split(" ").map(&:to_i)

res  = []
size = ary.size - 1

ary.each_with_index do |v, k|
  if k == size
    break
  end
  t = ary.slice(0..k).inject(:+)
  t2 = ary.slice(k+1..size).inject(:+)

  if t > t2
    res << t - t2
  else
    res << t2 - t
  end
end
puts res.min



Measured memory_bytes: 3836
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }


int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    map<string,int>mp;
    int n;cin>>n;
    _for(i,0,n){
        string s;cin>>s;
        ++mp[s];
    }
    cout<<"AC x "<<mp["AC"]<<'\n';
    cout<<"WA x "<<mp["WA"]<<'\n';
    cout<<"TLE x "<<mp["TLE"]<<'\n';
    cout<<"RE x "<<mp["RE"]<<'\n';
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

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


void solve(long long X, long long Y){
    ll ans = 0;
    if(X == 1){
        ans += 300000;
    }else if(X == 2){
        ans += 200000;
    }else if(X == 3){
        ans += 100000;
    }

    if(Y == 1){
        ans += 300000;
    }else if(Y == 2){
        ans += 200000;
    }else if(Y == 3){
        ans += 100000;
    }

    if(X == 1 && Y == 1){
        ans += 400000;
    }

    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>

using namespace std;

#define pb push_back
#define int long long


int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    int i = 0, cnt = 0, ans = 1000;
    while(i + 1 < n){
        while(i + 1 < n && v[i] >= v[i + 1]){
            i++;
        }
        cnt += ans / v[i];
        ans -= ans / v[i] * v[i];
        while(i + 1 < n && v[i] <= v[i + 1]){
            i++;
        }
        ans += v[i] * cnt;
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
s = str(input())
x = len(s)
tmp = 0

if x%2 != 0:
    for i in range((x-1)//2):
        if s[i] != s[x-i-1]:
            tmp += 1

else:
    for i in range(x//2):
        if s[i] != s[x-i-1]:
            tmp += 1

print(tmp)

Measured memory_bytes: 3060
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

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

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define P pair<int,int>
#define V vector<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(x);
    cout<<(x<1200?"ABC":"ARC")<<endl;
    return 0;
}


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

#define INF 1000000000000
#define MOD 1000000007

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    int cntr=0, bcntr=0;
    for(int i=0; i<n; i++){
        if(s[i]=='a'){
            if(cntr<a+b){
                cntr++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(s[i]=='b'){
            if(cntr<a+b && bcntr<b){
                cntr++;
                bcntr++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3780
from collections import Counter as C
n = int(input())
v = list(map(int, input().split()))

#偶数番と奇数番の同じ数字の数
evens = C(v[::2]).most_common()
odds = C(v[1::2]).most_common()
#[('数字', 出現数), ('数字', 出現数)...]

#偶数番と奇数番の数字が違うならそのままans
if evens[0][0] != odds[0][0]:
    ans = n - (evens[0][1] + odds[0][1])
#同じ時は各[0][1]と[1][1]の合計を比べて
# 出現数が多いほうがans
else:
    #oddsの長さが1より大きければ
    # rにevensの1番目の出現数とoddsの2番目の出現数の和を代入
    #  そうでなければevensの1番目の出現数を代入（oddsを全換えするため）
    r = evens[0][1] + odds[1][1] if len(odds) > 1 else evens[0][1]
    s = evens[1][1] + odds[0][1] if len(evens) > 1 else odds[0][1]
    if r > s:
        ans = n - r
    else:
        ans = n - s

print(ans)

Measured memory_bytes: 20700
//
//  main.cpp
//  [Problem B]
//
//  Created by Anson Thai on 11/4/20.
//  Copyright © 2020 Anson Thai. All rights reserved.
//

#include <iostream>
#include <map>
#include <iterator>
#include <algorithm>

int main(int argc, const char * argv[]) {
    
    int n;
    
    std::cin >> n;
    
    int array [n];
    
    for (int i=0; i<n; i++) {
           std::cin >> array[i];
    }
    
    
    int sum = 0;

    std::map<int, int> my_map;
    
    for (int i=0; i<n; i++) {
        
        my_map[array[i]] = 0;
    }

    for (int i=0; i<n; i++) {
        
        my_map[array[i]] += 1;
    }
    
    
    for(auto& x : my_map) {
        if (x.first > x.second) {
            sum += x.second;
        } else if (x.first < x.second) {
            sum += x.second - x.first;
        }
    }
    



    std::cout << sum << std::endl;
   
    return 0;
}


Measured memory_bytes: 5120
M,D=map(int,input().split())
ans=0
for i in range(1,M+1):
    for j in range(1,D+1):
        m=i
        d=j
        s=str(d)
        if len(s)<2:
            continue
        d1=int(s[0])
        d2=int(s[1])
        if d1>1:
            if d2>1:
                if d1*d2==m:
                    ans+=1
print(ans)

Measured memory_bytes: 40176
n = int(input())
ans = 0

import numpy as np

F = [list(map(int, input().split())) for i in range(n)]
P = [list(map(int, input().split())) for i in range(n)]

Cands = [[]]
for i in range(10):
  temp = []
  for cand in Cands:
    temp.append(cand + [0])
    temp.append(cand + [1])
    Cands = temp
Cands = Cands[1:]

max_p = -10000000000
for cand in Cands:
  sum_p = 0
  for i in range(n):
    day_num = np.dot(cand, F[i])
    sum_p += P[i][day_num]
  max_p = max(sum_p, max_p)
print(max_p)

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

int digitSum(int n){
    if(n==0) return 0;
    else return n%10 + digitSum(n/10);
}

int main(){
    int N;  cin >> N;
    int ans = 100;
    for(int i=1; i<=N/2; i++){
        ans = min(digitSum(i) + digitSum(N-i), ans);
    }
    cout << ans << endl;
}


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

 int main() {
 string s, t;
 cin >> s >> t;
 int ans = 0;
 if(s[0] == t[0]) ans++;
 if(s[1] == t[1]) ans++;
 if(s[2] == t[2]) ans++;
 cout << ans << endl;
 return 0;
 }

Measured memory_bytes: 3604
import java.io.*;
import java.util.StringTokenizer;
  
class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
static int ans=0;
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
}
  
private static void swap(int[] a,int s,int t){
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
}
  
private static void SelectionSort(int[] a){
for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
}
}
  
private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
}

Measured memory_bytes: 17052
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;


struct state{
	int id,cost,ac;
};

bool operator < (const state &a,const state &b){
	if(a.ac!=b.ac) return a.ac>b.ac;
	if(a.cost!=b.cost) return a.cost<b.cost;
	return a.id>b.id;
}

int main()
{
	int M,T,P,R;
	while(cin>>M>>T>>P>>R){
		if(M==0) break;
		vector<vector<int> >num_WA(T,vector<int>(P,0));
		vector<int> cost(T,0);
		vector<int> num_AC(T,0);
		rep(i,R){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			t--;
			p--;
			if(j==0){
				cost[t] += m+num_WA[t][p]*20;
				num_AC[t]++;
			}
			else{
				num_WA[t][p]++;
			}
		}
		vector<state> temp;
		rep(i,T){
			state hoge;
			hoge.cost=cost[i];
			hoge.id=i+1;
			hoge.ac=num_AC[i];
			temp.push_back(hoge);
		}
		sort(temp.begin(),temp.end());
		int bef_ac=0,bef_cost=0;
		rep(i,temp.size()){
			if(i!=0){
				if(bef_ac==temp[i].ac && bef_cost==temp[i].cost){
					cout<<"=";
				}
				else cout<<",";
			}
			cout<<temp[i].id;
			bef_ac=temp[i].ac;
			bef_cost=temp[i].cost;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
n,x = gets.split.map(&:to_i)
i_n = n.times.map{ gets.to_i}
counter = 0

total = 0
i_n.each{|n| total += n}
rmd = x - total


mindonut = i_n.min

while rmd >= mindonut
  rmd = rmd - mindonut
  counter += 1
end

puts counter + n

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	cout<<(k!=1?(n-(k)+1)-(1):0)<<endl;
}


Measured memory_bytes: 256
N = int(input())
edge = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    edge[a-1].append((c, b-1))
    edge[b-1].append((c, a-1))
Q, K = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(Q)]

import heapq

def dijkstra_heap(s):
    d = [10**12] * N
    used = [False] * N
    d[s] = 0
    used[s] = True
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        min_edge = heapq.heappop(edgelist)
        if used[min_edge[1]]:
            continue
        v = min_edge[1]
        d[v] = min_edge[0]
        used[v] = True
        for e in edge[v]:
            heapq.heappush(edgelist, (e[0] + d[v], e[1]))
    return d

dist = dijkstra_heap(K-1)
for q in query:
    x, y = q[0], q[1]
    x -= 1
    y -= 1
    print(dist[x] + dist[y])

Measured memory_bytes: 112928
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{$t :tt =>$f :expr } ) =>{$f (read_value !($iter ,$t ) ) } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut $iter =s .split_whitespace () ;input_inner !{$iter ,$($r ) *} } ;($($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
fn main() {
    #[allow(unused_imports)]
    use std::io::Write as _;
    let __out = std::io::stdout();
    #[allow(unused_mut, unused_variables)]
    let mut __out = std::io::BufWriter::new(__out.lock());
    #[allow(unused_macros)]
    macro_rules !print {($($arg :tt ) *) =>(::std ::write !(__out ,$($arg ) *) .unwrap () ) }
    #[allow(unused_macros)]
    macro_rules !println {($($arg :tt ) *) =>(::std ::writeln !(__out ,$($arg ) *) .unwrap () ) }
    #[allow(unused_macros)]
    macro_rules! echo {
        ($iter :expr ) => {
            echo!($iter, "\n")
        };
        ($iter :expr ,$sep :expr ) => {
            let mut iter = $iter;
            if let Some(item) = iter.next() {
                print!("{}", item);
            }
            for item in iter {
                print!("{}{}", $sep, item);
            }
            println!();
        };
    }
    input!(n, a: [usize; n]);
    let mut c = vec![0; 1_001_001];
    for &x in a.iter() {
        c[x] += 1;
    }
    let mut x = vec![true; 1_001_001];
    x[0] = false;
    let mut ans = 0;
    for i in 1..1_000_001 {
        if x[i] && c[i] > 0 {
            if c[i] == 1 {
                ans += c[i];
            }
            for j in (i * 2..1_000_001).step_by(i) {
                x[j] = false;
            }
        }
    }
    println!("{}", ans);
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int bookNum, algNum, algVal;
    cin >> bookNum >> algNum >> algVal;

    vint costs(bookNum);
    Graph<int> books(bookNum, vint(algNum));

    rep(i, bookNum) {
        cin >> costs[i];
        rep(j, algNum) {
            cin >> books[i][j];
        }
    }

    int min = INT_BIG;
    rep(flag, 1<<bookNum) {
        vint algoTmp(algNum, 0);
        int cost = 0;
        rep(j, bookNum) {
            if (flag & 1<<j) {
                cost += costs[j];
                rep(k, algNum) {
                    algoTmp[k] += books[j][k];
                }
            }
        }

        rep(i, algNum) {
            // cout << algoTmp[i] << " ";
            if (algoTmp[i] < algVal) {
                goto OUT;
            }
        }

        min = std::min(min, cost);

        OUT:
        ;
        // cout << endl;
    }
    if (min == INT_BIG) {
        cout << -1 << endl;
    } else {
        cout << min << endl;
    }
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int a[100050],n;
map<int,int> Map;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),Map[a[i]]++;
	int ans = 0;
	for (int i=1;i<=n;i++){
		int x = Map[a[i]];
		if (x >= a[i]){
			ans += x-a[i];
			Map[a[i]] = a[i];
		} else{
			ans += x;
			Map[a[i]] = 0;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5120
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string str;
  cin >> str;
  int ans = 0;
  for (int i = 1; i < str.size(); i++) {
    if (str[i] != str[i - 1]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<long long int> 
#define pb push_back
#define f(i,x,n) for (i=x;i<n;i++)

#define mx 1000000007
ll prod(ll temp,ll x){
    if(temp<x)
    swap(temp,x);
    if(x==0)
    return 0;
    ll y=temp;
    for(ll i=1;i<x;i++){
        temp=(temp+y)%mx;
    }
    return temp;
}
void solve(){
    ll n;
    cin >> n;
    ll a[n];
    ll sum=0;ll ans=0;
    ll pref[n+1];
    pref[0]=0;
    for(ll i=0;i<n;i++){cin >> a[i];
        ans=(ans+(sum*a[i])%mx)%mx;
        sum=(sum+a[i])%mx;
        
    }
    cout << ans << endl;
}
int main(){
	ios_base::sync_with_stdio(false); 
     	cin.tie(NULL);
	int t=1;
	while(t--)
	solve();	
	
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main() { 
    ll n,sum=0;
    priority_queue<ll> q;
    cin>>n;
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    sort(v.begin(),v.end(),std::greater<ll>());
    q.push(v[0]);
    for(ll i=1;i<n;i++) {
        sum+=q.top();
        q.pop();
        q.push(v[i]);
        q.push(v[i]);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6896
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };


int main() {
	ll N;
	cin >> N;
	rep(i, N)cin >> S[i];
	ll Q;
	cin >> Q;
	rep(i,Q) {
		int a;
		cin >> a;
		if (a==0) {
			int b, e;
			cin >> b >> e;
			ll ans = 1000000001;
			for (int j = b; j < e;++j) {
				ans = min(S[j], ans);
			}
			cout << ans << endl;
		}
		else {
			int b, e;
			cin >> b >> e;
			ll ans = -1000000001;
			for (int j = b; j < e; ++j) {
				ans = max(S[j], ans);
			}
			cout << ans << endl;
		}
	}
	return 0;
}





Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,k;
ll bb[2010][2010];
ll sb[2010][2010];
int main(){
	cin>>n>>k;
	REP(i,n){
		int x,y;
		char c;
		cin>>x>>y>>c;
		if(c=='W')y+=k;
		x%=2*k;
		y%=2*k;
		bb[x+1][y+1]++;
	}
	for(int i=1;i<=k*2;i++){
		for(int j=1;j<=k*2;j++){
			sb[i][j]=bb[i][j]+sb[i-1][j]+sb[i][j-1]-sb[i-1][j-1];
		}
	}
	ll ans=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			ll tans1=sb[i][j];
			ll tans2=sb[i][k*2]-sb[i][j+k];
			ll tans3=sb[k*2][j]-sb[k+i][j];
			ll tans4=sb[i+k][j+k]-sb[i][j+k]-sb[i+k][j]+sb[i][j];
			ll tans5=sb[k*2][k*2]-sb[i+k][k*2]-sb[k*2][j+k]+sb[i+k][j+k];
			ll tans=tans1+tans2+tans3+tans4+tans5;
			ans=max(ans,tans);
			ans=max(ans,n-tans);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 63232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n)    for (ll (i) = 0;   (i) < (n); ++(i))
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))

int N;
ll K;
vector<ll> A;
int neg_l, neg_r, pos_l, pos_r;
ll zero_cnt;

void add(ll& cnt, int idx, int l, int r, ll mid) {
    if (l > r or l < 0 or r < 0) return;
    bool fl = A[idx] * A[l] < mid;
    bool fr = A[idx] * A[r] < mid;
    /* */if (fl and fr) cnt += r - l + 1;
    else if (fl or fr) {
        int ok = fl ? l : r, ng = fl ? r : l;
        while (abs(ok - ng) > 1) {
            int m = (ok + ng) >> 1;
            ((A[idx] * A[m] < mid) ? ok : ng) = m;
        }
        cnt += fl ? ok - l + 1 : r - ok + 1;
    }
}

bool check(ll mid) {
    ll cnt = 0;
    if (neg_l != -1) FOR(i, neg_l, neg_r + 1) {
        add(cnt, i, i + 1, neg_r, mid);
        add(cnt, i, pos_l, pos_r, mid);
    }
    if (pos_l != -1) FOR(i, pos_l, pos_r + 1) {
        add(cnt, i, i + 1, pos_r, mid);
    }
    if (mid > 0) cnt += (zero_cnt * (zero_cnt - 1) >> 1) + zero_cnt * (N - zero_cnt);
    return cnt < K;
}

signed main() {

    cin >> N >> K;

    A.resize(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    // [l, r]
    neg_l = neg_r = pos_l = pos_r = -1;
    REP(i, N) {
        /* */if (A[i] < 0) { neg_r = i; if (neg_l == -1) neg_l = i; }
        else if (A[i] > 0) { pos_r = i; if (pos_l == -1) pos_l = i; }
        else ++zero_cnt;
    }

    ll ok = -(ll)1e18 - 1, ng = (ll)1e18 + 1;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) >> 1;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)break;
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(i%2==1){
                    if(j%2==0)printf(".");
                    else printf("#");
                }
                else{
                    if(j%2==0)printf("#");
                    else printf(".");
                }
            }
            printf("\n");
        }printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2040
import numpy as np
H,W = (int(T) for T in input().split())
Map = np.zeros((H+2,W+2),dtype=bool)
for TH in range(0,H):
    Map[TH+1,1:W+1] = [True if T=='#' else False for T in input()] 
Disp = np.full((H,W),'#')
for TH in range(0,H):
    for TW in range(0,W):
        if Map[TH+1,TW+1]==False:
            Disp[TH,TW] = np.sum(Map[TH:TH+3,TW:TW+3])
    print(''.join(Disp[TH,:]))

Measured memory_bytes: 27264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_4_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();

            int q = ReadInt();
            for (int i = 0 ; i < q ; i++)
            {
                int[] items = ReadIntAr();

                for (int j = 0 ; j < items[1] - items[0] ; j++)
                {
                    var tmp = line[items[0] + j];
                    line[items[0] + j] = line[items[2] + j];
                    line[items[2] + j] = tmp;
                }
            }
            Console.WriteLine(WriteAr(line));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

S = set()
blueCard = {}
for i in range(N):
	s = input()
	S.add(s)
	if s not in blueCard:
		blueCard[s] = 1
	else:
		blueCard[s] += 1

M = int(input())
redCard = {}
for i in range(M):
	t = input()
	S.add(t)
	if t not in redCard:
		redCard[t] = 1
	else:
		redCard[t] += 1

res = 0
for u in S:
	if u in blueCard and u not in redCard:
		res = max(res, blueCard[u])
	elif u in blueCard and u in redCard:
		res = max(res, blueCard[u] - redCard[u])
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
int a[maxn],b[maxn];
char s[maxn];
signed main()
{
	ios::sync_with_stdio(0);
	int k,a,b;
	cin >> k >> a >> b;
	int flag = 0;
	for(int i=a;i<=b;i++)
		if(i%k==0)
		{
			flag = 1;
			break;
		}
	if(flag)
		cout << "OK";
	else
		cout << "NG";
	return 0;
}

Measured memory_bytes: 3608
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
	immutable n = readNums()[0];
	ulong yen = 0;
	ulong btc = 0;
	foreach(i; 0 .. n) {
		const s = readln().chomp.split;
		const value = s[0].splitter(".").joiner.stripLeft('0').to!string.to!ulong;
		if(s[1] == "JPY") {
			yen += value;
		} else {
			btc += value;
		}
	}
	writefln("%s", yen + cast(real)(btc * 380000) / 10 ^^ 8);
}


Measured memory_bytes: 256
while True:
    n=int(input())
    m=int(input())
    if n==0:
        break
    a=[None for _ in range(m)]
    b=[None for _ in range(m)]
    friend = set()
    friend1=set()
    friend2=set()
    for i in range(m):
        a[i],b[i] = list(map(int, input().split()))
        if a[i] ==1:
            friend.add(b[i])
    for i in range(m):
        if a[i] in friend:
            friend1.add(b[i])
        if b[i] in friend:
            friend2.add(a[i])
    ans=friend|friend1|friend2
    ans.discard(1)
    print(len(ans))


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

int main()
{
	int x, i;
	
	cin >> x;
	
	for(i = 1; i <= 360; i++)
		if((x * i) % 360 == 0) break;
	
	cout << i;
	
	return 0;
}


Measured memory_bytes: 3596
def my_print(lst,a,b):
    for i in range(a,b+1):
        print(lst[i],end='')
    print()

def reverse(lst,a,b):
    lst2 = lst[a:b+1]
    lst2.reverse()
    lst[a:b+1] = lst2
    
    
str1 = list(input())
n = int(input())
for i in range(n):
    str2 = input().split()
    if str2[0]=='print':
        a,b = int(str2[1]),int(str2[2])
        my_print(str1,a,b)
    if str2[0]=='replace':
        a,b,p = int(str2[1]),int(str2[2]),str2[3]
        str1[a:b+1]=p
    if str2[0]=='reverse':
        a,b = int(str2[1]),int(str2[2])
        reverse(str1, a, b)


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

int main(void) {

  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll h, w;
    cin>>h>>w;
    ll n;
    cin>>n;
    vector<ll> c(n);
    for(ll i=0;i<n;++i){
        cin>>c[i];
    }
    
    vector<vector<ll>> ans(h, vector<ll> (w));
    ll a = 0, b = 0;
    bool flag = true;
    for(ll i=0;i<n;++i){
        for(ll j=0;j<c[i];++j){
            ans[a][b] = i+1;
            if(b == w -1 and flag == true){
                flag = false;
                a++;
            }else if(b == 0 and flag == false){
                flag = true;
                a++;
            }else{
                if(flag){
                    b++;
                }else{
                    b--;
                }
            }
        }
    }

    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(j != 0){
                cout<<' ';
            }
            cout<<ans[i][j];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 5008
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int a,b,c; cin >> a >> b >> c;
  if(b-a==c-b){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256