akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999999;



int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> b;
    for(int i=0;i<n;i++){
        if(i%2==0){
            b.push_back(a[i]);
        }
    }
    reverse(b.begin(),b.end());
    for(int i=0;i<n;i++){
        if(i%2==1){
            b.push_back(a[i]);
        }
    }
    if(n%2==0) reverse(b.begin(),b.end());
    for(int i=0;i<n;i++){
        cout<<b[i]<<" ";
    }
    cout<<endl;
}

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

int main() {

//変数の宣言

	int i,j,n,temp;


/////メイン処理/////

	cin >> n;
	
	for(j=0;j<n;j++){ 
//入力
		vector<int> a;
		
		for(i=0;i<3;i++){
			cin >> temp;
			a.push_back(temp);
		}
		sort(a.begin(),a.end());
		
//出力
		if (a[0]*a[0] + a[1]*a[1] == a[2]*a[2]) {
			cout << "YES" <<endl;
		}else{
			cout << "NO" <<endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1208
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string S;
    cin >> S;
    int cnt=0;
    for(int i = 0; i < S.size(); i++){
        if(i>=S.size()-(i+1)) break;
        if( S[i] != S[S.size()-(i+1)]){
            //cout << S[i] << endl;
            //cout << S[S.size()-(i+1)] << endl;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[100050];
int main()
{
	int m,n,sum=0,cnt=0;
	cin >> n >> m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>=0;i--)
	{
		if(a[i]>=sum/4.0/m) cnt++;
		else break;
	}
	if(cnt>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {
    int a,b,N,tmp;
    cin >> N>> a>>b;
    
   if(a<b){
        tmp=a;a=b;b=tmp;
    }
    tmp=a+b-N;
    if(tmp<0)
        tmp=0;
    printf("%d %d",b,tmp);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  map<string,ll> m;
  rep(i,n){
      string s;cin >> s;
      sort(all(s));
      m[s]++;
  }
   auto it = m.begin();
   ll ans = 0;
   while(it!=m.end()){
       ll tmp = it->second;
       ans += tmp * (tmp-1)/2;
       it++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 11264
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        char c = char.Parse(Console.ReadLine());
        char[] arr = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
        for(int i = 0; i < arr.Length; i++)
        {
            if(arr[i] == c)
            {
                Console.WriteLine(arr[i+1]);
                return;
            }
        }
    }

}

   

Measured memory_bytes: 25668
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

n,k = MI()
p =LI()
p.sort()
ans =0
for i in range(k):
    ans += p[i]
print(ans)

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

const int N = 1e5 + 10;

int n , m , a[N];
long long ans;

int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1; i <= n; i++)
		scanf("%d" , &a[i]);
	for(int i = 1; i <= n; i++){
		int d = (a[i - 1] + a[i]) - m;
		if(d > 0) a[i] -= d , ans += d;
	}
	printf("%lld" , ans);
	return 0;
}

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i,n) cin >> l[i];

	int ans = 0;
	rep(i,n) {
		for (int j = i + 1; j < n; j++) {
			if (l[i] == l[j]) continue;
			for (int k = j + 1; k < n; k++) {
				if (l[k] == l[i] or l[k] == l[j]) continue;
				if (l[i] < l[j] + l[k]) {
					if (l[j] < l[k] + l[i]) {
						if (l[k] < l[i] + l[j]) {
							ans++;
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	bool p[200005];
	memset(p,true,sizeof(p));
	p[0]=false;
	p[1]=false;
	for(int i=2;i*i<200000;i++)
	{
	    if(p[i]==true)
	    {
	        for(int j=i*i;j<200000;j+=i)
	        {
	            p[j]=false;
	        }
	    }
	}
	ll x;
	cin>>x;
	for(int i=x;i<200000;i++)
	{
	    if(p[i]==true)
	    {
	        cout<<i;
	        break;
	    }
	}
    return 0;
}







Measured memory_bytes: 512
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
m = sum(p[0: k])
sump = m

for i in range(1, n-k+1):
  sump = sump - p[i-1] + p[i+k-1]
  if m < sump:
    m = sump

ans = (m + k) / 2

print(ans)

Measured memory_bytes: 24812
A, B, N = map(int,input().split())
fivex = 0
i = 1
ans = 0
x = 0
# ans_x = -((-1)*A*N // B)
# if ans_x>N:
#     ans_x -= 1
# print(ans_x)
# print(int(A*ans_x/B)-A*int(ans_x/B))
while x <= B:
    x = -((-1)*i*B // A)
    if x > N:
        break
    now = i - A *  int(x / B)
    if now > ans and x <= N:
        # print(x)
        ans = now
    i += 1

print(ans)

Measured memory_bytes: 64196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int k, a, b;
	cin >> k >> a >> b;
	while (a <= b)
	{
		if (a % k == 0)
		{
			cout << "OK" << endl;
			return (0);
		}
		a++;
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==0&&b==0)break;
            boolean flag;
            for (int i = 0; i < a; i++) {
                flag = (i%2 == 1);
                for (int j = 0; j < b; j++) {
                    if (flag == false) {
                        System.out.print("#");
                        flag = true;
                    } else {
                        System.out.print(".");
                        flag = false;
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 35272
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    string s, t;
    cin>>s>>t;

    int n =s.length(), m=t.length();
    int ans = 1e9;

    for(int start = 0; start < n; ++start){
        if(start+m > n) break;
        int score = 0;
        for(int i = start; i < start+m; ++i){
            score += s[i]!=t[i-start];
        }
        ans = min(ans, score);
    }
    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3664
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    import itertools
    ans=0
    p=list(itertools.permutations(l))
    for x in p:
        z = list(x)
        for y in range(n-1):
            ans+=((z[y][0]-z[y+1][0])**2+(z[y][1]-z[y+1][1])**2)**0.5
    print(ans/len(list(p)))
resolve()

Measured memory_bytes: 8308
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

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

if n == 1:
    print(1)
    exit()

MOD = 10 ** 9 + 7

MAX = max(p) + 1

inv = [0]+[1]
for i in range(2,MAX + 1):
    inv += [inv[MOD % i] * (MOD - MOD // i) % MOD]

prime = [0 for i in range(MAX)]

max_map = dict()


# function to return a^n
def power(a, n):
    if n == 0:
        return 1
    p = power(a, n // 2) % MOD
    p = (p * p) % MOD

    if n & 1:
        p = (p * a) % MOD
    return p


# function to find the smallest prime
# factors of numbers upto MAX
def sieve():
    prime[0], prime[1] = 1, 1
    for i in range(2, MAX):
        if prime[i] == 0:
            for j in range(i * 2, MAX, i):
                if prime[j] == 0:
                    prime[j] = i
            prime[i] = i

        # function to return the LCM MODulo M


def lcmModuloM(arr, n):
    for i in range(n):
        num = arr[i]

        temp = dict()

        # temp stores mapping of prime factors
        # to its power for the current element
        while num > 1:

            # factor is the smallest prime
            # factor of num
            factor = prime[num]

            # Increase count of factor in temp
            if factor in temp.keys():
                temp[factor] += 1
            else:
                temp[factor] = 1

            # Reduce num by its prime factor
            num = num // factor

        for i in temp:
            # store the higest power of every prime
            # found till now in a new map max_map
            if i in max_map.keys():
                max_map[i] = max(max_map[i], temp[i])
            else:
                max_map[i] = temp[i]

    ans = 1

    for i in max_map:
        # LCM is product of primes to their
        # higest powers MODulo M
        ans = (ans * power(i, max_map[i])) % MOD
    return ans

sieve()
c = lcmModuloM(p, n)

ans = 0
for x in p:
    ans = (ans + c * inv[x]) % MOD

print(ans)

Measured memory_bytes: 54112
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename T> class BIT {
private:
	int n;
	vector<T> bit;
public:
	// 0_indexed で i 番目の要素に x を加える
	void add(int i, T x){
		i++;
		while(i < n){
			bit[i] += x, i += i & -i;
		}
	}
	// 0_indexed で [0,i] の要素の和(両閉区間！！)
	T sum(int i){
		i++;
		T s = 0;
		while(i > 0){
			s += bit[i], i -= i & -i;
		}
		return s;
	}
	BIT(){}
	//初期値がすべて0の場合
	BIT(int sz) : n(sz+1), bit(n, 0){}
	BIT(vector<T>& v) : n((int)v.size()+1), bit(n, 0){
		for(int i = 0; i < n-1; i++){
			add(i,v[i]);
		}
	}
	void print(){
		for(int i = 0; i < n-1; i++){
			cout << sum(i) - sum(i-1) << " ";
		}
		cout << "\n";
	}
	//-1スタート
	void print_sum(){
		for(int i = 0; i < n; i++){
			cout << sum(i-1) << " ";
		}
		cout << "\n";
	}
};
vector<int> zaatu(vector<ll>& u)
{
    int n = (int)u.size();
    vector<ll> sa = u;
    sort(sa.begin(), sa.end());
    vector<int> nu(n);
    rep(i,n){
        nu[i] = lower_bound(sa.begin(), sa.end(), u[i]) - sa.begin();
    }
    return nu;
}

//u を昇順にソートするのに必要な交換回数(転倒数) (u は (0~n-1の並び替え))
long long inv_count(vector<int>& u)
{
	int n = (int)(u.size());
	BIT<int> bt(n);
	long long ans = 0;
	for(ll i = 0; i < n; i++){
		ans += i-bt.sum(u[i]);
		bt.add(u[i],1);
	}
	return ans;
}

int main(){
    int n;
    cin >> n;
    vector<ll> s(n);
    vector<ll> p(n);
    rep(i,n){
        cin >> s[i];
        if(i!=0){
            s[i]+=s[i-1];
        }
    }
    rep(i,n){
        cin >> p[i];
    }
    vector<int> rrr = zaatu(s);
    ll ans = inv_count(rrr);
    sort(s.begin(),s.end());
    bool flag = 1;
    rep(i,n){
        if(i==0){
            if(s[0]<p[0]){
                flag = 0;
            }
        }else{
            if(s[i]-s[i-1]<p[i]){
                flag = 0;
            }
        }
    }
    if(flag){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5528
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101010];
int up[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	map<int, vector<int>> buf;
	rep(i, 0, N) if(0 < A[i]) buf[A[i]].push_back(i);

	int ans = 0;
	int tot = 0;
	for (auto ite = buf.rbegin(); ite != buf.rend(); ite++)
	{
		auto v = ite->second;

		fore(i, v) {
			up[i] = true;

			int yoko = 0;
			if (0 < i and up[i - 1]) yoko++;
			if (i + 1 < N and up[i + 1]) yoko++;

			if (yoko == 0) tot++;
			else if (yoko == 2) tot--;
		}

		chmax(ans, tot);
	}

	cout << ans << endl;
}



Measured memory_bytes: 14904
n,m,x=map(int,input().split())
A=list(map(int,input().split()))
if x>A[m-1] or x<A[0]:
    print(0)
    exit()
    k=0
for i in range(m):
    if A[i]>x:
        k=i
        break
print(min(k,m-k))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs;
		inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]), m = Integer.parseInt(inputs[1]);

		N[] nodes = new N[n];
		for ( int i = 0; i < n; i++ ) {
			nodes[i] = new N();
		}

		for ( int i = 0; i < m; i++ ) {
			inputs = br.readLine().split(" ");
			int x = Integer.parseInt(inputs[0]) - 1, y = Integer.parseInt(inputs[1]) - 1;
			nodes[x].chldList.add(nodes[y]);
			nodes[y].prntCnt++;
		}

		ArrayDeque<N> toCheck = new ArrayDeque<>();
		for ( N node : nodes ) {
			if ( node.prntCnt == 0 ) toCheck.add(node);
		}

		int lenMax = 0;
		while ( toCheck.size() > 0 ) {
			N node = toCheck.pollFirst();
			for ( N chld : node.chldList ) {
				chld.prntCnt--;
				chld.len = Math.max(node.len + 1, chld.len);
				lenMax = Math.max(lenMax, chld.len);
				if ( chld.prntCnt == 0 ) {
					toCheck.add(chld);
				}
			}
		}
		System.out.println(lenMax);
	}
}

class N {

	int				len			= 0;
	int				prntCnt		= 0;
	ArrayList<N>	chldList	= new ArrayList<>();

	public N() {
	}
}


Measured memory_bytes: 53500
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
struct BIT{
    int n;
    vector<int>bit;
    BIT(int x){
        bit.resize(x+1,0);
        n=x;
    }
    int sum(int i){
        int res=0;
        while(i>0){
            res+=bit[i];
            i-=i&-i;
        }
        return res;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};
int n;
P p[200010];
void compress(){
    map<int,int>x,y;
    rep(i,n){
        x[p[i].fi]=1;
        y[p[i].se]=1;
    }
    int N=0;
    for(P p:x){
        x[p.fi]=N;
        N++;
    }
    N=0;
    for(P p:y){
        y[p.fi]=N;
        N++;
    }
    rep(i,n){
        p[i].fi=x[p[i].fi]+1;
        p[i].se=y[p[i].se]+1;
    }
}
int LU[200010],LD[200010],RU[200010],RD[200010];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>p[i].fi>>p[i].se;
    sort(p,p+n);
    compress();
    BIT bit(n);
    rep(i,n){
        LU[i]=bit.sum(p[i].se);
        LD[i]=i-LU[i];
        bit.add(p[i].se,1);
    }
    BIT bit2(n);
    for(int i=n-1;i>=0;i--){
        RU[i]=bit2.sum(p[i].se);
        RD[i]=n-1-i-RU[i];
        bit2.add(p[i].se,1);
    }
    int ans=0;
    rep(i,n){
        int a=modpow(2,LU[i])-1;
        int b=modpow(2,RU[i])-1;
        int c=modpow(2,LD[i])-1;
        int d=modpow(2,RD[i])-1;
        ans+=modpow(2,n-1);
        ans%=mod;
        ans+=a*d;
        ans%=mod;
        ans+=b*c;
        ans%=mod;
        ans+=a*b%mod*c;
        ans%=mod;
        ans+=a*b%mod*d;
        ans%=mod;
        ans+=a*c%mod*d;
        ans%=mod;
        ans+=b*c%mod*d;
        ans%=mod;
        ans+=a*b%mod*c%mod*d;
        ans%=mod;
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int INF = 1e+9;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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 a[100010][3];
int dp[100010][3];

int main () {
  int N; cin >> N;
  rep(i,N) rep(j,3) cin >> a[i][j];

  //rep(i,100010) rep(j,3) dp[i][j] = 0;
  //rep(j,3) dp[0][j] = 0;
  rep(i,N) {
    rep(j,3) {
      rep(k,3) {
        if (j == k) continue;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k]);
      }
    }
  }

  int ans = 0;
  rep(i,3) ans = max(ans, dp[N][i]);
  cout << ans << endl;
}

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

int main(){
  int N,ans;
  ans = 0;
  string S;
  cin>>N>>S;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A'){
      if(S.at(i+1)=='B'){
        if(S.at(i+2)=='C'){
          ans++;
        }
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include<stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) {ll tp=a;a=b;b=tp;}
const ll MOD = 1000000007;

int main(){
    int a,b,c; scanf("%d%d%d", &a,&b,&c);
    int x; scanf("%d", &x);
    rep(i,x){
        if(a>=b) b*=2;
        else c*=2;
    }

    if(a<b&&b<c) puts("Yes");
    else puts("No");
    //printf("%lld", ans);
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (ll t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    ll n, c;
    cin >> n >> c;
    vector<pair<ll, ll>> S;
    REP(i, n)
    {
        ll x, v;
        pair<ll, ll> temp;
        cin >> x >> v;
        temp.first = x, temp.second = v;
        S.push_back(temp);
    }

    vector<ll> fs;
    vector<ll> maxfs;
    fs.push_back(S[0].second - S[0].first);
    REP(i, n - 1)
    {
        ll nextf = fs[i] + S[i + 1].second + S[i].first - S[i + 1].first;
        fs.push_back(nextf);
    }
    maxfs.push_back(fs[0]);
    REP(i, n - 1)
    {
        maxfs.push_back(max(maxfs[i], fs[i + 1]));
    }

    vector<ll> gs;
    vector<ll> maxgs;
    gs.push_back(S[n - 1].second - (c - S[n - 1].first));
    REP(i, n - 1)
    {
        ll nextf = gs[i] + S[n - i - 2].second + (c - S[n - i - 1].first) - (c - S[n - i - 2].first);
        gs.push_back(nextf);
    }
    maxgs.push_back(gs[0]);
    REP(i, n - 1)
    {
        maxgs.push_back(max(maxgs[i], gs[i + 1]));
    }

    ll ansofb = -1, ansofa = -1;
    //when B is where Nakahashi starts
    ansofb = maxfs[n - 1];
    REP(i, n - 1)
    {
        ll temp = maxfs[n - i - 2] + gs[i] - (c - S[n - i - 1].first);
        if (ansofb < temp)
            ansofb = temp;
    }

    //when A is where Nakahashi starts
    ansofa = maxgs[n - 1];
    REP(i, n - 1)
    {
        ll temp = maxgs[n - i - 2] + fs[i] - S[i].first;
        if (ansofa < temp)
            ansofa = temp;
    }

    ll ans = max(ansofa, ansofb);
    if (ans <= 0)
        cout << 0 << endl;
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> square(H, vector<int> (W));
    int x, y, a;
    int b, c, d, e;
    for (int i = 0; i < N; i++){
        cin >> x >> y >> a;
        if (a == 1){
            b = 0;
            c = H;
            d = 0;
            e = x;
        }
        else if (a == 2) {
            b = 0;
            c = H;
            d = x;
            e = W;
        }
        else if (a == 3) {
            b = 0;
            c = y;
            d = 0;
            e = W;
        }
        else {
            b = y;
            c = H;
            d = 0;
            e = W;
        }
        for (int j = b; j < c; j++){
            for (int k = d; k < e; k++){
                square[j][k] = 1;
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cnt += square[i][j];
        }
    }
    cout << H * W - cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> x(3);
  while(cin >> x[0] >> x[1] >> x[2]){
    sort(ALL(x));
    int ans;
    if(x[0] == x[1])ans = x[2];
    else ans = x[0];
    cout << ans << endl;
    x.clear();
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}

		int m = sc.nextInt();
		int[] t = new int[m];
		for (int i = 0; i < m; i++) {
			t[i] = sc.nextInt();
		}

		/*
		 * int i, j = 0; if (n >= m) { for (i = 0; i < m; i++) {
		 * 
		 * for (j = 0; j < n; j++) { if (d[j] != -1 && d[j] == t[i]) { d[j] = -1; break;
		 * } } if (j >= n) { break; } }
		 * 
		 * if (j >= n) { System.out.println("NO"); } else { System.out.println("YES"); }
		 * } else { System.out.println("NO"); }
		 */

		Map<Integer, Integer> df = new HashMap<Integer, Integer>();
		Map<Integer, Integer> tf = new HashMap<Integer, Integer>();

		for (int x : d) {
			if (df.containsKey(x)) {
				df.put(x, df.get(x) + 1);
			} else {
				df.put(x, 0);
			}
		}

		for (int x : t) {
			if (tf.containsKey(x)) {
				tf.put(x, tf.get(x) + 1);
			} else {
				tf.put(x, 0);
			}
		}

		if (df.size() >= tf.size()) {
			for (int x : t) {
				if (!df.containsKey(x) ||  tf.get(x) > df.get(x)) {
					System.out.println("NO");
					System.exit(0);
				}
			}
		} else {
			System.out.println("NO");
			System.exit(0);
		}

		System.out.println("YES");
	}
}

Measured memory_bytes: 146064
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

void out(std::deque<int>& list)
{
    std::deque<int>::iterator l = list.begin();
    while(l != list.end()){
        cout << *l;
        ++l;
        if(l != list.end()) cout << " ";
        else cout << endl;
    }
}
int main()
{
    int n;
    cin >> n;
    std::vector<std::string> v1;
    std::vector<int> v2;
    std::string cmd;
    int key = 0;
    std::deque<int> list;
    for(int i=0; i<n; i++){
        cin >> cmd;
        if(cmd == "insert"){
            cin >> key;
            list.push_front(key);
        }else if(cmd == "delete"){
            cin >> key;
            std::deque<int>::iterator tmp
              = std::find(list.begin(), list.end(), key);
            if(tmp != list.end()){
                list.erase(tmp);
            }
        }else if(cmd == "deleteFirst"){
            list.pop_front();
        }else if(cmd == "deleteLast"){
            list.pop_back();
        }
    }
    out(list);
}


Measured memory_bytes: 7200
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>
#include <queue>

using namespace std;

int main() {
    int N; cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    string str = "";
    while (N != 0) {
        int r = N % 2;
        if (r < 0) r += 2;

        N = (N - r) / (-2);
        str += to_string(r);
    }
    reverse(str.begin(), str.end());
    cout << str << endl;
}

Measured memory_bytes: 256
#alpha=[chr[i] for i in range(ord("a"),ord("z")+1)]
s=input()
dict={}
check=False
for i, ele in enumerate(s):
    try:
      if i-dict[ele]<=2:
        print("{} {}".format(dict[ele]+1,i+1)) 
        check=True
        break
    except:pass
    dict[ele]=i
if (check==False):
  print("-1 -1")

Measured memory_bytes: 39408
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

int n;
string a,b,c;
int ans;

signed main(){
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		if((a[i]==b[i])&&(b[i]!=c[i]))ans++;
		else if((b[i]==c[i])&&(a[i]!=c[i]))ans++;
		else if((c[i]==a[i])&&(b[i]!=c[i]))ans++;
		else if((a[i]!=b[i])&&(b[i]!=c[i]))ans+=2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
while len(S) > 0:
    if len(S) >= 7 and S[-7:] == 'dreamer':
        S = S[0:-7]
    elif len(S) >= 6 and S[-6:] == 'eraser':
        S = S[0:-6]
    elif len(S) >= 5 and S[-5:] == 'dream':
        S = S[0:-5]
    elif len(S) >= 5 and S[-5:] == 'erase':
        S = S[0:-5]
    else:
        break
if len(S) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
bool vis[N];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++)
    {
        int x;scanf("%d",&x);
        while(x--)
        {
            int y;scanf("%d",&y);vis[y]=true;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(!vis[i]) ans++;
    printf("%d\n",ans);
}


Measured memory_bytes: 3820
N=int(input())
hlist=list(map(int,input().split()))
hantei="Yes"
kabe=0
for i in range(1,N):
  if hantei=="No":
    break
  kabe=max(kabe,hlist[i])
  if kabe>=hlist[i]+2:
    hantei="No"
print(hantei)

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int x = 0;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'I') {
      x++;
    }
    else {
      x--;
    }
    ans = max (ans, x);
  }
  
  
  cout << ans << endl;
  return 0;
}

  
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
	int x;
	cin>>x;
	if(x<600)
		cout<<8;
	else if(x<800)
		cout<<7;
	else if(x<1000)
		cout<<6;
	else if(x<1200)
		cout<<5;
	else if(x<1400)
		cout<<4;
	else if(x<1600)
		cout<<3;
	else if(x<1800)
		cout<<2;
	else
		cout<<1;
	
}

int main()
{
	fastio;
	int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	vector<int>A(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		ans += A.at(i) - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//C - Go Home: 30 Min ---------
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll x, t = 1;
    cin >> x;
    while((t * (t+1)) / 2 < x) t++;
    cout << t << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

public static void main(String[] args) {
        Scanner scan = new Scanner (System.in);
        int s1 = scan.nextInt();
        int s2 = scan.nextInt();
        int s3 = scan.nextInt();
        int s4 = scan.nextInt();   
        int s5 = scan.nextInt();
        int s6 = scan.nextInt();
        int s7 = scan.nextInt();
        int s8 = scan.nextInt();
        int s9 = scan.nextInt();
        int s10 = scan.nextInt();
        
        System.out.println(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10);
}
        }


Measured memory_bytes: 26148
fn main() {
    let ny = read_vec::<i32>();
    let n = ny[0];
    let y = ny[1];

    for i in 0..n+1 {
        for j in 0..n+1-i {
            let k = n - i - j;

            if y == 10000 * i + 5000 * j + 1000 * k {
                println!("{} {} {}", i, j, k);
                return
            }
        }
    }
    println!("-1 -1 -1");
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll N;cin>>N;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    ll ans=0;
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ans+=A[0];
    if(N%2==0){
        for(int i=1;i<N/2;i++){
            ans+=A[i]*2;
        }
    }
    else{
        for(int i=1;i<(N+1)/2;i++){
            if(i==(N+1)/2-1){
                ans+=A[i];
            }
            else{
                ans+=A[i]*2;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var t = long.Parse(inputs[1]);

            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();

            var result = 0L;

            for (var i = 1; i < n; i++)
            {
                var d = list[i] - list[i - 1];
                result += d > t ? t : d;
            }
            result += t;

            Console.WriteLine(result);
        }
    }
}


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

int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = n % k;
	ans = min(ans, abs(n%k - k));
	cout << ans << endl;
	return 0;
}

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

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;

int main() {
    ll N, M, A, sum = 0;
    cin >> N >> M;
    REP(i, M) {
        cin >> A;
        sum += A;
    }
    if(N - sum < 0)
        cout << -1 << endl;
    else
        cout << N - sum << endl;
}

Measured memory_bytes: 3596
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, M, Q = map(int, readline().split())
    A = [[0] * (N + 1) for _ in range(N + 1)]
    for _ in range(M):
        l, r = map(int, readline().split())
        A[l][r] += 1

    for i in range(N):
        for j in range(N):
            A[i + 1][j + 1] += A[i][j + 1] + A[i + 1][j] - A[i][j]

    ans = [0] * Q
    for i in range(Q):
        p, q = map(int, readline().split())
        p -= 1
        q -= 1
        ans[i] = A[q + 1][q + 1] - A[q + 1][p] - A[p][q + 1] + A[p][p]

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 23764
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var (x,y)=scan.nextLine().split(" ").map{ it.trim().toLong() }.toTypedArray()
    var arr = scan.nextLine().split(" ").map{ it.trim().toLong() }.toTypedArray()
    var prev = 0.toLong()

    var sum = 0.toLong()
    for(i in 0..(y-1))
        prev+=arr[i.toInt()]

    for(i in y..arr.size-1)
    {
        var temp = prev - arr[i.toInt()-y.toInt()]
        temp+=arr[i.toInt()]

            if(temp>prev)
                println("Yes")
            else
                println("No")
        prev=temp
    }
}


Measured memory_bytes: 88508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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 dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

//modの値の確認をすること
int main(){
    ll n,m;
    cin >> n >> m;
    vector<vector<ll> > e(n,vector<ll>(0));
    vector<ll> g(n,INF);
    g[0] = 0;
    rep0(i, m){
        ll a,b;
        cin >> a >> b;
        --a;--b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    
    queue<ll> to,from,erase;
    to.push(0);
    while (!to.empty()) {
        from = to;
        to = erase;
        while (!from.empty()) {
            ll f = from.front();
            rep0(i, e[f].size()){
                if(g[e[f][i]] == INF){
                    to.push(e[f][i]);
                    g[e[f][i]] = g[f] + 1;
                }
            }
            from.pop();
        }
    }
    pf("Yes");
    rep1(i, n - 1){
        ll mark = INF,min = INF;
        rep0(j, e[i].size())if(chmin(min, g[e[i][j]]))mark = e[i][j] + 1;
        pf(mark);
    }
    return 0;
}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    string s;
    cin>>s;
    stack<char> ss;
    for(int i=0; i<N; ++i){
        if(ss.empty()==true){
            ss.push(s[i]);
        }else if(ss.top() != s[i]){
            ss.push(s[i]);
        }
    }
    cout<<ss.size()<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m, tot = 0;
  cin >> n;
  vector<ll> t(n);
  rep(i, n) {
    cin >> t[i];
    tot += t[i];
  }

  cin >> m;

  ll p1, p2;

  rep(i, m) {
    cin >> p1 >> p2;
    cout << tot - t[p1 - 1] + p2 << endl;
  }

  return 0;
}


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

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 1;
    ll res = 0;
    rep(i,n){
        int idx = n-1-i;
        if(s[idx]=='B'){
            res += (n-cnt) - idx;
            cnt++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

struct Node {
  std::unordered_set<int> in_edge;
  std::unordered_set<int> out_edge;
};

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

  int v, e;
  cin >> v >> e;
  std::vector<Node> node(v);
  for (int i = 0; i < e; i++) {
    int from, to;
    cin >> from >> to;
    node[from].out_edge.insert(to);
    node[to].in_edge.insert(from);
  }

  std::queue<int> search_set;
  std::vector<int> result;

  for (int i = 0; i < v; i++) {
    if (node[i].in_edge.empty()) {
      search_set.push(i);
    }
  }

  while (!search_set.empty()) {
    int tgt = search_set.front();
    search_set.pop();
    result.push_back(tgt);
    for (auto itr = node[tgt].out_edge.begin(); itr != node[tgt].out_edge.end();
         itr++) {
      node[*itr].in_edge.erase(tgt);
      if (node[*itr].in_edge.empty()) {
        search_set.push(*itr);
      }
    }
  }

  for (auto x : result) {
    cout << x << endl;
  }

  return 0;
}



Measured memory_bytes: 8264
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

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

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

int main(){
    int n;
    double S[1000]={0},sum,m,buf;
    
    cout << fixed;
    cout.precision(6);

    while(1){
        cin >> n;
        if(n == 0) break;
        
        buf = sum = 0;
        
        for(int i=0;i<n;i++){
            cin >> S[i];
            sum += S[i];
        }
        m = sum/n;
        for(int i=0;i<n;i++){
            buf += pow(S[i]-m,2);
            S[i] = 0;
        }
        cout << sqrt(buf/n) << endl;
        
    }
}


Measured memory_bytes: 3248
#include<iostream>
#include<cstdio>
#include<map>
#define ll long long
using namespace std;
int n;
map<ll,ll>cnt;
int main()
{
	ll ans=0;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		ll a;
		scanf("%lld",&a);
		ans+=cnt[a-i];
		cnt[-a-i]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25788
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,a[maxn];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int ans=inf;
	for(int i=a[1];i<=a[n];i++)
	{
		int res=0;
		for(int j=1;j<=n;j++) res+=(i-a[j])*(i-a[j]);
		if(res<ans) ans=res;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll a,b,c;
	cin>>a>>b;
	c=a+b;
	if(c>=10){
		cout<<"error"<<endl;
	}else{
		cout<<c<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
    val(a,b)=readInts()
    if(a>=10){
        println(b)
    }else{
        println(b+100*(10-a))
    }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){cout<<c<<endl;}
  else if(b==c){cout<<a<<endl;}
  else{cout<<b<<endl;}
}


Measured memory_bytes: 384