akhauriyash/Code-Regression huggingface dataset:
b = list(map(int,input().split()))

if b[0] == 1 and b[1] == 1:
	print(1)
elif b[0] == 1:
	print(b[1]-2)
elif b[1] == 1:
	print(b[0] -2)

else:
	print(b[0]*b[1] - 2*(b[0] + b[1] - 2))

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

int main()
{
    int n;
    cin>>n;
    vector<int>x(n),y(n);
    for(int i=0;i<n;i++)
    {
        int w,e;
        cin>>w;
        cin>>e;
        {
            x[i]=w;
            y[i]=e;
        }
        
    }
    int c=0;
    bool flag=false;
    for(int i=0;i<n/*-2+1*/;i++)
    {
            if(x[i]-y[i]==0){
            c++;
        }
        if(c==3)
        {
            break;
        }
        else if(x[i]!=y[i])
        {
            c=0;
        }
        
    }
    if(c>=3)
    {
        cout<<"Yes"<<endl;
    }

    else
    {
            cout<<"No"; 
    }
    
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int A, B;
	cin >> A >> B;
	A--; B--;
	cout << A * B << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

	vector<vector<int>>rate(2,vector<int>(3,0));

	int solve(int n,int pre,int post){
		vector<int>dp(n+1,0);
		rep(i,n+1)dp[i]=i;
		rep(i,n+1)rep(j,3)if(i>=rate[pre][j]&&rate[pre][j]<rate[post][j])dp[i]=max(dp[i],dp[i-rate[pre][j]]+rate[post][j]);
		return dp[n];
	}

signed main(){
	int n;cin>>n;
	rep(i,2)rep(j,3)cin>>rate[i][j];
	cout<<solve(solve(n,0,1),1,0)<<endl;

	
}

Measured memory_bytes: 195584
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 1000000000, MAXI = N, D = 14;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 5, flag = 1;
//     cout << tc << "\n";
//     while (tc--)
//     {
//         int a = rand()%N+1;
//         a *= flag;
      
//         flag *= -1;

//         int b = rand()%MAXI + 1, c;

//         int d = rand()%D + 1;

//         int flag2 = rand()%3, k;

//         if(flag2==0)
//         {
//         	k = rand()%d+1;
//         	c = a + k*b;
//         }
//         else if(flag2==1)
//         {
//         	k = rand()%d + 1;
//         	c = a - k*b;
//         }
//         else
//         	c = rand()%MAXI;

//         cout << a << " " << b << " " << c << " " << d;
//         cout << "\n";
//         cout << "~\n";
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 
 
 
//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005

 
// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    
   	int k;
   	cin >> k;

   	int ans = 0;
   	for(int i=1;i<=k;i++)
   	{
   		for(int j=1;j<=k;j++)
   		{
   			for(int l=1;l<=k;l++)
   				ans += __gcd(l, __gcd(i, j));
   		}
   	}

   	cout << ans;

    
    return 0;
 
} 

Measured memory_bytes: 3640
#include <math.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define rrep(I,N) for(int I=N; I>=0; I--)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

int main() {
  int N, x;
  int a[100002];
  cin >> N >> x;

  a[0] = 0;
  repj(i, 1, N+1) {
    cin >> a[i] ;
  }

  long ans = 0;
  repj(i, 1, N+1) {
    int sub = 0;
    if (a[i] + a[i-1] > x) {
      sub = min(a[i], a[i] + a[i-1] - x);
    }
    ans += sub;
    a[i] -= sub;
  }

  printf("%ld\n", ans);
  return 0;
}




Measured memory_bytes: 640
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using Number = uint64_t;
using NumberSet = std::vector<uint64_t>;

Number count(bool valid, const NumberSet& nums) {
    Number n = 0;
    if (valid) {
        n = 1;
        auto halfSize = nums.size() / 2;
        for(decltype(halfSize) i = 0; i < halfSize; ++i) {
            n = (n * 2) % 1000000007;
        }
    }
    return n;
}

bool check(NumberSet& nums) {
    std::sort(nums.begin(), nums.end());
    auto size = nums.size();
    decltype(size) index = 0;
    Number n = 1;

    if ((size % 2) != 0) {
        if (nums[0] != 0) {
            return false;
        }
        index = 1;
        n = 2;
    }

    while(index < nums.size()) {
        if ((nums[index] != n) || (nums[index+1] != n)) {
            return false;
        }
        index += 2;
        n += 2;
    }

    return true;
}

int main(int argc, char* argv[]) {
    size_t size = 0;
    std::string paramLine;
    std::getline(std::cin, paramLine);
    std::istringstream is1(paramLine);
    is1 >> size;

    std::string numLine;
    std::getline(std::cin, numLine);
    std::istringstream is2(numLine);

    NumberSet nums;
    for(size_t i=0; i<size; ++i) {
        Number num = 0;
        is2 >> num;
        nums.push_back(num);
    }

    auto valid = check(nums);
    std::cout << count(valid, nums);
    return 0;
}

Measured memory_bytes: 2948
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N;
    cin >> N;
    ll p[100];
    for(ll i = 1; i <= N; i++)cin >> p[i];
    ll ans = 0;
    for(ll i = 2; i < N; i++){
        if((p[i] < p[i + 1]) && (p[i] < p[i - 1]));
        else if((p[i] > p[i + 1]) && (p[i] > p[i - 1]));
        else ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
x, y = list(map(int, input().split()))
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
print("Yes" if x in a and y in a or x in b and y in b or x in c and y in c else "No")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<queue>
using namespace std;
int n,a,b;
int c[10001];
int tot;
int main()
{
cin>>n>>a>>b;tot=n;
for(int i=1;i<=n;i++)cin>>c[i];
for(int i=1;i<=n;i++)
{
	if(c[i]>=a&&c[i]<b)tot--;
}
cout<<tot<<endl;
	return 0;
 }


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		int V=in();
		if(V==-1) break;

		double DV=V/2.0;
		while(abs(DV*DV*DV-V)>=0.00001*V){
			double DV2 = DV-(DV*DV*DV-V)/(3.0*DV*DV);
			DV = DV2;
		}
		printf("%.8lf\n",DV);
	}
	return 0;
}


Measured memory_bytes: 3208
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long h = sc.nextLong();

		// 計算
		long result = 0;
		long cnt = 1;
		while(h > 1){
		    result += cnt;
		    cnt *= 2;
		    h /= 2;
		}
		result += cnt;
		
		// 出力
		System.out.println(result);
	}
}


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

//

int main(){
    int n; cin>>n;
    vector<int> l(n);
    rep(i,0,n) cin>>l[i];
    sort(all(l));
    ll cnt=0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            ll temp=distance(l.begin(),lower_bound(all(l),l[i]+l[j])) - j -1;
            cnt+=temp;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import re
from itertools import accumulate
S = input()
target_ls = re.findall(r"R+L+", S)
res_ls = [0 for i in range(len(S))]
for i, ind in enumerate(accumulate([0] + [len(i) for i in target_ls][:-1])):
    target = target_ls[i]
    r_pos = target.find("L")
    if r_pos % 2 == 0:
        res_ls[ind + r_pos - 1] = len(target) // 2
        res_ls[ind + r_pos] = len(target) - len(target) // 2
    else:
        res_ls[ind + r_pos - 1] = len(target) - len(target) // 2
        res_ls[ind + r_pos] = len(target) // 2

print(" ".join([str(i) for i in res_ls]))

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int gcd(int a,int b)
{
  return (a%b==0? b:gcd(b,a%b));
}

int main()
{
  int a,b;
  cin>>a>>b;
  cout<<gcd(a,b)<<endl;
}


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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

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

	int ans = 0;
	int cnt = 0, lst = -1;
	for (int x : a) {
		if (x == lst) {
			++cnt;
		} else {
			ans += cnt / 2;
			cnt = 1;
		}
		lst = x;
	}
	ans += cnt / 2;
	printf("%d\n", ans);

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<double> prob(n+1);
    for(int i = 1; i <= n; i++)
        cin >> prob[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1)); 
    dp[0][0] = 1.000000000;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= n; j++)
            if(j == 0)
                dp[i][j] = (1.000000000 - prob[i]) * dp[i-1][j];
            else
                dp[i][j] = (prob[i] * dp[i-1][j-1]) + ((1.000000000 - prob[i])*dp[i-1][j]);
    cout << fixed << setprecision(10) << accumulate(dp[n].begin()+(n/2)+1, dp[n].end(), 0.0);
    return 0;
}


Measured memory_bytes: 73772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(){
    int a,b,c;cin>>a>>b>>c;
    if(((a==b)&&(a!=c))||((a==c)&&(a!=b))||((c==b)&&(a!=c))){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

int main(){
    IOS

    int n;
    cin>>n;
    int a[n+1];
    FOR(i,1,n+1){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int m=(a[n]+1)/2;
    int d=MOD;
    FOR(i,1,n+1){
        if(abs(a[i]-m)<abs(d-m)){
            d=a[i];
        }
    }
    cout<<a[n]<<" "<<d;


    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define EACH(i,c) for (auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N, M, C;
int B[21];
int A[21][21];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M >> C;
  REP(i, M) cin >> B[i];
  REP(i, N) REP(j, M) cin >> A[i][j];
  int ans = 0;
  REP(i, N) {
    int sum = 0;
    REP(j, M) sum += A[i][j]*B[j];
    sum += C;
    ans += (sum > 0);
  }
  cout << ans << endl;

  return 0;
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int L[2200];
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> L[i];
    }
    sort(L,L+N);
    int ans=0;
    rep(i, N) {
        rep(j, i) {
            rep(k, j) {
                ans+=L[i]<L[j]+L[k];
            }
        }
    }
    cout << ans << endl;
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
    int cnt1 = A.size();
    sort(A.begin(), A.end());
    decltype(A)::iterator result = unique(A.begin(), A.end());
    A.erase(result, A.end());
    int cnt2 = A.size();
    cout << (cnt1 == cnt2 ? YES : NO) << endl;
}

// Generated by 1.1.6 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);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)

Measured memory_bytes: 9176
#include <stdio.h>
int main()
{
    int w,h,n,x,y;
    while(1)
    {
        scanf("%d%d",&w,&h);
        if(w == 0&&h == 0)break;
        int mem[20][20] = {0};
        scanf("%d",&n);
        for(int i = 0; i < n; i++)
        {
            scanf("%d%d",&y,&x);
            mem[x - 1][y - 1] = 1;
        }
        int dp[20][20] = {1};
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                if(mem[i][j] == 1)dp[i][j] = 0;
                else if(i != 0||j != 0)dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            }
        }
        printf("%d\n",dp[h - 1][w - 1]);
    }
    return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
 
 
int main() {

	lld t;
	t=1;
	// cin>>t;
	while(t--)
	{
  
      string s;
      cin>>s;
      for(lld i=0;i<3;i++)
      	cout<<s[i];
      cout<<"\n";

	}
  
  return 0;
}

Measured memory_bytes: 3592
N,A,B=map(int,input().split())

if N <= 0 or A > B:
    ans = 0
elif N == 1:
    if A == B:
        ans = 1
    else:
        ans = 0
elif N >= 2:
    ans = B * (N-2) - A * (N-2) + 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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 print(x) cout << (x) << endl;

ll n, k, a[1008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> k;
	rep(i, 1, n){cin >> a[i];}
	a[0] = 0LL;
	rep(i, 1, n){a[i] += a[i-1];}
	
	vector<ll> v;
	rep(i, 1, n){
		rep(j, i, n){
			v.push_back(a[j]-a[i-1]);
		}
	}
	ll ans = 0LL;
	rrep(b, 40, 0){
		ll bit = (1LL << b);
		ll cnt = 0;
		vector<ll> u;
		for(ll i = 0; i < v.size(); i++){
			if((v[i] & bit) == bit){
				cnt++;
				u.push_back(v[i]);
			}
		}
		if(cnt >= k){
			ans += bit;
			v.swap(u);
		}
	}
	print(ans)
	return 0;
}

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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (!H && !W) break;
    for (int i{}; i < H; ++i) {
      for (int j{}; j < W; ++j) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	ll n, a, b; cin >> n >> a >> b;
    ll cnt = n / (a + b);
    ll noko = n % (a + b);
    cout << a * cnt + (noko > a ? a : noko) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
S = input()
rS = S[::-1]
n = len(S)
sS = S[:int(n/2):]
rsS = sS[::-1]
SS = S[int(n/2)+1::]
rSS = SS[::-1]
kaibun1 = (S == rS)
kaibun2 = (sS == rsS)
kaibun3 = (SS == rSS)

print('Yes' if kaibun1 and kaibun2 and kaibun3 else 'No')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   int i,j,k,l;
   int a,b,c,d;
   int memory[2];
   char e[1000][102];
   for(i=0; fgets(e[i],105,stdin) != NULL; i++) ;
   memory[0] = i;

   for(i=0;i<memory[0];i++) {
      for(j=0;e[i][j];j++) {
         if(e[i][j] == '@') {
            memory[1] = e[i][++j] - '0';
            ++j;
            for(k=0;k<memory[1];k++) printf("%c",e[i][j]);
         }
         else printf("%c",e[i][j]);
      }
   }

              
   return 0;
}

Measured memory_bytes: 1084
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(int argc, char const *argv[])
{
  int a,b;
  cin >> a >> b;

  int n;
  n = b-a;
  int h;
  h = (n+1)*n/2;

  println(h-b);


  return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> num(n);
	rep(i,n){
		cin >> num.at(i);
	}
	int ans = 0;
	for(int i = 1; i < n - 1; i++){
		if(num.at(i - 1) < num.at(i) && num.at(i) < num.at(i + 1)) ans++;
		else if(num.at(i - 1) > num.at(i) && num.at(i) > num.at(i + 1)) ans++;
	}
	cout << ans << endl;
} 

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

using namespace std;

int main()
{
    int c,h;
    set<char>se;
    string s;
     cin>>s;
    for(int i=0;i<s.size();i++)
          se.insert(s[i]);
    if(s.size()==se.size())
        cout<<"yes";
    else 
        cout<<"no";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//約数列挙
//昇順
//#include <vector>
//#include <cmath>
std::vector<long long> div(long long n) {
	std::vector<long long> v(1, 1);
	if (n == 1) return v;
	for (long long i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) v.push_back(i);
	}
	if (sqrt(n) == (long long)sqrt(n)) {
		for (long long i = v.size() - 2; i >= 0; i--) v.push_back(n / v[i]);
	}
	else {
		for (long long i = v.size() - 1; i >= 0; i--) v.push_back(n / v[i]);
	}
	return v;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m;
	cin >> n >> m;

	vector<ll> v = div(m);
	auto itr = lower_bound(all(v), n);
	cout << m / (*itr) << endl;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

c_m = a // c
c_M = b // c
if a % c != 0:
              c_m += 1

d_m = a // d
d_M = b // d
if a % d != 0:
              d_m += 1

if c > d:
              q = c
              r = d
else:
              q = d
              r = c

while r != 1 and r != 0:
              q_next = r
              r_next = q%r
              q = q_next
              r = r_next          
gcd = 0
if r == 1:
              gcd = 1
if r == 0:
              gcd = q

lcm =(c*d)//gcd
cd_m = a // (lcm)
cd_M = b // (lcm)
if a % ((c*d)//gcd) !=0:
              cd_m += 1

cd_cnt=(cd_M-cd_m+1)

dim = (c_M-c_m+1) + (d_M-d_m+1) - (cd_cnt)
ans = b - a + 1 - dim
print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s);
	OUT(inII(s[0], 'A', 'Z') ? 'A' : 'a');
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

bool check(int n) {
  int count = 0;

  repf(i, 1, n + 1) {
    if(count > 8) {
      break;
    }

    if(n % i == 0) {
      count++;
    }
  }

  return count == 8;
}

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

  int count_num = 0;

  repf(i, 1, n + 1) {
    if(i % 2 != 1) {
      continue;
    }
    if(check(i)) {
      count_num++;
    }
  }

  cout << count_num << endl;
}

Measured memory_bytes: 3608
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

######################################################

H, W, D = [int(_) for _ in input().split()]

A = [[int(_) for _ in input().split()]
     for _ in range(H)]

B = [None] * (H * W + 1)
for i in range(H):
    h = i * W
    for j in range(W):
        B[h + j] = (A[i][j], (i, j))
B[H * W] = (0, (-1, -1))
B = sorted(B, key=lambda x: x[0])
costs = [0] * (H * W + 1)
for i in range(H * W, 0, -1):
    if i + D <= H * W:
        costs[i] = costs[i + D] + abs(B[i][1][0] - B[i + D][1][0]) + abs(B[i][1][1] - B[i + D][1][1])

for i in range(int(input())):
    l,r = [int(_) for _ in input().split()]
    print(costs[l] - costs[r])



Measured memory_bytes: 23856
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int N, C;
int imos[30][101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> C;
    rep(i, 0, N) {
        int a, b, c; cin >> a >> b >> c;
        a--; c--;
        imos[c][a]++;
        imos[c][b]--;
    }
    rep(c, 0, C) rep(i, 1, 101010) imos[c][i] += imos[c][i - 1];
    rep(c, 0, C) rep(i, 0, 101010) if (imos[c][i]) imos[c][i] = 1;

    int ans = 0;
    rep(i, 0, 101010) {
        int cnt = 0;
        rep(c, 0, C) cnt += imos[c][i];
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
from logging import *
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s')
disable(CRITICAL)

n = int(input())

f = [0]*(n+1)
x = 1
while x*x < n:
    y = 1
    while y*y < n:
        if x*y >= n: continue
        z = 1
        while z*z < n:
            k = x*x + y*y + z*z + x*y + y*z + z*x
            if 1<=k<=n:
                debug('x {} y {} z {} k {}'.format(x,y,z,k))
                f[k] += 1
            z += 1
        y += 1
    x += 1
for i in range(1,n+1):
    debug('f[{}] {}'.format(i,f[i]))
    print(f[i])


Measured memory_bytes: 10756
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
int n, a, b, c;
vector <int> l;

int rec(vector <int> ll = l)
{
    int res = 1e9;
    rep(i, ll.size())
    {
        rep(j, ll.size())
        {
            rep(k, ll.size())
            {
                if(i == j || j == k || i == k) continue;
                res = min(res, abs(a - ll[i]) + abs(b - ll[j]) + abs(c - ll[k]));
            }
        }
    }

    if(ll.size() > 3)
    {
        rep(i, ll.size())
        {
            range(j, i + 1, ll.size())
            {
                vector <int> cp_ll(ll);
                cp_ll.push_back(cp_ll[i] + cp_ll[j]);
                cp_ll.erase(cp_ll.begin() + j);
                cp_ll.erase(cp_ll.begin() + i);
                res = min(res, 10 + rec(cp_ll));
            }
        }
    }

    return res;
}

int main() {
    cin >> n >> a >> b >> c;
    l.resize(n);
    rep(i, n) cin >> l[i];
    cout << rec() << endl;
    return 0;
}

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


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll n,k; cin>>n>>k;
  ll ans=0;
  rep(i,n){
  ll t; cin>>t;
    if(t>=k)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a[3];
	for (int i(0); i < 3; i++) {
		cin >> a[i];
	}
	sort(a, end(a));
	if (a[0] == a[1]) {
		cout << a[2];
	}
	else if (a[0] == a[2]) {
		cout << a[1];
	}
	else {
		cout << a[0];
	}
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    map<ll, set<ll>> m;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        m[-a].insert(i);
    }
    m[0].insert(-1);

    ll cnt = 0;
    vector<ll> res(N);
    ll mi = INF;
    for(auto it = m.begin(); it != m.end(); ++it) {
        if(it->first == 0) {
            break;
        }
        cnt += it->second.size();
        mi = min(mi, *(it->second.begin()));
        ll next = std::next(it)->first;
        res[mi] += cnt * (next - it->first);
    }

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


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

//WeightedUnionFind
template<class T>
class WeightedUnionFind {
public:
	int* p;   //親配列のポインタ
	int* rank;
	int N;   //要素数
	int* check;   //同値な要素の数
	T* diff_weight;   //差分
	//diff用
	T weight(int n) {
		parent(n);
		return diff_weight[n];
	}
public:
	WeightedUnionFind(int _N){
		N = _N;
		p = new int[N];
		rank = new int[N];
		check = new int[N];
		diff_weight = new T[N];
		for (int n = 0; n < N; n++) {
			p[n] = n;
			rank[n] = 0;
			check[n] = 1;
			diff_weight[n] = 0;
		}
	};
	~WeightedUnionFind() {
		delete p;
		delete rank;
		delete check;
		delete diff_weight;
	}
	//親要素を返す
	int parent(int n) {
		if (p[n] == n)return n;
		int par = parent(p[n]);
		diff_weight[n] += diff_weight[p[n]];
		return p[n] = par;
	}
	//差分(weight(y)-weight(x))を返す xとyが同じグループであるように!
	T diff(int x, int y) {
		return weight(y) - weight(x);
	}
	//weight(y)-weight(x)=wとなるようにマージ すでに同チームならばfalse
	bool merge(int x, int y, T w) {
		w += weight(x);
		w -= weight(y);
		x = parent(x);
		y = parent(y);
		if (x == y)return false;
		if (rank[x] < rank[y]) {
			swap(x, y);
			w = -w;
		}
		int groupsum = check[x] + check[y];
		if (rank[x] == rank[y]) {
			rank[x]++;
		}
		p[y] = x;
		diff_weight[y] = w;
		check[x] = groupsum;
		return true;
	}
	//同じグループか判定する
	bool issame(int x, int y) {
		return parent(x) == parent(y);
	}
	//自分のグループの要素数を返す
	int size(int n) {
		return check[parent(n)];
	}
};

int N, M;

int main() {
	cin >> N >> M;
	WeightedUnionFind<long long> UF(N);
	for (int m = 0; m < M; m++) {
		int L, R, D;
		cin >> L >> R >> D;
		L--;
		R--;
		if (!UF.issame(L, R)) {
			UF.merge(L, R, D);
		}
		else {
			if (UF.diff(L, R) != D) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

bool lunlun(ll x) {
    int last = -1;
    while (x > 0) {
        int d = x % 10;
        if (last != -1 && abs(last - d) > 1) {
            return false;
        }
        x /= 10;
        last = d;
    }
    return true;
}

string fxd;
int fxd_size = 0;
ll memo[18][15][2][2];
ll roll(int digit, int last, int less, int oz) {
    if (digit == 0) {
        return !oz;
    }
    ll &ans = memo[digit][last][less][oz];
    if (~ans) {
        return ans;
    }
    int cur_d = fxd[fxd_size - digit] - '0';
    ans = 0;
    fori (i, 0, 10) {
        if (last != 11 && !oz && abs(i - last) > 1) {
            continue;
        }
        if (!less && i > cur_d) {
            continue;
        }
        ans += roll(digit - 1, i, less || i < cur_d, oz && i == 0);
    }
    return ans;
}

ll cnt(ll x) {
    memset(memo, -1, sizeof memo); 
    fxd = to_string(x);
    int cnt_d = fxd.size();
    fxd_size = cnt_d;
    ll total = 0;
    total += roll(cnt_d, 11, 0, 1);
    return total;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll k;
    cin >> k;
    ll left = 1, right = (ll) 1e11;
    ll ans = -1;
    while (left <= right) {
        ll mid = (left + right) / 2;
        if (cnt(mid) >= k) {
            ans = mid;
            right = mid - 1;
        }
        else {
            left = mid + 1;
        }
    }
    cout << ans << endl;
    return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 500001
#define ll int
typedef pair<pi,int> pii;

int N,Q;
int C[maxn];
const int sqrtn = 700;
pii query[maxn];
int ans[maxn];
int coun[maxn];

int32_t main(){
	fast;
	
	cin>>N>>Q;
	
	FOR(i,1,N) cin>>C[i];
	
	FOR(i,1,Q){cin>>query[i].f.f>>query[i].f.s; query[i].s = i;}
	
	
	sort(query+1,query+Q+1, [] (pii i,pii j){
		return pi(i.f.f / sqrtn,i.f.s) < pi(j.f.f/sqrtn, j.f.s);
	});
	
	int l = 1, r = 1;
	
	int res = 1;
	coun[C[1]]++;
	
	FOR(i,1,Q){
		pi cur = query[i].f;
		
		while (r < cur.s){
			r++;
			if (coun[C[r]] == 0) res++;
			coun[C[r]]++;
		}
		
		while (l > cur.f){
			l--;
			if (coun[C[l]] == 0) res++;
			coun[C[l]]++;
		}
		
		while (r > cur.s){
			coun[C[r]]--;
			if (coun[C[r]] == 0) res--;
			r--;
		}
		
		while (l < cur.f){
			coun[C[l]]--;
			if (coun[C[l]] == 0) res--;
			l++;
		}
		
		ans[query[i].s] = res;
		
	}
	
	FOR(i,1,Q) cout<<ans[i]<<'\n';
		
	
}



Measured memory_bytes: 21392
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

int main() {
  using P = std::pair<int, int>;

  int n, m;
  std::cin >> n >> m;

  /*
  問題を言い換えるための下処理をする
  */

  std::vector<int> a(n), c(n + 1, 0); // c: 隣接する b の差分
  std::vector<P> bombs(n);            // first: A, second: B
  for (P &e : bombs) {
    std::cin >> e.first >> e.second;
  }
  std::sort(bombs.begin(), bombs.end()); // 座標の昇順にする
  for (int i = 0; i < n; i += 1) {
    a[i] = bombs[i].first;
    c[i] ^= bombs[i].second;
    c[i + 1] ^= bombs[i].second;
  }
  // この処理で c[i] = b[i] xor b[i+1] になる

  std::map<P, int> edge_index;
  // 辺の両端の pair から辺の index を取得する辞書
  // first <= second になっている
  // 多重辺があると消えてしまうが、今回は特に困らない
  std::vector<std::vector<int>> graph(n + 1); // グラフ
  for (int i = 0; i < m; i += 1) {
    int l, r;
    std::cin >> l >> r;
    // l, r を座標圧縮後の値に直す
    l = std::lower_bound(a.begin(), a.end(), l) - a.begin();
    r = std::upper_bound(a.begin(), a.end(), r) - a.begin();
    edge_index[{l, r}] = i;
    graph[l].push_back(r);
    graph[r].push_back(l);
  }

  /*
  下処理終わり
  グラフから辺を選んで両端を反転させ、c を全て 0 にする問題に帰着された
  */

  std::set<int> ans; // 使う辺の index の集合

  // DFS を行い、辺の使用不使用を決定していく
  std::vector<bool> visited(n + 1, false);
  std::function<void(int)> dfs = [&](int v) -> void {
    visited[v] = true;
    for (int u : graph[v]) {
      if (visited[u])
        continue;
      dfs(u);
      if (c[u] == 1) {
        // uv 辺を使用することに決定
        // edge_index[{u, v}] だと u > v の時に正しくアクセスできないことに注意
        int id = edge_index[std::minmax(u, v)];
        ans.insert(id);
        c[u] ^= 1;
        c[v] ^= 1;
      }
    }
  };
  // グラフが連結とは限らないので、0 から DFS するだけだと足りない
  for (int i = 0; i < n + 1; i += 1) {
    if (!visited[i])
      dfs(i);
    // この時点で i は探索済
    // それでも c[i] が 0 に出来てないなら、不可能
    if (c[i] == 1) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }

  std::cout << ans.size() << std::endl;
  for (int e : ans) {
    std::cout << e + 1 << " ";
  }

  return 0;
}

Measured memory_bytes: 33536
#include<stdio.h>

int main(){
  char s[3];
  scanf("%s",s);
  int res=700;
  for(int i=0;i<3;i++){
  if(s[i]=='o'){
   res+=100; 
    
  }
  
  }
  
  printf("%d\n",res);
  
 return 0; 
}

Measured memory_bytes: 128
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())
z = [0] * n
w = [0] * n
for i in range(n):
    z[i] = x[i] + y[i]
    w[i] = x[i] - y[i]
cand1 = max(z) - min(z)
cand2 = max(w) - min(w)
print(max(cand1, cand2))


Measured memory_bytes: 40356
import sys
s=input()
A,B =map(int,input().split())
table=[[] for i in range(2)]#0が横1が縦
t = 0
k=0
for i in range(len(s)):
    if s[i]=='F':
        k+=1
    else:
        table[t].append(k)
        t=(t+1)%2
        k=0
table[t].append(k)
L=len(s)
Lx=[set() for i in range(len(table[0]) +1)]
Ly=[set() for i in range(len(table[1]) +1)]
Lx[0].add(0)
Ly[0].add(0)
for i in range(len(table[0])):
    x = table[0][i]
    if i==0:
        Lx[1].add(x)
        continue
    for a in Lx[i]:
        if -L<=a+x<=L:
            Lx[i+1].add(a+x)
        if -L<=a-x<=L:
            Lx[i+1].add(a-x) 
flag=True
for a in Lx[len(table[0])]:
    if a==A:
        flag =False
if flag:
    print('No')
    sys.exit()
    
for i in range(len(table[1])):
    x = table[1][i]
    for a in Ly[i]:
        if -L<=a+x<=L:
            Ly[i+1].add(a+x)
        if -L<=a-x<=L:
            Ly[i+1].add(a-x)
flag=True
for a in Ly[len(table[1])]:
    if a==B:
        flag =False
if flag:
    print('No')
    sys.exit()
    
print('Yes')

Measured memory_bytes: 271368
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
Ans=[0]*(n+1)
Children=[[] for _ in range(n+1)]
Cnt=[0]*(n+1); Cnt[0]=1
for _ in range(n+m-1):
    a,b=map(int,input().split())
    Children[a].append(b)
    Cnt[b]+=1
root=Cnt.index(min(Cnt))
V=[root]
while V:
    v=V.pop()
    for u in Children[v]:
        if Cnt[u]==1:
            Ans[u]=v
            V.append(u)
        else:
            Cnt[u]-=1
print(*Ans[1:],sep='\n')

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

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> v(26);
        int ma = 0;
        char res1 = 0; int res2 = 0;
        for(int i=0; i<n; ++i) {
            char c = 0;
            cin >> c;
            if(res1 != 0) {
                continue;
            }
            int id = c-'A';
            v[id]++;
            if(v[ma] < v[id]) {
                ma = id;
            }
            int mi = 1e9;
            for(int j=0; j<v.size(); ++j) {
                if(j == ma) {
                    continue;
                }
                mi = min(mi, v[ma]-v[j]);
            }
            if(mi > n-i-1) {
                res1 = 'A' + ma;
                res2 = i+1;
            }
        }
        if(res1 == 0) {
            cout << "TIE" << endl;
        } else {
            cout << res1 << " " << res2 << endl;
        }
    }
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	string s ;
	cin >> s ;
	int ans = 0 ;
	char se[4] = {'A','C','G','T'};
	int count = 0 ;
	bool acgt = false ;
	rep(i,s.size()){
		acgt = false ;
		rep(j,4){
			if(s[i] == se[j]){
				count ++ ;
				chmax(ans,count);
				acgt = true; 
			}
		}
		if(!acgt){ 
			count = 0 ;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define endl "\n"
using namespace std;
ll arr[105][100005];
int main()
{
 ll s[1000][2]={0};
  ll n,w;cin>>n>>w;
    for(ll i=0;i<n;i++)
    {
        cin>>s[i][0]>>s[i][1];
    }

    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
            {
                arr[i][j]=0;
            }
            else{
            if(s[i-1][0]<=j)
            {
                arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
            }
            else

            {
                arr[i][j]=arr[i-1][j];
            }
            }
        }
    }
    cout<<arr[n][w]<<endl;;

    return 0;
}


Measured memory_bytes: 80128