akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

struct XY {
  int x, y;
  XY&operator+=(const XY&d) { x += d.x; y += d.y; return *this; }
  XY operator+(const XY&d)const { return XY(*this) += d; }
  bool operator==(const XY&d)const { return x == d.x && y == d.y; }
  bool check(int w, int h)const { return 0 <= x && x < w && 0 <= y && y < h; }
};
const XY d4[] = { { -1,0 }, { 1,0 }, { 0,-1 }, { 0,1 }, };
template<class T> auto get(T& a, XY d)->decltype(a[d.y][d.x]) { return a[d.y][d.x]; }
ostream& operator<<(ostream& os, XY d) { return os << '(' << d.x << ',' << d.y << ')'; }
const XY d8[] = { { -1, 0 },{ 1, 0 },{ 0, -1 },{ 0, 1 },{ -1, -1 },{ 1, -1 },{ 1, 1 },{ -1, 1 } };



void Calc() {

  var(int, h, w);
  auto a = in.Array<string>(h);

  rep(i, h)rep(j, w) if (a[i][j] != '#') {
    int cnt = 0;
    for (auto& k : d8) {
      XY pos{ j, i };
      pos += k;
      if (pos.check(w, h))if (a[pos.y][pos.x] == '#')cnt++;
    }
    a[i][j] = cnt + '0';
  }

  for (auto& i : a) {
    cout << (i) << endl;
  }

}


Measured memory_bytes: 256
/*
ID: yaoxinw2
TASK: test
LANG: C++
*/
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
set<string>ans;
int n;
string a;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		ans.insert(a);
	}
	cout<<ans.size()<<endl;
	return 0;
} 

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

long long xor_sum(long long a) {
	long long res = 0;
	if (a % 2 == 0) {
		res ^= a;
		--a;
	}
	return res ^ ((a+1)%4/2);
}

int main() {
	long long a, b;
	cin >> a >> b;
	long long ans;
	if (a == 0) ans = xor_sum(b);
	else ans = xor_sum(b) ^ xor_sum(a-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem: D - Wizard in Maze
// Contest: AtCoder - AtCoder Beginner Contest 176
// URL: https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
using namespace std;
// typedef long long ll;
template<typename T>inline void read(T &FF){
	T RR=1;FF=0;char CH=getchar();
	for(;!isdigit(CH);CH=getchar())if(CH=='-')RR=-1;
	for(;isdigit(CH);CH=getchar())FF=(FF<<1)+(FF<<3)+(CH^48);
	FF*=RR;
}
char sm[1010][1010];
int h[1010][1010];
priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > >q;
int dx[25]={-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
int dy[25]={-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2};
signed main(){
	// memset(h,-0x3f,sizeof(h));
	int n,m;read(n);read(m);
	int a,b,c,d;read(a);read(b);read(c);read(d);
	for(int i=1;i<=n;i++)scanf("%s",sm[i]+1);
	// if(a==c&&b==d){
		// cout<<0;
		// return 0;
	// }
	// for(int i=1;i<=n;i++)
		// for(int j=1;j<=m;j++)
			// cout<<sm[i][j]<<(j==m?'\n':' ');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			h[i][j]=INT_MAX;
	h[a][b]=0;
	// cout<<sm[1]<<endl;
	// for(int i=1;i<=m;i++)cout<<sm[3][m];
	// cout<<endl;
	q.push(make_pair(0,make_pair(a,b)));
	while(q.size()){
		int zx=q.top().second.first,zy=q.top().second.second,zs=q.top().first;q.pop();
		// cout<<zx<<" "<<zy<<" "<<zs<<endl;
		if(zx==c&&zy==d)return cout<<zs,0;
		// cout<<zx<<" "<<zy<<endl;
		// x.pop();y.pop();s.pop();
		for(int i=0;i<25;i++){
			int tx=zx+dx[i],ty=zy+dy[i];
			// cout<<zx<<" "<<zy<<" "<<tx<<" "<<ty<<endl;
			int a=zs+1;
			if(i==7||i==11||i==12||i==16)a--;
			if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&a<h[tx][ty]&&sm[tx][ty]=='.'){
				h[tx][ty]=a;
				// x.push(tx);y.push(ty);s.push(a);
				// cout<<tx<<" "<<ty<<" "<<a<<" "<<i<<" "<<dx[i]<<" "<<dy[i]<<endl;
				q.push(make_pair(a,make_pair(tx,ty)));
				// if(tx==c&&ty==d){
					// cout<<a;
					// return 0;
				// }
			}
		}
	}cout<<-1;
	return 0;
}

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

using namespace std;
#define ll long long
#define mod 1000000007

int dp[100001][101];
vector<int> v;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    v.resize(n);

    for (auto &i : v) {
        cin >> i;
    }

    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < v.size(); j++) {
            if (v[j] <= i) {
                if (!dp[i - v[j]][0]) dp[i][1] = true;
                if (!dp[i - v[j]][1]) dp[i][0] = true;
            } else {
                break;
            }
        }
    }

    if (dp[k][0]) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
}


Measured memory_bytes: 43044
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 解説を読んで回答
#
# https://betrue12.hateblo.jp/entry/2018/09/30/125042
# がわかりやすい
#
# 任意の長さを表現するには1, 2, 4, 8, ...という2のべき乗の列が使えそうなこと、
# X軸とY軸の条件を満たすために座標変換を行うことがポイント

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

def solve(N, XYs):

    # 偶奇が一致しない場合は構成不可能
    mod2 = [(x + y) % 2 for x, y in XYs]
    if min(mod2) != max(mod2):
        print(-1)
        return

    # 使う腕の長さは基本的に1, 2, 4, 8, ...。
    # ただしmod 2 = 0の場合は長さ1の腕を一本追加
    arms = [2 ** x for x in range(31)]
    if mod2[0] == 0:
        arms = [1] + arms
    arms.reverse()

    print(len(arms))
    print(*arms)
    for x, y in XYs:
        # 座標変換
        u, v = x + y, x - y
        # print("===u, v, x, y = {}, {}, {}, {}===".format(u, v, x, y))

        ans = ''
        for arm in arms:

            before_x = (u + v) // 2
            before_y = (u - v) // 2

            if u > 0:
                u -= arm
            else:
                u += arm
            if v > 0:
                v -= arm
            else:
                v += arm

            after_x = (u + v) // 2
            after_y = (u - v) // 2

            # 目標地点から原点に向かう方向に移動しているので
            # 記号も逆になるのに注意
            if before_x == after_x:
                if before_y < after_y:
                    ch = 'D'
                else:
                    ch = 'U'
            else:
                if before_x < after_x:
                    ch = 'L'
                else:
                    ch = 'R'
            ans += ch

        print(ans)

        # 検算
        assert u == 0 and v == 0
        pos_x = pos_y = 0
        for d, arm in zip(ans, arms):
            if d == 'U': pos_y += arm
            elif d == 'D': pos_y -= arm
            elif d == 'L': pos_x -= arm
            elif d == 'R': pos_x += arm
        assert x == pos_x
        assert y == pos_y


N = int(input())
XYs = []
for n in range(N):
    x, y = map(int, input().split())
    XYs.append((x, y))
solve(N, XYs)


Measured memory_bytes: 6680
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
#define ll long long
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> //lower_bound , upper_bound
// using namespace __gnu_pbds;//kth smallest : *pd.find_by_order(k-1) , no. of elem < X : pd.order_of_key(X) , delete X : pd.erase(X).
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl '\n'
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define tc ll tc;cin>>tc;while(tc--)
const ll mod=(1e+9)+7;
const ll sz = 2e5+9;
ll gcd(ll a,ll b) {if(b==0)return a;return gcd(b,a%b);}
ll power(ll a,ll b,ll m = mod) {ll res = 1;while(b>0){if(b&1)res = (res*a)%m;b = b>>1;a = (a*a)%m;}return res;}

void solve()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n),ans(n,1e9);
    for(auto &x:v) cin>>x;
    ans[0]=0;
    f(i,0,n){
        fb(j,i-1,max(0LL,i-k)){
            ans[i]=min(ans[i],ans[j]+abs(v[i]-v[j]));
        }
    }


    // ans[1]=abs(v[1]-v[0]);
    // f(i,2,n) ans[i]=min(ans[i-1]+abs(v[i]-v[i-1]),ans[i-2]+abs(v[i]-v[i-2]));
    cout<<ans[n-1]<<nl;
    
    
}
 
int main()
{
    #ifdef JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    clock_t beg = clock();
    solve();
    clock_t end = clock();
    fprintf(stderr, "%.3f sec, Copyright %c 2019 PyThor. \n", double(end - beg) / CLOCKS_PER_SEC , 184);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

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

	for(int k=0;k<n;k++){
		if(k>0)	cout<<endl;

		int cel[9][9];
		bool chk[9][9];
		for(int i=0;i<9;i++)for(int j=0;j<9;j++)cin>>cel[i][j],chk[i][j]=false;

		for(int i=0;i<9;i++){
			int pos[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
			for(int j=0;j<9;j++){
				if(pos[cel[i][j]]==-1)	pos[cel[i][j]]=j;
				else{
					chk[i][pos[cel[i][j]]]=true;
					chk[i][j]=true;
				}
			}
		}

		for(int j=0;j<9;j++){
			int pos[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
			for(int i=0;i<9;i++){
				if(pos[cel[i][j]]==-1)	pos[cel[i][j]]=i;
				else{
					chk[pos[cel[i][j]]][j]=true;
					chk[i][j]=true;
				}
			}
		}

		for(int y=0;y<9;y+=3)for(int x=0;x<9;x+=3){
			int pos[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
			for(int i=y;i<y+3;i++){
				for(int j=x;j<x+3;j++){
					if(pos[cel[i][j]]==-1)	pos[cel[i][j]]=i*10+j;
					else{
						chk[pos[cel[i][j]]/10][pos[cel[i][j]]%10]=true;
						chk[i][j]=true;
					}
				}
			}
		}

		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				cout<<(chk[i][j]?'*':' ')<<cel[i][j];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, q;
    cin >> n >> m >> q;
    vvi trains(n, vi(n, 0));
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        trains[l][r]++;
    }
    vvi sm(n+1, vi(n+1, 0));
    rep(i, n) rep(j, n) {
        sm[i+1][j+1] = sm[i+1][j] + sm[i][j+1] - sm[i][j] + trains[i][j];
    }
    rep(i, q) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        int ans = sm[n][b+1] - sm[n][0] - sm[a][b+1] + sm[a][0];
        cout << ans << endl;
    }

}

Measured memory_bytes: 2944
#include <stdio.h>
int main(void)
{
	int n;

	scanf("%d", &n);

	if(n == 19 || n == 29 || n == 39 || n == 49 || n == 59 || 
		n == 69 || n == 79 || n == 89 || n == 90 || 
        n == 91 || n == 92 || n == 93 || n == 94|| 
		n == 95 || n == 96 || n == 97 || n== 98||n == 99){
		printf("Yes\n");
	}else{
		printf("No\n");
	}	

return 0;
}

Measured memory_bytes: 128
// W i B
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 1000000007
#define pb push_back
#define bit(x,p) ((x>>p) & 1)
#define ll long long
#define Task "CF"
using namespace std;

const int base = 100003;
const int maxn = 300005;

int k;

void Solve(){
    cin >> k;
    for(int i = 1;i <= k;++i) cout << "ACL";
}
void NumTime(){
    cerr << "Toi" << "\n";cerr << "Di" << "\n";cerr << "Chep" << "\n";cerr << "Code" << "\n";
}


int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
	if(fopen(Task".inp","r")){
		freopen(Task".inp","r",stdin);
		freopen(Task".out","w",stdout);
	}
    int test = 1;
//    cin >> test;
    while(test --){
        NumTime();
        Solve();
    }
}
 // V T An


Measured memory_bytes: 3616
// Kagami Mochi

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end(), greater<int>());

    int count = 1;

    int cur_width = d[0];
    for (int i = 1; i < n; i++) {
        if (cur_width > d[i]) {
            count++;
            cur_width = d[i];
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
struct cc{
    int p=-1;
    int d=-1;
    int l=-1;
    int r=-1;
};

cc tree[100000];

void depth(int a){
    if(tree[a].p==-1){
        tree[a].d=0;
        return ;
    }
    if(tree[a].d!=-1){
        return ;
    }
    depth(tree[a].p);
    tree[a].d=tree[tree[a].p].d+1;
}
int main(){
    int n,a,b,jud;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(b!=0){
            cin>>tree[a].l;
            jud=tree[a].l;
            tree[jud].p=a;
            for(int j=1;j<b;j++){
                cin>>tree[jud].r;
                jud=tree[jud].r;
                tree[jud].p=a;
            }
        }
    }
    for(int i=0;i<n;i++){
        depth(i);
        printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,tree[i].d);
        if(tree[i].p==-1){
            printf("root, [");
        }
        else if(tree[i].l!=-1){
            printf("internal node, [");
        }
        else{
            printf("leaf, [");
        }
        if(tree[i].l!=-1){
            int jud2=tree[i].l;
            printf("%d",tree[i].l);
            while(tree[jud2].r!=-1){
                printf(", ");
                printf("%d",tree[jud2].r);
                jud2=tree[jud2].r;
            }
        }
        printf("]\n");
    }
    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a;
  vector<int> vec;
  int alice = 0;
  int bob = 0;
  cin >> n;
  REP(i,n){
      cin >> a;
      vec.push_back(a);
  }
  SORT(vec);
  reverse(vec.begin(),vec.end());
  REP(i,n){
      if (i%2==0){
          alice+=vec[i];
      }else{
          bob+=vec[i];
      }
    
  }
  cout << alice - bob << endl;

}

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

using namespace std;

#define ll long long

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

	bool flag = false;
	for (char c : w) {
		if (c == 'C') flag = true;
		if (flag && c == 'F') {
			puts("Yes");
			return 0;
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

ll dp[401][401];

ll sum(ll i,ll j,vector<ll> &v)
{
    ll ans=0;
    for(ll k=i;k<=j;k++)
    {
        ans+=v.at(k);
    }
    return ans;
}

ll cost(ll i,ll j,vector<ll> &v)
{
    if(i>=j)
    {
        return dp[i][j]=0;
    }
    else
    {
        if(dp[i][j]!=-1)
        {
            return dp[i][j];
        }
        
        ll min=LLONG_MAX;
        for(ll k=i;k<=j-1;k++)
        {
            ll ans=cost(i,k,v)+cost(k+1,j,v);
            //cout<<ans<<" ";
            if(min>ans)
            {
                min=ans;
            }
        }
        return dp[i][j]=sum(i,j,v)+min;
    }
}

ll solve(ll n,vector<ll> &v)
{
    memset(dp,-1,sizeof(dp));
    return cost(1,n,v);
}

int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>v.at(i);
    }
    cout<<solve(n,v);
    return 0;
}

Measured memory_bytes: 4852
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SLR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if args else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class BIT:
    def __init__(self, li):
        self.n, self.data = len(li) + 1, [0] + li
        for i in range(1, self.n):
            if i + (i & -i) < self.n: self.data[i + (i & -i)] += self.data[i]

    def add(self, i, a):
        i += 1
        while i < self.n:
            self.data[i] += a
            i += i & -i

    # sum of [0, i)
    def acc(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    # sum of [l, r)
    def get(self, l, r = None):
        if r is None: r = l+1
        return self.acc(r) - self.acc(l)



def main():
    N, K = LI()
    A = IR(N)
    B = [ai - K for ai in A]
    cum = list(itertools.accumulate(B))
    mapping = {}
    count = 0
    for ci in sorted(cum):
        if not ci in mapping:
            mapping[ci] = count
            count += 1
    mappedcum = [mapping[ci] for ci in cum]

    bit = BIT([0]*N)

    ans = 0
    for i, ci in enumerate(mappedcum):
        ans += bit.acc(ci+1)
        if cum[i] >= 0: ans += 1
        bit.add(ci, 1)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 160816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>x(n);
    int ma=-1e8,mi=1e8;
    rep(i,n){
        cin >> x[i];
        ma = max(ma,x[i]);
        mi = min(mi,x[i]);
    }
    ll ans = 1e18;
    for(int i = mi;i <= ma;i++){
        ll num = 0;
        rep(j,n){
            num += (x[j]-i)*(x[j]-i);
        }
        ans =  min(ans,num);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int W = sc.nextInt();

        long[][] dp = new long[N + 1][W + 1];
        for (int i = 0; i <= N; i++) {
            Arrays.fill(dp[i], -1);
        }

        dp[0][0] = 0;
        for (int i = 0; i < N; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            for (int j = 0; j <= W; j++) {
                if (dp[i][j] == -1) {
                    continue;
                }
                dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
                if (j + w > W) {
                    continue;
                }
                dp[i + 1][j + w] = Math.max(dp[i + 1][j + w], dp[i][j] + v);
            }
        }

        System.out.println(Arrays.stream(dp[N]).max().getAsLong());
    }
}


Measured memory_bytes: 127696
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	string s;
	cin >> s;

	cout << (s == "ABC" ? "ARC" : "ABC") << "\n";

	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;


int main(){
    cin>>N;
    reps(i,1,50001){
        ll temp = i * 108;
        if(temp/100 == N){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    string S, T; cin >> S >> T;
    cout << T+S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

int equal(int x, int y, int z) {
  int res = 0;
  if (x == y) res++;
  if (y == z) res++;
  if (z == x) res++;
  return res;
}

void solve(istream& cin, ostream& cout) {
  int K, S;
  cin >> K >> S;
  ll ans = 0;
  REP(x, K+1) {
    REP(y, K+1) {
      int z = S - x - y;
      if (z >= 0 && z <= K) ans++;
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cini(n);
    while(n) {
        if(n%10==7) {
            cout<<"Yes"<<endl;
            return;
        }
        n/=10;
    }
    cout<<"No"<<endl;
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;cin >> N;
    string ans="No";
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(i*j==N){
                ans="Yes";
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int N, W;
int w[100000];
int v[100000];
long long int dp[100001];

int main(){

    scanf("%d %d", &N, &W);
    for(int i = 0; i < N; i++){
        scanf("%d %d", &w[i], &v[i]);
    }

    for(int i = 0; i <= W; i++){
        dp[i] = 0;
    }

    for(int i = 0; i < N; i++){
        for(int j = W; j >= w[i]; j--){
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }

    printf("%ld\n", dp[W]);

    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(){
	int N, A ,B;
	scanf("%d",&N);
	scanf("%d",&A);
	scanf("%d",&B);
	char S[N];
	scanf("%s",S);
	int i, win = 0;
	int f = 0;

	for(i = 0 ; i<N ; i++)
	{
		if(S[i] == 'c')
			printf("No\n");
		else if(S[i] == 'a')
		{
			if(win < A+B){
				printf("Yes\n");
				win++;
			}
			else{
				printf("No\n");
			}
		}
		else
		{
			f++;
			if(win < A+B && f <= B){
					printf("Yes\n");
						win++;
			}
			else
				printf("No\n");
		}
	}
	return 0;
}

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

#define BIT(x) (1 << (x))

struct Piece {
	int h, w;
	vector<int> v;
};

int H, W;
int n;
int board[20];
Piece p[10][4];

void generate(vector<vector<int> > v, Piece p[])
{
	for (int i = 0; i < 4; i++){
		int bx = 20, by = 20, ex = -1, ey = -1;
		for (int j = 0; j < 20; j++){
			for (int k = 0; k < 20; k++){
				if (v[j][k]){
					bx = min(bx, j);
					by = min(by, k);
					ex = max(ex, j);
					ey = max(ey, k);
				}
			}
		}
		p[i].h = ex - bx + 1;
		p[i].w = ey - by + 1;
		p[i].v.assign(p[i].h, 0);
		for (int j = 0; j < p[i].h; j++){
			for (int k = 0; k < p[i].w; k++){
				if (v[bx + j][by + k]){
					p[i].v[j] |= BIT(k);
				}
			}
		}
		
		vector<vector<int> > nx(20, vector<int>(20));
		for (int i = 0; i < 20; i++){
			for (int j = 0; j < 20; j++){
				nx[i][j] = v[j][19 - i];
			}
		}
		v = nx;
	}
}

vector<int> ch;
vector<int> used;
bool check()
{
	int sum = 0;
	for (int i = 0; i < 20; i++){
		sum += __builtin_popcount(~board[i]);
	}
	for (int i = 0; i < ch.size(); i++){
		for (int j = 0; j < p[ch[i]][0].v.size(); j++){
			sum -= __builtin_popcount(p[ch[i]][0].v[j]);
		}
	}
	return sum == 0;
}

bool can(int x, int y, Piece &pi)
{
	for (int i = 0; i < pi.h; i++){
		if (board[x + i] & (pi.v[i] << y)){
			return false;
		}
	}
	return true;
}

bool act(int x, int y, Piece &pi)
{
	for (int i = 0; i < pi.h; i++){
		board[x + i] ^= pi.v[i] << y;
	}
}

bool ng()
{
	int b[20] = {};
	for (int i = 0; i < 20; i++) b[i] = board[i];
	for (int i = 0; i < ch.size(); i++){
		if (used[i]) continue;
		for (int a = 0; a < 4; a++){
			Piece &pi = p[ch[i]][a];
			for (int j = 0; j + pi.h <= H; j++){
				for (int k = 0; k + pi.w <= W; k++){
					if (can(j, k, pi)){
						for (int l = 0; l < pi.h; l++){
							b[j + l] |= pi.v[l] << k;
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < 20; i++){
		if (b[i] != -1) return true;
	}
	return false;
}

bool dfs(int cur)
{
	if (cur == ch.size()) return true;
	if (ng()) return false;
	
	for (int a = 0; a < 4; a++){
		Piece &pi = p[ch[cur]][a];
		for (int i = 0; i + pi.h <= H; i++){
			for (int j = 0; j + pi.w <= W; j++){
				if (can(i, j, pi)){
					act(i, j, pi);
					used[cur] = true;
					bool f = dfs(cur + 1);
					act(i, j, pi);
					used[cur] = false;
					if (f) return true;
				}
			}
		}
	}
	return false;
}

int main()
{
	while (scanf("%d %d", &H, &W), H){
		memset(board, -1, sizeof(board));
		
		for (int i = 0; i < H; i++){
			string str;
			cin >> str;
			for (int j = 0; j < W; j++){
				if (str[j] == '.') board[i] ^= BIT(j);
			}
		}
		
		scanf("%d", &n);
		for (int i = 0; i < n; i++){
			int h, w;
			scanf("%d %d", &h, &w);
			vector<vector<int> > buf(20, vector<int>(20));
			for (int j = 0; j < h; j++){
				for (int k = 0; k < w; k++){
					char c;
					cin >> c;
					if (c == '#') buf[j][k] = 1;
				}
			}
			generate(buf, p[i]);
		}
		
		int m;
		scanf("%d", &m);
		for (int i = 0; i < m; i++){
			int k;
			scanf("%d", &k);
			ch.resize(k);
			used.assign(k, 0);
			for (int j = 0; j < k; j++){
				scanf("%d", &ch[j]);
				ch[j]--;
			}
			puts(check() && dfs(0) ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 1252
#include<cstdio>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){

	string s;
        int cnt=0;
	while(cin>>s){
                if (cin.eof()) break;
                string temp;
		for(int i=s.size()-1;i>=0;i--){
  		    temp.push_back(s[i]);
	        }
                string s1=temp;
                if(s==s1) cnt++;
	}
        cout<< cnt << endl;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		double[] s=sc.Da;
		double ans=0;
		for(int i = 1;i<=s[0];i++) {
			double k=0,p=i;
			while(p<s[1]){p*=2;k++;}
			ans+=(1.0/s[0])*Math.Pow(0.5,k);
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

bool isPrime[1000006];
ll cnt[1000007] = {0};
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	fill(isPrime, isPrime+1000006, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i <= 1000005; ++i) {
		for (int j = i*2; j <= 1000005; j += i) {
			isPrime[j] = false;
		}
	}
	REP(i, 1000006) {
		cnt[i+1] = cnt[i] + (isPrime[i] ? 1 : 0);
	}
	int N;
	while ( cin >> N ) {
		cout << cnt[N+1] << endl;
	}
}

Measured memory_bytes: 11948
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n, r;
    cin >> n >> r;

    if (n >= 10) cout << r << endl;
    else {
    	cout << (r + (100*(10-n))) << endl;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
    int n,a;
    int min = 1000001;
    int max = -1000001;
    long long sum = 0;
    
    cin >> n;
    
    
    for (int i = 0 ; i < n ; i ++) {
        
        cin >> a;
        
        if (a <= min) {
            
            min = a;
            
        } 
        
        if (a >= max) {
            
            max = a;
            
        }
        
        sum = sum + a;
        
    }
    
    cout << min << " " << max << " " << sum << endl;
    
}



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

int main() {
	string s, t;
	long long k, c = 0;
	cin >> s >> k;
	t = s;
	long long S = s.size();
	rep(i, S) {
		if (i != 0 && s[i] == s[i - 1]) {
			s[i] = '.';
			c++;
		}
	}
	long long C = 0;
	rep(i, S) {
		if (i == 0) {
			if (t[0] == s[S - 1]) {
				t[0] = '.';
				C++;
			}
		}
		else {
			if (t[i] == t[i - 1]) {
				t[i] = '.';
				C++;
			}
		}
	}
	long long ans;
	if (t[S - 1] == s[S - 1]) ans = c + C * (k - 1);
	else ans = S * k / 2;
	cout << ans << endl;
}


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

int main(void){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    vector<ll> vec(4);
    vec[0] = a*c;   vec[1] = a*d;
    vec[2] = b*c;   vec[3] = b*d;
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    cout << vec[0] << endl;
    return 0;

}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int Q=in();
	multiset<int> S;
	REP(i,Q){
		int q=in();
		if(q==1){
			auto res = S.equal_range(in());
			out(distance(res.first,res.second));
		}
		else if(q==2){
			S.erase(in());
		}
		else if(q==3){
			int L=in(),R=in();
			auto start = S.lower_bound(L);
			auto end = S.upper_bound(R);
			while(start!=end){
				out(*start);
				++start;
			}
		}
		else{
			S.insert(in());
			out(S.size());
		}
	}
	return 0;
}


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



int main(){


    int n;
    cin >> n;
    vector<int> a1(n);
    vector<int> a2(100,0);
    for(int i = 0;i < n;i++){
        cin >> a1[i];
        //cout << a1[i] << endl;
    }

    int ans = 0;
    for(int i = 0;i < n;i++){
        
        if(a2[a1[i]] == 0){
            ans++;
            a2[a1[i]]++;
        }

    }

    cout << ans << endl;



    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    int t1, t2, r1, r2;
    cin >> t1 >> t2 >> r1 >> r2;
    if(r1 == -1 || r2 == -1){
        if(t1 < t2) {
            cout << "Alice" << endl;
        }
        else if (t1 > t2){
            cout << "Bob" << endl;
        }
        else{
            cout << "Draw" << endl;
        }
    }
    else{
        if(r1 > r2) {
            cout << "Alice" << endl;
        }
        else if (r1 < r2){
            cout << "Bob" << endl;
        }
        else{
            cout << "Draw" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int n, ans = 0; cin >> n;
    vector<int> P;
    rep (i, 0, n) {
        int p; cin >> p;
        P.push_back(p);
    }

    rep (i, 0, P.size()-2) {
        vector<int> tmp_vec;
        copy(P.begin()+i, P.begin()+i+3, back_inserter(tmp_vec));
        int tmp_val = tmp_vec[1];
        sort(tmp_vec.begin(), tmp_vec.end());
        if (tmp_vec[1] == tmp_val) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
//#define mod 998244353
using namespace std;
ll power(ll x,ll n)
{
	ll res =1;
	while(n>0)
	{
		if(n%2==1)
	res=res*x;
	x=x*x;
	n=n/2;
	}
	return res;
	
}


int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    int ans=0;
    if(n>=2)
    {
    	ans=ans+n*(n-1)/2;
	}
	if(m>=2)
	ans+=m*(m-1)/2;
	cout<<ans;
    
    
    

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int a[n];
    map<ll,ll> mp;

    rep(i,n){
        cin >> a[i];
        a[i] -= i;
        mp[a[i]]++;
    }
    ll ans = 0;
    rep(i,n){
        ans += mp[-a[i]-2*i];
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 27120
<?php

$aa = [];
while(true){
    fscanf(STDIN,"%d",$n);
    if($n == 0){
        break;
    }
    $data = explode(" ", trim(fgets(STDIN)));
    $s = array_sum($data)/$n;
    
    foreach($data as $k=>$v){
        $aa[] = (($data[$k] - $s)**2) / $n;
    }
    
    echo sqrt(array_sum($aa)),PHP_EOL;
    $aa = [];
}


Measured memory_bytes: 9644
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const ll INF = 1000000007;
const int MAX_V = 2001;

struct edge{
  int to;
  ll cost;
};
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int V,int s){
  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+V,INF);
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.se;
    if(d[v] < p.first)continue;
    rep(i,sz(G[v])){
      edge e = G[v][i];
      if(d[e.to] > d[v]+e.cost){
        d[e.to] =  d[v]+e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}
int chk[2001][2001];
  
int main() {
  int n,x,y;
  cin >> n >> x >> y;
  x--;y--;
  rep(i,n-1){
    edge e1;
    e1.to = i+1;
    e1.cost = 1;
    G[i].push_back(e1);
    edge e2;
    e2.to = i;
    e2.cost = 1;
    G[i+1].push_back(e2);
  }
  edge e;
  e.to = y;
  e.cost = 1;
  edge e2;
  e2.to = x;
  e2.cost = 1;
  G[x].push_back(e);
  G[y].push_back(e2);
    vi ans(n,0);
  rep(i,n){
    dijkstra(n,i);
    rep(j,n){
      if(i==j || chk[i][j])continue;
      if(d[j] == INF) continue;//show(d[j]);
      //cout<<i<<":"<<j<<":"<<d[j]<<endl;
      ans[d[j]]++;
      chk[i][j] = 1;
    }
  }
  srep(i,1,n){
    cout<<ans[i]/2<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 16000
#include<stdio.h>
#include<stdlib.h>
int linearSearch(int,int*,int);
int main(){
  int n1,n2,*N1,*N2,i,count=0;
  scanf("%d",&n1);
  N1 = (int *)malloc(n1 * sizeof(int));
  for(i=0;i<n1;i++){
    scanf("%d",&N1[i]);
  }
  scanf("%d",&n2);
  N2 = (int *)malloc(n2 * sizeof(int));
  for(i=0;i<n2;i++){
    scanf("%d",&N2[i]);
  }
  for(i=0;i<n2;i++){
    if(linearSearch(N2[i],N1,n1) == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}

int linearSearch(int key,int *A,int n){
  int i;
  for(i=0;i<n;i++){
    if(A[i]==key)return 1;
  }
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void in(ll &x){ cin >> x; }
void pin(ll &x, ll &y){ cin >> x >> y; }


int main(){
    ll N,M,K,a,b,p,q,x,y,z;
    ll A, B;
    in(N);
    pin(A, B);
    a=N/(A+B);
    x=0;
    x+=a*A;
    N=N%(A+B);
    x+=min(A,N);
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
// not solved by myself
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int res[] = {
            A + B,2 * A - 1, 2*B - 1
        };
        System.out.println(max(res,3));


    }

     public static long max(int[] ar,int size){
        long max = 0;
        for(int i = 0; i< size;i++)
            if(max < ar[i])
                max = ar[i];
        return max;
    }


    public static long max(List<Long> ar){
        long max = 0;
        for(int i = 0; i< ar.size();i++)
            if(max < ar.get(i))
                max = ar.get(i);
        return max;
    }

    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }


    public static long gcd(long m, long n) {
        if(m == 0)
            return n;
        if(n == 0)
            return m;
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}





Measured memory_bytes: 22996