akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, r;
    while(cin >> n >> r, n | r){
        vector<int> v(n);
        for (int i = 0; i < n; ++i) {
            v[i] = n-i;
        }
        for (int i = 0; i < r; ++i) {
            int p, c;
            cin >> p >> c;
            vector<int> u(c+p-1);
            for (int j = 0; j < c+p-1; ++j) {
                u[(j+c)%(c+p-1)] = v[j];
            }
            for (int j = 0; j < c+p-1; ++j) {
                v[j] = u[j];
            }
        }
        cout << v.front() << "\n";
    }
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 100002

int main(){
	Fio;
	ll h,w;
	cin>>h>>w;
	vector<string>S(h);
	f(i,h)cin>>S[i];
	ll dp[h+1][w+1];
	dp[0][0] = 1;
	fo(i,0,h-1){
		fo(j,0,w-1){
			if(S[i][j]=='#'){
				dp[i][j]=0;
				continue;
			}
			if(i==0 && j==0)continue;
			if(i==0)dp[i][j] = dp[i][j-1]%inf;
			else if(j==0)dp[i][j] = dp[i-1][j]%inf;
			else{
				dp[i][j] = dp[i-1][j]+dp[i][j-1];
				dp[i][j] = dp[i][j]%inf;
			}
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

Measured memory_bytes: 12472
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N,M;
    cin >> N >> M;
    ll A[M];
    rep(i,M) cin >> A[i];
    ll out = N;
    rep(i,M){
        out -= A[i];
    }
    if(out<0) out = -1;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3672
package main

import(
    "fmt"
)

func main() {
    var n, m int
    var answer int
  	sum := 0
    fmt.Scan(&n, &m)
    var a[11111] int
    for i := 0 ; i < m ; i++{
        fmt.Scan(&a[i])
        sum += a[i]
    }
    answer = n - sum
    if answer < 0 {
        answer = -1
    }
    fmt.Println(answer)
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	ll n = sz(s);
	vl res(n);
	FOR(i,0,n-1) if (s[i] == 'R' && s[i+1] == 'L') {
		ll j = i;
		while (j >= 0 && s[j] == 'R') {
			res[i + (i-j)%2]++;
			j--;
		}
		j = i+1;
		while (j < n && s[j] == 'L') {
			res[i + (j-i)%2]++;
			j++;
		}
	}


	FOR(i,0,n) cout << res[i] << " \n"[i==n-1];
}



Measured memory_bytes: 1488
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 21:45:38 2020
2020-04-13 00:14:06にPython3で提出したのと同じコードを、PyPy3で再提出した。
@author: H_Hoshigi
"""
 
import math
 
K = int(input())
 
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            answer += math.gcd(math.gcd(a, b), c)
print(answer)
 

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

int main()
{
    int n, distanceMin, distanceMax, input;
    cin >> n;
    for(int i=0; i<n; ++i)
    {

        cin >> input;
        if(i==0)
        {
            distanceMin = input;
            distanceMax = input;
        }
        else
        {
            if(input < distanceMin)
                distanceMin = input;
            else if(input > distanceMax)
                distanceMax = input;
        }
    }
    cout << distanceMax - distanceMin;
    return 0;
}


Measured memory_bytes: 256
/*  ex7_1
    kosaq   */

#include <stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;//構造体を定義

point shift_point(point vertex1, point vertex2){//既に判明している二頂点の座標から、反時計回りに考えて隣にある頂点の座標を求める関数
    point vertex3;//新たに求める頂点を定義
    int difference_x, difference_y;//既に判明している二点について、その二点間のx,y座標の差（符号あり）をそれぞれ定義

    difference_x = vertex2.x_elem - vertex1.x_elem;//既に判明している二点のx座標の差（符号あり）
    difference_y = vertex2.y_elem - vertex1.y_elem;//既に判明している二点のy座標の差（符号あり）

    vertex3.x_elem = vertex2.x_elem - difference_y;//新たに判明する頂点のx座標は元のx座標からdifference_yを引いたものに等しい
    vertex3.y_elem = vertex2.y_elem + difference_x;//新たに判明する頂点のy座標は元のy座標にdifference_xを足したものに等しい

    return vertex3;//新たに判明した頂点を返す
}

int main(void){
    point corner1, corner2;//既に判明している頂点をそれぞれ定義
    point corner3, corner4;//まだ判明していない頂点をそれぞれ定義

    scanf("%d %d %d %d", &corner1.x_elem, &corner1.y_elem, &corner2.x_elem, &corner2.y_elem);//判明しているものについて入力

    corner3 = shift_point(corner1, corner2);//1,2番目の頂点から3番目を求める
    corner4 = shift_point(corner2, corner3);//2,3番目の頂点から4番目を求める

    printf("%d %d %d %d\n", corner3.x_elem, corner3.y_elem, corner4.x_elem, corner4.y_elem);//新たに判明した二頂点を答えとして出力
    return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;



int main(){
    long r,D,x;
    cin>>r>>D>>x;
    REP(i,10){
        x=r*x-D;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

string t[] = {"dream", "dreamer", "erase", "eraser"};
string s;

int main() {
	cin >> s;
	int now = s.size();
	while (now > 0) {
		int fl = 0;
		for (int i = 0; i < 4; ++i) {
			if (now >= (int)t[i].size() && s.substr(now - t[i].size(), t[i].size()) == t[i]) {
				fl = 1;
				now -= t[i].size();
				break;
			}
		}
		if (!fl) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}




Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

    rep(i, s.size()) {
        cout << 'x';
    }
    cout << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int r,g,b;
  scanf("%d %d %d",&r,&g,&b);
  int rgb=100*r+10*g+b;
  if(rgb%4==0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

const int MAX_N = 50;

long long thickness[MAX_N + 1];

void thickness_init()
{
    thickness[0] = 1;
    for (int i = 1; i < MAX_N + 1; i++) {
        thickness[i] = thickness[i-1] * 2 + 3;
    }
}

long long rec(int level, long long x) {
    if (x == 0) return 0;
    if (level == 0 && x == 1) return 1;

    long long ret = 0;

    if (1 <= x && x <= thickness[level-1]+1)
    {
        ret = rec(level-1, x-1);
    }
    else if (thickness[level-1]+1 < x && x < thickness[level]) {
        ret = rec(level-1, thickness[level-1]) + 1 + rec(level-1, x - 2 - thickness[level-1]);
    }
    else if (x == thickness[level])
    {
        ret = 2 * rec(level-1, thickness[level-1]) + 1;
    }
    return ret;
}

int main()
{
    thickness_init();
    long long n, x;
    std::cin >> n >> x;
    std::cout << rec(n, x) << std::endl;
    return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

s = float(input())

tmp = decimal.Decimal(s/3)
ans = decimal.Decimal(tmp) * decimal.Decimal(tmp) *decimal.Decimal(tmp)

print("{:.10f}".format(ans))


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

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    long double thita = fabs(30*H+0.5*M - 6*M);
    long double thita2 = thita * M_PI / 180.0;

    long double result = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(thita2));
    cout << std::fixed << std::setprecision(15) << result << endl;
    return 0;
}

Measured memory_bytes: 4092
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define int long long

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for(int i = 1 ; i <= m ; i ++)
		for(int j = i ; j <= d ; j ++)
		if(i == (j % 10) * (j/10) && (j%10) >= 2 && (j/10) >= 2) ans ++;
	cout << ans;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	m := map[int]int{}
	for i := 0; i < M; i++ {
		m[nextInt()]++
		m[nextInt()]++
	}

	for i := 1; i <= N; i++ {
		fmt.Println(m[i])
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = sorted(LIST())
B = sorted(LIST())
C = sorted(LIST())

def binary_search(list, item):
    low = 0
    high = len(list) - 1
    f = False

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            f = True
            break
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1
    if f:
        return high
    return low

b = [0]*N
for i in range(N):
	b[i] = bisect_left(A, B[i])

c = [0]*N
for i in range(N):
	c[i] = bisect_left(B, C[i])

bb = [0] + list(accumulate(b))

s = 0
for i in range(len(c)):
	s += bb[c[i]]
print(s)

Measured memory_bytes: 119572
// Problem : A - Multiplication 1
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b; cin >> a >> b;
	cout << a * b << endl;
	return 0;
}
 


Measured memory_bytes: 3652
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    printf("Possible\n");
  else printf("Impossible\n");
  
  return 0;
}
              

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(n % (a + b), a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int n, m, p[100005], q[100005];
bool del[100005];
vector<int> hv[100005];
int x[100005], y[100005];
vector<int> hvx, hvy;

struct fenw_t
{
	int dat[100005];
	
	void add(int id, int val)
	{
		id ++;
		while(id <= hvy.size()) {
			dat[id] = (dat[id] + val) % MOD;
			id += id & -id;
		}
	}
	
	int query(int id)
	{
		int ret = 0;
		while(id > 0) {
			ret = (ret + dat[id]) % MOD;
			id -= id & -id;
		}
		return ret;
	}
}tre;

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, n) scanf("%d", &p[i]);
	rep1(i, m) scanf("%d", &q[i]);
	q[0] = -INF;
	q[m + 1] = INF;
	m += 2;
	int cur = 0;
	rep(i, n) {
		while(q[cur + 1] < p[i]) cur ++;
		if(cur == 0 || cur == m - 2) del[i] = true;
		x[i] = p[i] - q[cur];
		y[i] = q[cur + 1] - p[i];
	}
	
	hvy.push_back(0);
	rep(i, n) {
		if(del[i]) continue;
		hvx.push_back(x[i]);
		hvy.push_back(y[i]);
	}
	sort(hvx.begin(), hvx.end());
	hvx.resize(unique(hvx.begin(), hvx.end()) - hvx.begin());
	sort(hvy.begin(), hvy.end());
	hvy.resize(unique(hvy.begin(), hvy.end()) - hvy.begin());
	rep(i, n) {
		if(del[i]) continue;
		x[i] = lower_bound(hvx.begin(), hvx.end(), x[i]) - hvx.begin();
		y[i] = lower_bound(hvy.begin(), hvy.end(), y[i]) - hvy.begin();
		hv[x[i]].push_back(y[i]);
	}
	
	tre.add(0, 1);
	rep(i, hvx.size()) {
		sort(hv[i].begin(), hv[i].end());
		hv[i].resize(unique(hv[i].begin(), hv[i].end()) - hv[i].begin());
		for(int j = hv[i].size() - 1; j >= 0; j --) tre.add(hv[i][j], tre.query(hv[i][j]));
	}
	printf("%d\n", tre.query(hvy.size()));
	return 0;
}

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

using namespace std;

int n, s[220], ans;

int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < 2*n ; i++ ) scanf("%d", s+i);
    sort(s, s+2*n);
    for(int i = 0 ; i < 2*n ; i+=2 ) ans += s[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, s;
int a[200020];
long long z;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0, j = 0; i < n; s ^= a[i++])
	{
		while (j < n && (s & a[j]) == 0)
		{
			s ^= a[j++];
		}
		z += j - i;
	}
	printf("%lld\n", z);
	return 0;
}

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

int main()
{
	int l[10], v[2];
	char d;
	while (cin >> l[0] >> d >> l[1] >> d >> l[2] >> d >> l[3] >> d >> l[4] >> d >> l[5] >> d >> l[6] >> d >> l[7] >> d >> l[8] >> d >> l[9] >> d >> v[0] >> d >> v[1]){
		double L = 0, V = v[0] + v[1],a = 0;
		for (int i = 0; i < 10; ++i){
			L += l[i];
		}

		a = L * v[0] / V;
		
		for (int i = 0; i < 10; ++i){
			a -= l[i];
			if (a <= 0){
				cout << i+1 << endl;
				break;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
 
int main(){
  int n;
  scanf("%d\n",&n);
  char s[n];
  for(int i = 0; i < n; ++i) scanf("%c",&s[i]);
  int k;
  scanf("\n%d",&k);
  char bin = s[k-1];
  for(int i = 0; i < n; ++i){
    if(s[i] != bin) s[i] = '*';
  }
  for(int i = 0; i < n; ++i) printf("%c",s[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 110;

int main() {
	int n;
	cin >> n;
	int a[N];
	rep(i, n) cin >> a[i];
	bool ans = true;
	rep(i, n) {
		if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
			ans = false;
		}
	}
	cout << (ans ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;


int main(){
    string a,b;
    cin>>a>>b;

    ll siza = a.size();
    ll sizb = b.size();

    if(siza>sizb){
        cout<<"GREATER";
    } else if(siza<sizb){
        cout<<"LESS";
    } else{

        bool flag = true;
        for(ll i=0;i<sizb;i++){
            if(a[i] == b[i]){
                continue;
            } else if(a[i] > b[i]){
                cout<<"GREATER";
                return 0;
            } else{
                cout<<"LESS";
                return 0;
            }
        }
        
            cout<<"EQUAL";
        
    }
    
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,i;
    cin >>N>>i;
    
    cout << N-i+1 << endl;


    return 0;
    

}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        int count=0;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    for(int l=0;l<10;l++){
                        if(i+j+k+l==n)
                            count++;
                    }
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}
 

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  string T;
  cin >> T;
  REP(i, T.size()) if (T[i] == '?') T[i] = 'D';
  cout << T << endl;
}


Measured memory_bytes: 3756
n=int(input())
a,b=[None]*100000,[None]*100000
for i in range(100000):
    a[i]=[None]*2
    a[i][0]=0
    a[i][1]=i
    b[i]=[None]*2
    b[i][0]=0
    b[i][1]=i
l=list(map(int,input().split()))
for i in range(n//2):
    a[l[2*i]-1][0]+=1
    b[l[2*i+1]-1][0]+=1
a.sort(reverse=True)
b.sort(reverse=True)
if a[0][1]==b[0][1]:
    print(n-max(a[0][0]+b[1][0],a[1][0]+b[0][0]))
else:
    print(n-a[0][0]-b[0][0])

Measured memory_bytes: 72772
n,m=map(int,input().split())
lst=[list(input().split()) for _ in range(m)]
pena_lst=[0]*n
acn_lst=[0]*n

for p,s in lst:
    p=int(p)-1
    if acn_lst[p]==1:
        continue
    if s =="AC":
        acn_lst[p]=1
    else: pena_lst[p]+=1
pena=0
acn=0
for i in range(n):
    acn+=acn_lst[i]
    if acn_lst[i]==1:
        pena+=pena_lst[i]
print(acn,pena)


Measured memory_bytes: 27448
from collections import deque
N, M = map(int, input().split())
p = [0]
ans = [0]
for i in range(N):
    p.append(list())
    if i == 0:
        ans.append(0)
    else:
        ans.append(-1)
for i in range(M):
    A, B = map(int, input().split())
    p[A].append(B)
    p[B].append(A)
D = deque([1])
while D:
    ind = D.popleft()
    for i in p[ind]:
        if ans[i] == -1:
            D.append(i)
            ans[i] = ind

if -1 in ans[2:]:
    print('No')
else:
    print('Yes')
    for i in ans[2:]:
        print(i)

Measured memory_bytes: 34936
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){

	int A,B;
	cin>>A>>B;
	
	if(A%3==0||B%3==0||(A+B)%3==0){
		cout<<"Possible"<<endl;
	}
	else{
		cout<<"Impossible"<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main (void) {
	int i, j;
	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n",i, j, i*j);

		}
	}
	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  int N, K, C;
  cin >> N >> K >> C;
  string s;
  cin >> s;

  int cnt = 0;
  int idx = 0;
  vi front;
  while (idx < s.size() && cnt <= K) {
    if (s[idx] == 'o') {
      front.pb(idx);
      idx += C+1;
      cnt++;
    } else {
      idx++;
    }
  }
  cnt = 0;
  idx = s.size() - 1;
  vi back;
  while (idx >= 0 && cnt <= K) {
    if (s[idx] == 'o') {
      back.pb(idx);
      idx -= C+1;
      cnt++;
    } else {
      idx--;
    }
  }
  reverse(All(back));
  vi ans;
  rep(i, 0, K) {
    if (front[i] == back[i]) {
      ans.pb(front[i]);
    }
  }

  for (int a: ans) {
    cout << a+1 << endl;
  }

  return 0;
};


Measured memory_bytes: 4236
x,y = map(int,input().split())

c=0

if x ==1:
  c+=300000
elif x ==2:
  c+=200000
elif x==3:
  c+=100000
if y==1:
  c+=300000
elif y==2:
  c+=200000
elif y==3:
  c+=100000

if c==600000:
  c+=400000

print(c)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

vector<vector<int>> dp(20,vector<int> (200005,INF));
signed main() {
  int d, g;
  cin >> d >> g;
  g/=100;
  vector<int> p(d+1),c(d+1);
  for (int i = 1; i <= d; i++) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }
  dp[0][0]=0;
  for(int i=1;i<=d;i++){
    rep(j,g+1){
      if(dp[i-1][j]<INF){
        for(int k=0;k<=p[i];k++){
          int sum=i*k+(k==p[i]?c[i]:0);
          cmin(dp[i][min(g,j+sum)],dp[i-1][j]+k);
        }
        cmin(dp[i][min(g,j+i*p[i])],dp[i-1][j]+p[i]);
      }
    }
  }

  cout<<dp[d][g]<<endl;

  return 0;
}


Measured memory_bytes: 33024
#include <iostream>
#include <vector>

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

    std::vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }

    std::vector<int> b;
    b.reserve(n);
    for (int i = n - 1; i >= 0; i -= 2) {
        b.push_back(a[i]);
    }
    const int start = (n % 2 == 0) ? 0 : 1;
    for (int i = start; i < n; i += 2) {
        b.push_back(a[i]);
    }

    for (int i = 0; i < n; ++i) {
        std::cout << b[i];
        if (i != n - 1) {
            std::cout << " ";
        } else {
            std::cout << std::endl;
        }
    }
}


Measured memory_bytes: 3712
A, B, K = list(map(int, input().split(" ")))

for i in range(K):
    
    if i % 2 == 0:
        if A % 2 == 1:
            A = A - 1

        A_half = A / 2
        B += A_half
        A = A_half

    else:

        if B % 2 == 1:
            B = B - 1

        B_half = B / 2
        A += B_half
        B = B_half

print(int(A), int(B))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define reff(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long int
#define pll pair<ll,ll>
#define fill(a,x) memset(a,x,sizeof(a))
#define mb make_pair
#define pb push_back
#define F first
#define S second
#define M 1000000007
#define sc(x) scanf("%d",&x)
#define scc(x1,x2) scanf("%d%d",&x1,&x2)
#define sccc(x1,x2,x3) scanf("%d%d%d",&x1,&x2,&x3)
#define pr(x) printf("%lld ",x)
#define dbg(a)          std::cerr<<#a<<"="<<(a)<<"\n"
#define dbg1(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define dbg2(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define dbg3(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define all(v) v.begin(),v.end()
#define PI 3.14159265
#define co cout<<"fuck"<<endl
const int INF = 2034567891;
const ll INF64 = 4234567890123456789ll;
long long nc3(long long v){return (v * (v - 1ll) * (v - 2ll)) / 6ll;}
long long nc2(long long v){return (v * (v - 1ll)) / 2ll;}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
const int N = 10+2e5;
bool isprime(ll n) {
    if (n < 2) return 0;
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;
    return 1;
}
double dist(pll p1, pll p2)
 {
    return (p1. F - p2.F)*(p1.F - p2.F) +
          (p1.S - p2.S)*(p1.S - p2.S);
 }
ll power(ll x,ll y)
{
    ll ans=1;
    while(y>0){
        if(y&1)
            ans=(ans*x)%M;
        x=(x*x)%M;
        y/=2;
    } 
    return ans;
}
int main()
{
     fast;
     ll a,b,n;
     cin>>a>>b>>n;
     ll ma;
	 if(n>=b-1)
	 {
	    ma = (a*(b-1))/b;
	 }
	 else
	   ma=(a*n)/b;
	 cout<<ma;
	 
}   

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;

int main(int argc,char *argv[])
{
	ul n;
	std::cin >> n;

	ul ans = 0;
	for (ul i = 1;i <= n;++i)
	{
		if (!(i%3) || !(i%5)) { continue; }
		ans += i;
	}

	std::cout << ans << std::endl;

	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vpll v;
  rep(i,n){
    ll a,b; cin>>a>>b;
    v.emplace_back(b,a);
  }
  vsort(v);
  ll pos=0;
  rep(i,n){
    pos+=v[i].second;
    if(pos>v[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

int main(){
  string s,t;
  cin >>s;
  cin >>t;
  
  int c=0;
  
  for(int i=0; i<3;i++){
    if(s.at(i)==t.at(i))
    {c++;}
  }
  cout <<c<<endl;
  

}

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

using namespace std;

const int maxN = 100;

struct MaximumMatching {
	static const int maxn = maxN;
	static const int maxm = maxN;

	int n, m;
	vector<int> E[maxn];
	int xlnk[maxn];
	int ylnk[maxm];
	bool vis[maxm];

	void resize(const int & n, const int & m) {
		for (int i = 0; i < this->n; i++)
			E[i].clear();
		this->n = n;
		this->m = m;
	}

	void add_edge(const int & u, const int & v) {
		E[u].push_back(v);
	}

	bool dfs(const int & u) {
		for (const auto & v : E[u]) {
			if (!vis[v]) {
				vis[v] = true;
				if (ylnk[v] == -1 || dfs(ylnk[v])) {
					xlnk[u] = v;
					ylnk[v] = u;
					return true;
				}
			}
		}
		return false;
	}

	int maximum_matching() {
		int ans = 0;
		memset(xlnk, -1, sizeof xlnk[0] * n);
		memset(ylnk, -1, sizeof ylnk[0] * m);
		for (int i = 0; i < n; i++) {
			memset(vis, false, sizeof vis[0] * m);
			if (dfs(i))
				ans++;
		}
		return ans;
	}
};

int N;
int a[maxN], b[maxN], c[maxN], d[maxN];
MaximumMatching MM;

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

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < N; i++)
		cin >> c[i] >> d[i];

	MM.resize(N, N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j])
				MM.add_edge(i, j);
		}
	}

	cout << MM.maximum_matching() << '\n';

	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	int k, x;
	
	cin >> k >> x;
	
//	if(k + x - 1 <= 1000000){
//		for(int i = x; i < k + x; i++){
//			cout << i << " ";
//		}
//	}
//	else{
//		for(int i = x; i > k - x; i--){
//			cout << i << " ";
//		}
//	}

	vector<int> v;
	
	v.push_back(x);
	for(int i = x - 1, j = 0; j < k - 1; j++, i--){
		v.push_back(i);
	}
	for(int i = x + 1, j = 0; j < k - 1; j++, i++){
		v.push_back(i);
	}
	
	sort(v.begin(), v.end());
	
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
	}
	
	cout << endl;
	
    return 0;
}



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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
	
	
	string a;
	cin >> a;
	int flag=0;
	for(int i=0;i<a.length();i++) {
		if(a[i]=='7') {
			flag=1;
		}
	}

	if(flag==1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  
        static long[] a;
        static long N;
        static long K;
        
        static void Main(string[] args)
        {
          //入力を受け取る
          int N = int.Parse(Console.ReadLine());
          //int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          var first = 0;
          var second = 0;
          var best = 0;
          
          for(int i = 0; i < N ; i++){
            int A = int.Parse(Console.ReadLine());
            if(A >= first){
              best = i;
              second = first;
              first = A;
            }else if(A >= second){
              second = A;
            }
          }
          
          for(int i = 0; i < N ; i++){
            if(i != best){
              Console.WriteLine(first);
            }else{
              Console.WriteLine(second);
            }
          }
        }
 }

Measured memory_bytes: 16584
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char** argv) {
    int tam;
    scanf("%d", &tam);
    string letras;
    cin>> letras;
    if (tam % 2 != 0) {
        printf("No");
    } else {
        int meio = tam / 2;
        for (int i = 0; i < meio; i++) {
            if (letras[i] != letras[i + meio]) {
                printf("No");
                return 0;
            }
        }
        printf("Yes");

    }
    return 0;
}



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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main(){
	ll n; cin >> n;
	if(n%10 == 3) {
		cout << "bon\n";
	} else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
		cout << "pon\n";
	} else {
		cout << "hon\n";
	}
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    ll q; cin>>q;
    vector<vector<ll>> que(q,vector<ll>(2,0));


    rep(i,0,q){
        cin>>que[i][0]>>que[i][1];
    }

    vector<bool> v;
    v.resize(110000,true);
    v[0]=false; v[1]=false;
    rep(i,2,v.size()){
        if(v[i]){
            for(int j=i*2; j<v.size(); j+=i){
                v[j]=false;
            }
        }
    }
    
    vector<ll> cum(110000,0);
    rep(i,1,cum.size()){
        if(i%2==1 && v[i]==true && v[(i+1)/2]==true){
            cum[i]=cum[i-1]+1;
        }else{
            cum[i]=cum[i-1];
        }
    }

    rep(i,0,q){
        cout<<cum[que[i][1]]-cum[que[i][0]-1]<<endl;
    }
}

Measured memory_bytes: 7040
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	char buf[11];
	while (scanf("%s\n", buf) != EOF)
	{
		int n[10];
		for (int i = 0; i < 10; ++i)
			n[i] = buf[i] - '0';

		for (int i = 9; i > 0; --i)
			for (int j = 0; j < i; ++j)
				n[j] = (n[j] + n[j+1]) % 10;

		printf("%d\n", n[0]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int &x:l)
    cin >> x;
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  int length = 0;
  for (int i = 0; i < K; i++){
    length += l.at(i);
  }
  
  cout << length << endl;
  return 0;
}



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

int main() {
	int w,h,x,y,r;
	
	cin>>w>>h>>x>>y>>r;
	
	
	if( x>=r && y>=r && x<=w-r && y<=h-r ){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

int main()
{
    s64 d, t, s;
    cin >> d >> t >> s;

    if(t * s >= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }    

    return 0;
}


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

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

    if (n % 1000 == 0) {
        cout << 0 << endl;
        return 0;
    }

    int ans = ((n / 1000) + 1) * 1000 - n;

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{ int p,l,r; };
struct Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL) return ;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return ;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return ;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",  u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i = 0;i < n;i++) T[i].p = NIL;
  for(i = 0;i < n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  for(i = 0;i < n;i++) if(T[i].p == NIL) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}

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

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

    if(a+b == c+d)
        cout<<"Balanced"<<endl;
    else if(a+b > c+d)
        cout<<"Left"<<endl;
    else
        cout<<"Right"<<endl;

    return 0;
}


Measured memory_bytes: 256
%:pragma GCC optimize(2)
#include<bits/stdc++.h>
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
typedef long long ll;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 3e5 + 10, inf = 5176666;
int tr[N << 2][2], M;
int idx[N], a[N], n, m, ans[N], top = 0;
// 0 Å¼Êý, 1 ÆæÊý
inline void Build() {
    memset(tr, 127 / 3, sizeof(tr));
    for(M = 1; M <= n + 1; M ++);
    for(int i = M + 1; i <= M + n; i ++) tr[i][(i - M) & 1] = a[i - M];
    for(int i = M; i; i --) {
        for(int a = 0; a < 2; a ++) {
            tr[i][a] = min(tr[i << 1][a], tr[i << 1 | 1][a]);
//          cout << i << ' ' << a << ' ' << tr[i << 1][a] << ' ' << tr[i << 1 | 1][a] << "\n";
        }
    }
}
 
inline void U(int u, int v, int k) {
    for(tr[u += M][k] += v; u; u >>= 1, tr[u][k] = min(tr[u << 1][k], tr[u << 1 | 1][k]));
}
 
inline int Q(int s, int t, int k, int ans = inf) {
    if(s > t) return ans;
    for(s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
        if(~s & 1) ans = min(ans, tr[s ^ 1][k]);
        if(t & 1) ans = min(ans, tr[t ^ 1][k]);
    }
    return ans;
}
 
struct T {
    int tr[N << 2];
    inline int A(int x, int val) {
        for(; x <= n ;x += x & -x) tr[x] += val;
    }
     
    inline int Q(int x, int ans = 0) {
        for(; x >= 1; x -= x & -x) ans += tr[x]; return ans;
    }
}bit;
 
struct Node {
    int l, r;//ºÏ·¨µÄÇø¼ä
    int s, t;//Ñ¡µÄÎ»ÖÃ
    int o, v;//one or zero
    Node(int L = 0, int R = 0) {
//      cout << L << ' ' << R << "\n";
//      out(bit.Q(L));
        int kk = bit.Q(L) & 1;
        int one = Q(L, R, kk ^ 1);
        int two = Q(idx[one] + 1, R, kk);
        l = L, r = R;
        s = idx[one], t = idx[two];
        o = one;
        v = two;
//      cout << l << ' ' << r << ' ' << s << ' ' << t << ' ' << o << ' ' << v << " Node test\n";
    }
    bool operator < (const Node &rhs) const {
        return o > rhs.o || (o == rhs.o && v > rhs.v);
    }
};
priority_queue<Node> q;
 
inline void A(Node &u) {
//  out(u.o);out(u.v);
    ans[++ top] = u.o;
    ans[++ top] = u.v;
    bit.A(u.s, 1);
    bit.A(u.t, 1);
}
 
main() {
//  freopen("1.in", "r", stdin);
//  freopen("100.out", "w" ,stdout);
    read(n);for(int i = 1; i <= n; i ++) read(a[i]), idx[a[i]] = i;
    Build();
//  cout << Q(1, n, 1) << ' ' << Q(1, n, 0) << "\n";
//  return 0;
    q.push(Node(1, n));
    while(!q.empty()) {
        Node u = q.top(); q.pop();A(u);
        if(u.l < u.s - 1) q.push(Node(u.l, u.s - 1));
        if(u.s + 1 < u.t - 1) q.push(Node(u.s + 1, u.t - 1));
        if(u.t + 1 < u.r) q.push(Node(u.t + 1, u.r));
    }
    for(int i = 1; i <= top; i ++) {
        assert(ans[i] >= 1 && ans[i] <= n);
        cout << ans[i] << ' ';
    }
    putchar('\n');
}

Measured memory_bytes: 16884
#include <iostream>
#include <map>
using namespace std;
const int Maxn=105;
map <int,int> dp[Maxn];
int n,m,ans;
int w[Maxn],v[Maxn];
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>w[i]>>v[i];
	dp[0][0]=0;
	for (int i=0;i<n;i++)
	{
		for (auto &it:dp[i])
		{
			int w1=it.first,v1=it.second;
			dp[i+1][w1]=max(dp[i+1][w1],v1);
			if (w1+w[i+1]<=m) dp[i+1][w1+w[i+1]]=max(dp[i+1][w1+w[i]],v1+v[i+1]);
		}
	}
	for (auto &it:dp[n])
	{
		int w1=it.first;
		int v1=it.second;
		if (w1<=m) ans=max(ans,v1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
n, m = map(int, input().split())
K = []
S = []
for i in range(m):
    k, *s = map(int, input().split())
    K.append(k)
    S.append(s)
p = list(map(int, input().split()))

ans = 0
for i in range(1<<n):
    onoff = [None] * m
    for j in range(m):
        cnt = 0
        for s in S[j]:
            if (i >> (s-1)) & 1:
                cnt += 1
        if cnt % 2 == p[j]:
            onoff[j] = True
    if all(onoff):
        ans += 1

print(ans)

Measured memory_bytes: 42476
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n;
ll ans=0;
char s[N];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int cnt=0;
	for (int i=n;i;i--)
	if (s[i]=='W') cnt++;
	else ans+=cnt;
	cout<<ans;
	return 0;
}

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

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

	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());

	ll ans = 0;
	int t = n - 1;

	for(int i=0; i<n; i++){
		int lim = 2;
		if(i == 0) lim = 1;
		for(int j=0; j<lim; j++){
			if(t > 0){
				ans += a[i];
				t--;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4048