akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define MODNUM (INT(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	string s;
	cin >> s;
	EACH(c, s) { cout << 'x'; }
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map> 
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   cin >> n;
   vector<int> v(n);
   for (int i = 0;i < n;i++){
      cin >> v[i];
   }
   sort(v.begin(),v.end(),greater<int>());
   int a= 0,b = 0;
   for (int i = 0;i < n;i++){
      if (i%2 == 0) a+=v[i];
      else b+=v[i];
   }
   cout << a - b << endl;
   
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define loop(i,a,b) for(int i=a;i<b;i++)
#define scnarr(arr, n) for (int i = 0; i < n; ++i) cin >> arr[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>

//Constants
const int MOD = 1000000007; /* 1e9 + 7*/
const int MAXN = 1000005; /*1e6 +5 */


int spf[1000009]; // stores the smallest prime factor of a number

void sieve()
{
spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;
    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

/* Iterative Function to calculate (x^y)%p in O(log y) */
int power(int x,  int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

void solve()
{
  int n;cin>>n;string s;
  cin>>s;
  int start=0 , endm=n-1 , cnt=0;
  while(start<=endm)
  {
      if(s[start]=='W' && s[endm]=='R')
      {
          cnt++;
          start++;
          endm--;
      }
      else
      {
          if(s[endm]=='W')
            endm--;
          if(s[start]=='R')
            start++;
      }

  }
  cout<<cnt<<endl;
}

int32_t main()
{
   // faster;
    //sieve();
    // int t;cin>>t;
    // while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3724
import heapq
N = int(input())
es = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))
Q,K = map(int, input().split())
K -= 1

INF = float('inf')
ds = [INF for i in range(N)]
ds[K] = 0
visited = [0 for i in range(N)]
q = [K]
heapq.heapify(q)
while q:
    now = heapq.heappop(q)
    visited[now] = 1
    for to,cost in es[now]:
        ds[to] = min(ds[to], ds[now]+cost)
        if visited[to]: continue
        heapq.heappush(q,to)

for i in range(Q):
    x,y = map(int, input().split())
    x,y = x-1, y-1
    print(ds[x] + ds[y])


Measured memory_bytes: 44300
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int,pair<int,int>>
#define ld long double
#define lld long long
#define mp make_pair
#define nmax 100005
using namespace std;
int n, x, y;
int c1, c2;
priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int>>>>hp;
vector<pair<int,int>>g[nmax];
vector<pii>ptsX, ptsY;
int h[nmax], tata[nmax], mh, n1, n2;
lld ans, add;
void unionn(int x, int y)
{
    if (h[x] > h[y])
        tata[y] = x;
    else if (h[x] < h[y])
        tata[x] = y;
    else
        tata[y] = x, ++h[x];
}
int findd(int x)
{
    int cx = x, aux;
    while (tata[x])
        x = tata[x];
    if (x != cx)
    {
        while (tata[cx])
        {
            aux = tata[cx];
            tata[cx] = x;
            cx = aux;
        }
    }
    return x;
}
bool cmp1(pii a, pii b)
{
    if (a.second.first == b.second.first)
        return a.second.second < b.second.second;
    return a.second.first < b.second.first;
}
bool cmp2(pii a, pii b)
{
    if (a.second.second == b.second.second)
        return a.second.first < b.second.first;
    return a.second.second < b.second.second;
}
int main()
{
    scanf("%d",&n);
    for (int i=1; i<=n; ++i)
    {
        scanf("%d %d",&x,&y);
        ptsX.pb(mp(i,mp(x,y)));
        ptsY.pb(mp(i,mp(x,y)));
    }
    sort(ptsX.begin(), ptsX.end(), cmp1);
    sort(ptsY.begin(), ptsY.end(), cmp2);
    for (int i=0; i<ptsX.size()-1; ++i)
    {
        c1 = ptsX[i].first;
        c2 = ptsX[i+1].first;
        add = min(abs(ptsX[i].second.first - ptsX[i+1].second.first), abs(ptsX[i].second.second - ptsX[i+1].second.second));
        hp.push(mp(add,mp(c1,c2)));
    }
    for (int i=0; i<ptsY.size()-1; ++i)
    {
        c1 = ptsY[i].first;
        c2 = ptsY[i+1].first;
        add = min(abs(ptsY[i].second.first - ptsY[i+1].second.first), abs(ptsY[i].second.second - ptsY[i+1].second.second));
        hp.push(mp(add,mp(c1,c2)));
    }
    for (;mh<n-1 && !hp.empty();)
    {
        auto act = hp.top();
        hp.pop();
        n1 = act.second.first;
        n2 = act.second.second;
        c1 = findd(n1);
        c2 = findd(n2);
        if (c1 != c2)
        {
            ans+=act.first;
            unionn(c1,c2);
            ++mh;
        }
    }
    cout<<ans<<'\n';
    return 0;
}


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

int countChar(string str, int n){
    char pivot;
    int i,j;
    int cnt = 0;

    i = 0;
    while (i < str.length()){
        pivot = str.at(i);
        //cout << "pivot: " << pivot << endl;
        j = i;
        do
        {
            //cout << "If True" << endl;
            j++;
            if (j == n)
            {
                //cout << "in break" << endl;
                break;
            }
            //cout << "str.at(" << j << "): " << str.at(j) << endl;
        } while (pivot == str.at(j));
        i = j;
        cnt++;
        //cout << "cnt: " << cnt << endl;
    }
    return cnt;
}

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

    // 部分連続を数え上げればよい
    cout << countChar(S, N) << endl;
}

Measured memory_bytes: 512
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    dict = defaultdict(int)
    for _ in range(N):
        str = ''.join(sorted(input().rstrip()))
        dict[str] += 1

    ans = 0
    for val in list(dict.values()):
        if 1 < val:
            ans += val*(val-1)//2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18236
N=int(input())
s=[list(map(int,input().split())) for i in range(N)]
A=N
c=0
s.sort(key=lambda x: x[0])

Check=[[s[i][0]-s[i][1],s[i][0]+s[i][1]] for i in range(N)]
tmp=Check[0][1]
for j in range(1,N):
    if tmp > Check[j][0]:
        c=c+1
        tmp=min(tmp, Check[j][1])
    else:
        tmp=Check[j][1]
    
print(A-c)

Measured memory_bytes: 41740
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,w,cnt=0;
  char c;
  cin >> h >> w;
  for (int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c;
      if(c=='#'){
        cnt++;
      }
    }
  }
  if(cnt==h+w-1){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int f(long x){
	int d=0;
	while(x>INT_MAX){
		d++;
		x/=10;
	}
	int y=x;
	while(y!=0){
		d++;
		y/=10;
	}
	return d;
}

int main(void){
	long n;
	scanf("%ld", &n);
	int m=sqrt(n), i;
	int ans=f(n);
	for(i=2; i<=m; i++){
		if(n%i==0){
			int now = f(n/i);
			if(now<ans) ans=now;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
inf = 10 ** 10
m = a[n-1]
a = [-inf] + a[0:n-1] + [inf]
left = bisect.bisect_left(a, m//2)
if m//2 - a[left-1] < a[left] - m//2:
    print(m, a[left-1])
else:
    print(m, a[left])


Measured memory_bytes: 14428
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

ans = 0

for i in range(1,n+1):
	po = n // i
	ans += po * (2*i+(po-1)*i) // 2
print(ans) 

Measured memory_bytes: 66844
import sys
from itertools import combinations
input=sys.stdin.readline

n=int(input())
s={}
for i in range(n):
    tmp=input()[0]
    if tmp in ['M','A','R','C','H']:
        s[tmp]=s.get(tmp,0)+1

ans=0

cmb=list(combinations(s.values(),3))

for a,b,c in cmb:
    ans+=a*b*c

print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int nxt[21][202020];
int bef[21][202020];
int dp1[1102020], dp2[1102020];
int d[202020];
int ans[202020];
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	d[0] = -1010101010, d[num + 1] = 1010101010;
	for (int i = 1; i <= num; i++)scanf("%d", &d[i]);
	int pt = 0;
	for (;;)
	{
		int now = 0;
		for (int i = 1; i <= num + 1; i++)
		{
			if (d[i] - d[i - 1] > gen)now = i - 1;
			bef[pt][i] = now;
		}
		bef[pt][0] = 0;
		now = num + 1;
		for (int i = num; i >= 0; i--)
		{
			if (d[i + 1] - d[i] > gen)now = i + 1;
			nxt[pt][i] = now;
		}
		nxt[pt][num + 1] = num + 1;
		pt++;
		if (gen == 0)break;
		gen /= 2;
	}
	//for (int i = 0; i <= num + 1; i++)printf("%d %d\n", nxt[0][i], bef[0][i]);
	fill(dp1, dp1 + (1 << pt), 1);
	for (int p = 0; p < (1 << pt); p++)
	{
		for (int i = 0; i < pt; i++)
		{
			if (p&(1 << i))continue;
			dp1[p + (1 << i)] = max(dp1[p + (1 << i)], nxt[i][dp1[p]]);
		}
	}
	fill(dp2, dp2 + (1 << pt), num);
	for (int p = 0; p < (1 << pt); p++)
	{
		for (int i = 0; i < pt; i++)
		{
			if (p&(1 << i))continue;
			dp2[p + (1 << i)] = min(dp2[p + (1 << i)], bef[i][dp2[p]]);
		}
	}
	//for (int i = 0; i < (1 << pt); i++)printf("%d %d\n", dp1[i], dp2[i]);
	for (int p = 0; p < (1 << pt); p+=2)
	{
		int q = (1 << pt) - 2 - p;
		if (nxt[0][dp1[p]]>dp2[q])ans[dp1[p]] = 1;
	}
	int t = 0;
	for (;;)
	{
		if (ans[t])
		{
			for (int j = t; j < nxt[0][t]; j++)ans[j] = 1;
			t = nxt[0][t];
		}
		else t++;
		if (t == num + 1)break;
	}
	for (int i = 1; i <= num; i++)printf(ans[i] ? "Possible\n" : "Impossible\n");
}

Measured memory_bytes: 44544
#include <bits/stdc++.h>
using namespace std;
int f[100010],n,a[100010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(i>=2)
			f[i]=f[i-1]+abs(a[i]-a[i-1]);
		if(i>=3)
			f[i]=min(f[i],f[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double


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

  ll ci,ct=0;
  for (ll i = 0; i < n; i++)
  {
    cin>>ci;
    ct++;
    for (ll j = 2; j*j <= ci; j++)
    {
      if (ci%j==0) {
        ct--;
        break;
      }
    }
    
  }
  cout<<ct<<endl;

  return 0;
}



Measured memory_bytes: 3044
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    long long int N,K;
    long long int q0=0, q=0;
    cin >>N>>K;

    q0 = N/K;
    
    q = q0;
    
    if(K/2<=N%K){
        q = q0+1;
    }


    if(K%2 ==1){
        printf("%lld", q0*q0*q0);
    }else{
        printf("%lld", q0*q0*q0 + q*q*q  );
    }

    return 0;

}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

char f[101][101];
Int d[101][101];

int main() {
    Int h, w;
    cin >> h >> w;
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            cin >> f[i][j];
            d[i][j] = INF;
        }
    } 
    d[0][0] = (f[0][0] == '#');
    queue<pair<Int, Int>> q;
    q.push({0, 0});
    while (not q.empty()) {
        pair<Int, Int> p = q.front();
        q.pop();
        Int dy[] = {0, 1};
        Int dx[] = {1, 0};
        for (Int i = 0; i < 2; i++) {
            Int ny = dy[i] + p.fi;
            Int nx = dx[i] + p.se;
            if (ny == h or nx == w) continue;
            if (f[p.fi][p.se] == '.' and f[ny][nx] == '#') {
                if (d[ny][nx] > d[p.fi][p.se] + 1) {
                    d[ny][nx] = d[p.fi][p.se] + 1;
                    q.push({ny, nx});
                }
            } else {
                if (d[ny][nx] > d[p.fi][p.se]) {
                    d[ny][nx] = d[p.fi][p.se];
                    q.push({ny, nx});
                }
            }
        }
    }
    dump(d[h - 1][w - 1]);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll dp[205][205];
int main(){FIN
    ll n,m,r;cin>>n>>m>>r;
    ll dp[n][n];
    REP(i,n) REP(j,n) dp[i][j] = mod;
    REP(i,n) dp[i][i] = 0;

    
    vll obj(r); REP(i,r) cin>>obj[i];
    REP(i,r) obj[i]--;
    REP(i,m){
        ll a,b,c;cin>>a>>b>>c;
        a--; b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
    REP(k,n){
        REP(i,n){
            REP(j,n) dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
        }
    }
    VSORT(obj);
    ll ans=inf;
    
    do {
        ll dis=0;
        REP(i,r-1) dis += dp[obj[i+1]][obj[i]];
        // cout<<dis<<endl;
        ans = min(dis, ans);  
    } while(next_permutation(ALL(obj)));

    cout<<ans<<endl;
    // cout<<dp[3][100]<<endl;
    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

ll dx[8] = {1, 1, 1, 1, -1, -1, -1, -1}, dy[8] = {1, 1, -1, -1, 1, 1, -1, -1}, dz[8] = {1, -1, 1, -1, 1, -1, 1, -1};

signed main(){
    int n,m;
    cin >> n >> m;
    ll x[n],y[n],z[n];
    REP(i,n){
        cin >> x[i] >> y[i] >> z[i];
    }
    ll ans = 0;
    ll sum[n] = {};
    REP(i,8){
        REP(j,n){
            sum[j] = x[j] * dx[i] + y[j] * dy[i] + z[j] * dz[i];
        }
        sort(sum, sum + n);
        reverse(sum, sum + n);
        ll tmp = 0;
        REP(j,m){
            tmp += sum[j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    LL ans = n*n;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2) cout << -1;
    else {
        k = (n - 1) * (n - 2) / 2 - k;
        cout << n - 1 + k << '\n';
        for (int i = 2; i <= n; i++) cout << 1 << ' ' << i << '\n';
        for (int i = 2; i <= n; i++) {
            for (int j = 2; j < i; j++) {
                cout << j << ' ' << i << '\n';
                k--;
                if (!k) break;
            }
            if (!k) break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N;

int main() {
	S(N);
	set<string> ss;
	string s = "";
	cin >> s;
	ss.insert(s);
	int ans = 1;
	for(int i = 1; i < N; i++) {
		string st = "";
		cin >> st;
		if (ss.count(st) == 0) {
			ss.insert(st);
			ans++;
		}
	}
	P(ans);
}
	

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t=1;
    //cin >> t;
    while (t--)
    {
        ll a,b;
        cin>>a>>b;
        
        cout<<a*b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b,c;cin >> a >> b >> c;
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define N (100010)
typedef long long LL;
int x[N],d[N];
int main(){
	int n,a,b;
	LL ans=0;
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++) scanf("%d",x+i);
	for (int i=2;i<=n;i++) d[i]=x[i]-x[i-1];
	std::sort(d+2,d+n+1);
	for (int i=n;i>1;i--){
		if (1ll*d[i]*a>1ll*b){
			ans+=b;
		}
		else {
			for (int j=2;j<=i;j++){
				ans+=1ll*a*d[j];
			}
			break;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
//00
#include<iostream>

using namespace std;

int dfs(int p,int q,int a,int n,int f,int l){
  if(p==0){
    return 1;
  }else if(n<1){
    return 0;
  }else{
    int c=0;
    for(int i=l;i*f<=a;i++){
      int np=p*i-q;
      int nq=q*i;
      if(np>=0){
	c+=dfs(np,nq,a,n-1,i*f,i);
      }
    }
    return c;
  }
}

int main(){
  for(int p,q,a,n;cin>>p>>q>>a>>n,p|q|a|n;){
    cout<<dfs(p,q,a,n,1,1)<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Coloring Colorfully
	var S string
	fmt.Scanf("%s", &S)

	var A, B string
	for i := 0; i < len(S); i++ {
		if i%2 == 0 {
			A += string('0')
			B += string('1')
		} else {
			A += string('1')
			B += string('0')
		}
	}

	var countA, countB int
	for i := 0; i < len(S); i++ {
		if A[i] != S[i] {
			countB++
		} else {
			countA++
		}
	}

	fmt.Println(math.Min(float64(countA), float64(countB)))
}


Measured memory_bytes: 8004
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	double PU[5];
	int P[5], key = 0, tmp = 10, D, sum = 0;
	for (int i = 0; i < 5; i++) {
		cin >> P[i];
		PU[i] = ceil((double)P[i] / 10) * 10;
		D = P[i] % 10;
		if (tmp > D && D != 0) {
			key = i;
			tmp = D;
		}
	}
	
	for (int i = 0; i < 5; i++) {
		if (i == key) {
			sum += P[i];
		}
		else {
			sum += PU[i];
		}
	}

	cout << sum;

	return 0;

}

Measured memory_bytes: 256
data = gets.split(" ")
limit = data[1].to_i
count = data[0].to_i

db=Array.new
count.times do |i|
    d = gets.split(" ")
    db.push(d)
end 

db = db.find_all {|item| item[1].to_i <= limit.to_i}
int = 10000
db.each do |d|
    i = d[0].to_i 
    if i < int 
        int = i 
    end 
end 
if int == 10000
    puts "TLE"
else 
    puts int 
end 

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vi a(n), x(n);
  REP(i, n) {
    cin >> a[i];
    x[i] = a[i];
  }
  sort(ALL(a));

  REP(i, n) {
    if (x[i] <= a[n / 2 - 1]) {
      cout << a[n / 2] << endl;

    } else {
      cout << a[n / 2 - 1] << endl;
    }
  }
}


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

using ll = long long;

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  bool multi = false;
  if (x == W / 2 && y == H / 2) multi = true;

  cout << fixed << setprecision(9) << W * H / 2 << " ";
  cout << defaultfloat << ((multi)? 1 : 0) << endl;
}


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

int main(){
  int N,x; cin >> N >> x;
  int a,b;
  cin >> a >> b;
  if(N==2){
    cout << max(a+b-x,0) << endl;
  }else{
    long long count=0;
    if(a>x){
      count+=(a+b-x);
      a=0;
    }else if(a+b>x){
      count+=(a+b-x);
      a=x-a;
    }else{
      a=b;
    }
    for(int i=0; i<N-2; i++){
      cin >> b;
      if(a+b>x){
        count+=(a+b-x);
        a=x-a;
      }else{
        a=b;
      }
    }
    cout << count << endl;
  }
}

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

int main() {
    int y,m,d;
    char slash;
    cin >> y >> slash >> m >> slash >> d;
    if(m <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;


int main(void){
    //入力
    int N, D;
    cin >> N >> D;
    //監視員は2D+1だけ監視する．
    if( N % (2*D + 1) == 0){
      cout << N / (2*D + 1) << endl;
    }
    else{
      cout << N / (2*D + 1) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

var N, K int

func main() {
  cur := 1
  fmt.Scanf("%d\n%d", &N, &K)

  for i := 0; i < N; i++ {
    if cur * 2 < cur + K {
      cur *= 2
    } else {
      cur += K
    }
  }

  fmt.Println(cur)
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int  n; VI a(3);
	cin >>n >>a[0] >>a[1] >>a[2];
	vector<string> s(n);
	rep(i, n) cin >>s[i];
	bool ok = 1;
	string ans;
	rep(i, n){
		int sm = a[0]+a[1]+a[2];
		if(sm <= 0){ ok=0; break;}
		int p1 = s[i][0]=='A'? 0: 1;
		int p2 = s[i][1]=='C'? 2: 1;
		if(a[p1]==0 && a[p2]==0){ ok=0; break;}
		
		if(sm ==1){
			if(a[p2]==0){a[p1]--; a[p2]++; ans += 'A'+p2;}
			else if(a[p1]==0){a[p2]--; a[p1]++; ans += 'A'+p1;}
		}else{
			if(a[p2]==0){a[p1]--; a[p2]++; ans += 'A'+p2;}
			else if(a[p1]==0){a[p2]--; a[p1]++; ans += 'A'+p1;}
			else if(a[p1]==1 && a[p2]==1 && i<n-1){
				int pp1 = s[i+1][0]=='A'? 0: 1;
				int pp2 = s[i+1][1]=='C'? 2: 1;
				auto q = a;
				q[p1]--; q[p2]++;
				if(q[pp1]==0 && q[pp2]==0){
					a[p1]++; a[p2]--; ans += 'A'+p1;
				}else{
					a[p1]--; a[p2]++; ans += 'A'+p2;
				}
				
			}else{
				if(a[p1]>=a[p2]){a[p1]--; a[p2]++; ans += 'A'+p2;}
				else{a[p1]++; a[p2]--; ans += 'A'+p1;}
			}
		}
		
	}
	if(ok){
		cout <<"Yes\n";
		for(auto z: ans) cout << z <<"\n";
	}else cout <<"No\n";
	return 0;
}


Measured memory_bytes: 6692
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C = map(int, readline().split())

print('YES' if A <= C <= A + B else 'NO')


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

int main(void)
{
    ll n,cnt=0;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];

    sort(all(l));
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(l[i]+l[j]>l[k] && l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]) cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <limits.h>
#include <ios>
using namespace std;
#define FOR(i,n) for(int i = 0; i < n; ++i)
typedef vector<long> vec;
int cnt = 0;

void Merge(vec& vA, int l, int m, int r){
	int d1 = m - l,
		d2 = r - m;
	vec vL(d1 + 1, 0);
	vec vR(d2 + 1, 0);
	int i, j, k;
	FOR(i, d1) vL[i] = vA[l + i];
	FOR(i, d2) vR[i] = vA[m + i];
	vL[d1] = LONG_MAX;
	vR[d2] = LONG_MAX;
	i = j = 0;
	for (k = l; k < r; ++k){
		++cnt;
		if (vL[i] <= vR[j]){
			vA[k] = vL[i];
			++i;
		}
		else{
			vA[k] = vR[j];
			++j;
		}
	}
}

void MergeSort(vec& vA, int l, int r){
	if (l >= r - 1)	return;
	int m = (l + r) / 2;
	MergeSort(vA, l, m);
	MergeSort(vA, m, r);
	Merge(vA, l, m, r);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vec vA(n, 0);
	FOR(i, n) cin >> vA[i];
	MergeSort(vA, 0, n);
	FOR(i, n){
		cout << vA[i];
		if (i != n - 1) cout << " ";
	}
	cout << "\n" << cnt << "\n";

	return 0;
}

Measured memory_bytes: 8876
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


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

    
  int ans = 0;  
  rep(num,1000){
    string temp = "";
    temp.push_back('0'+(num/100));
    temp.push_back('0'+((num/10)%10));
    temp.push_back('0' + (num%10));
    //cout << temp << endl;
    int ind = 0;
    int i = 0;
    while(ind < 3){
      if(i == s.size()) break;
      if(s[i]==temp[ind]){
        if(ind == 2) ans++;
        ind++;
      }
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Data.Array.IO

main = do
        n <- readLn
        nums <- map read.words<$>getLine
        arr <- newListArray (0,(n-1)) nums :: IO (IOArray Int Int)
        (arr, s) <- selectionSortCounted n arr
        getElems arr >>= putStrLn.unwords.map show
        print s

selectionSortCounted :: Int -> IOArray Int Int -> IO (IOArray Int Int, Int)
selectionSortCounted n arr = do
        swapped <- execStateT (countSwap 0) 0
        return (arr, swapped)
        where
            countSwap :: Int -> StateT Int IO ()
            countSwap i = if i >= n then return ()
                                    else do
                                        pos <- liftIO $ searchMinPos i n arr
                                        liftIO $ swap arr i pos
                                        if pos == i then countSwap (i+1)
                                                    else modify (+1) >> countSwap (i+1)

selectionSort n arr = do
        forM_ [0..(n-1)] $ \i ->do
            pos <- searchMinPos i n arr
            swap arr i pos
        return arr

swap arr x y = do
        v <- readArray arr x
        readArray arr y >>= writeArray arr x
        writeArray arr y v

searchMinPos :: Int -> Int -> IOArray Int Int -> IO Int
searchMinPos j n arr = evalStateT (func j) j
    where
        func :: Int -> StateT Int IO Int
        func count = if count >= n then get >>= return
                                   else do
                                       minj <- get
                                       ej <- liftIO $ readArray arr count
                                       eminj <- liftIO $ readArray arr minj
                                       if ej < eminj then put count >> func (count+1)
                                                     else func (count+1)

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

int main(){
  int X;
  cin>>X;
  int ans,yakusu;
  for(int i=X;i<=100003;i++){
    yakusu=0;
    for(int j=1;j<=i;j++){
      if(i%j==0){
        yakusu++;
      }
    }
    if(yakusu==2){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3576
from sys import stdin

h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [["" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]

lin = []

for i in li:
    lin.append(i)
    lin.append(i)

for i in lin:
    print("".join(i))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        
        if(a == b) {
            System.out.println("a == b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a < b");
        }
    }
}


Measured memory_bytes: 26208
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

typedef pair<double, int> pdi;
int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int n;
    double x, y, r;
    cin >> n;
    vector<vector<double>> pts;
    for(int i = 0; i < n; i++) {
        cin >> x >> y >> r;
        pts.push_back({x, y, r});
    }
    vector<vector<double>> mat(n+2, vector<double>(n+2, INT_MAX));
    for(int i = 0; i < n; i++) {
        for(int j = i; j < n; j++) {
            double xx = pts[i][0] - pts[j][0];
            double yy = pts[i][1] - pts[j][1];
            double dis = sqrt(xx*xx+yy*yy);
            mat[i][j] = mat[j][i] = max(dis - (pts[i][2]+pts[j][2]), 0.0);
        }
    }
    for(int i = 0; i < n; i++) {
        double xx = pts[i][0] - sx;
        double yy = pts[i][1] - sy;
        double dis = sqrt(xx*xx+yy*yy);
        mat[n][i] = mat[i][n] = max(dis - (pts[i][2]), 0.0);

        xx = pts[i][0] - tx;
        yy = pts[i][1] - ty;
        dis = sqrt(xx*xx+yy*yy);
        mat[n+1][i] = mat[i][n+1] = max(dis - (pts[i][2]), 0.0);
    }
    mat[n][n+1] = mat[n+1][n] = sqrt(pow(sx-tx, 2) + pow(sy-ty, 2));
    priority_queue<pdi, vector<pdi>, greater<pdi>> pq;
    pq.push({0.0, n});
    vector<int> visit(n+2, false);
    // dijkstra
    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        int node = p.second;
        if (visit[node] == true)
            continue;
        visit[node] = true;
        double cur_dis = p.first;
        if (node == n+1) {
            cout << fixed << setprecision(12) << cur_dis << endl;
            break;
        }
        for(int i = 0; i < n+2; i++) {
            if (visit[i] == true) continue;
            pq.push({cur_dis+mat[node][i], i});
        }
    }
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    ll K;
    cin >> N >> K;
    map<int, ll> A;
    rep(i, N){
        int a, b;
        cin >> a >> b;
        if(A.count(a)) A[a] += b;
        else A[a] = b;
    }

    ll ans_i = K; 
    for(auto i : A){
        if(ans_i <= i.second){
            cout << i.first << endl;
            break;
        }
        ans_i -= i.second;
    }
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

ll nCrNaive(const long long n, long long k) {
    if (n < 0) return 0;
    if (k < 0) return 0;
    ll ret = 1;
    k = min(k,n-k);
    for (int i = 0; i < k; i++) {
        ret *= (ll)n - (ll)i;
        ret /= ll(i+1);
    }
    return ret;
}

void solve(long long N, std::vector<long long> A){
    unordered_map<ll,ll> m;
    for (long long i = 0; i < N; i++) {
        m[A[i]]++;
    }
    // vout(m);
    // vector<int> cmb(m.size());
    // vector<int> cmb2(m.size());
    unordered_map<ll,ll> mcmb;
    // unordered_map<ll,ll> mcmb2;
    ll sum=0;
    for (auto& e: m) {
        if(e.second>=2){
            mcmb[e.first]=nCrNaive(e.second, 2);
        }
        sum+=mcmb[e.first];
    }
    // vout(mcmb);
    // debg(sum);
    for (long long i = 0; i < N; i++) {
        // cout << sum-mcmb[A[i]]+mcmb[A[i]]-(A[i]-1) << endl;
        cout << sum-(m[A[i]]-1) << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 16072
n, q = [int(elem) for elem in input().split()]
s = input()
new_s = [0]
num = 0
for st1, st2 in zip(s[:-1], s[1:]):
    if st1 == "A" and st2 == "C":
        num += 1
        new_s.append(num)
    else:
        new_s.append(num)

out = []
for i in range(0, q):
    l, r = [int(elem) for elem in input().split()]
    out.append(new_s[r-1] - new_s[l-1])  

for elem in out:
    print(elem)


Measured memory_bytes: 10292
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll c;
    cin >> c;
    ll n500 = c / 500;
    ll n5 = (c%500)/5;
    cout << n500*1000+n5*5 << endl;
 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0;
    cin>>n;
    string str;
    cin>>str;
    for(i=0;i<n;i++){
        if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,ans; char st[N];
int main()
{
	int i;
	scanf("%s",st+1);
	n = strlen(st+1);
	for(i=2;i<=n;i++)
		if(st[i]!=st[i-1]) ans++;
	cout<<ans;
	return 0;
}


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

using namespace std;

const int mod=2019;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int l, r;
	cin >> l >> r;
	int mini=1e9;
	int prvi=1e9;
	for(int i=l; i<r; i++){
		if(i-l==2019){
			break;
		}
		for(int j=i+1; j<=r; j++){
			if(prvi==(i%mod)*(j%mod)%mod){
				break;
			}
			if(j==i+1){
				prvi=(i%mod)*(j%mod)%mod;
			}
			mini=min(mini, (i%mod)*(j%mod)%mod);
		}
	}
	cout << mini << '\n';
	return 0;
}

Measured memory_bytes: 256
high_water_marks = {}
areas = []

depth = 0
offset = 0
for i in input():
  if i == "/":
    depth -= 1
    if depth in high_water_marks:
      hwm = high_water_marks[depth]
      new_area = [hwm, offset - hwm]
      while len(areas) > 0 and areas[-1][0] > hwm:
        a = areas.pop()
        new_area[1] += a[1]
      areas.append(new_area)
  elif i == "_":
    pass
  else:
    high_water_marks[depth] = offset
    depth += 1

  offset += 1

total = 0
for a in areas: total += a[1]
print(total)
sizes = [a[1] for a in areas]
sizes.insert(0, len(areas))
print(" ".join(map(str, sizes)))

Measured memory_bytes: 9464
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

string a,b,c;

int main(){
    cin>>a>>b>>c;
    printf("%c%c%c\n",toupper(a[0]),toupper(b[0]),toupper(c[0]));
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=3e3+5;
vector<int> v[N],e[N];
int sg[N],vis[N],a[N],deg[N],q[N];
int main(){
	ri n,i,x,y,l,r;
	gi(n);
	for(i=1;i<=n;++i) gi(a[i]);
	for(i=1;i^n;++i){
		gi(x);gi(y);
		if(a[x]==a[y]) continue;
		if(a[x]<a[y]) swap(x,y);
		v[x].push_back(y);
	//	printf("add %d %d\n",x,y);
		++deg[x];
		e[y].push_back(x); 
	}
	l=1;r=0;
	for(i=1;i<=n;++i)
		if(!deg[i])
			q[++r]=i;
	while(l<=r){
		x=q[l++];
		for(int y:v[x])
			vis[sg[y]]=1;
		while(vis[sg[x]]) ++sg[x];
		for(int y:v[x])
			vis[sg[y]]=0;
	//	printf("sg %d %d\n",x,sg[x]);
		for(int y:e[x])
			if(!--deg[y])
				q[++r]=y; 
	}
	for(i=1;i<=n;++i)
		if(sg[i]) print(i),putc(' ');
	putc('\n'); 
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

void solution() {
  int n, m;
  cin >> n >> m;
  vector<int> g[n + 1];
  vector<bool> vis(n + 1, false);
  vector<int> ans(n + 1, -1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int count = 0;
  queue<int> q;
  q.push(1);
  vis[1] = true;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    count++;
    for (int v : g[cur]) {
      if (vis[v]) continue;
      vis[v] = true;
      ans[v] = cur;
      q.push(v);
    }
  }
  if (count != n)
    cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) cout << ans[i] << endl;
  }
}

int32_t main() {
  DESYNC;
  solution();
}


Measured memory_bytes: 12992
#include <stdio.h>

int main( void )
{
    long a,b,r,t,x,y;
    
    while( scanf("%ld %ld",&a,&b ) != EOF )
    {
        x = a;
        y = b;
        if( a < b ){
        	t = b;
        	b = a;
        	a = t;
		}
        r = a % b;
		while(r != 0){
            a = b;
            b = r;
            r = a % b;
		}
        printf("%ld %ld\n",b, x/b*y);
    }
    return 0;
}

Measured memory_bytes: 1744
from sys import stdin
N, H = [int(_) for _ in stdin.readline().rstrip().split()]
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
B.sort(reverse=True)
ans = 0
for b in B:
    if b <= A[-1] or H <= 0:
        break
    H -= b
    ans += 1
print(ans + max(0, (H-1)//A[-1]+1))

Measured memory_bytes: 11312
import std.stdio;
import std.algorithm;
import std.range;
import std.string;
import std.conv;

void main()
{
	int N = readln.chomp.to!int;
	auto L = readln.chomp.split(' ').map!(s => s.to!int).array;
	L.sort();
	int result;
	foreach(i; 0 .. N)
	{
		result += min(L[i*2],L[i*2+1]);
	}
	writeln(result);
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl l;
/******* define variable end *******/
int solve() {
	cin >> n;
	l.resize(n);
	REP(i, n){
		cin >> l[i];
	}
	sort(ALL(l));
	ll ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			auto ite = upper_bound(l.begin() + j + 1, l.end(), abs(l[i]-l[j]));
			auto ite2 = lower_bound(l.begin() + j + 1, l.end(), l[i]+l[j]);
			ans += ite2 - ite;
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3616