akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

input = sys.stdin.readline

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return tuple(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, Q, STX, D):
    E = []
    for i, (s, t, x) in enumerate(STX):
        E.append((s-x, 1, x, i))
        E.append((t-x, -1, x, i))

    E.sort(reverse=True)

    q = []
    done = set()
    D = [(i, d) for i, d in enumerate(D)]
    D.sort(reverse=True)
    ans = [-1] * Q
    while D:
        while E and E[-1][0] <= D[-1][1]:
            t, e, x, i = E.pop()
            if e == 1:
                heapq.heappush(q, (x, i))
            else:
                done.add((x, i))

        while q and q[0] in done:
            heapq.heappop(q)

        i, d = D.pop()
        if q:
            ans[i] = q[0][0]

    for i in range(Q):
        print(ans[i])


def main():
    N, Q = read_int_n()
    STX = tuple(read_int_n() for _ in range(N))
    D = tuple(read_int() for _ in range(Q))
    (slv(N, Q, STX, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 148992
from itertools import permutations
n = int(input())
p = tuple(input().split())
q = tuple(input().split())

# print(p)
# print(q)

l = [str(i+1) for i in range(n)]

cnt = 1
for v in permutations(l,n):
    if p == v:
        a = cnt
    if q == v:
        b = cnt
    cnt += 1
print(abs(a-b))

Measured memory_bytes: 73516
include Math

# http://www.h6.dion.ne.jp/~jpe02_tn/ki-5.html
def get_center(x1, y1, x2, y2, x3, y3)
  a1 = 2*(x2 - x1)
  b1 = 2*(y2 - y1)
  c1 = x1**2 - x2**2 + y1**2 - y2**2
  a2 = 2*(x3 - x1)
  b2 = 2*(y3 - y1)
  c2 = x1**2 - x3**2 + y1**2 - y3**2
  x = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
  y = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
  return x, y
end

def get_length(x1, y1, x2, y2, x3, y3)
  a = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))
  b = sqrt((x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3))
  c = sqrt((x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1))
  return a, b, c
end

def get_radius(x1, y1, x2, y2, x3, y3)
  a, b, c = get_length(x1, y1, x2, y2, x3, y3)
  s = (a + b + c)/2.0
  area = sqrt(s*(s-a)*(s-b)*(s-c))
  (a*b*c)/(4.0*area)
end

n = gets.to_i
n.times do
  x1, y1, x2, y2, x3, y3 = gets.split(/\s/).map(&:to_f)
  r = get_radius(x1, y1, x2, y2, x3, y3)
  cx, cy = get_center(x1, y1, x2, y2, x3, y3)
  puts sprintf('%.3f %.3f %.3f', cx, cy ,r)
end

Measured memory_bytes: 6188
def main():
    A,B,C = tuple(int(c) for c in input().split())
    K = int(input())

    #Cをi回、Bをj回倍にする
    for i in range(K+1):
        c2 = C * 2**i
        for j in range(K-i+1):
            #print(i, j)
            b2 = B * 2**j
            if c2 > b2 > A:
                print('Yes')
                exit()
    else:
        print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

void dfs(int x, int y) {}

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000005;
using namespace std;
int main(){

    long long x, y; cin >> x >> y;
    long long ans = 1;
    while( (x*2LL) <= y ){
        ans++;
        x*=2LL;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;
static const ll MOD = 1000000007;

int N, R;
int a[MAX_N];
ll fact[MAX_N];

int bit[MAX_N + 1];
void add(int pos, int num){
	for(int i = pos; i <= N; i += (i & -i)) bit[i] += num;
}
int sum(int pos){
	int res = 0;
	for(int i = pos; i > 0; i -= (i & -i)) res += bit[i];
	return res;
}

int main(){
	for(int i = 0; i < MAX_N; i++){
		if(i == 0) fact[i] = 1;
		else fact[i] = i * fact[i - 1];
		fact[i] %= MOD;
	}
	for(;;){
		scanf("%d", &N);
		if(N == 0) break;
		for(int i = 0; i <= N; i++) bit[i] = 0;
		for(int i = 0; i < N; i++) a[i] = i + 1;
		scanf("%d", &R);
		for(int i = 0; i < R; i++){
			int s, t;
			scanf("%d %d", &s, &t);
			s--;
			t--;
			swap(a[s], a[t]);
		}
		ll res = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--){
			res += (ll)sum(a[i]) * fact[cnt];
			res %= MOD;
			add(a[i], 1);
			cnt++;
		}
		printf("%lld\n", res);
	}
	return 0;
}



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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

int dp[3013][3013];

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    string s;
    cin >> n >> s;
    dp[0][1]=1;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=i+1;j++)
        {
            if(s[i-1]=='<')
                dp[i][j]=dp[i-1][j-1];
            else
                dp[i][j]=(dp[i-1][i]-dp[i-1][j-1]+mod)%mod;
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
    cout << dp[n-1][n];
    return 0;
}


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

int main() {
    int H, A;
    cin >> H >> A;
    cout << H/A + bool(H%A) << endl;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
input = sys.stdin.readline

n = int(input())
p = list(map(int,input().split()))


result = 0
l = len(p)
for i in range(1, l-1):
    # i-1, i, i+1を取り出す
    li = p[i-1:i+2]
    # iを記憶してソートする
    c = li[1]
    li = sorted(li)
    # 2番目の要素が記憶した要素と一致しているならカウンタを進める
    if c == li[1]:
        result += 1
    
# カウンタの数値を出力する
print(result)

Measured memory_bytes: 39888
#!/usr/local/bin/ruby
i=gets.split

a=i[0].to_i
b=i[1].to_i
c=i[2].to_i

if a>b
   x=a
   a=b
   b=x
end

if b>c
   x=b
   b=c
   c=x
end

if a>b
   x=a
   a=b
   b=x
end

printf("%d %d %d\n",a,b,c)

Measured memory_bytes: 6108
#include<stdio.h>
#define N 100
#define INF 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n, w[N][N], d[N];
void sss(void);

int main() {
  int i, j, u, c, v, k;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      w[i][j] = INF;
    }
  }

  for (i = 0; i < n; i++) {
    scanf("%d%d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d%d", &v, &c);
      w[u][v] = c;
    }
  }

  sss();
  
  for (i = 0; i < n; i++) 
    printf("%d %d\n", i, d[i]);

  return 0;
}
void sss(void) {
  int i, j, u, minCost, color[N];
  
  for (i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  color[0] = GRAY;

  while (1) {
    minCost = INF;
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < minCost) {
	minCost = d[i];
	u = i;
      }
    }

    if (minCost == INF) break;
    color[u] = BLACK;

    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && w[u][i] != INF) {
	if (d[u] + w[u][i] < d[i]) {
	  d[i] = d[u] + w[u][i];
	  color[i] = GRAY;
	}
      }
    }
  }
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N, W;
    cin >> N >> W;
    vector<lint> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    // 状態 (i,j) : a[0]~a[i-1] から選んだ時 v の総和が j である
    // mi(i,j) : 状態 (i,j) でのwの総和の最小値
    vector<vector<lint>> mi(N + 1, vector<lint>(1e5 + 100, LINF));
    mi[0][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= 1e5; j++) {
            if (mi[i - 1][j] != LINF) mi[i][j] = mi[i - 1][j];
            if (j - v[i - 1] >= 0 and mi[i - 1][j - v[i - 1]] != LINF) {
                mi[i][j] = min(mi[i][j], mi[i - 1][j - v[i - 1]] + w[i - 1]);
            }
        }
    }

    lint ans = -1;
    for (lint j = 0; j <= 1e5; j++) {
        if (mi[N][j] <= W) { ans = max(ans, j); }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 83260
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if s[0] == s[1] && s[1] == s[2] && s[0] == s[2] || s[1] == s[2] && s[2] == s[3] && s[1] == s[3] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    A--;
    ll div = C / gcd(C, D) * D;
    ll numB = B - ( (B / C) + (B / D) - (B/div) );
    ll numA = A - ( (A / C) + (A / D) - (A/div) );
    cout << numB - numA << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string a;
	string b;
	string ans;
	cin >> a >> b;
	int as = a.l_ength();
	int bs = b.l_ength();
	for( int i = 0; i < bs; ++i ){
		ans += a[i];
		ans += b[i];
	}
	if( as - bs == 1 ){
		ans += a[as-1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#abc092b

n=int(raw_input())
d,x=map(int,raw_input().split())
a=[]
for i in xrange(n):
 a.append(int(raw_input()))
s=[]
for i in xrange(n):
 y=d/a[i]+1
 if d%a[i]==0:
  y-=1
 s.append(y)
res=sum(s)+x
print res


Measured memory_bytes: 2696
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  string s; cin >>s;
  int n=s.size();
  int ans=0;
  rep(i,n){
    if(s.at(i)!=s.at(n-i-1)) ans++;
  }
  printf("%d",ans/2);
}

/// confirm df==0 ///


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $a);
$datas = explode(' ',trim(fgets(STDIN)));

$count = 0;

for ($i = 0; $i < count($datas); $i++) {
  for($j = $i+1; $j < count($datas); $j++) {
    $count += $datas[$i] * $datas[$j];
  }
}
      
echo $count;

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll unsigned long long int

int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		long double a, b;
		cin>>a>>b;
		long double ans = a*b;
		long double one = 1.0;
		ll finalAns = ans;
		cout<<finalAns<<"\n";
	}
}

Measured memory_bytes: 3732
import itertools
n, m, x = map(int, input().split())
lst = []

for i in range(n):
    lst.append([int(i) for i in input().split()])

ans_list = []

for i in range(1, n + 1):
    for j in itertools.combinations(lst, i):
        under_list = [0] * m
        money = 0
        for k in j:
            money += k[0]
            for i in range(m):
                under_list[i] += k[i + 1]
        if all([i >= x for i in under_list]):
            ans_list.append(money)

if not ans_list:
    ans = -1
else:
    ans = min(ans_list)

print(ans)


Measured memory_bytes: 9324
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var K = int.Parse(Console.ReadLine());
            var c = S[K - 1];
            string ret = string.Empty;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == c)
                {
                    ret += c;
                }
                else
                {
                    ret += "*";
                }
            }

            Console.WriteLine(ret);
        }
    }
}

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

int main() {
  int A,B;
  cin >>A >>B;
  if(A==2){
    cout <<"No" <<endl;
    return 0;
  }
  else{
    if(B==2){
      cout <<"No" <<endl;
      return 0;
    }
  }
  cout <<"Yes" <<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int D = 8;
    int n, m;
    cin >> n >> m;
    // 0 +++ 1 ++- 2 +-+ 3 +-- 4 -++ 5 -+- 6 --+ 7 ---
    vector<vector<ll>> dsum(D);
    REP(i,n) {
        ll x, y, z;
        cin >> x >> y >> z;
        REP(j,D) {
            ll x2 = ((j & 1) == 1) ? -x : x;
            ll y2 = ((j & 2) == 2) ? -y : y;
            ll z2 = ((j & 4) == 4) ? -z : z;
            dsum[j].push_back(x2 + y2 + z2);
        }
    }
    REP(i,D) sort(RALL(dsum[i]));

    ll ans = 0;
    REP(i,D) {
        ll tmp = 0;
        REP(j,m) tmp += dsum[i][j];
        ans = max(ans,tmp);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
int a,b,cnt=1;
int main()
{
	fast();
	cin>>a>>b;
	cout<<(b-1)/(a-1)+((b-1)%(a-1)!=0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
double x[20];
string s[20];
void solve(){
	cin >> n;
	double ans = 0;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> s[i];
		if(s[i] == "JPY") ans += x[i];
		else ans += x[i]*380000;
	}
	printf("%.10f\n", ans);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

#define FOR(i, m, n) for (int i = m; i <= n; ++i)

int main() {
  int A, B;
  cin >> A >> B;
  int cnt;
  FOR(i,A,B) {
    int s = i % 10, t = i / 10000;
    int u = i / 10 % 10, v = i / 1000 % 10;
    if ( s == t && u == v ) ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static long cnt(long n) {
		long count = 0;
		if(n %2 == 0) {
			long k = 10;
			
			while(k <= n) {
				count += n/k;
				k *= 5;
			}
		}
		
		return count;
		
		
		
	}



	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long  n = stdIn.nextLong();

		long a = cnt(n);
		
		System.out.println(a);

	}

}


Measured memory_bytes: 21844
/*******************************
* BASMILLAHHIR RAHMANNIR RAHIM *
* MD SHAHINUR RAHMAN           *
* DATE: 26/sep/2020            *
* DEPT. OF CSE                 *
* LEADING UNIVERSITY, SYLHET   *
*******************************/
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<math.h>
#define shahin std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax=1000*1007;
const int mod = 1e9 + 7;
 
using namespace std;
char wcz[nax];
 
bool fu(int a, int b){
    return (a>b);
}
int gcd(int x,int y){
    return x?gcd(y%x, x):y;
}
 
void fun(){
    
   ll n;
   cin >> n;
   for(int i=0;i<n;i++){
                   cout << "ACL";
   }
   
}
   
   
int main()
{
    shahin
  /*  ll tc,i=1,sum=0,A=0,B=0;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/  
   fun();
   
}

Measured memory_bytes: 3588
#include <stdio.h>
int main() {
	char str[3][101], next;
	unsigned char p;
	int th[3] = { 0 };
	for (int i = 0;i < 3;i++) {
		scanf("%s", str[i], 100);
	}
	next = str[0][th[0]++]; 
	while (next != '\0') {
		p = next - 'a';
		next = str[p][th[p]++];
	}
	printf("%c\n", p + 'A');
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1 + 1e5;
typedef long long LL;
typedef pair < int, int > II;
typedef pair < int, II > III;

long long r;

int main()
{
    #define TASK "ABC"
  //  freopen(TASK".inp","r",stdin);
  //  freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> r;
    cout << LL(r * r);

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main () {

 int N;
 int vet[100];
 int a,b;

 scanf("%d", &N);

 if (N==2){
   scanf("%d%d",&a,&b);
   printf("%d\n", a*b);
 }
 if (N != 2) {
   a= ( N*(N-1) )/2;
   b=0;
   for( int i=0; i<N; i++) {
     scanf("%d", &vet[i]);
   }

   for(int k=0; k < N ;k++){
     for(int j=k+1; j< N ;j++) {
        b += vet[k]*vet[j];
     }
   }
   printf("%d\n",b);
 }


  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
using namespace std;
#define pi acos(-1.0)

int main()
{

ll n;
cin>>n;
if(n%1000==0)
cout<<"0\n";
else
{
	ll d= n/1000;
	
	ll c= (d+1)*1000-n;
	
	cout<<c<<endl;
}

return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans;
		if (a >= 0 && b >= 0) {
			if (b >= a) {
				ans = b - a;
			} else {
				ans = a - b + 2;
				if (b == 0) {
					ans--;
				}
			}
		} else if (a < 0 && b > 0) {
			if (b >= -a) {
				ans = b + a + 1;
			} else {
				ans = -(b + a) + 1;
			}
		} else if (a < 0 && b == 0) {
			ans = -a;
		} else if (a >= 0 && b < 0) {
			if (-b >= a) {
				ans = -b - a + 1;
			} else {
				ans = a + b + 1;
			}
		} else {
			if (-b > -a) {
				ans = - b + a + 2;
			} else {
				ans = b - a;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
n = int(input())
hhh = list(map(int, input().split()))
ans = 0

while any(hhh):
    watering = False

    for i in range(n):
        if hhh[i] == 0:
            watering = False
        else:
            hhh[i] -= 1
            if not watering:
                watering = True
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;



int main(){
    string S;
    cin >> S;
    int N = S.size();
    int atA;
    int atZ;
    for(int i = 0;i<N-1;i++){
        if(S.at(i) == 'A'){
            atA = i;
            break;
        }
    }
    for(int j=S.size()-1;j>0;j--){
        if(S.at(j) == 'Z'){
            atZ = j;
            break;
        }
    }
    cout << atZ - atA + 1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n, m,hi,lo;
string s;

int main() {
	cin >> n;
	hi = n / 100;
	lo = n % 100;
	if (hi>0&&hi<13)
	{
		hi = 1;
	}
	else { hi = 0; }
	if (lo > 0 && lo < 13)
	{
		lo = 1;
	}
	else { lo = 0; }
	if (hi&&lo)
	{
		cout << "AMBIGUOUS"<<endl;
	}
	else if (hi == 1 && lo == 0) {
		cout << "MMYY" << endl;
	}
	else if (hi == 0 && lo == 1) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA"<<endl;
	}
}

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

using namespace std ;

#define l first
#define r second

const int M = 40 ;
const int N = 1200010 ;
const int MAX = 1001000001 ;

int dep ;
int maxn ;
int ans[N] ;
int n, m, k ;
int base[N] ;
int L[M][N] ;
int R[M][N] ;
int farfrl[N] ;
int farfrr[N] ;
pair<int, int> rg[N] ;

void Init_dp(){
    for (int j = m ; j >= 0 ; j >>= 1){
        R[++ dep][n + 1] = n + 1 ;
        for (int i = 1 ; i <= n ; ++ i)
            L[dep][i] = (base[i] - base[i - 1] > j) ? i : L[dep][i - 1] ;
        for (int i = n ; i >= 1 ; -- i)
            R[dep][i] = (base[i + 1] - base[i] > j) ? i : R[dep][i + 1] ;
        if (!j) break ;
    }
    return ;
}
void Auxiliary_dp(){
    for (int i = 0 ; i <= maxn ; i += 2)
        for (int j = 1 ; j <= dep ; ++ j)
            if (1 << (j - 1) & i){
                farfrl[i] = max(farfrl[i], R[j][ farfrl[i ^ (1 << (j - 1))] + 1]) ;
                farfrr[i] = min(farfrr[i], L[j][ farfrr[i ^ (1 << (j - 1))] - 1]) ;
            }
    return ;
}
int main(){
    cin >> n >> m ;
    base[0] = -MAX ;
    base[n + 1] = MAX ; k = -1 ;
    for (int i = 1 ; i <= n ; ++ i)
        scanf("%d", &base[i]) ; Init_dp() ;
    for (int i = 1 ; i <= n ; ++ i)
        rg[i].l = L[1][i], rg[i].r = R[1][i] ;
    sort(rg + 1, rg + n + 1) ; maxn = (1 << dep) - 1 ;
    for (int i = 0 ; i <= maxn ; ++ i) farfrr[i] = n + 1 ;
    k += unique(rg + 1, rg + n + 1) - rg ; Auxiliary_dp() ;
    for (int i = 1 ; i <= k ; ++ i)
        for (int j = 0 ; j <= maxn ; j += 2)
            if (farfrl[j] + 1 >= rg[i].l && farfrr[(maxn ^ j) ^ 1] - 1 <= rg[i].r)
                { for (int o = rg[i].l ; o <= rg[i].r ; ++ o) ans[o] = 1 ; break ; }
    for (int i = 1 ; i <= n ; ++ i) puts(ans[i] ? "Possible" : "Impossible") ; return 0 ;
}
/*
0 8
0 8
1 7
0 8
1 7
0 8
2 6
0 8
*/


Measured memory_bytes: 127360
#include <iostream>
#include <vector>
#define SIZE 100001
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	ll sum = 0;
	vector<ll> num(SIZE);
	for(int i=0,cur;i<n;i++){
		cin>>cur; num[cur]++; sum += cur;
	}
	int q; cin>>q;
	while(q--){
		int b,c; cin>>b>>c;
		sum += (num[b] * (c - b));
		num[c] += num[b];
		num[b] = 0;
		cout<<sum<<'\n';
	}
}

Measured memory_bytes: 3992
(defun solve (s)
  (let ((r (count #\R s))
        (b (count #\B s)))
    (if (> r b)
        "Yes"
        "No")))

(defun main ()
  (read)
  (let ((s (read-line)))
    (format t "~A~%" (solve s))))

(main)


Measured memory_bytes: 11492
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI 3.141592654
#define e exp(1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void fast(){

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

#ifdef ONLINE_JUDGE
	//freopen("alice.in ", "r", stdin);

	//freopen("little.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);

	// freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		ll k;
	cin >> k;
	ll even = k / 2,odd =k-even;
	cout << even*odd << finl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,tem=0,num=0;
  cin>>n;
  int a[n],c[n]={};
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  while(1){
    c[tem]++;
    if(c[tem]==2){
      cout<<"-1";
      return 0;
    }
    tem = a[tem]-1;
    num++;
    if(tem==1){
      cout<<num;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input! {
        a: i32,
        b: usize,
        mut c: [i32; a],
    }
    c.sort();

    let mut sum:i32=0;
    for i in 0..b {
        sum += c[i];
    }
    println!("{:?}", sum);

}


Measured memory_bytes: 2196
#include<stdio.h>
int main(void)
{
	int n,m,c;
	scanf("%d",&n);
	while(n!=0){
		c=0; m=n;
		while(m!=1){
			if(m%2==0) m=m/2;
			else m=m*3+1; c++;
		}
		printf("%d\n",c);
		scanf("%d",&n);
	}
	return 0;
}	

Measured memory_bytes: 2728
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		int[,] A = new int[H,W];
		for(var i=0;i<H;i++){
			string str2 = Console.ReadLine();
			for(var j=0;j<W;j++){
				if(str2.Substring(j,1)=="#"){
					A[i,j] = 1;
				}
			}
		}
		int[,] D1 = new int[H+600,W+600];
		for(var i=0;i<H+W;i++){
			int sum = 0;
			for(var j=0;j<=i+300;j++){
				if(i-j>=0 && i-j<H && j>=0 && j<W){
					if(A[i-j,j] == 1){
						sum += 1;
					}
				}
				if(i-j>=H+300 || j>=W+300){
					break;
				}
				D1[i-j+300,j+300] = sum;
			}
		}
		int[,] D2 = new int[H+600,W+600];
		for(var i=0;i<H+W;i++){
			int sum = 0;
			for(var j=0;j<=i+300;j++){
				if(j>=0 && j<H && W-1-i+j>=0 && W-1-i+j<W){
					if(A[j,W-1-i+j] == 1){
						sum += 1;
					}
				}
				if(j>=H+300 || W-1-i+j >= W+300){
					break;
				}
				D2[j+300,W-1-i+j+300] = sum;
			}
		}
		for(var i=0;i<H+600;i++){
			string str5 = "";
			for(var j=0;j<W+600;j++){
				str5 += D2[i,j] + " ";
			}
			//Console.WriteLine(str5);
		}
		int ans = 0;
		for(var i=0;i<H;i++){
			for(var j=0;j<W;j++){
				int m = Math.Min(Math.Max(H-1,W-1),Math.Max(Math.Max(i,H-1-i),Math.Max(j,W-1-j)));
				for(var k=1;k<=m;k++){
					if(i-k>=0 && A[i-k,j] == 1 && i+k<H && A[i+k,j] == 1){
						if(j-k>=0 && A[i,j-k] == 1){
							ans += 1;
						}
						if(j+k<W && A[i,j+k] == 1){
							ans += 1;
						}
					}
					if(j-k>=0 && A[i,j-k] == 1 && j+k<W && A[i,j+k] == 1){
						if(i-k>=0 && A[i-k,j] == 1){
							ans += 1;
						}
						if(i+k<H && A[i+k,j] == 1){
							ans += 1;
						}
					}
					if(i-k>=0 && A[i-k,j] == 1 && j-k>=0 && A[i,j-k] == 1){
						ans += Math.Abs(D1[i+k+300,j+300] - D1[i+1+300,j+k-1+300]);
						//for(var l=1;l<k;l++){
						//	if(i+k-l<H && j+l<W && A[i+k-l,j+l] == 1){
						//		ans += 1;
						//	}
						//}
					}
					if(j-k>=0 && A[i,j-k] == 1 && i+k<H && A[i+k,j] == 1){
						ans += Math.Abs(D2[i-k+300,j+300] - D2[i-1+300,j+k-1+300]);
						//for(var l=1;l<k;l++){
						//	if(i-k+l>=0 && j+l<W && A[i-k+l,j+l] == 1){
						//		ans += 1;
						//	}
						//}
					}
					if(i+k<H && A[i+k,j] == 1 && j+k<W && A[i,j+k] == 1){
						ans += Math.Abs(D1[i+300,j-k+300] - D1[i-k+1+300,j-1+300]);
						//for(var l=1;l<k;l++){
						//	if(i-k+l>=0 && j-l>=0 && A[i-k+l,j-l] == 1){
						//		ans += 1;
						//	}
						//}
					}
					if(j+k<W && A[i,j+k] == 1 && i-k>=0 && A[i-k,j] == 1){
						ans += Math.Abs(D2[i+300,j-k+300] - D2[i+k-1+300,j-1+300]);
						//for(var l=1;l<k;l++){
						//	if(i+k-l<H && j-l>=0 && A[i+k-l,j-l] == 1){
						//		ans += 1;
						//	}
						//}
					}
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 22668
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int N, X[100];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> X[i];

  int minv = 10000000;
  for (int i = 0; i < 100; i++) {
    int SUM = 0;
    for (int j = 0; j < N; j++) {
      SUM += pow((X[j] - i), 2.0);
    }
    minv = min(minv, SUM);
  }

  cout << minv << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

//D
int main(){
ll N; cin>>N;
cout<<N*(N-1)/2<<endl;

    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		char al;
		if(a.length() == 1){
			al = a.charAt(0);
		}else{
			al = a.charAt(a.length()-1);
		}

		char bl = b.charAt(0);
		char cl = c.charAt(0);

		if(al == bl){
			if(b.length() != 1){
				bl = b.charAt(b.length()-1);
			}
			if(bl == cl){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21972
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];

    ll sum=0;
    for(int i=0;i<n;i++) sum += a[i];
    ll k;
    if(sum%((n*(n+1)/2))==0)
        k= sum / (n*(n+1)/2);
    else {
        cout << "NO" << endl;
        return 0;
    }
    bool flag = true;
    vector<ll> d(n);
    d[0] = a[0] - a[a.size()-1];
    for(int i=1;i<n;i++) {
        d[i] = a[i] - a[i-1];
        if(k < d[i])
            flag = false;
        if((-(d[i]-k))%n!=0)
            flag = false;
        if(!flag) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1792
import sys
N = int(input().strip())
D = list(map(int, input().strip().split(" ")))
print(N, len(D), file=sys.stderr)

import collections
Dd = collections.defaultdict(int)
for d in D:
    Dd[d] += 1

M = int(input().strip())
T = list(map(int, input().strip().split(" ")))
print(M, len(T), file=sys.stderr)
Td = collections.defaultdict(int)
for t in T:
    Td[t] += 1

for k,v in Td.items():
    if Dd[k] < v:
        print("NO")
        exit(0)
print("YES")
exit(0)


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

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


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

ll n,k;
ll a[100100];
ll dig[50];
int main(){
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		ll t=1;
		for(ll j=0;j<50;j++){
			dig[j]+=(a[i]/t)%2;
			t*=2;
		}
	}
	ll t=0;
	//for(ll j=49;j>=0;j--)cout<<dig[j]<<endl;
	ll now=pow(2,50);
	for(ll i=49;i>=0;i--){
		now=now/2;
		if(t+now>k)continue;
		if(dig[i]<=(n-1)/2)t+=now;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans+=a[i]^t;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main(){
	ll n; cin >> n;
	ll t[n], a[n];
	for(int i = 0; i < n; ++i) cin >> t[i];
	for(int i = 0; i < n; ++i) cin >> a[i];
	vector<pair<ll, bool> > po(n, pair<ll, bool>(1145148931919810, 0));
	ll maxv = t[0];
	po[0] = pair<ll, bool>(t[0], 1);
	for(int i = 1; i < n; ++i){
		if(t[i] > maxv){
			maxv = t[i];
			po[i] = pair<ll, bool>(t[i], 1);
		}else{
			po[i] = pair<ll, bool>(maxv, 0);
		}
	}
	if(po[n - 1].first != a[n - 1] && po[n - 1].second){
		cout << 0 << endl;
		return 0;
	}else{
		po[n - 1] = pair<ll, bool>(a[n - 1], 1);
	}
	maxv = a[n - 1];
	for(int i = n - 2; i >= 0; --i){
		if(a[i] > maxv){
			if(po[i].first != a[i] && po[i].second){
				cout << 0 << endl;
				return 0;
			}
			po[i] = pair<ll, bool>(a[i], 1);
			maxv = a[i];
		}else{
			if(po[i].second && po[i].first > maxv){
				cout << 0 << endl;
				return 0;
			}else{
				if(!po[i].second) po[i].first = min<ll>(po[i].first, a[i]);
			}
		}
	}
	ll ans = 1;
	ll mod = 1e9 + 7;
	for(int i = 0; i < n; ++i){
		if(!po[i].second){
			ans *= po[i].first;
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
string s;
int n;
map<string,int> h[19];
int main(){
    cin>>n>>s;
    for(int i=0;i<(1<<n);i++){
        string cur=""; int cnt=0;
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==0){
                cur += s[j]; cnt++;
            }
        }
        for(int j=0;j<n;j++){
            if((i>>j)&1) cur+=s[j];
        }
        h[cnt][cur]++;
    }
    reverse(s.begin(),s.end());
    ll ans =0;
    for(int i=0;i<(1<<n);i++){
        string cur="";int cnt=0;
        for(int j=0;j<n;j++){
            if(((i>>j)&1)){
                cnt++; cur+=s[j];
            }
        }
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==0) cur+=s[j];
        }
        ans+=h[cnt][cur];
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 73984
s = input()
k = int(input())
flag = 1
cnt = 1
ans = 0
a1 = 0
a2 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        flag += 1
if flag == len(s):
    print(len(s) * k // 2)
    exit()

for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        cnt += 1
    else:
        a1 += cnt // 2
        cnt = 1
a1 += (cnt // 2)
cnt = 1

s2 = s + s
for i in range(1, len(s2)):
    if s2[i] == s2[i - 1]:
        cnt += 1
    else:
        a2 += cnt // 2
        cnt = 1
a2 += (cnt // 2)
r = a2 - a1
print(a1 + (k - 1) * r)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	pair<long long, long long> R[100010] = {}; 
	for(int i = 0; i < N; i++){
		long long x, l; cin >> x >> l; 
		R[i].first = x + l; R[i].second = x - l; 
	}
	sort(R, R+N); 
	int ans = 0; 
	long long r = -2000000007; 
	for(int i = 0; i < N; i++){
		if(R[i].second >= r){
			ans ++; 
			r = R[i].first; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << a / b<<endl;
	cout << a%b<<endl;
	double c, d;
	c = a;
	d = b;
	cout << fixed<<c / d << endl;
	int q; cin >> q;
}


Measured memory_bytes: 3284
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;
ll f[N],g[N];
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll inv(ll a)
{
    return pows(a,mod-2)%mod;
}
int C(int i,int m) {
    memset(f,0,sizeof f);
    memset(g,0,sizeof g);
    g[0]=i+1; f[1]=i+1;
    for(int k=2;k<=m+1;k++) f[k]=f[k-1]*(i+k)%mod*inv(k)%mod;
    for(int j=1;j<=m;j++) g[j]=(g[j-1]+f[j+1])%mod;
    return g[m];
}
int main()
{

    int r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;
    r1--;
    c1--;
    cout<<((C(r2,c2)-C(r1,c2)-C(r2,c1)+C(r1,c1)%mod+mod)%mod)<<endl;
    return 0;

}


Measured memory_bytes: 19224
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 21 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0;//, sign = 1;
        // while(check(), notDigits[(int)buf[idx]]){ idx++; }
        // if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(/*check(), */!notDigits[buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        idx++;
        return /*sign **/ ret;
    }
};

string ans;
void out(int num){
    if(!num){
        // putchar('0');
        ans += '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        ans += buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    // for(int i = 1; i <= lim; i++){
    //     accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) >> 1]);
    // }
    for(int i = 1; i <= lim; i += 2){
        accs[i] = prime[i] && prime[(i + 1) >> 1];
    }
    for(int i = 1; i <= lim; i++){
        accs[i] += accs[i - 1];
    }
    // printd(accs[lim]);
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    ans.reserve(4 * q);
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        ans += '\n';
    }
    // cout << ss.str();
    cout << ans;
    // write(1, ans.data(), ans.size());
}


Measured memory_bytes: 2560
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    for(int  i=0;i<n;i++){
      arr[i]=sc.nextLong();
    }
    int max =0;
    int count=0;
    for(int i=0;i<n-1;i++){
      if(arr[i]>=arr[i+1]){
        count++;
      //  System.out.println(count);
      }
      else{
        if(count>max){
          max=count;
        }
        count=0;
      }
    }
    if(count>max){
      max=count;
    }
    System.out.println(max);
  }
}

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

int main(){
        int a = 0;
        string s;
        cin >> s;
        if(s[0] == '+'){
                ++a;
        }else{
                --a;
        }
        if(s[1] == '+'){
                ++a;
        }else{
                --a;
        }
        if(s[2] == '+'){
                ++a;
        }else{
                --a;
        }
        if(s[3] == '+'){
                ++a;
        }else{
                --a;
        }
        cout << a << endl;
        return 0;
}

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

const int MOD = 1000000007;
const int MAXN = 3055;
const int MAXX = 200055;

ll pw(ll n, ll k) {
	ll r = 1; for(; k; k >>= 1) {
		if(k & 1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

ll F[MAXX], RF[MAXX];
ll dp[MAXN];

int A[MAXN], B[MAXN], O[MAXN];

int H, W, N;

ll C(int a, int b) { return F[a] * RF[b] % MOD * RF[a-b] % MOD; }
ll f(int a, int b) { return C(a+b, a); }

int main() {
	ios::sync_with_stdio(false);

	F[0] = 1;
	for(int i = 1; i < MAXX; i++) F[i] = F[i-1] * i % MOD;
	RF[MAXX-1] = inv(F[MAXX-1]);
	for(int i = MAXX-1; i; i--) RF[i-1] = RF[i] * i % MOD;

	cin >> H >> W >> N;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
	N++; A[N] = H; B[N] = W;
	iota(O, O+N+1, 0); sort(O+1, O+N+1, [&](int a, int b) {
		if(A[a] != A[b]) return A[a] < A[b];
		return B[a] < B[b];
	});

	for(int oi = 1, i; oi <= N; oi++) {
		i = O[oi];
		ll &ret = dp[i];
		ret = f(A[i]-1, B[i]-1);
		for(int oj = 1, j; oj < oi; oj++) {
			j = O[oj];
			if(A[j] > A[i] || B[j] > B[i]) continue;
			ret -= dp[j] * f(A[i]-A[j], B[i]-B[j]) % MOD;
			if(ret < 0) ret += MOD;
		}
	}

	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 3456
#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 main(void){
	int n, i;
	int a[200000][2];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d%d", &a[i][1], &a[i][0]);
	}
	qsort(a, n, sizeof(int)*2, comp);
	int t=0;
	for(i=0; i<n; i++){
		t+=a[i][1];
		if(t>a[i][0]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=998244353;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a) {return powmod(a, mod-2);}

const int N=2005;
int dist[N][N];
int res[N][N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int x,y;
    cin>>x>>y;
    for(int i=1;i<=n-1;i++){
        for(int j=i+1;j<=n;j++){
            dist[i][j]=1+dist[i][j-1];
            dist[j][i]=dist[i][j];
        }
    }
    vector<ll>k(n+1,0);
    dist[x][y]=1;dist[y][x]=1;
    for(int i=1;i<=n-1;i++){
        for(int j=i+1;j<=n;j++){
            res[i][j]=min(dist[i][j],dist[i][x]+dist[x][y]+dist[y][j]);
            k[res[i][j]]++;
        }
    }
    for(int i=1;i<=n-1;i++){
        cout<<k[i]<<endl;
    }


    return 0;
    }


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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        int t=i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10;
        if(a<=t&&t<=b)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  queue<int> c[26];
  string ss = "";
  ss = s + s;
  for(int i=0;i<ss.length();i++){
    int num = ss[i] - 'a';
    c[num].push(i+1);
  }
  int cc[26][100007];
  for(int j=0;j<26;j++){
    for(int i=0;i<s.length()+1;i++){
      if(c[j].empty()){
        cc[j][i] = -1;
      }
      else{
        int top = c[j].front();
        if(i < top) cc[j][i] = top;
        else{
          c[j].pop();
          top = c[j].front();
          cc[j][i] = top;
        }
      }
    }
  }
  long long ans = 0;
  for(int i=0;i<t.length();i++){
    int tnum = t[i]-'a';
    long long cr = ans%s.length();
    ans += cc[tnum][cr]-cr;
    if(cc[tnum][cr] < 0){
      ans = -1;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11648