akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"unicode"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	if unicode.IsUpper(rune(S[0])) {
		fmt.Println("A")
	} else {
		fmt.Println("a")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1808
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N){
  op(N*(N-1)/2)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n;
vector<int> a;
ll mod = 1e9+7;
int main(){
  cin >> n;
  REP(i,n){
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  if(n%2 ==1 && a[0] == 0){
    a.erase(a.begin());
  }
  REP(i,n/2){
    //cout << a[2*i] <<a[2*i+1]<<endl;
    if(a[2*i]  == (i+1)*2 - ((n+1)%2) && a[2*i] == a[2*i+1]){
      continue;
    }else{
      cout << 0<<endl;
      return 0;
    }
  }
  ll res = 1;
  ll a = 2;
  ll k = n / 2;
  while(k > 0){
    if(k&1ll) res = res * a %mod;
    a = a* a % mod;
    k >>= 1;
  }
  cout << res << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

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

    ll m = n % k;
    ll ans = min(m, abs(m - k));
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

ll n;
ll a[200006];
ll ans;
ll now = 1;
ll x = 1;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if(i >= 2) x *= 2, x %= M;
    }
    if(n == 1)
    {
        printf("%lld", a[0] * 2 % M);
        return 0;
    }
    sort(a, a + n, greater<ll>());
    now = x;
    for(ll i = 0; i < n; i++)
    {
        now += x;
        now %= M;
        ans += now * a[i] % M;
        ans %= M;
    }
    printf("%lld", ans * x % M * 4 % M);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
    int n;
    scanf("%d",&n);
    for (int i = 1;i <= n;i++) scanf("%d",&a[i]);
    reverse(a+1,a+n+1);
    a[0] = 1e9+7;
    for (int i = 1;i <= n;i++)
        if (a[i] > a[i-1])
            a[i]--;
    bool flag = true;
    for (int i = 1;i <= n;i++)
        if (a[i] > a[i-1])
            flag = false;
    cout << (flag ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

#define INF 1000000000

long long merge(int A[], int left, int mid, int right)
{
    long long counter = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1];
    int R[n2 + 1];
    for(int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for(int i = 0; i < n2; i++)
        R[i] = A[mid + i];
    L[n1] = INF;
    R[n2] = INF;
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++)
    {
        if(L[i] <= R[j])
        {
            A[k] = L[i];
            i++;
        }
        else
        {
            counter += n1 - i;
            A[k] = R[j];
            j++;
        }
    }
    return counter;
}

long long merge_sort(int A[], int left, int right)
{
    if(left + 1 < right)
    {
        int mid = (left + right) / 2;
        long long count1 = merge_sort(A, left, mid);
        long long count2 = merge_sort(A, mid, right);
        long long count3 = merge(A, left, mid, right);
        return count1 + count2 + count3;
    }
    else return 0;
}

int main()
{
    int n;
    scanf("%d", &n);
    int A[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    long long inv_num = merge_sort(A, 0, n);
    std::cout << inv_num << std::endl;
}


Measured memory_bytes: 4808
N, M = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(N)])

ans = 0
count = 0
for ab in AB:
    if count == M: break
    if M - count >= ab[1]:
        ans += ab[0] * ab[1]
        count += ab[1]
    else:
        ans += ab[0] * (M - count)
        count += (M - count)

print(ans)


Measured memory_bytes: 28656
from itertools import combinations

n = int(input())
s = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for _ in range(n):
	head = list(input())[0]
	if head == "M" or head == "A" or head == "R" or head == "C" or head == "H":
		s[head] += 1

ans = 0

for a, b, c in combinations(s.items(), 3):
	ans += a[1] * b[1] * c[1]

print(ans)

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, a, b;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	vector<bool> ok;

	int oka = 0;
	int okb = 0;

	for(int i=0; i<n; i++){
		if(s[i] == 'a'){
			if(oka + okb < a+b){
				oka++;
				ok.push_back(true);
			}else{
				ok.push_back(false);
			}
		}else if(s[i] == 'b'){
			if(oka + okb < a+b && okb < b){
				okb++;
				ok.push_back(true);
			}else{
				ok.push_back(false);
			}
		}else{
			ok.push_back(false);
		}
	}

	for(int i=0; i<n; i++){
		if(ok[i]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	

	return 0;
}


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

typedef long long LL;

const int maxn = 10000 + 10;
const int mod = 998244353;

char a[maxn], b[maxn];
LL fac[maxn], ifac[maxn];

LL fpm(LL a, LL b) {
	LL res = 1;
	for(; b > 0; b >>= 1) {
		if(b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}

void init() {
	fac[0] = 1;
	for(int i = 1; i < maxn; ++i) fac[i] = fac[i-1] * i % mod;

	ifac[maxn-1] = fpm(fac[maxn-1], mod-2);
	for(int i = maxn-1; i >= 1; --i) ifac[i-1] = ifac[i] * i % mod;
}

LL dp[2][maxn], ans;
LL M(LL x) { return x > 0 ? x : 0; }
LL C(int n, int k) {
	return fac[n] * ifac[k] % mod * ifac[n-k] % mod;
}

int main() {
	init();
	scanf("%s%s", a, b);
	
	int len = strlen(a), k = 0, n = 0;
	for(int i = 0; i < len; ++i) {
		if(a[i] == '1') ++ n;
		if(a[i] == '1' && b[i] == '0') ++ k;
	}
	
	if(k == 0) {
		return printf("%lld\n", fac[n]*fac[n] % mod), 0;
	}
	
	dp[1][0] = 1;
	int cur = 0;
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 0; j <= i && j <= k; ++j) {
			dp[cur][j] = 0;
			if(j) dp[cur][j] = dp[cur^1][j-1] * (k-j+1) % mod * (k-j+1) % mod;
			dp[cur][j] = (dp[cur][j] + M(n-k-i+1+j) * dp[cur^1][j] % mod * (k-j)) % mod;
		}
		//cerr << dp[cur][k] * C(n, i) % mod * fac[n-i] % mod * fac[n-i] % mod << endl;
		ans = (ans + dp[cur][k] * C(n, i) % mod * fac[n-i] % mod * fac[n-i] % mod) % mod;
		cur ^= 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

int main()
{
  char express[20];
  int bob;
  scanf("%s\n%d", express, &bob);
  strcat(express, "E");
  stack<int> stk;
  char op;
  int num;
  int miscalc;
  sscanf(express, "%d%s", &miscalc, express);
  stk.push(miscalc);
  while(strcmp(express, "E") != 0){
    sscanf(express, "%c%d%s", &op, &num, express);
    if(op == '*'){
      miscalc *= num;
      int x = stk.top(); stk.pop();
      stk.push(x*num);
    } else {
      miscalc += num;
      stk.push(num);
    }
  }
  int corcalc = 0;
  while(!stk.empty()){
    corcalc += stk.top(); stk.pop();
  }
  if(bob == corcalc && bob != miscalc) cout << "M" << endl;
  if(bob != corcalc && bob == miscalc) cout << "L" << endl;
  if(bob == corcalc && bob == miscalc) cout << "U" << endl;
  if(bob != corcalc && bob != miscalc) cout << "I" << endl;
  return 0;
}

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

int cnt(double x, double k) {
    int cnt = 0;
    while (x < k) {
        x *= 2;
        cnt++;
    }
    return cnt;
}

int main() {
    std::cout<<std::fixed<<std::setprecision(50);
    double n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) ans += 1.0 / n * pow(0.5, cnt(i, k));
    cout << ans << endl;
}


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

#define ll long long

typedef vector<ll> Vi;
typedef priority_queue<ll, Vi, greater<ll> > Pque;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    Pque fila;
    for (int i = 0; i < n; i++) {
        int aux;
        scanf("%d", &aux);
        fila.push(-aux);
    }

    for (int i = 0; i < m; i++) {
        int aux = fila.top();
        fila.pop();
        fila.push(aux/2);
    }

    ll soma = 0;
    for (int i = 0; i < n; i++) {
        int aux = fila.top();
        fila.pop();
        soma += -aux;
    }

    printf("%lld\n", soma);
}


Measured memory_bytes: 1528
N=int(input())
A=list(map(int,input().split()))
S=sum(A)

m=0
for i in range(N):
  if m+A[i]<=S//2:
    m+=A[i]
  else:
    ind=i
    break
  
if m==S/2:
  print(0)
  exit()
  
n=S-m-A[ind]

if n<m:
  n+=A[ind]
else:
  m+=A[ind]
  
print(abs(m-S//2)+abs(n-S//2))

Measured memory_bytes: 26224
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern; 

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String a = scan.nextLine();
        String b = scan.nextLine();

        String reg = "^" + a + "[a-z]$";
        Pattern p = Pattern.compile(reg);
        Matcher m = p.matcher(b);

        if(m.find()){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        scan.close();
    }
}

Measured memory_bytes: 38612
n=int(raw_input())
ret=[]
for y in range(n/2):
	a=y+1
	b=n-a
	r1 = 0
	r2 = 0
	for i in str(a):
		r1 += int(i)
	for x in str(b):
		r2 += int(x)
	r=r1+r2
	ret.append(r)
print min(ret)

Measured memory_bytes: 4740
N = int(input())
A = list(map(int, input().split()))
c = 0
flg = True

while flg:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            print(c)
            exit()

    c += 1



Measured memory_bytes: 2940
#include<stdio.h>
int ta[10010],to[30010],nt[30010],rta[10010],rto[30010],rnt[30010];
int id[10010],rid[10010],cmp[100010],r=0,f[10010]={0};
void dfs(int s){
  int i;
  f[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(f[to[i]]==0)dfs(to[i]);
  }
  id[rid[s]=r++]=s;//printf("\n");
}
void rdfs(int s,int k){
  int i;
  f[s]=2;
  cmp[s]=k;
  for(i=rta[s];i+1;i=rnt[i]){
    if(f[rto[i]]==1)rdfs(rto[i],k);
  }
}
void scc(int v,int e,int *a,int *b){
  int i,k;
  for(i=0;i<v;i++)ta[i]=rta[i]=-1;
  for(i=0;i<e;i++){
     nt[i]= ta[rto[i]=a[i]];
    rnt[i]=rta[ to[i]=b[i]];
    ta[a[i]]=rta[b[i]]=i;
  }
  /*for(i=0;i<v;i++){printf("%d:",i);
    for(k=ta[i];k+1;k=nt[k])printf("%d ",to[k]);
    printf("\n");
  }printf("\n");
  for(i=0;i<v;i++){printf("%d:",i);
    for(k=rta[i];k+1;k=rnt[k])printf("%d ",rto[k]);
    printf("\n");
  }printf("\n");//*/
  for(i=k=0;i<v;i++){
    if(f[i]==0)dfs(i);
  }
  //for(i=0;i<v;i++)printf("%d %d %d\n",i,id[i],rid[i]);
  for(i=r;i;i--){
    if(f[id[i-1]]==1)rdfs(id[i-1],id[i-1]);
  }//printf("\n");
  //for(i=0;i<v;i++)printf("%d %d %d\n",i,id[i],cmp[i]);
}
int main(){
  int v,e,a[100010],b[100010],s,t,i;
  scanf("%d %d",&v,&e);
  for(i=0;i<e;i++)scanf("%d %d",&a[i],&b[i]);
  scc(v,e,a,b);
  scanf("%d",&v);
  while(v--){
    scanf("%d %d",&s,&t);
    printf("%d\n",cmp[s]-cmp[t]?0:1);
  }
  return 0;
}

Measured memory_bytes: 1644
#include<iostream>
using namespace std;
bool flag1[1005],flag2[1005];
char ch[1005][1005];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>ch[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(ch[i][j]=='#')
			{
				flag1[i]=1;
				break;
			}
		}
	}
	for(int j=1;j<=m;j++)
	{
		for(int i=1;i<=n;i++)
		{
			if(ch[i][j]=='#')
			{
				flag2[j]=1;
				break;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!flag1[i]) continue;
		for(int j=1;j<=m;j++)
		{
			if(!flag2[j]) continue;
			cout<<ch[i][j];
		}
		cout<<endl;
	}
	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll N; cin >> N;
  vector<ll> p(N);
  REP(i, N) cin >> p[i];
  SORT(p);
  ll ans = 0;
  REP(i, N) ans += p[i];
  ans -= p[N-1]/2;
  cout << ans << endl;  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

int ans_count,T,N,table[200][200],div_x[6] = {0,1,-1,1,-1,0},div_y[6] = {1,1,0,0,-1,-1};
int BASE = 100;

bool rangeCheck(int x,int y){
	if(abs(x) <= T && abs(y) <= T)return true;
	else{
		return false;
	}
}

void recursive(int x,int y,int turn){
	for(int i = 0; i < 6; i++){
		if(turn <= T && table[BASE+y+div_y[i]][BASE+x+div_x[i]] != -1){
			if(table[BASE+y+div_y[i]][BASE+x+div_x[i]] == 0){
				table[BASE+y+div_y[i]][BASE+x+div_x[i]] = turn;
				ans_count++;
				recursive(x+div_x[i],y+div_y[i],turn+1);
			}else if(table[BASE+y+div_y[i]][BASE+x+div_x[i]] > turn){
				table[BASE+y+div_y[i]][BASE+x+div_x[i]] = turn;
				recursive(x+div_x[i],y+div_y[i],turn+1);
			}
		}
	}
}

void func(){

	for(int i = 0; i < 200;i++){
		for(int k = 0; k < 200;k++)table[i][k] = 0;
	}

	int x,y;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);

		table[BASE+y][BASE+x] = -1;
	}

	scanf("%d %d",&x,&y);

	table[BASE+y][BASE+x] = 1;

	ans_count = 1;

	recursive(x,y,1);

	printf("%d\n",ans_count);

}

int main(){

   while(true){
	   scanf("%d %d",&T,&N);
	   if(T == 0 && N == 0)break;

	   func();
   }

    return 0;
}

Measured memory_bytes: 2740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  int ans = 0;
  rep(i,n)rep(j,n)rep(k,n) {
    if (i < j && j < k) {
      if (l[i] == l[j]) continue;
      if (l[i] == l[k]) continue;
      if (l[k] == l[j]) continue;
      if ((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,z;
    cin >> n;
    vi v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    a=1e9;
    for(int i=-100; i<=100; i++){
        b=0;
        for(int j=0; j<n; j++){
            b+=(v[j]-i)*(v[j]-i);
        }
        a=min(a,b);
    }
    cout << a << el;
    
    return 0;
}


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

#define sort(ob) sort(ob.begin(),ob.end())
#define rev(ob) reverse(ob.begin(),ob.end())
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define for(start,End,I) for(int i=start; i<=End; i+=I)
//#define For(s,E,I)For(s2,E2,I2) for(int k=s; k<=E; k+=I)for(int j=s2; j<=E2; j+=I2)
int main()
{
    fast;

    ll n,k,sum=1,x,pum=0;

    cin >> n >> k;

    for(1,n,1){
        cin >> x;
        pum+=x;
        if(pum<=k){
            sum++;
        }
        else break;
    }

    cout << sum << "\n";




    return 0;
}


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

int main (){
  int H, W;
  cin >> H >> W;
  
  vector<string> pix(H);
  
  cout << string (W + 2, '#') << endl;
  
  for (int i = 0; i < H; i++){
    cin >> pix.at(i);
    cout << '#' << pix.at(i) << '#' << endl;
    }
  
   cout << string (W + 2, '#') << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        int a, b, c;
        a = p[i - 1];
        b = p[i];
        c = p[i + 1];

        if ((a < b && b < c) || (c < b && b < a)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
#define next fuck
#define fi first
#define se second
using namespace std;
int main()
{

    int x;
    cin>>x;
    if(x == 3 || x == 7 || x == 5) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n, ll m = MOD){
        if(n == 0) return 1LL;
        ll res = power(x * x % m, n/2, m);
        if(n % 2 == 1) (res *= x) %= m;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

void solve(){
    ll S;
    cin >> S;
    ll ans = 0;
    ll max_num = S / 3;
    Combination cb(200010);

    rep(i,1,max_num+1){
        ll amari = S - 3 * i;
        ans += cb.nck(amari+i-1, i-1);
        ans %= MOD;
    
    }
    print(ans);
    

}

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

Measured memory_bytes: 7948
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
    cin>>n;

     int c=0;

       while(n > 0)
       {
          int rem=n % 10;

            if(rem==7)
            {
              c++;
              break;
            }
            n=n/10;
       }

         if(c > 0)
          cout<<"Yes";

          else
          cout<<"No";
}


Measured memory_bytes: 3632
from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from collections import * #deque, Counter,OrderedDict,defaultdict
#set([]) 
import math
import copy
import itertools
import string
import sys
myread = lambda : map(int,raw_input().split())
def solver():
    S = "aiueo"
    c = raw_input()
    if c in S:
        print "vowel"
    else:
        print "consonant"


if __name__ == "__main__":
    solver()
    

Measured memory_bytes: 3172
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> key(M);
    vector<int> price(M);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        price[i] = a;
        int num = 0;
        rep(i, b) {
            int c;
            cin >> c;
            c--;
            num |= (1 << c);
        }
        key[i] = num;
    }
    vector<ll> dp(1 << N, INF);
    dp[0] = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        for(int i = 0; i < M; i++) {
            dp[bit | key[i]] = min(dp[bit | key[i]], dp[bit] + price[i]);
        }
    }
    if(dp[(1 << N) - 1] == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[(1 << N) - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  {
    Int A=0;
    for(Int i=0;i<n;i++)
      A+=G[i].size()&1;
    cout<<A/2<<" ";
  }

  auto check=
    [&](Int x)->Int{
      Int ng=0;
      function<Int(Int, Int)> dfs=
        [&](Int v,Int p)->Int{
          vector<Int> vs;
          for(Int u:G[v]){
            if(u==p) continue;            
            vs.emplace_back(dfs(u,v)+1);
          }
          
          if(G[v].size()&1)
            vs.emplace_back(0);
          sort(vs.begin(),vs.end());
          
          Int k=vs.size();
          if(p<0){
            assert(~k&1);
            for(Int i=0;i<k/2;i++)
              if(vs[i]+vs[k-(i+1)]>x) return ng=1;
            return 0;
          }
          
          assert(k&1);
          
          auto check2=
            [&](Int y)->Int{
              vector<Int> us;
              for(Int i=0;i<k;i++)
                if(i!=y) us.emplace_back(vs[i]);
              Int l=us.size();
              assert(~l&1);
              for(Int i=0;i<l/2;i++)
                if(us[i]+us[l-(i+1)]>x) return 0;
              return 1;
            };
          
          Int l=-1,r=k;
          while(l+1<r){
            Int m=(l+r)>>1;
            if(check2(m)) r=m;
            else l=m;
          }
          if(r==k) return ng=1;
          return vs[r];
        };
      
      dfs(0,-1);
      return !ng;
    };
    
  Int l=0,r=n;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(check(m)) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 19072
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil -> next; // ??????????¬????????´????????????????
	while(cur != nil && cur -> key != key){
		cur = cur -> next;
	}
	return cur;
}

void init(){
	 nil = (Node *)malloc(sizeof(Node));
	 nil -> next = nil;
	 nil -> prev = nil;
}

void printList(){
	Node *cur = nil -> next;
	int isf = 0;
	while(1){
		if(cur == nil) break;
		if(isf++ > 0) printf(" ");
		printf("%d",cur -> key);
		cur = cur -> next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t == nil) return;
	t -> prev -> next = t -> next;
	t -> next -> prev = t -> prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil -> next);
}

void deleteLast(){
	deleteNode(nil -> prev);
}

void deleteKey(int key){
	// ????´¢????????????????????????
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x -> key = key;
	// ???????????´??????????´??????????
	x -> next = nil -> next;
	nil -> next -> prev = x;
	nil -> next = x;
	x -> prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s%d",com,&key);
		if(com[0] == 'i'){insert(key);np++;size++;}
		else if(com[0] == 'd'){
			if(strlen(com)>6){
				if(com[6]=='F') deleteFirst();
				else if(com[6] == 'L') deleteLast();
			}else{
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	printList();

	return 0;
}

Measured memory_bytes: 33824
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

 
ll mo=1000000007;
 
ll modpow(ll a, ll n) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}
 
ll comb(int P_,int Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%mo, q=q*i%mo,P_--;
	
	return p*modpow(q,mo-2)%mo;
}
 
ll hcomb(int Q_,int P_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}


	void solve(){


		ini(n);
		ini(k);
		FOR(i,1,k+1){
			int tmp = comb((k-1),(i-1));
			int tmp1 = comb(n-k+1,i);
			int rick  = (tmp*tmp1)%mo;
			out(rick);
		}









	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 256
n, k=gets.split.map(&:to_i)

freq=Array.new(1_000_00+1){0}
n.times do
  a, b=gets.split.map(&:to_i)
  freq[a]+=b
end
cur=0
1.upto 1_000_00 do |i|
  cur+=freq[i]
  if cur>=k
    puts i
    break
  end
end


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll> > matrix;
// const ll S = 3e5 + 20;
// const ll N = 1e6 + 1;
// const ll PRIME = 1e9 + 7;
// const ll MAX = 1e6;


void solve()
{
   char ch;
   cin>>ch;
   if(isupper(ch))
   cout<<"A";
   else
   {
       cout<<"a";
   }
   
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}


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

int main() {
	int a[3], cnt = 0;
	cin >> a[0] >> a[1] >> a[2];

	int m = max({ a[0], a[1], a[2] });
	
	for (int i = 0; i < 3; i++) {
		for (int j = a[i] + 2; j <= m; j += 2) {
			a[i] += 2;
			cnt++;
		}
	}

	if (a[0] == a[1] && a[1] == a[2]) {
		cout << cnt;
	}
	else {
		int mcnt = 0;
		for (int i = 0; i < 3; i++) {
			mcnt += (a[i] == m);
		}
		if (mcnt == 1) {
			cnt++;
		}
		else {
			cnt += 2;
		}
		cout << cnt;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn main() {
   input! {
      n: usize,
   }
   let mut ans = n;
   for i in 0..=n {
      let mut n1 = i;
      let mut n2 = n - i;

      let mut res = 0;
      while n1 > 0 {
         res += n1 % 6;
         n1 /= 6;
      }
      while n2 > 0 {
         res += n2 % 9;
         n2 /= 9;
      }
      ans = std::cmp::min(ans, res);
   }
   println!("{}", ans);
}


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

int main(){
	string str;
	cin >> str;
	cout << str[0];
	cout << str.l_ength()-2;
	cout << str[str.l_ength()-1];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c,i,count=0;
	scanf("%d %d %d",&a,&b,&c);

	for(i=a;i<=b;i++)
{
		if(c%i==0)count++;
}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

int main(){
    int N;
    cin >> N;
    long long map[300][300];
    bool path[300][300];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> map[i][j];
            path[i][j]=true;
        }
    }

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                long long a,b,c;
                a=map[i][j]; b=map[j][k]; c=map[k][i];
                if(a+b<c || b+c<a || c+a<b){
                    cout << -1 << endl;
                    return 0;
                }
                if(a+b==c) path[k][i]=path[i][k]=false;
                if(b+c==a) path[i][j]=path[j][i]=false;
                if(c+a==b) path[j][k]=path[k][j]=false;
            }
        }
    }

    long long len=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(path[i][j]) len+=map[i][j];
        }
    }

    cout << len << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int ans[2000];

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

    int N, X, Y;
    cin >> N >> X >> Y;

    for (int i = 1; i < N; ++i) for (int j = i+1; j <= N; ++j)  {
        int d = 0;
        if (i < X) {
            if (j <= X) {
                d = j-i;
            } else if (j < Y) {
                d = X-i + min(j-X, 1+Y-j);    
            } else {
                d = X-i + 1 + j-Y;    
            }
        } else if (i == X) {
            if (j < Y) {
                d = min(j-X, 1+Y-j);    
            } else {
                d = 1 + j-Y;    
            }
        } else if (i < Y) {
            d = min(i-X+1+abs(j-Y), j-i);
        } else {
            d = j-i;
        }
        ++ans[d];
    }

    for (int k = 1; k < N; ++k) {
        cout << ans[k] << '\n';
    }
    cout << endl;

    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< int, i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2

signed main()
{
    int2(n, k);
    vi data(n);

    rep(i, n) {
        cin >> data[i];
    }
    sort(all(data));
    int yui = data[0], infi = data[n-1];

    rep(i, n-1) {
        if (data[i+1] - data[i]) {
            yui = min(yui, (data[i+1] - data[i]));
        }
    }

    if (n == 1 && yui == k) {
        cout << "POSSIBLE" << endl;
        return 0;
    } else if (n == 1) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    if (infi < k) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if (yui == 1) {
        cout << "POSSIBLE" << endl;
        return 0;
    }

    rep(i, n) {
        if (data[i] % yui) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    if (k % yui) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    } else {
        cout << "POSSIBLE" << endl;
        return 0;
    }

    return 0;
}




Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(){
    char str[1001], s[10], st[1001];
    int q,a,b,j;
    scanf("%s",str);
    scanf("%d", &q);
    for(int i=0; i<q; i++){
        scanf("%s %d %d",s,&a,&b);
        if(s[2]=='v'){
            for(j=a; j<=b; j++){
                st[b-j]=str[j];
            }
            for(j=a; j<=b; j++){
                str[j]=st[j-a];
            }
        }
        if(s[2]=='p'){
            scanf("%s",st);
            for(j=0; st[j]!='\0'; j++){
                str[a+j]=st[j];
            }
        }
        if(s[2]=='i'){
            for(j=a; j<=b; j++){
                printf("%c",str[j]);
            }
            printf("\n");
        }
    }
    return 0;
}




Measured memory_bytes: 2592
#include <iostream>

using namespace std;

int main() {
    int x,y;
    while(1){
        cin>> x >> y ;
        if(x == 0 && y == 0)break;
        if(x<y){
        cout << x <<" "<< y <<endl;
        }
        else{
        cout << y <<" "<< x <<endl;
        }
    }
    return 0;
}

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

using namespace std;

const int N = 1003, M = 1000000007;
char s[N][N];
int dp[N][N];

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	dp[1][1] = 1;
	for (int i = 1; i <= n; i++) {
		s[i][0] = '.';
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= m; j++) {
			dp[i][j] += ((dp[i-1][j] + dp[i][j-1]) % M) * (s[i][j] == '.');
		}
	}
	printf("%d", dp[n][m]);
	return 0;
}


Measured memory_bytes: 5120
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long Q = sc.nextLong();
	        
	        int H = 100000;
	        int[] m = new int[H];
	        int[] p = new int[H];
	        int[] mlike=new int[H];
	        int k=0;
		m[1]=-1;
	        for(int i=2;i<H;i++) {
	        	if(m[i]==0) {
	        		m[i]=1;
	        		if(m[(i+1)/2]==1) {
	        			mlike[i]=1;
	        		}
	        		p[k]=i;
	        		k++;
	        		for(int j=i+i;j<H;j=j+i) {
	        			m[j]=i;
	        		}
	        	}
	        }
	        
	        int[] likesum=new int[H];
	        for(int i=1;i<H;i++) {
	        	if(mlike[i]==1) {
	        		likesum[i]=likesum[i-1]+1;
	        	} else {
	        		likesum[i]=likesum[i-1];
	        	}
	        }
	        
	        StringBuffer str=new StringBuffer();
	        for(int i=0;i<Q;i++) {
	        	int l=sc.nextInt();
	        	int r=sc.nextInt();
	        	int sum=0;
	        	
	        	str.append(likesum[r]-likesum[l-1]);
	        	str.append("\n");
	        }
	        System.out.println(str);
	 }
	 

}

Measured memory_bytes: 65432
#include <iostream>

int main()
{
    int four_cnt = 0, two_cnt = 0;
    int prog_num;
    std::cin >> prog_num;
    int num;
    for (int i = 0; i < prog_num; ++i) {
        std::cin >> num;
        if (num % 4 == 0) {
            four_cnt++;
        } else if (num % 2 == 0) {
            two_cnt++;
        }
    }

    if (2 * four_cnt + 1 >= prog_num) {
        std::cout << "Yes" << std::endl;
    } else {
        if (four_cnt == 0 && two_cnt == 1) {
            std::cout << "No" << std::endl;
        } else if (2 * four_cnt + two_cnt >= prog_num){
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }
    return 0;
}


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

using namespace std;

int main(){
	string s,x;
	cin>>s>>x;
	int m=1e9;
	for(int i=0;i<=(int)s.length()-(int)x.length();i++){
		int p=0;
		for(int j=0;j<x.length();j++){
			if(s[i+j]!=x[j])
				p++;
		}
		m=min(p,m);
	}
	cout<<m;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;

    s[k-1] = tolower(s[k-1]);
    cout<<s;


    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
// use std::cmp::max;
// use std::cmp::min;
use std::collections::HashMap;
// use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        Xs: [i64; N],
    }

    let mut sorted_Xs: Vec<(i64, usize)> = Vec::new();
    for i in 0..N {
        let tpl = (Xs[i], i);
        sorted_Xs.push(tpl)
    }
    sorted_Xs.sort();

    let mut orig_ind_to_sorted_ind: HashMap<usize, usize> = HashMap::new();
    for sorted_ind in 0..N {
        let orig_ind = sorted_Xs[sorted_ind].1;
        orig_ind_to_sorted_ind.insert(orig_ind, sorted_ind);
    }

    let mid_ind: usize = (N - 2) / 2 + 1;
    for orig_ind in 0..N {
        let sorted_ind: usize = *orig_ind_to_sorted_ind.get(&orig_ind).unwrap();

        // if sorted_Xs[sorted_ind] < sorted_Xs[mid_ind] {
        if sorted_ind < mid_ind {
            println!("{}", sorted_Xs[mid_ind].0);
        } else {
            println!("{}", sorted_Xs[mid_ind - 1].0);
        }
    }
}


Measured memory_bytes: 17208
import kotlin.math.max

fun main(args: Array<String>) {
    fun readLineAndSplitBySpace() = readLine()!!.split(" ")

    val (N, M) = readLineAndSplitBySpace().map { it.toInt() }
    val hArray = readLineAndSplitBySpace().map { it.toInt() }

    val nearHigherArray = IntArray(N) { 0 }
    repeat(M) {
        val (a, b) = readLineAndSplitBySpace().map { it.toInt() }
        val aIndex = a - 1
        val bIndex = b - 1

        nearHigherArray[aIndex] = max(nearHigherArray[aIndex], hArray[bIndex])
        nearHigherArray[bIndex] = max(nearHigherArray[bIndex], hArray[aIndex])
    }

    var counter = 0
    hArray.forEachIndexed { index, high ->
        if (high > nearHigherArray[index]) counter++
    }

    println(counter)
}


Measured memory_bytes: 63160
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int c = (a + b) / 2;
	if (abs(c - a) == abs(c - b)) {
		cout << c << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int> pii;
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;

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

	int count = max(a, b);
	int val = min(a,b);

	for(int i = 0; i < count; ++i)
		cout << val;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;	
char a[2000];
int main(){
	cin >> a;
	int n=strlen(a);
	bool ok=1;
	for (int i=0;i<n;i++){
		if (a[i]=='C') ok=0;
		if (!ok&&a[i]=='F') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    
    int ans = 0;

    REP(A, N){
        bool f = true;
        REP(i, N)REP(j, N){
            if(i != j && S[(i+A)%N][j] != S[(j+A)%N][i]){
                f = false;
                break;
            }
            if(!f) break;
        }
        if(f) ans += N-A;
    }
    // cout << ans << "\n";
    FOR(B, 1, N){
        bool f = true;
        REP(i, N)REP(j, N){
            if(i != j && S[i][(j+B)%N] != S[j][(i+B)%N]){
                f = false;
                break;
            }
            if(!f) break;
        }
        if(f) ans += N-B;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
<?php

fscanf(STDIN, "%d %d", $a, $b);
printf("a %s b%s", compare($a, $b), PHP_EOL);

function compare($a, $b)
{
    if ($a > $b) {
        return ">";
    } else if ($a < $b) {
        return "<";
    } else {
        return "==";
    }
}

Measured memory_bytes: 6548