akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<string,int> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<P,int> > x(n);
    rep(i,n){
      cin>>x[i].first.first>>x[i].first.second;
      x[i].first.second*=-1;
      x[i].second=i+1;
    }
    sort(begin(x),end(x));
    for(auto itr:x){
      cout<<itr.second<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)
#include <stdlib.h>

typedef struct tree {
  lld value;
  struct tree *left;
  struct tree *right;
} tree_t;

int search_and_insert(tree_t *tree, lld value) {
  if (value == tree->value) {
    return 0;
  } else if (value < tree->value) {
    if (tree->left == NULL) {
      tree->left = malloc(sizeof(tree_t));
      tree->left->value = value;
      tree->left->left = NULL;
      tree->left->right = NULL;
      return 1;
    } else {
      return search_and_insert(tree->left, value);
    }
  } else {
    if (tree->right == NULL) {
      tree->right = malloc(sizeof(tree_t));
      tree->right->value = value;
      tree->right->left = NULL;
      tree->right->right = NULL;
      return 1;
    } else {
      return search_and_insert(tree->right, value);
    }
  }
}

void free_tree(tree_t *tree) {
  if (tree->left != NULL) {
    free_tree(tree->left);
  }
  if (tree->right != NULL) {
    free_tree(tree->right);
  }
  free(tree);
}

int main(void) {
  int n;
  lld q, r = 0;
  unsigned char c;
  tree_t *tree = NULL;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    q = 0;
    while (1) {
      c = getchar();
      if (c == '\n') {
        break;
      }
      q *= 27;
      q += c - 'a' + 1;
    }
    if (tree != NULL) {
      r += search_and_insert(tree, q);
    } else {
      tree = malloc(sizeof(tree_t));
      tree->value = q;
      tree->left = NULL;
      tree->right = NULL;
      r += 1;
    }
  }
  
  free_tree(tree);

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


Measured memory_bytes: 7956
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a = f()[0]
    b = f()[0]
    c = f()[0]
    x = f()[0]

    ans = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if i*500 + j * 100 + k*50 == x:
                    ans += 1

    
    print(ans)


solve()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int K, X;
        Scanner scan = new Scanner(System.in);
        K = scan.nextInt();
        X = scan.nextInt();
        if(K*500>=X){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 21844
//
//  main.cpp
//  testing
//
//  Created by 伊藤大騎 on 2019/01/07.
//  Copyright © 2019 HamamatsuJOHOKU. All rights reserved.
//
/*
 科目選択 (Selecting Subjects)
 
 JOI 君は物理，化学，生物，地学，歴史，地理の 6 科目のテストを受けた． それぞれのテストは 100 点満点で採点された．
 JOI 君は物理，化学，生物，地学の 4 科目から 3 科目を選択し，歴史，地理の 2 科目から 1 科目を選択する．
 テストの合計点が最も高くなるように科目を選ぶとき， JOI 君の選んだ科目のテストの合計点を求めよ．
 
 入力は 6 行からなり，1 行に 1 つずつ整数が書かれている．
 1 行目には JOI 君の物理のテストの点数 A が書かれている．
 2 行目には JOI 君の化学のテストの点数 B が書かれている．
 3 行目には JOI 君の生物のテストの点数 C が書かれている．
 4 行目には JOI 君の地学のテストの点数 D が書かれている．
 5 行目には JOI 君の歴史のテストの点数 E が書かれている．
 6 行目には JOI 君の地理のテストの点数 F が書かれている．
 書かれている整数 A, B, C, D, E, F はすべて 0 以上 100 以下である．
 
 出力
 JOI 君が選んだ科目のテストの合計点を 1 行で出力せよ．
 
 入出力例
 
 入力例 1    入力例 2
 100        15
 34         21
 76         15
 42         42
 10         15
 0          62
 
 出力例 1    出力例 2
 228        140
 
 入出力例 1 では，JOI 君が物理，生物，地学，歴史の 4 科目を選ぶとき，テストの合計点が最高になる．
 物理，生物，地学，歴史の点数はそれぞれ 100, 76, 42, 10 なので，選んだ科目のテストの合計点は 228 である．
 
 入出力例 2 では，JOI 君が化学，生物，地学，地理の 4 科目を選ぶとき，テストの合計点が最高になる．
 化学，生物，地学，地理の点数はそれぞれ 21, 15, 42, 62 なので，選んだ科目のテストの合計点は 140 である．
 
 入出力例 2 では，JOI 君が物理，化学，地学，地理の 4 科目を選ぶ場合でも，選んだテストの合計点は 140 である．
 
 */

#include <iostream>
#include <algorithm>

using namespace std;
int main (){

    int hairetsu[6]={0},ans=0,maxim=0;
    
    for (int i=0;i<6;i++){
        cin>>hairetsu[i];
    }
    
    for (int i=0;i<3;i++){
        for (int j=0;j<4;j++){
            if (maxim<hairetsu[j]){
                maxim=hairetsu[j];
            }
        }
    
        ans+=maxim;
    
        for (int j=0;j<4;j++){
            if (hairetsu[j]==maxim){
                hairetsu[j]=0;
                maxim=0;
            }
        }
    }
    ans+=max(hairetsu[4],hairetsu[5]);
    
    cout<<ans<<endl;
    
return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string n;
    cin >> n;
    if (n.find('7') != string::npos)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
    int N,M,i,sum=0,A[10000];
    scanf("%d %d",&N,&M);
    for(i=0;i<M;i++)
    {
        scanf("%d",&A[i]);
    }
    for(i=0;i<M;i++)
    {sum=sum+A[i];
    }
    if(sum>N)
    {
        printf("-1\n");
    }
    else
    {
       printf("%d\n",N-sum);
    }

    return 0;
}


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

int main() {
  vector<int> x(5);
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
 
int main()
{
	ll n, ans = 0, sum = 0;
	cin >> n;
	rep(i,0,n) {
		int t;
		cin >> t;
		if (t == 0) {
			ans += sum / 2;
			sum = 0;
		}
		else {
			sum += t;
		}
	}
	ans += sum / 2;
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
  string S;
  cin >> S;
  if (S[0] > '1' || (S[0] == '1' && S[1] > '2') || (S[0] == '0' && S[1] == '0')) {
    if (S[2] > '1' || (S[2] == '1' && S[3] > '2') || (S[2] == '0' && S[3] == '0')) {
      cout << "NA" << endl;
    } else {
      cout << "YYMM" << endl;
    }
  } else {
    if ((S[2] == '0' && S[3] != '0') || (S[2] == '1' && S[3] <= '2')) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int array[10];
	int n,l=0;
	while(scanf("%d",&n) != EOF)
	{
		if(n != 0)
		{
			array[l] = n;
			l++;
		}
		else
		{
			printf("%d\n",array[l-1]);
			l--;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
int main() {
  INIT;
  
  int n,h;
  int count =0;
  cin >> n >> h;
  int a[n],b[n];
  REP(i,n){
    cin >> a[i] >> b[i];
  }
  std::vector<int> va(a, a+n);

  int imax = *std::max_element(va.begin(), va.end());
  int suffix;
  REP(i,n){
    if(a[i] == imax){
      suffix = i;
      break;
    }
  }

  std::vector<int> vb(b, b+n);
  sort(vb.begin(), vb.end(),std::greater<int>());

  REP(i,n){
    if(vb[i] < imax){
      break;
    }
    h -= vb[i];
    count +=1;
    if(h <= 0){
      printf("%d\n", count);
      exit(0);
    }
  }

  while (1) {
    h -= imax;
    count++;
    if(h <= 0){
      printf("%d\n", count);
      exit(0);
    }
  }

/*
  // vの全ての要素にdisp()関数を適用する
  std::for_each(v.begin(), v.end(), disp);
  
  // 要素の内容を書き換えても構わないし、呼び出し順序に依存した処理を書いても構わない
  std::for_each(v.begin(), v.end(), mutate());
  std::for_each(v.begin(), v.end(), disp);
  
  */
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll a,b;
     cin>>a>>b;
     if(a>0)
        cout<<"Positive"<<endl;
     else if( a<=0 && b>=0)
        cout<<"Zero"<<endl;
     else
     {
         if((abs(b-a)+1)%2==0)
            cout<<"Positive"<<endl;
         else
            cout<<"Negative"<<endl;
     }


}


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

/* [pos][rest kazu][rest sum] */
long long memo[101][10][1001];

long long tansaku(int pos,int rest_kazu,int rest_sum) {
	long long result=0;
	if(rest_kazu==0 && rest_sum==0)return 1;
	else if(pos>100 || rest_kazu<0 || rest_sum<0)return 0;
	if(memo[pos][rest_kazu][rest_sum]>0)return memo[pos][rest_kazu][rest_sum]-1;
	result+=tansaku(pos+1,rest_kazu,rest_sum);
	result+=tansaku(pos+1,rest_kazu-1,rest_sum-pos);
	memo[pos][rest_kazu][rest_sum]=result+1;
	return result;
}

int main(void) {
	int n,s;
	while(scanf("%d%d",&n,&s)==2 && (n|s)!=0) {
		printf("%lld\n",tansaku(0,n,s));
	}
	return 0;
}

Measured memory_bytes: 8216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010,MOD=int(1e9)+7;
char s[maxn];
int N,f[maxn][13];
int main(){
	//freopen("in","r",stdin);
	scanf("%s",s+1);
	N=strlen(s+1);
	f[0][0]=1;
	for(int i=0;i<N;i++)
		for(int j=0;j<13;j++)
			if(f[i][j])
				if(s[i+1]=='?')
					for(int k=0;k<10;k++)
						(f[i+1][(j*10+k)%13]+=f[i][j])%=MOD;
				else
					(f[i+1][(j*10+s[i+1]-'0')%13]+=f[i][j])%=MOD;
	printf("%d\n",f[N][5]);
	return 0;
}



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

int main() {
	int N,A,X,Y;
	cin >> N >> A;
	//Xは商、Yは余り
	X = N/500;
	Y = N-500*X;
	
	if ((A > Y)||(A == Y)){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
  
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N= 100001;
int f[N], inv[N];

int fastPower(int a, int b){
	if(b== 0)
		return 1;
	int res = fastPower(a, b/ 2);
	if(b% 2== 1)
		return ((res* res)% mod* a)% mod;
	return (res* res)% mod;
}

int nCk(int n, int k){
	return ((f[n]* inv[k])% mod* inv[n-k])% mod;
}

void solve() {
        f[0]= 1;
	inv[0] = fastPower(1, mod- 2);
	for(int i= 1; i< N; ++i){
		f[i] = (i* f[i-1])% mod;
		inv[i] = fastPower(f[i],mod-2);
	}

	int n, k; cin >> n>> k;
	vector<int> v(n);

	for (auto& i: v) cin >> i;

        sort(all(v));
        reverse(all(v));

	vector<int> res;

	for (int i= 0; i<= n- k; i++) {
                res.push_back(nCk(n- i- 1, k- 1));
	}

        int ans= 0;

	for (int i= 0; i< res.size(); i++) {
                ans= (ans+ res[i]* v[i])% mod;
	}

	for (int i= 0; i< res.size(); i++) {
                ans= (((ans- res[i]* v[n- i- 1])% mod)+ mod)% mod;
	}

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

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 6108
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int w, a, b;
	scanf("%d %d %d", &w, &a, &b);
	if(a<b) printf("%d\n", std::max(0, b-a-w));
	else printf("%d\n", std::max(0, a-b-w));
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read4();
      Read5();
Modular[] check=new Modular[N];
      for(int i=0;i<N;i++){check[i]=new Modular(0);}
      int j=0;
if(K<=j || s[j]!=1){check[0]=1;}else{j++;}
if(N>1){if(K<=j || s[j]!=2){check[1]=check[0]+1;}else{j++;}}
for(int i=2;i<N;i++){
check[i]=check[i-1]+check[i-2];
if(j<K && s[j]-1==i){check[i]=0;j++;}
}
      
      Console.WriteLine(((int)check[N-1]).ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
for(int i=0;i<K;i++){
        string tmp = Console.ReadLine();
        s.Add(int.Parse(tmp));
}
 
    }


}
class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    private static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
        case 0:
            return 1;
        case 1:
            return a;
        default:
            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r)  ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}


Measured memory_bytes: 22752
a,b,c,d = map(int,input().split())
print('R'*(c-a)+'U'*(d-b)+'L'*(c-a)+'D'*(d-b+1)+'R'*(c-a+1)+'U'*(d-b+1)+'L'+'U'+'L'*(c-a+1)+'D'*(d-b+1)+'R')

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

int main(void) {
	int  num[30] = {0}, t;
	
	for (int i = 0; i < 28; i++) {
		cin >> t;
		num[t-1] = 1;
	}
	
	for (int i = 0; i < 30; i++) {
		if (num[i] == 0)
			cout << i + 1 << endl;
	}
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = pow(3, n);
    int odd = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0)  odd *= 2;
    }
    cout << ans - odd << endl;
}   

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef priority_queue <int> pi;
typedef priority_queue <int, vector<int>, greater<int>> pg;
typedef unsigned long long int ulli;

int main() {
    long long int N, X;
    cin >> N >> X;
    vector <int> m;
    int temp;
    for(int i = 0; i < N; ++i) {
        cin >> temp;
        m.push_back(temp);
    }
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        X -= m[i];
        ++ans;
    }
    sort(m.begin(),m.end());
    while(X >= m[0]) {
        ++ans;
        X -= m[0];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	//input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var output = 0;
  var count = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i,i+1);
    if(tmp == "B"){
       count++;
    }else{
      output += count;
    }
  }
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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


int main(){
	int h,r,x=-1;
	cin>>h>>r;
	if(h<0){
		if(h+r==0)x=0;
		if(h+r>0)x=1;
	}
	if(h>=0)x=1;
	cout<<x<<endl;
	return 0;

}



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

int main() {
    int ans = 0;
    string N;
    cin >> N;
    for(char x : N) {
        int y = int(x) - 48;
        ans = (ans + y) % 9;
    }
    if(ans == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <bits/extc++.h>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=500005;
//i_am_noob
int n,m,u,v,ans=0;
scc_graph g(maxn);
vector<vector<signed>> vec;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m;
    rep(m){
        cin >> u >> v;
        g.add_edge(u,v);
    }
    vec=g.scc();
  	for(auto vec1: vec) if(vec1[0]<n) ans++;
    print1(ans);
    for(auto vec1: vec) if(vec1[0]<n){
        print0(sz(vec1));
        for(auto u: vec1) print0(u);
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 40628
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<int> A,color;

int N;

int solve(void) {
    color.push_back(A[0]);
    for(int i = 1;i < N;i++) {
        auto iter = upper_bound(color.begin(),color.end(),A[i]);
        if(iter == color.end()) {
            color.push_back(A[i]);
        } else {
            *iter = A[i];
        }
    }

    return color.size();
}

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.push_back(-a);
    }

    cout<<solve()<<endl;

    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>  
#include <cstring>  
#include <cmath>  
#include <cstdlib>  
#include <ctime>  
#include <iostream>  
#include <algorithm>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <stack>  
#include <map>  
#include <set>  
#include <utility>  
   
using namespace std;  
#define LL long long  
#define pb push_back  
#define mk make_pair  
#define mst(a, b)   memset(a, b, sizeof a)  
#define REP(i, x, n)    for(int i = x; i <= n; ++i)  
const int qq = 2e5 + 10;  
int a[qq], b[qq];  
   
int main(){  
    int n;  scanf("%d", &n);  
    REP(i, 1, n){  
        scanf("%d", a + i);  
    }  
    int l = 1, r = n;  
    int cnt = 1, p = n;  
    for(int i = n; i >= 1; --i){  
        if(cnt & 1) b[l++] = a[p--];  
        else    b[r--] = a[p--];  
        cnt++;  
    }  
    REP(i, 1, n - 1){  
        printf("%d ", b[i]);  
    }  
    printf("%d\n", b[n]);  
    return 0;  
}  

Measured memory_bytes: 3712
//https://atcoder.jp/contests/abc161/tasks/abc161_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll m;
	cin>>m;
	vector<ll> lis;
	lis.resize(n);
	ll sum=0;
	//ll min=0;
	ll i;
	for(i=0;i<n;i++)
	{
		cin>>lis[i];
		sum=sum+lis[i];
	}
	sort(lis.begin(),lis.end());
	//min=(1/(4*m))*sum;
	vector<ll> sel;
	for(i=n-1;i>=0;i--)
	{
		if(lis[i]*4*m>=sum)
		{
			sel.push_back(lis[i]);	
		}
	}
	ll x;
	x=sel.size();
	if(x>=m)
	{
		cout<<"Yes"<<"\n";
	}
	else
	{
		cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3544
N = int(input())
A = tuple(map(int, input().split()))

def calc(B):
    P, Q = B[0], B[1]
    ret = [None] * N
    ret[1] = (P, Q)
    mid = 1

    for right in range(2, N - 2):
        Q += B[right]
        while mid < right:
            newP = P + B[mid]
            newQ = Q - B[mid]

            if abs(newP - newQ) >= abs(P - Q):
                break
            mid += 1
            P = newP
            Q = newQ

        ret[right] = (P, Q)

    return ret

left = calc(A)[1: -2]
right = calc(A[:: -1])[1: -2][:: -1]

ans = 10**10
for (P, Q), (R, S) in zip(left, right):
    ans = min(ans, abs(max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)


Measured memory_bytes: 58140
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No"<<endl;
    }
	
	return 0;
}
 


Measured memory_bytes: 256
n,a,b=map(int,input().split())
l=list(map(int,input().split()))
tukare=0
now=l[0]
for i in range(1,n):
  if a*(l[i]-now)>b:
    tukare+=b
  else:
    tukare+=a*(l[i]-now)
  now=l[i]
print(tukare)



Measured memory_bytes: 14252
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x%2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x%i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())
    input_array = [int(input()) for i in range(element_number)]

    output = 0
    for x in input_array:
        if(is_prime(x)):
            output += 1

    print(output)

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

int main(){
	int k,m,g,y,n;
	cin >> k;
	for(int i=0;i<k;i++){
		int mg=0;
		cin >> g >> y >> n;
		for(int j=0;j<n;j++){
			int ng=g;
			int tf,q;
			double p;
			cin >> tf >> p >> q;
			if(tf){//単利
				for(int ii=0;ii<y;ii++)
					ng+=(int)(ng*p)-q;
			}else{//複利
				int r=0;
				for(int ii=0;ii<y;ii++){
					r+=(int)(ng*p);
					ng-=q;
				}
				ng+=r;
			}
			mg=max(mg,ng);
		}
		cout << mg << endl; 
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 1e3 + 10;

int n, m;

void prework(){

}

void read(){

}

const int INF = 1e9 + 7;

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

int vis[MAXN][MAXN];
char s[MAXN][MAXN];
int K;

int dis(int p, int q){
	int ret = min(min(p - 1, n - p), min(q - 1, m - q));
//	cout<<p<<' '<<q<<' '<<ret<<' '<<K<<endl;
	return ret / K + (ret % K != 0);
}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d%d%d", &n, &m, &K);
	int x = 0, y = 0;
	for(int i = 1; i <= n; i++){
		scanf("%s", s[i] + 1);
		for(int j = 1; j <= m; j++){
			if (s[i][j] == 'S'){
				x = i, y = j;
			}
			vis[i][j] = INF;
		}
	}
	queue<PII> Q;
	Q.push(PII(x, y));
	vis[x][y] = 0;
	while(!Q.empty()){
		PII nico = Q.front();
		Q.pop();
		int x = nico.first, y = nico.second;
		if (vis[x][y] >= K)
			break;
		for(int k = 0; k < 4; k++){
			int xx = x + dx[k], yy = y + dy[k];
			if (xx >= 1 && xx <= n && yy >= 1 && yy <= m 
				&& vis[xx][yy] > vis[x][y] + 1
				&& s[xx][yy] == '.'){
					vis[xx][yy] = vis[x][y] + 1;
					Q.push(PII(xx, yy));
				}
		}
	}
/*	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++)
			cout<<vis[i][j]<<' '; cout<<endl;
	}
	*/
	int ans = INF;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if (vis[i][j] <= K)
				ans = min(1 + dis(i, j), ans);
	printf("%d\n", ans);
}

void printans(){

}

int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	int cnt = 0;
	ll res = 1;
	rep(i, 0, N) {
		int a; cin >> a;
		if((i - cnt) * 2 == a) {
			MUL(res, (i - cnt + 1));
			cnt++;
		}
	}
	rep(i, 0, N - cnt) {
		MUL(res, i + 1);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000000
#define MOD 1000000007 
#define N 100005
#define M 1000000
#define LOG 20
#define KOK 300
#define EPS 0.0000001
using namespace std;

int n,m;
int ans[N];
int f[N<<1];
vector<ii> v[N<<1];

int get(int x) {

	int res=0;

	for(int i=x;i>=1;i-=i&-i) res+=f[i];

	return res;

}

void up(int x) {

	for(int i=x;i<=m+m;i+=i&-i) f[i]++;

}

int main() {

	scanf("%d %d",&n,&m);

	for(int i=1;i<=n;i++) {

		int l,r;

		scanf("%d %d",&l,&r);

		v[r].pb({l,1});

	}

	for(int i=1;i<=m;i++) {

		for(int j=i;j<=m+m;j+=i) {

			v[j].pb({j-i,0});

		}

	}

	for(int i=1;i<=m+m;i++) {

		sort(all(v[i]),[](ii a,ii b){return a.nd<b.nd;});

		for(auto x:v[i]) {

			if(x.nd) {

				up(x.st);

			}
			else {

				ans[i-x.st]+=get(i-1)-get(x.st);

			}

		}

	}

	for(int i=1;i<=m;i++) printf("%d\n",n-ans[i]);

}	

Measured memory_bytes: 40192
#include <bits/stdc++.h>
#define ll signed long long int
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 1000005
using namespace std;

ll a[MAXX], b[MAXX], c[MAXX], k = 0;

signed main()
{
	FAST;
	ll  n, m;
	cin >> n >> m;
	for(ll i = 0; i < m; i++){
		cin >> a[i];
		k += a[i];
	}
	if(n - k < 0){
		cout << -1;
		return 0;
	}
	cout << n -k;
	
}

Measured memory_bytes: 3688
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i=0; i<n; i++){
            int d = sc.nextInt();
            map.put(d, i);
        }
        System.out.println(map.size());
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;
void solve1();
void solve()
{
    int T;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int x;cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3648
from heapq import heappush, heappop
N, M = map(int, input().split())
D = {i+1: [] for i in range(M)}
for _ in range(N):
  A, B = map(int, input().split())
  if A <= M:
    D[A].append(B)
rew = 0
pq = []
for i in range(M):
  for j in D[i+1]:
    heappush(pq, -j)
  if pq != []:
    rew += -heappop(pq)
print(rew)

Measured memory_bytes: 26856
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 <<  endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a)  a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
 
using namespace std;
 
int a[100005];
long long cumulative[100005];
vector<int> b;
 
int binarySearch(int x){
   int st = 0;
   int en = b.size() - 1;
   int iter = 40;
   int mid;
   ++x;
   while(iter--){
      mid = (st + en) / 2;
      if(b[mid] < x){
         st = mid;
      }
      else{
         en = mid;
      }
   }
   --x;
   int res = -1;
   for(int i = max((int)0, mid - 5); i <= min((int)b.size() - 1, mid + 5); ++i){
      if(b[i] <= x){
         res = i;
      }
   }
   return res;
}
 
int main(){
   int N, M;
   cin >> N >> M;
   int x;
   long long res = 0;
   for(int n = 0; n < N; ++n){
      scanf("%d", &a[n]);
      res += a[n];
   }
   for(int m = 0; m < M; ++m){
      scanf("%d", &x);
      res += x; 
      b.pb(x); 
   }
   sort(all(b));
   cumulative[0] = b[0];
   for(int n = 1; n < b.sz; ++n){
      cumulative[n] = cumulative[n - 1] + b[n];
   }
   for(int n = 0; n < N; ++n){
      int i = binarySearch(a[n]);
      if(i == -1){
         res += M * 1ll * a[n];   
      }
      else{
         res += cumulative[i];
         res += (M - (i + 1)) * 1ll * a[n];
      }
   }
   cout << res << endl;
   return 0;
}

Measured memory_bytes: 1912
#include<iostream>
using namespace std;
int w,h,mapp[100][100],xi,yi,n;
int solve(int x,int y);
int main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0){break;}
    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	mapp[i][j]=0;
      }
    }
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>xi>>yi;
      mapp[xi-1][yi-1]=1;
    }
    cout<<solve(0,0)<<endl;
  }
}
int solve (int x,int y){
  if(x<0 || y<0 || x==w || y==h){
    return 0;
  }
  if(mapp[x][y]==1){return 0;}
  if(x==w-1 && y==h-1){return 1;}
  return solve(x+1,y)+solve(x,y+1);
}

Measured memory_bytes: 1172
#include <iostream>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  ll ans = 1LL;
  for(int i = 1; i <= n; ++i) {
    ans = (ans * i) % MOD;
  }
  cout << (ans % MOD) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int N;
        double M,SUM;
 
        try {
            while((N = Integer.parseInt(br.readLine())) != 0){
 
                String input[] = br.readLine().split("\\s+");
                double array[] = new double[input.length];
 
                SUM = 0;
 
                for(int i = 0; i < input.length; i++){
                    array[i] = Double.parseDouble(input[i]);
                    SUM += array[i];
                }
 
                M = SUM/(double)N;
                SUM = 0;
 
                for(int i = 0; i < array.length; i++){
                    SUM += (array[i]-M)*(array[i]-M);
                }
 
                System.out.printf("%.10f\n", Math.sqrt(SUM/(double)N));
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 27580
#include<iostream>
#include<cmath>

using namespace std;
/*
	v = 9.8t
	y = 4.8t^2
	割れる速度になるtを求め、その時間でどのくらいの距離になるか計算する。
*/
int main() {
	double v;

	while (cin >> v) {
		double t = v / 9.8;
		double y = 4.9 * t * t;

		int N = static_cast<int>(ceil(y / 5)) + 1;

		cout << N << endl;
	}
}

Measured memory_bytes: 1228
#pragma GCC optimize(2)
#include <bits/stdc++.h>

namespace __temp_inbuilt{
	int read(void){
		int res = 0, sign = 1;
		char ch = std::getchar();
		while(!std::isdigit(ch)){
			if(ch == '-')
				sign = -1;
			ch = std::getchar();
		}
		while(std::isdigit(ch))
			res = res * 10 + ch - 48, ch = std::getchar();
		return sign * res;
	}
	
	template<class Tp>
		void write(const Tp &x){
			if(x > 9)
				write(x / 10);
			std::putchar(x % 10 + 48);
	}
}

using __temp_inbuilt::read;

template<class Tp>
	void writeln(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar('\n');
	}

template<class Tp>
	void writesp(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar(' ');
	}

template<class Tp>
	void write(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

namespace contest{
	const int MAXN = 5e5 + 19;
	
	int n, q, c[MAXN];
	int belong[MAXN];
	struct Node{
		int l, r;
		int id;
	}node[MAXN];
	inline bool cmp(const Node &a, const Node &b){
		return belong[a.l] != belong[b.l] ? a.l < b.l : a.r < b.r;
	}
	
	int L = 1, R = 0, RES = 0, cnt[MAXN];
	inline void ins(int p){
		if(!cnt[c[p]])++RES;
		++cnt[c[p]];
	}
	inline void del(int p){
		--cnt[c[p]];
		if(!cnt[c[p]])--RES;
	}
	int split(int l, int r){
		while(L > l)
			ins(--L);
		while(R < r)
			ins(++R);
		while(L < l)
			del(L++);
		while(R > r)
			del(R--);
		return RES;
	}
	
	int ans[MAXN];
	
	int main(){
		n = read(), q = read();
		for(int i = 1; i <= n; ++i)
			c[i] = read();
		int block_size = std::sqrt(n) + 1;
		for(int i = 1; i <= n; ++i)
			belong[i] = (i - 1) / block_size + 1;
		for(int i = 1; i <= q; ++i)
			node[i].l = read(), node[i].r = read(), node[i].id = i;
		std::sort(node + 1, node + 1 + q, cmp);
		for(int i = 1; i <= q; ++i)
			ans[node[i].id] = split(node[i].l, node[i].r);
		for(int i = 1; i <= q; ++i)
			writeln(ans[i]);
		return 0;
	}
}

int main(){
	contest::main();
	return 0;
}

Measured memory_bytes: 17412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll fpow(ll a,ll b){
    ll ret = 1;
    while (b) {
        if (b&1) ret = ret*a%MOD;
        a = a*a%MOD;
        b >>= 1;
    }
    return ret;
}
ll dp[MAXn];
int main(){
    IOS();
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i=k;i;i--) {
        dp[i] = fpow(k/i,n);
        for (ll j=i*2;j<=k;j+=i) dp[i] -= dp[j];
        ans = (ans + i*dp[i]%MOD) % MOD;
        while (ans < 0) ans += MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4368
#include<stdio.h>
int main()
{
    int a,b,c,sum1,sum2,sum3,count=0;
    scanf("%d%d%d",&a,&b,&c);
    while(a%2==0 && b%2==0 && c%2==0)
    {
        sum1=a/2;
        sum2=b/2;
        sum3=c/2;
        a=sum2+sum3;
        b=sum1+sum3;
        c=sum1+sum2;
        count++;
        if(a==b && b==c)
        {
            count=-1;
            break;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int i,j,k=0,ta,n,arr[1000],str[1000];
char s[1000],t[1000];
int main()
{
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%d",&j);
    k=k+j;
    }
    printf("%d",k-n);
    return 0;
}


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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

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

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

long depths[100005];

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

  long n;
  cin >> n;

  long mx = 0;
  bool isFst = true;
  bool canDo = true;
  rep(i, n) {
    long d;
    cin >> d;
    mx = max(d, mx);
    depths[d]++;
    if (isFst && d != 0) {
      canDo = false;
    }
    if (!isFst && d == 0) {
      canDo = false;
    }
    isFst = false;
  }

  mint res = 1;
  rep(i, mx) {
    mint a = depths[i];
    a = a.pow(depths[i+1]);
    res *= a;
  }

  cout << (canDo?res.x:0) << endl;
}


Measured memory_bytes: 1024
N, M = [int(x) for x in input().split()]
s = []; c = []
for _ in range(M):
    s_tmp, c_tmp = [int(x) for x in input().split()]
    s.append(s_tmp); c.append(c_tmp)

ans_list = [0] * N
is_not_checked = [True] * N
exist = True

for i in range(M):
    if N > 1 and s[i] == 1 and c[i] == 0:
        ans = -1
        exist = False
        break
    elif is_not_checked[s[i] - 1]:
        ans_list[s[i] - 1] = c[i]
        is_not_checked[s[i] - 1] = False
    elif ans_list[s[i] - 1] != c[i]:
        ans = -1
        exist = False
        break

if N > 1 and is_not_checked[0]:
    ans_list[0] = 1

if exist:
    ans = 0
    for i in range(N):
        ans += ans_list[i] * 10 ** (N - i - 1)

print(ans)

Measured memory_bytes: 3064
n, t = map(int, input().split(" "))
list_a = list(map(int, input().split(" ")))
list_profit = []
min_price = list_a[0]
for a in list_a:
  if min_price < a:
    list_profit.append(a - min_price)
  else:
    list_profit.append(0)
    min_price = a
max_profit = max(list_profit)
print(list_profit.count(max_profit))

Measured memory_bytes: 14228
N = int(input())

def makePrimes():
    primeList = []
    isPrime = [True for _ in range(55556)]
    isPrime[0] = False
    isPrime[1] = False

    for i in range(2, 55556):
        if not isPrime[i]:
            continue
        if i % 5 == 1:
            primeList.append(i)

        for j in range(i, 55556, i):
            isPrime[j] = False

    return primeList

primeList = makePrimes()
print(*primeList[:N])

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

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

    if (n < 1 || n > 81) {
        cout << "No" << endl ;
        return 0 ;
    }
    
    for (int i = 1 ; i <= 9; i++) {
        if ((n%i == 0) && n/i >= 1 && n/i <= 9) {
            cout << "Yes" << endl ;
            return 0 ;
        }
    }
    
    cout << "No" << endl ;
    return 0 ;
}

Measured memory_bytes: 256