akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1e4 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, a[MXN], cnt, sum;

int main(){
	ios;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i < n; i++){
		sum += a[i];
		if(2 * sum >= a[i + 1]){
			cnt++;
		}else{
			cnt = 0;
		}
	}
	cout << cnt + 1;
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        
        String[] input = lines[0].split(" ");
        int n = Integer.parseInt(input[0]);
        
        System.out.println(n*n*n);
    }
    
    private static String[] getStdin() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> lines = new ArrayList<>();
        while (scanner.hasNext()) {
            lines.add(scanner.nextLine());
        }
        return lines.toArray(new String[lines.size()]);
    }
}

Measured memory_bytes: 21972
import numpy as np
N, M, V, P = [int(_) for _ in input().split()]
A = np.array([int(_) for _ in input().split()], dtype=int)
A.sort()


def check(idx):
    a = A[idx]
    # idx問目(0-indexed)を勝たせられるかどうか
    # M回すべてidx問目であればa→a+M
    # A[:idx]とA[N-P+1:]はM回全て選択したとしてもidx問目の可否が悪化することは無い
    # 　N-P+1<=idxであれば必ずOK
    # 　A[idx]+M<A[N-P]であれば必ずNG
    # A[idx+1:N-P+1]から(V-P-idx)個をM回選択したときの総数<=(a+M)*(N-P-idx)であればOK
    if N - P + 1 <= idx:
        return True
    elif a + M < A[N - P]:
        return False
    else:
        return sum(A[idx + 1:N - P +
                     1]) + (V - P - idx) * M <= (a + M) * (N - P - idx)


lb = -1
rb = N
# Min x for check(x) == True
while rb - lb > 1:
    mid = (rb + lb) // 2
    if check(mid):
        rb = mid
    else:
        lb = mid
print(N - rb)


Measured memory_bytes: 38448
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main() {
	// your code goes here
	int N, Q;
 
	cin >> N >> Q;
  vector<string> S(N);
  for (auto& i : S) {
    cin >> i;
    i += '#';
  }
  S.push_back("################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################");
 

  vector<vector<int>> num(N+1);
  
  for (auto& i : num)
    i.resize(Q+1, 0);
  
  auto numv = num;
    for (int i = N-1;i>=0; i--)
		for (int j = Q-1;j>=0; j--)
	{
          if (S[i][j] == '.') {
            num[i][j] = 1;
            if (S[i][j+1] == '.')
              num[i][j] += num[i][j+1];
          }
          else
            num[i][j] = 0;

          if (S[i][j] == '.') {
            numv[i][j] = 1;
            if (S[i+1][j] == '.')
              numv[i][j] += numv[i+1][j];
          }
          else
            numv[i][j] = 0;
	}
  
  int result = 0;
    for (int i = 0;i<N; i++)
		for (int j = 0;j<Q; j++)
	{
          
          if (S[i][j] == '.') {
            if (j > 0) num[i][j] = max(num[i][j],num[i][j-1]);
            if (i > 0) numv[i][j] = max(numv[i][j],numv[i-1][j]);
          	result = max(result, num[i][j] + numv[i][j] - 1);
          }
    }
  
	cout << result << endl;
 
	return 0;
}

Measured memory_bytes: 35840
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>

using namespace std;

int main(void)
{
	map <int, int> count;
	long long m1 = 0, m2 = 0;
	int temp, n;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		if (count[temp] <= 3)
		{
			count[temp]++;
		}

		if (count[temp] == 2 || count[temp] == 4)
		{
			if (m1 < temp)
			{
				m2 = m1;
				m1 = temp;
			}
			else if (m2 < temp)
			{
				m2 = temp;
			}
		}
	}

	cout << m1*m2 << endl;

	return 0;
}

Measured memory_bytes: 4992
a[9];main(z,n,m,i){for(;scanf("%d%d",&m,&n)*n;puts(a))for(*a=1;~n--;)for(i=18;i;a[i]=~n?a[i+1]+=z*m/1e4,z*m%10000:z&&!printf("%d%.3s",z,51-i*3+"MtsFksNytAsgGgsGokSaiSeiKanKo\0JouJo\0GaiKeiChoOkuMan"))z=a[--i];}

Measured memory_bytes: 616
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
     
    int cards[4][13];
    for(int suit = 0;suit<4;suit++){
        for(int num = 0;num<13;num++){
            cards[suit][num]=0;
        }
    }
 
    for(int i=0;i<n;i++)
    {
        char suit;
        int x;
        cin >> suit;
        cin >> x;
        switch(suit){
            case 'S':
                cards[0][x-1]=1;
                break;
            case 'H':
                cards[1][x-1]=1;
                break;
            case 'C':
                cards[2][x-1]=1;
                break;
            case 'D':
                cards[3][x-1]=1;
                break;
        }
    }
    for(int suit = 0;suit<4;suit++){
        for(int num = 0;num<13;num++){
             
            if(cards[suit][num]==0){
                switch(suit){
                    case 0:
                        cout << 'S' << " ";
                        break;
                    case 1:
                        cout << 'H' << " ";
                        break;
                    case 2:
                        cout << 'C' << " ";
                        break;
                    case 3:
                        cout << 'D' << " ";
                        break;
            }
            cout << (num+1) << endl;
                 
            }
             
        }
    }
     
 
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int N=1e5+5;
const ll p=1000000007;


int main()
{
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    for(ll i=1;i<=1000000;i++)
    {
        ll x=i*0.08;
        ll y=i*0.1;
        if(x==a&&y==b)
        {
            cout<<i<<endl;return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

int N,K;
int H[200200];

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

int main(){
	int i;
	long long total = 0;
	
	scanf("%d",&N);
	scanf("%d",&K);
	
	for(i = 0; i < N; i++){
		scanf("%d",&(H[i]));
	}
	
	qsort(H,N,sizeof(int),compare);

	for(i=K; i < N;i++){
		total += H[i];
	}
	
	printf("%lld\n",total);
}
	
	

Measured memory_bytes: 1788
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]


N, M, K = map(int, input().split())
A, B = [0] * M, [0] * M  # 入力時に 0-index に合わせる
C, D = [0] * K, [0] * K  # 入力時に 0-index に合わせる

direct =[[] for _ in range(N)]  # 同じ集合の友達もしくはブロック関係の人
uf = UnionFind(N)  # 友達関係をまとめた UnionFind 木

for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
    direct[A[i]].append(B[i])
    direct[B[i]].append(A[i])
    uf.unite(A[i], B[i])

for i in range(K):
    C[i], D[i] = map(int, input().split())
    C[i] -= 1
    D[i] -= 1
    if uf.is_same(C[i], D[i]):
        direct[C[i]].append(D[i])
        direct[D[i]].append(C[i])

ans = [0] * N
for i in range(N):
    ans[i] = uf.group_size(i) - len(direct[i]) - 1
print(*ans)


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

using namespace std;

constexpr long long INF = (long long)1e18;

#define x first
#define y second

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


vector<pair<long double,long double>> in;
	
long double cal(long double X, long double Y){
	long double maximum = 0;
	
	for(int i = 0; i < in.size(); i++){
		maximum = max(maximum, (in[i].x - X) * (in[i].x - X) + (in[i].y - Y) * (in[i].y - Y));
	}
	
	return sqrt(maximum);
}
	
long double ternary_search2(long double X, long double l = 0, long double h = 1000){
	long double y1, y2, minimum = INF;
	
	for(int i = 0; i < 45; i++){
		y1 = (2 * l + h) / 3;
		y2 = (l + 2 * h) / 3;
		
		long double f1 = cal(X, y1);
		long double f2 = cal(X, y2);
		
		minimum = min(minimum, f1);
		minimum = min(minimum, f2);
		
		if(f1 < f2) {
			h = y2;
		} else {
			l = y1;
		}
	}
	
	return minimum;
}

long double ternary_search(long double l = 0, long double h = 1000){
	long double x1, x2, minimum = INF;
	
	for(int i = 0; i < 45; i++){
		x1 = (2 * l + h) / 3;
		x2 = (l + 2 * h) / 3;
		
		long double f1 = ternary_search2(x1);
		long double f2 = ternary_search2(x2);

		minimum = min(minimum, f1);
		minimum = min(minimum, f2);
		
		if(f1 < f2) {
			h = x2;
		} else {
			l = x1;
		}
	}
	
	return minimum;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].x>>in[i].y;
	}
	
	cout<<ternary_search()<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double oo = 1e18;
 
int n, x[100100], y[100100];
char d[100100];
 
double calc(double t)
{
  double xMax = -oo, xMin = oo, yMax = -oo, yMin = oo;
  for (int i = 0; i < n; i++)
  {
    double curX = x[i], curY = y[i];
    if (d[i] == 'U') curY += t;
    else if (d[i] == 'D') curY -= t;
    else if (d[i] == 'R') curX += t;
    else curX -= t;
    xMax = max(xMax, curX);
    xMin = min(xMin, curX);
    yMax = max(yMax, curY);
    yMin = min(yMin, curY);
  }
  return (xMax - xMin) * (yMax - yMin);
}
 
int main()
{
  ios::sync_with_stdio(0);
  
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> d[i];
 
  double ans = calc(0), low = 0, high = 1e9;
  for (int turn = 0; turn < 150; turn++)
  {
    double mid1 = (low * 2 + high) / 3, v1 = calc(mid1);
    double mid2 = (low + high * 2) / 3, v2 = calc(mid2);
    if (v1 < v2) high = mid2;
    else low = mid1;
  }
 
  ans = min(ans, calc(low));
  cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 1152
# Tax Rate Changed
import math
ans = []


def tax(p, x):
    return p * (100 + x) // 100

while True:
    x, y, s = map(int, input().split())
    if x == 0 and y == 0 and s == 0:
        break
    max_price = []
    for i in range(1, s):
        for j in range(i, s):
            if tax(i, x) + tax(j, x) == s:
                max_price.append(tax(i, y) + tax(j, y))

    ans.append(max(max_price))

for i in ans:
    print(i)



Measured memory_bytes: 5688
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main
{

	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputValue = br.readLine().split(" ");
		String[] inputDirection = br.readLine().split("");
		Dice dice = new Dice(inputValue);

		for (String s : inputDirection)
		{
			switch (s)
			{
				case "N":
					dice.moveNourth();
					break;

				case "S":
					dice.moveSourth();
					break;

				case "E":
					dice.moveEast();
					break;

				case "W":
					dice.moveWest();
					break;
			}
		}

		System.out.println(dice.getTop());

	}

}

class Dice
{
	public int[] Array = new int[6];
	private int tmp;

	public Dice(String[] num)
	{
		for (int i = 0; i < 6; ++i)
			this.Array[i] = Integer.parseInt(num[i]);
	}

	// ??????????????????????????????
	public void moveWest()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[2];
		this.Array[2] = this.Array[5];
		this.Array[5] = this.Array[3];
		this.Array[3] = this.tmp;
	}

	// ??????????????????????????????
	public void moveNourth()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[1];
		this.Array[1] = this.Array[5];
		this.Array[5] = this.Array[4];
		this.Array[4] = this.tmp;
	}

	// ??????????????????????????????
	public void moveEast()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[3];
		this.Array[3] = this.Array[5];
		this.Array[5] = this.Array[2];
		this.Array[2] = this.tmp;
	}

	// ?????????????????????????????????
	public void moveSourth()
	{
		this.tmp = this.Array[0];
		this.Array[0] = this.Array[4];
		this.Array[4] = this.Array[5];
		this.Array[5] = this.Array[1];
		this.Array[1] = this.tmp;
	}

	public int getTop()
	{
		return this.Array[0];
	}
}

Measured memory_bytes: 24620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// int mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j=1,k,temp,a,b=0,n;
    cin >> n;
    while(n>0){
        n/=2;
        b+=j;
        j*=2;
    }
    cout << b;
}

Measured memory_bytes: 256
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
liset = set()
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    liset.add((a,b))
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if (i,j) not in liset:
            print(a + b)
            exit()
print(a + b - 1)

Measured memory_bytes: 110288
#include<stdio.h>

int main(){
    int i,j,w[20],k[20];
    int aw[20], ak[20];
    int sw, sk;

    for(i=0;i<10;i++)
        scanf("%d",&w[i]);
    for(i=0;i<10;i++)
        scanf("%d",&k[i]);

    for(j=0;j<10;j++){
        int use;
        ak[j] = 1000000000;
        for(i=0;i<10;i++){
            if(k[i] < ak[j]){
                ak[j] = k[i];
                use = i;
            }
        }
        k[use] = 100000000;
    }

    for(j=0;j<10;j++){
        int use;
        aw[j] = 1000000000;
        for(i=0;i<10;i++){
            if(w[i] < aw[j]){
                aw[j] = w[i];
                use = i;
            }
        }
        w[use] = 100000000;
    }

    sw=aw[9]+aw[8]+aw[7];
    sk=ak[9]+ak[8]+ak[7];

    printf("%d %d\n",sw,sk);

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

class Node{
public:
  int count, left, right;
  Node() : count(0), left(-1), right(-1) {}
};

Node data[200];
int size;
string out;

void input(int l, int r, string& str, int p){
  data[p].count++;
  if(str.size() == 3) return;
  int cnt = 0;
  for(int i=l;i<=r;i++){
    if(str[i] == '(') cnt++;
    if(str[i] == ')') cnt--;
    if(str[i] == ',' && cnt == 1){
      if(l+1 != i){
        if(data[p].left == -1) data[p].left = size++;
        input(l+1, i-1, str, data[p].left);
      }
      if(i+1 != r){
        if(data[p].right == -1) data[p].right = size++;
        input(i+1, r-1, str, data[p].right);
      }
    }
  }
}

void output(char ope, int p){
  if(ope == 'i' && data[p].count < 2) return;
  out += '(';
  if(data[p].left != -1) output(ope, data[p].left);
  out += ',';
  if(data[p].right != -1) output(ope, data[p].right);
  out += ')';
}

main(){
  char ope;
  string a, b;
  while(cin >> ope >> a >> b){
    fill(data, data+100, Node());
    size = 1;
    input(0, (int)a.size()-1, a, 0);
    input(0, (int)b.size()-1, b, 0);
    out = "";
    output(ope, 0);
    cout << out << endl;
  }
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, a[200002], k;

int main(){
	cin >> n >> k;
	for(int i=0;i<n;i++){
		int b;
		cin >> b;
		a[b]++;
	}
	sort(a,a+n+1);
	int ans=0;
	for(int i=1;i<=n-k;i++){
		ans += a[i];
	}
	cout <<  ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int ls;
string s,s1;
int main()
{
cin>>s;
s1=s;
reverse(s.begin(),s.end());
for(int i=0; i<s.size(); i++)
{
	if(s[i]=='b')s[i]='d';
	else if(s[i]=='d')s[i]='b';
	else if(s[i]=='p')s[i]='q';
	else if(s[i]=='q')s[i]='p';
}
if(s1==s)cout<<"Yes";
else cout<<"No";
return 0;
}


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

namespace {
    template <typename T, std::size_t N>
    inline size_t sizeOfArray(const T (&)[N])
    {
        return N;
    }
}

int main() {
    char ch;
    int alpha_cnt[26] = {};

    while (cin >> ch) {
        if (ch >= 'A' && ch <= 'Z') {
            ch += 'a' - 'A';
        }
        int num = ch - 'a';
        if (num >=0 && num <= 25) {
            alpha_cnt[num]++;
        }
    }

    for (int i = 0; i < sizeOfArray(alpha_cnt); i++) {
        cout << (char)(i + 'a') << " : " << alpha_cnt[i] << endl; 
    }

    return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>

int main(){
  int i,j,k;
  long long int x,ans=0;
  scanf("%lld",&x);
  
  ans += (x/11)*2;
  x %= 11;
  if(x!=0){
  if(x >6)
    ans+=2;
  else
    ans++;
  }
  printf("%lld\n",ans);
  return 0;
}
    
  



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

int main()
{
    int num = 0;
    int pnum = 0;
    string numbers;

    cin >> numbers;

    for (int i = 0; i < 4; i++)
    {
        num = int(numbers[i]);
        if(i>0){
            if(num == pnum){
                cout << "Bad" << endl;
                return 0;
            }else{
                pnum = num;
            }
        }else{
            pnum = num;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

map<int,int> cache;

int gcd(int a,int b){
	if(b>a)swap(a,b);
	
	while(b){
		a=a%b;
		swap(a,b);
	}
	return a;
}

map<int,int> lcmm;

main(){
	int n,a,b;
	while(cin>>n>>a>>b){
		if(n==0 && a==0 && b==0)break;
		
		cache.clear();
		lcmm.clear();
		
		int lcm=a*b/gcd(a,b);
		int mind=gcd(a,b);
		
		for(int i=0;i*a<=lcm;i++){
			for(int j=0;j*b+i*a<=lcm;j++){
				if(i==0 && j==0)continue;
				lcmm[a*i+j*b]=a*i+j*b;
			}
		}
		

		
		int ans=lcmm.size()+(n-lcm)/mind;
		if(n<lcm){
			ans=0;
			for(int i=1;i<=n;i++){
				if(lcmm[i])++ans;
			}
		}
		
		
		cout<<n-ans<<endl;
	}
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) lli((x).size())
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
 
typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
 
#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}

int main(){
	int n; cin>>n;
	vector<pair<int,int> >  v;
	rep(i,0,n){
		int fo; cin>>fo;
		v.pb({fo,i});
	}
	sort(all(v));
	for(auto x : v){
		cout<<x.ss+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 4240
#include <ctype.h>
#include <stdio.h>

int main(void){
    char ch;
    int alphabet[26] = { 0 };
    int i;
    
    while(scanf("%c", &ch) != EOF){
        if(!isalpha(ch)) continue;
        if(islower(ch))
            alphabet[ch - 'a']++;
        else if(isupper(ch))
            alphabet[ch - 'A']++;
    }
    
    for(i = 0; i < 26; i++){
        printf("%c : %d\n", i + 'a', alphabet[i]);
    }
    
    return 0;
}



Measured memory_bytes: 2100
#include <cstdio>

bool judge(int year)
{
	if (year % 4 == 0) {
		if (year % 100 != 0) {
			return true;
		} else if(year % 400 == 0){
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}

int main(void){
	int a, b, n_data;
	bool flag;//うるう年があるかどうか
	n_data=0;//いくつ目のデータセットか

	while (1) {
		scanf("%d%d", &a, &b);
		if (a == 0 && b == 0) {
			break;
		}

		if (n_data != 0) {//もし最初のデータセットでなければ
			printf("\n");
		}

		flag = false;
		for (int i=a; i <= b; i++) {
			if (judge(i)) {
				printf("%d\n", i);
				flag = true;
			}
		}
		if (!flag) {//もしうるう年がなければ
			printf("NA\n");
		}

		n_data++;
	}

	return 0;
}

Measured memory_bytes: 1044
import java.util.*;
 class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();

		int[][][] hs = new int[4][3][10];

		
		for(int i=0;i<n;i++){
			int b = sc.nextInt();
		    int f = sc.nextInt();
		    int r = sc.nextInt();
			int v = sc.nextInt();
			
			hs[b-1][f-1][r-1] += v;
		}

		for(int r=0;r<4;r++){
			for(int y=0;y<3;y++){
				for(int o=0;o<10;o++){

					System.out.print(" " + hs[r][y][o]);
					if(o==9){
						System.out.println();
					}
				}
			}
			if(r != 3){
				System.out.println("####################");
			}
		}
	}
}


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

ll findpow(ll a,ll b){
    ll cnt=0,i,j;
    while(a>1){
        a=a/b;
        cnt++;
    }
    return cnt;
}

int main(){
    ll i,j,k,sum,flag=0,t,m,n;
   string s1,s2,s;
cin>>s;
if(s[3]==s[2]&&s[4]==s[5]){
       cout<<"Yes"<<endl;
}
else{
     cout<<"No"<<endl;
}

   
       
    
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    ll ans = 0;

    rep(i, n) {
        int a;
        cin >> a;
        ans += mp[i - a];
        mp[i + a]++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20520
/*
* @Author: Kabid
* @Date:   2020-04-16 00:45:39
*/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define in(x)  scanf("%d", &x);
#define ins(x) scanf("%s", &x);
#define out(x) printf("%d", x);
#define outs(x) printf("%s", x);
#define _ putchar(' ');
#define lin puts("");

int t,i,j=0,k,l,x=0,r,la,lb;
long long c=0,m=1,ci=0,ca=0,cb=0;
char s[100001];
char sa[501],sb[501];
int a[1001],b[1001]={0},e[101]={0},g[101]={0},d;
int main(){
	in(x)
	for(i=1;i<=x;i++){
		if(i%15!=0 && i%3!=0&&i%5!=0){
			c+=i;
		}
	}
	printf("%lli",c);

		

	
	
	
	
	


    return 0;
 }
	
		


Measured memory_bytes: 1740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>
#include <sstream>
#include <iomanip>

using namespace std;

using Graph = vector<vector<int> >;

vector<int> seen;



int main()
{
	int N;

	cin >> N;

	int sum = 0;

	vector<int> Ds(N);
	for (int ni = 0; ni < N; ni++) {
		cin >> Ds[ni];
	}

	for (int li = 0; li < N - 1; li++) {
		for (int ri = li + 1; ri < N; ri++) {
			sum += Ds[li] * Ds[ri];
		}
	}


	//printf("%d %d %lld", xi, yi, H + gap);

	cout << sum;
	

	return 0;
}



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


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli inf = 10000 * 10000;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string s;
	cin >> s;

	if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main()
{
  int N ;
  string S ;
  cin>>N>>S ;
  
  if(N%2==0){
    int center=N/2 ;
    for(int i=0;i<center;i++){
      if(S.at(i)!=S.at(i+center)){
        cout<<"No"<<endl ;
        return 0 ;
      }
    }
    cout<<"Yes"<<endl ;
  }else cout<<"No"<<endl ;
  
  return 0 ;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n , k ;
int p[ 100005 ] ;
vector< int > v[ 100005 ] ;

void init() {
  scanf( "%d%d" , &n , &k ) ;
  for ( int i = 1 ; i <= n ; i ++ ) {
    scanf( "%d" , &p[ i ] ) ;
    if ( i != 1 ) v[ p[ i ] ].push_back( i ) ;
  }
}

int dp[ 100005 ] ;
int ans = 0 ;

void dfs( int now ) {
  for ( int nxt : v[ now ] ) {
    dp[ nxt ] = dp[ now ] + 1 ;
    dfs( nxt ) ;
  }
}

int ord[ 100005 ] ;
bool ex[ 100005 ] ;

void process() {
  ans = 0 ;
  dp[ 1 ] = 0 ;
  dfs( 1 ) ;
  bool same = true ;
  int cyc = dp[ p[ 1 ] ] + 1 ;
  if ( cyc != 1 ) {
    same = false ;
    ans ++ ;
    cyc = 1 ;
  }
  for ( int i = 1 ; i <= n ; i ++ ) ord[ i ] = i ;
  sort( ord + 1 , ord + n + 1 , [&]( int a , int b ) {
    return dp[ a ] > dp[ b ] ;
  } ) ;
  memset( ex , true , sizeof ex ) ;
  ex[ 1 ] = false ;
  for ( int id = 1 ; id <= n ; id ++ ) {
    int i = ord[ id ] ;
    if ( ex[ i ] == false ) continue ;
    for ( int j = 0 ; j <= k ; j ++ ) {
      if ( j == k ) {
        ans ++ ;
        break ;
      }
      ex[ i ] = false ;
      i = p[ i ] ;
      if ( ex[ i ] == false ) break ;
    }
  }
  printf( "%d\n" , ans ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
     ll  n; cin>>n;
     ll ans=1ll*10000*10000*10000;
     for(int i=1;1ll*i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,n/i+i-2);
        }
     }
     cout<<ans<<endl;
     return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate


def read():
    N = int(input().strip())
    return N,


def solve(N):
    ans = 0
    for a in range(1, N):
        b, c = divmod(N, a)
        if c == 0:
            ans += (b-1)
        else:
            ans += b
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main (){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC";
    }else if(r <2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.next();
	String ans = str.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","");
	if(ans.length()==0) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 28752
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 

 
int main()
{
    int X,A,B;
  int i=0;      
 // 整数の入力
    scanf("%d", &X);
    scanf("%d", &A);
    scanf("%d", &B);
/*
  // printf("%d\n",N);
    for(i = 1; i < N +1;i++){
      scanf("%d %d %d", &t[i],&x[i], &y[i]);      
//      printf("%d %d %d", t[i],x[i], y[i]);
      t_temp=t[i] - t[i-1];
/*      if(0 < x[i] - x[i-1]) x_temp=x[i] - x[i-1];
      else  x_temp=x[i-1] - x[i];
      if(0 < y[i] - y[i-1]) y_temp=y[i] - y[i-1];
      else  y_temp=y[i-1] - y[i];
 */
  /*
      x_temp=abs(x[i] - x[i-1]);
      y_temp=abs(y[i] - y[i-1]);
      
//      printf("%d %d %d\n", t_temp,x_temp, y_temp);
 //     printf("%d \n", abs((t_temp-(x_temp+y_temp))));
  //    printf("%d \n", t_temp-(x_temp+y_temp));
      if((0>(t_temp-(x_temp+y_temp))) || ((1==(t_temp-(x_temp+y_temp)) %2))){
//      if(0>(t_temp-(x_temp+y_temp))){
//        if(0 != abs((t_temp-(x_temp+y_temp)) ) %2 ){
        printf("No\n");
        return 0;
      }
    }
 */

  while(1){

    if(0>X-A-(B*i)) break;
  i++;
  }
  
  printf("%d\n",X-A-(B*(i-1)));

return 0;
}


Measured memory_bytes: 128
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"


def solve():
    N = int(input())
    A = list(sorted(list(map(int, input().split())), reverse=True))

    alice, bob = 0, 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            alice += a
        else:
            bob += a

    return alice - bob


def main():
    print(solve())


if __name__ == '__main__':
    main()

Measured memory_bytes: 3916
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		int n=getInt();

		Map<Long,Integer>a=new TreeMap<>(Comparator.reverseOrder());

		INS(n).asLongStream().forEach(i->a.merge(i,1,Integer::sum));

		long r=-1;
		for(Entry<Long,Integer> e:a.entrySet()) {
			long k=e.getKey();
			int v=e.getValue();
			if(r==-1&&v>=4) {
				System.out.println(k*k);
				return;
			}
			if(r==-1&&v>=2) {
				r=k;
				continue;
			}
			if(r!=-1&&v>=2) {
				System.out.println(r*k);
				return;
			}
		}
		System.out.println(0);
	}
}

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

int main(){
  char s[4];
  int count=0;
  cin >> s;
  sort(s,s+4);
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[3]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    ll N;
    cin >> N;
    vector<string> S(N);
    vector<vector<ll>> A(N, vector<ll>(26));

    rep(i, N) {
        rep(j, 26) {
            A[i][j] = 0;
        }
    }

    rep(i, N) {
        cin >> S[i];
        rep(j, S[i].size()) {
            A[i][S[i][j] - 'a']++;
        }
    }

   string ans = "";
   ll tmp;
   char w;

    rep(j, 26) {
        tmp = 50;
        rep(i, N) {
            tmp = min(tmp, A[i][j]);
        }
        w = 'a' + j;
        rep(i, tmp){
            ans = ans + w;
        }
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define fi first
#define sec second
#define pb push_back
int num[10],cnt[10];
int sum[10000];
int m;
void dfs(int x,int s){
	if(x==m){
		sum[s]++;
		return;
	}
	for(int i=0;i<=cnt[x];i++){
		dfs(x+1,s+num[x]*i);
	}
}
int main(){
	while(1){
		memset(sum,0,sizeof(sum));
		scanf("%d",&m);
		if(m==0)break;
		for(int i=0;i<m;i++){
			scanf("%d %d",&num[i],&cnt[i]);
		}
		dfs(0,0);
		int n,g;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d",&g);
			printf("%d\n",sum[g]);
		}
	}
	return 0;
}

Measured memory_bytes: 1232
n=int(input())
a=list(map(int,input().split()))

#R,B,Gの順に埋めていく
#R,B,Gの現在の数を保存する
cnt={'R':0,'B':0,'G':0}
ans=1
for i in range(n):
    count=0
    edi=0
    for j in 'RBG':
        if cnt[j]==a[i]:
            count+=1
            if edi==0:
                cnt[j]+=1
                edi=1
    ans*=count
print(ans%(10**9+7))

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

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

const int MOD = 2019;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int L, R;
    cin >> L >> R;

    if (L / MOD != R / MOD) {
        cout << 0 << "\n";
        return 0;
    }

    L %= MOD, R %= MOD;
    int b = min(L, R), e = max(L, R);

    int minv = 3000;
    for (int i = b; i <= e; ++i) {
        for (int j = i + 1; j <= e; ++j) {
            minv = min(minv, i * j % MOD);
        }
    }

    cout << minv << "\n";

    return 0;
}


Measured memory_bytes: 256
while True:
  m, f, r = map(int, input().split())
  if m == -1 and f == -1 and r == -1:
    break
  elif m == -1 or f == -1:
    print('F')
  elif m + f >= 80:
    print('A')
  elif m + f >= 65:
    print('B')
  elif m + f >= 50:
    print('C')
  elif m + f >= 30:
    if r >= 50:
      print('C')
    else:
      print('D')
  else:
    print('F')


Measured memory_bytes: 5592
def output(X):
  for x in X:
    print(*x)

N,K = map(int,input().split())
ALL = N*(N-1)//2
MAX = ALL - (N-1)
if K > MAX:
  print(-1)
  exit()
G = []
req = ALL-K
cnt = 0
for i in range(1,N+1): #1-N
  for j in range(i+1,N+1): #i+1-N
    if i == 1:
      G.append([i,j])
      cnt += 1
    else:
      if cnt >= req:
        print(req)
        output(G)
        exit()
      else:
        G.append([i,j])
        cnt += 1
print(req)
output(G)

Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	char T[200000], D[200000];
	rep(i, Q) {
		cin >> T[i] >> D[i];
	}

	int L = -1;
	for (int i = Q - 1; i >= 0; i--) {
		if (L < N - 1 && D[i] == 'L' && S[L + 1] == T[i]) L++;
		else if (L >= 0 && D[i] == 'R' && S[L] == T[i]) L--;
	}
	int R = N;
	for (int i = Q - 1; i >= 0; i--) {
		if (R > 0 && D[i] == 'R' && S[R - 1] == T[i]) R--;
		else if (R < N && D[i] == 'L' && S[R] == T[i]) R++;
	}

	int kotae = max(0, R - L - 1);
	co(kotae);

	Would you please return 0;
}

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

int main() {
  int n, d, s = 0, t;
  cin >> n;
  t = n;
  d = log10(n) + 1;

  for (int i = d; i > 0; i--) {
    s += t / (int)pow(10, i - 1);
    t = t % (int)pow(10, i - 1);
  }

  cout << (n % s == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
   int n,a,b,c,re;
   scanf("%d",&n);
   a=n%10;
   n=n/10;
   b=n%10;
   if(a==9||b==9){
    printf("Yes\n");
   }
   else{
    printf("No");
   }

}

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

int main(void){
	int n;
	while (cin >> n && n)
	{
		vector<int> h;
		h.resize(n + 1);
		for (int i = 0; i < n + 1; ++i){
			cin >> h[i];
		}
		for (int i = 0; i<n + 1; ++i)
		{
			vector<int>p = h;
			p.erase(p.begin()+i);
			int sa = p[1] - p[0];
			int i2;
			for (i2 = 1; i2 < p.size(); i2++){
				if (p[i2] - p[i2 - 1] != sa){
					break;
				}
			}

			if (i2==p.size()) {
				cout << h[i] << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int D = cin.nextInt();

        int ans = (int) Math.Ceiling(N / (float) (D * 2 + 1));

        WriteLine(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
import sys
S=list(input())
S.reverse()
S="".join(S)
#print(S)

while S:
  if len(S)<5:
    print("NO")
    sys.exit(0)  
  
  if S[:5]=="maerd":
    S=S[5:]
  elif S[:7]=="remaerd":
    S=S[7:]
  elif S[:5]=="esare":
    S=S[5:]
  elif S[:6]=="resare":
    S=S[6:]
  else:
    print("NO")
    sys.exit(0)
    
print("YES")

Measured memory_bytes: 3956
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int A, B; cin >> A >> B;
    int res = 0;
    rep(i, A, B+1) {
      if (i/10000 == i%10 and (i/1000)%10 == (i/10)%10) ++res;
    }
  
    cout << res << endl;
}

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

int main() {
    int N;
    int cnt = 0, ans = 0;

    cin >> N;

    for (int n = 1; n <= N; n+=2) {
        cnt = 0;

        for (int v = 1; v <= n; v++) {
            // can divide
            if (n % v == 0) {
                cnt++;
            }
        }
        if (cnt == 8) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
#define hash hush
typedef long long ll;
typedef long double ld;
signed  main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES\n";
	else cout<<"NO\n";
}


Measured memory_bytes: 256
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function to return the value of (str % k) 
int getMod(string str, int n, int k) 
{ 

	// pwrTwo[i] will store ((2^i) % k) 
	int pwrTwo[n]; 
	pwrTwo[0] = 1 % k; 
	for (int i = 1; i < n; i++) 
	{ 
		pwrTwo[i] = pwrTwo[i - 1] * (2 % k); 
		pwrTwo[i] %= k; 
	} 

	// To store the result 
	int res = 0; 
	int i = 0, j = n - 1; 
	while (i < n) 
	{ 

		// If current bit is 1 
		if (str[j] == '1') 
		{ 

			// Add the current power of 2 
			res += (pwrTwo[i]); 
			res %= k; 
		} 
		i++; 
		j--; 
	} 
	return res; 
} 

int main() {
	int n,c;
	string str;
	cin>>n;
	cin>>str;
	int cnt=0;
	for (int i=0;i<n;i++){
		if (str[i]=='1'){
			cnt++;
		}
	}
	int pwrTwo[n],pwrTwo1[n]; 
	int k=cnt+1;
	pwrTwo[0] = 1 % k; 
	for (int i = 1; i < n; i++) 
	{ 
		pwrTwo[i] = pwrTwo[i - 1] * (2 % k); 
		pwrTwo[i] %= k; 
	} 

	// To store the result 
	int res = 0,res1=0; 
	int i = 0, j = n - 1; 
	while (i < n) 
	{ 

		// If current bit is 1 
		if (str[j] == '1') 
		{ 

			// Add the current power of 2 
			res += (pwrTwo[i]); 
			res %= k; 
		} 
		i++; 
		j--; 
	}
	
	if (cnt>1){
		k=cnt-1;
		pwrTwo1[0] = 1 % k; 
		for (int i = 1; i < n; i++) 
		{ 
			pwrTwo1[i] = pwrTwo1[i - 1] * (2 % k); 
			pwrTwo1[i] %= k; 
		} 
	
		
		
		 int i = 0;
		 int j = n - 1; 
		while (i < n) 
		{ 
	
			// If current bit is 1 
			if (str[j] == '1') 
			{ 
	
				// Add the current power of 2 
				res1 += (pwrTwo1[i]); 
				res1 %= k; 
			} 
			i++; 
			j--; 
		}
	}
	//cout<<"res "<<res<<"res1 "<<res1<<endl;
	for (int i=0,j=n-1;i<n;i++,j--){
		int r=0;
		int ct=0;
		//cout<<endl;
		if (str[i]=='0'){
			//cout<<"res "<<res<<"pwrtwo "<<pwrTwo[j]<<endl;
			r = res+(pwrTwo[j]); 
			//cout<<"before "<<r<<endl;
			r %= (cnt+1); 
			//cout<<"after "<<r<<endl;
			ct++;
		}
		else{
			if (cnt>1){
				//cout<<"res1 "<<res1<<"pwrtwo "<<pwrTwo1[j]<<endl;
				r =res1-(pwrTwo1[j])+(cnt-1); 
				//cout<<"before "<<r<<endl;
				r %= (cnt-1);
				//cout<<"after "<<r<<endl;
				ct++;
			}
		}
		
		//cout<<r<<endl;
		while(r!=0){
			//cout<<"here"<<endl;
			int res=__builtin_popcount(r);
			r=r%res;
			ct++;
		}
		cout<<ct<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 5288
import java.util.Scanner;

public class Main {

	private static final String DAY_OF_THE_WEEK[] = { "SUN","MON","TUE","WED","THU","FRI","SAT"};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int answer = 0;

		for (int i = 0; i < 7; i++) {
			if (S.equals(DAY_OF_THE_WEEK[i])) {
				answer = (7 - i) % 8;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 22484
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  if (x[0]+x[1]==x[2]||x[0]+x[2]==x[1]||x[1]+x[2]==x[0]) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES";
	else cout<<"NO";
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  co((a-1)*(b-1));
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  if(S=="SAT"){
    cout << 1 << endl;
  }else if(S=="MON"){
    cout << 6 << endl;
  }else if(S=="TUE"){
    cout << 5 << endl;
  }else if(S=="WED"){
    cout << 4 << endl;
  }else if(S=="THU"){
    cout << 3 << endl;
  }else if(S=="FRI"){
    cout << 2 << endl;
  }else if(S=="SUN"){
    cout << 7 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t[55];
string s[55];
map <string,int> dur;
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		cin>>t[i];
	}
	string final;
	cin>>final;
	bool record=0;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(record){
			ans+=t[i];
		}else{
			if(s[i]==final){
				record=1;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

count = 0
forecast1 = S[0]
result1 = T[0]

if forecast1 == result1:
    count = count + 1


forecast2 = S[1]
result2 = T[1]

if forecast2 == result2:
    count = count + 1

    
forecast3 = S[2]
result3 = T[2]

if forecast3 == result3:
    count = count + 1

print(count)


Measured memory_bytes: 9056