akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#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 btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll n;
int main()
{
	FAST
	cin>>n;
	vector<ll> A(n, 0);
	FOR(i,0,n-1) cin>>A[i];
	ll ans = 1;
	vector<ll> co(n, 0);
	ll mod=1e9+7;
	ll zero = 0;
	FOR(i,0,n-1) {
		if(A[i]) {
			ans *= co[A[i]-1], ans%=mod;
			-- co[A[i]-1];
		} else ++ zero;
		++ co[A[i]];
	}
	if(zero == 1) ans *= 3, ans%=mod;
	if(zero == 2) ans *= 6, ans %= mod;
	if(zero == 3) ans *= 6, ans %= mod;
	if(accumulate(all(co), 0ll) > 3) return cout<<0, 0;
	cout<<ans<<'\n';
}


Measured memory_bytes: 1792
n = int(input())
b_s = [int(h) for h in input().split()]

ans = 0
left = b_s[0]
right = left
ans += left
#print(left)
for i in range(1, n - 1):
  right = b_s[i]
  a_i = min(left, right)
  #print(a_i)
  ans += a_i
  left = right
ans += right
#print(right)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mx=1000000;
const int mod=998244353;
const int inv2=(mod+1)/2;
#define N 1000100
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,mu[N],s[N],c[N],ans;
void init(int n){
	mu[1]=1;
	for(int i=1;i<=n;++i){
		for(int j=i+i;j<=n;j+=i){
			mu[j]-=mu[i];
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=i;j<=n;j+=i){
			s[j]=(s[j]+mu[i]*i)%mod;
		}
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		++c[read()];
	}
	init(mx);
	for(int i=1;i<=mx;++i){
		int tmp=0;
		for(int j=1;j<=mx/i;++j){
			tmp=(tmp+1LL*j*c[j*i])%mod;
		}
		tmp=1LL*tmp*tmp%mod*i%mod*s[i]%mod;
		ans=(ans+tmp)%mod;
	}
	for(int i=1;i<=mx;++i){
		ans=(ans-1LL*c[i]*i)%mod;
	}
	ans=1LL*(ans+mod)%mod*inv2%mod;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 15464
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1]%d7 + C[i - 1][j]%d7)%d7;}}}
    return C[n][k]%d7;
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}

int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,m;
    cin>>n>>m;
    if(n<10&&m<10&&n>=0&&m>=0){cout<<n*m;}
    else{cout<<-1;}
    
//code ends
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split("").map(&:to_i)
k = gets.chomp.to_i
count = 0

s.each do |i|
    break if i != 1
    count += 1
end

if k <= count
    puts 1
    exit
end

s.each do |i|
    if i != 1 then
        puts i
        break
    end
end

Measured memory_bytes: 1788
from sys import stdin
N=int(stdin.readline().rstrip())

blue=[]
for i in range(N):
    blue.append((input()))

M=int(stdin.readline().rstrip())

red=[]
for j in range(M):
    red.append((input()))

ans = len(set(blue)) * [0]
for ind,k in enumerate(set(blue)):
    ans[ind] = blue.count(k) - red.count(k)

print(max(max(ans),0))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int H,W,K;
    cin >> H >> W >> K;
    char s[300][300];
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            cin >> s[h][w];
        }
    }
    
    int cnt=0;
    int ans[300][300]={};
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(s[h][w]=='#'){
                cnt++;
                
                for(int i=w; i>=0; i--){
                    if(ans[h][i]==0){
                        ans[h][i]=cnt;
                    }else{
                        break;
                    }
                }
            }
        }
    }
    
    for(int i=0; i<H; i++){
        int exist=0;
        for(int j=W-1; j>=0; j--){
            if(ans[i][j]!=0){
                exist = ans[i][j];
                break;
            }
        }
        
        if(exist!=0){
            for(int j=W-1; j>=0; j--){
                if(ans[i][j]==0){
                    ans[i][j] = exist;
                }
            }
        }
    }
    
    int last=0;
    for(int i=0; i<H; i++){
        if(ans[i][0]!=0){
            last = max(last,i);
            for(int j=0; j<W; j++){
                for(int k=i-1; k>=0; k--){
                    if(ans[k][j]==0){
                        ans[k][j]=ans[i][j];
                    }else{
                        break;
                    }
                }
            }
        }
    }
    
    for(int i=last+1; i<H; i++){
        for(int j=0; j<W; j++){
            ans[i][j] = ans[last][j];
        }
    }
    
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            cout<<ans[h][w];
            if(w==W-1){
                cout<<endl;
            }else{
                cout<<" ";
            }
        }
    }
    return 0;
    
}


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

int main()
{
    int a, b, c, k, l, m;
    cin >> a >> b >> c >> k;


    l = k - a;

    if (l > 0)
    {
        l -= b;
        if (l > 0)
        {
            l -= c;
            if (l > 0)
            {
                cout << a-c << endl;
                return 0;
            }
            else
            {
                m = c + l;
                cout << a-m << endl;
                return 0;
            }
        }
        else
        {
            cout << a << endl;
            return 0;
        }
    }
    else
    {
        cout << k << endl;
        return 0;
    }

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define MAX_N 101000
#define MAX_LOG_V 20
int N,root=0;
vector<int> g[MAX_N];
int parent[MAX_LOG_V][MAX_N];
int depth[MAX_N];
void dfs(int v,int p,int d){
	depth[v]=d;
	parent[0][v]=p;
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]!=p){
			dfs(g[v][i],v,d+1);
		}
	}
	return;
}
void init(){
	dfs(root,-1,0);
	//dfs();
	for(int i=0;i<MAX_LOG_V-1;i++){
		for(int v=0;v<N;v++){
			if(parent[i][v]==-1)parent[i+1][v]=-1;
			else parent[i+1][v]=parent[i][parent[i][v]];
		}
	}
	return;
}
int lca(int u,int v){
	if(depth[u]>depth[v])swap(u,v);
	for(int i=MAX_LOG_V-1;i>=0;i--){
		if(((depth[v]-depth[u])>>i)&1)v=parent[i][v];
	}
	if(u==v)return u;
	for(int i=MAX_LOG_V-1;i>=0;i--){
		if(parent[i][u]!=parent[i][v]){
			u=parent[i][u];
			v=parent[i][v];
		}
	}
	return parent[0][u];
}

int main(){
	cin >> N;
  int U,V;
  cin >> U >> V;
  U--;V--;
  root = V;
	for(int i=0;i<N-1;i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);

	}
	init();
  int ans = 0;
  for(int i=0;i<N;i++){
    if(g[i].size()==1&&i!=root){
      int c = lca(i,U);
      // cout << i << endl;
      // cout << c << endl;
      if(c==U){
        ans = max(ans,depth[i]-1);
      }else{
        int A = depth[c];
        int B = depth[U]-depth[c];
        // cout << A << ' ' << B << endl;
        if(A>B){
          ans = max(ans,depth[i]-1);
        }
      }
    }
  }
  cout << ans << endl;
	return 0;
}



Measured memory_bytes: 19200
import sys

input = sys.stdin.readline

sx, sy, tx, ty = list(map(int, input().split(' ')))

dfx = tx - sx
dfy = ty - sy

routes = ''

routes += 'U' * dfy
routes += 'R' * dfx
routes += 'D' * dfy
routes += 'L' * dfx

routes += 'L'
routes += 'U' * (dfy + 1)
routes += 'R' * (dfx + 1)
routes += 'D'

routes += 'R'
routes += 'D' * (dfy + 1)
routes += 'L' * (dfx + 1)
routes += 'U'

print(routes)




Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
 
lli maxA(lli a,lli b,lli c){
	lli rtn = max(a,b);
	rtn = max(rtn,c);
	return rtn;
}
lli minA(lli a,lli b,lli c){
	lli rtn = min(a,b);
	rtn = min(rtn,c);
	return rtn;
}
 
signed main(){
 
	lli n;
	cin>>n;
	vector<lli> p(n);
 	REP(i,0,n)cin>>p[i];
 
 	lli cnt=0;
 	for(lli i=1;i<n-1;i++){
 		lli maxB = maxA(p[i-1],p[i],p[i+1]);
 		lli minB = minA(p[i-1],p[i],p[i+1]);
 		if(p[i] != maxB && p[i] != minB)cnt++;
 	}
 
 	cout<<cnt<<endl;
 
 
	return 0;
}

Measured memory_bytes: 256
using System;


namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int H, W, K;
        private const int Mod = (int)1e9 + 7;
        private long[,] Memo;
        void Scan()
        {
            var sc = new Scanner();
            H = sc.NextInt();
            W = sc.NextInt();
            K = sc.NextInt() - 1;
        }

        public void Solve()
        {
            Scan();
            Memo = new long[H + 1, W];
            for (int i = 0; i <= H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    Memo[i, j] = -1;
                }
            }
            Console.WriteLine(Calc(0, 0));
        }

        private long Calc(int height, int start)
        {
            if (Memo[height, start] != -1) return Memo[height, start];
            if (height == H)
            {
                return start == K ? 1 : 0;
            }
            int[] fib = new int[] { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
            long ans = 0;
            if (start < W - 1)
            {

                ans += Calc(height + 1, start + 1) * fib[start] * fib[W - start - 2];
                ans %= Mod;
            }

            if (start > 0)
            {
                ans += Calc(height + 1, start - 1) * fib[start - 1] * fib[W - start - 1];
                ans %= Mod;
            }

            ans += Calc(height + 1, start) * fib[W - start - 1] * fib[start];
            ans %= Mod;
            Memo[height, start] = ans;
            return ans;
        }



        static void Main() => new Program().Solve();
    }


}


Measured memory_bytes: 11220
#!/usr/bin/python

paper = [[0] * 10 for i in range(10)]

def small(x, y):
    p = [[x, y]]
    for i, j in zip([-1, 0, 1, 0], [0, -1, 0, 1]):
        p.append([x + i, y + j])
    return p

def middle(x, y):
    p = small(x, y)
    for i, j in zip([1, -1, 1, -1], [1, 1, -1, -1]):
        p.append([x + i, y + j])
    return p

def big(x, y):
    p = middle(x, y)
    for i, j in zip([-2, 0, 2, 0], [0, -2, 0, 2]):
        p.append([x + i, y + j])
    return p

while True:
    try:
        x, y, size = map(int, input().split(','))
    except:
        break

    if size == 1:
        bp = small(x, y)
    elif size == 2:
        bp = middle(x, y)
    elif size == 3:
        bp = big(x, y)
    for p in bp:
        if 0 <= p[0] < 10 and 0 <= p[1] < 10:
            paper[p[1]][p[0]] += 1

print(sum(paper[y][x] == 0 for y in range(10) for x in range(10)))
print(max(paper[y][x] for y in range(10) for x in range(10)))

Measured memory_bytes: 6776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int m1 = input[0];
            int d1 = input[1];
            input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int m2 = input[0];
            int d2 = input[1];

            if (m2 == m1 + 1 && d2 == 1)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 13396
from itertools import product
H, W = map(int, input().split())
s = [input() for _ in range(H)]
visited = [[0]*W for _ in range(H)]
ans = 0

for y, x in product(range(H), range(W)):
    if visited[y][x]:
        continue
    visited[y][x] = 1
    w, b = 0, 0
    if s[y][x] == '#':
        b += 1
    else:
        w += 1
    stack = [(y, x)]

    while stack:
        cy, cx = stack.pop()
        for dy, dx in ((cy+1, cx), (cy-1, cx), (cy, cx+1), (cy, cx-1)):
            if not (0 <= dy < H and 0 <= dx < W) or visited[dy][dx] or s[cy][cx] == s[dy][dx]:
                continue
            visited[dy][dx] = 1
            if s[dy][dx] == '#':
                b += 1
            else:
                w += 1
            stack.append((dy, dx))

    ans += w * b

print(ans)


Measured memory_bytes: 49372
def main():
    n_money, y_yen = map(int, input().split())
    # money
    a, b, c = 10000, 5000, 1000
    for x in range(n_money+1):
        for y in range(n_money-x+1):
            z = n_money - x - y
            money = a * x + b * y + c * z
            if money == y_yen:
                print(f'{x} {y} {z}')
                return 0
    print('-1 -1 -1')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9104
#include <iostream>
#include <string>

using namespace std;

int main() {
		int N;
		cin >> N;
		string S, T;
		cin >> S >> T;

		int ans = 1e9;
		string TT = T;

		for (int shift = 0; shift <= T.size(); shift++) {
				int cnt = 0;
				for (int i = 0; i < S.size(); i++) {
						if (S[i] == TT[i]) cnt++;
				}
				ans = min(ans, N*2 - cnt);
				TT = " " + TT;
		}

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


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

using namespace std;

int main() {
	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	for(int i = l; i <= r; ++i) {
		if(i % d == 0) {
			ans += 1;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3584
function main(input) {
  const tmp = input.trim().split(' ')
  const a = parseInt(tmp[0], 10)
  const b = parseInt(tmp[1], 10)
  const c = parseInt(tmp[2], 10)
  const d = parseInt(tmp[3], 10)

  const ta = Math.ceil(c / b)
  const ao = Math.ceil(a / d)

  if (ta <= ao) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ba(m);
    rep(i, m){
        int tmp_a, tmp_b;
        cin >> tmp_a >> tmp_b;
        --tmp_a, --tmp_b;
        ba[i] = make_pair(tmp_b, tmp_a);
    }
    sort(ba.begin(), ba.end());
    int right_place = ba[0].first;
    int ans = 1;
    rep(i, m) {
        if ( right_place <= ba[i].second ) {
            right_place = ba[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if( b < a ){
		a--;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,l=map(int,input().split())\n"
"t=a=0\n"
"m=1e9\n"
"for i in range(n):\n"
"    if abs(l+i)<m:\n"
"        m=abs(l+i)\n"
"        t=l+i\n"
"    a+=l+i\n"
"print(a-t)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 7236
#!usr/bin/env python3
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LIR(n):
    return [LI() for i in range(n)]
class BIT:
    def __init__(self, size):
        self.size = size + 1
        self.dat = [0]*self.size

    def add(self, i, x=1):
        while i < self.size:
            self.dat[i] += x
            i += i&-i

    # sum[l,r)
    # sum[0,l] (r = None)
    def sum(self, l, r=None):
        if r is None:
            res = 0
            while l > 0:
                res += self.dat[l]
                l -= l&-l
            return res

        else:
            rres = 0
            while r > 0:
                rres += self.dat[r]
                r -= r&-r
            l -= 1
            lres = 0
            while l > 0:
                lres += self.dat[l]
                l -= l&-l
            return rres - lres


def solve():
    n,Q = LI()
    c = LI()
    q = LIR(Q)
    q = [[i,q[i]] for i in range(Q)]
    q.sort(key = lambda x:x[1][1])
    bit = BIT(n+1)
    i = 0
    p = [None]*(n+1)
    ans = [0]*Q
    for ind,(l, r) in q:
        while i < r:
            ci = c[i]
            j = p[ci]
            if j is not None:
                bit.add(j,-1)
            bit.add(i+1)
            p[ci] = i+1
            i += 1
        ans[ind] = bit.sum(l,r)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

	cin >> c;

	if('A'<=c && c<='Z'){
		cout << 'A';
	}else if('a'<=c && c<='z'){
		cout << 'a';	
	}

 
	return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 int main() {
	 int A, B, K;
	 cin >> A >> B >> K;
	 if (B - A + 1 <= 2 * K) {
		 for (int i = A; i <= B; i++) cout << i << endl;
	 }
	 else {
		 for (int i = 0; i < K; i++) cout << A + i << endl;
		 for (int i = K-1; i >= 0; i--) cout << B - i << endl;
	 }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        private static List<long> numList = new List<long>();
        private static StringBuilder numWorkStringBuilder = new StringBuilder();
        static void Solve()
        {
            string s = Console.ReadLine();
            int n = (int)( pow(2, s.Length - 1) - 1);
            long ans = 0;
            for(int i=0;i<=n;++i)
            {
                ans += CalcSum(s, i);
            }
            Console.WriteLine(ans);
        }
        private static long CalcSum(string s, int bit)
        {
            numWorkStringBuilder.Clear();
            numList.Clear();
            for(int i=0;i<s.Length;++i)
            {
                numWorkStringBuilder.Append(s[i]);
                if( (bit & (1 << i)) == 0) { continue; }
                AddCurrentNum();
                numWorkStringBuilder.Clear();
            }
            AddCurrentNum();

            return numList.Sum();
        }
        private static void AddCurrentNum()
        {
            string strNum = numWorkStringBuilder.ToString();
            long num = long.Parse(strNum);
            numList.Add(num);

        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11220
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
g=len(d)
cnt=0
d=sorted(d.items(),key=lambda x:x[1])
for i , j in d:
    if g<=k:
        print(cnt)
        break
    else:
        g-=1
        cnt+=j


Measured memory_bytes: 101832
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF (1ll<<60)
int main(){
	int n;
	cin >> n;
	if(n < 6){
		cout << 0 << endl;
		return 0;
	}
	vector<long long> e(n);
	for(int i = 0 ; i < n ; i++) cin >> e[i];
	sort(e.rbegin(),e.rend());
	long long answer = 0;
	for(int i = 0 ; i <= n - 6 ; i++){		
		for(int j = 0 ; j < (1<<6) ; j++){
			if(__builtin_popcount(j)==3){
				long long ok1 = INF , ok2 = INF;
				for(int k = 0 ; k < 6 ; k++){
					if(j>>k&1){
						if(ok1!=INF) ok1 -= e[i+k]; else ok1 = e[i+k];
					}else{
						if(ok2!=INF) ok2 -= e[i+k]; else ok2 = e[i+k];
					}
				}
				if(ok1 < 0 && ok2 < 0 && ok1 != INF && ok2 != INF){
					long long sum = 0;
					for(int k = 0 ; k < 6 ; k++) sum += e[i+k];
					answer = max(answer,sum);
				}
			}
		}
	}
	long long alpha = INF , beta = INF;
	for(int i = 0 ; i <= n - 3 ; i++){
		if(alpha==INF){
			if(e[i]<e[i+1]+e[i+2]){
				alpha = e[i]+e[i+1]+e[i+2];
				i += 2;
			}	
		}else{
			if(e[i]<e[i+1]+e[i+2]){
				beta = e[i]+e[i+1]+e[i+2];
				break;
			}	
		}
	}
	if(beta != INF) answer = max(beta+alpha,answer);
	cout << answer << endl;
	
	
	
	
}

Measured memory_bytes: 1652
//#include<atcoder/all>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
//using namespace atcoder;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,m;
    cin >> n >>m;
    ll ans=0;
    vector<vector<ll>> g(n+1);

    for(ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        g[a].PB(b);
        g[b].PB(a);
    }
    while(true){
        bool f=true;
        for(ll i=1;i<=n;i++){
            if(g[i].size()==1){
                ll tmp=g[i][0];
                g[tmp].erase(remove(g[tmp].begin(),g[tmp].end(),i), g[tmp].end());
                g[i].erase(g[i].begin());
                ans++;
                f=false;
            }
        }
        if(f) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
const int maxn=2e5+5;
ll n,k,d,a[maxn],pos,ans,cnt;
string s;
signed main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ans=INF;
    cin>>n>>k>>d;
    n=abs(n);
    if(n==0)
    {
        if(k%2)
            cout<<d<<endl;
        else
            cout<<0<<endl;
        return 0;
    }
    if(n/d<k)
    {
        cnt=k-n/d;
        if(cnt%2)
        {
            pos=abs(n-(n/d)*d);
            ans=min(ans,abs(pos+d));
            ans=min(ans,abs(pos-d));
        }
        else
        {
            pos=abs(n-(n/d)*d);
            ans=min(ans,pos);
        }
    }
    else
    {
        pos=abs(n-k*d);
        ans=min(ans,pos);
    }
    if(n/d+1<k)
    {
        cnt=k-(n/d+1);
        if(cnt%2)
        {
            pos=abs(n-(n/d+1)*d);
            ans=min(ans,abs(pos+d));
            ans=min(ans,abs(pos-d));
        }
        else
        {
            pos=abs(n-(n/d+1)*d);
            ans=min(ans,pos);
        }
    }
    else
    {
        pos=abs(n-k*d);
        ans=min(ans,pos);
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
string s;
int ans,n,i,j,k;
int main()
{
    cin>>n>>k>>s;
    while(j<n)
    {
        while(j<n&&s[j]=='1')
            ++j;
        ans=max(ans,j-i);
        while(j<n&&s[j]=='0')
            ++j;
        --k;
        if(k<0)
        {
            while(i<n&&s[i]=='1')
                ++i;
            while(i<n&&s[i]=='0')
                ++i;
        }
        ans=max(ans,j-i);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

string convert(const string &T)
{
  string S(T.size(), '?');
  
  N_TIMES(i, T.size()) {
    switch(T[i]) {
    case 'r': S[i] = 'p'; break;
    case 's': S[i] = 'r'; break;
    case 'p': S[i] = 's'; break;
    }
  }
  
  return S;
}

int main()
{
  uint64_t N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  string U = convert(T);
  
  const auto get_point = [&](char c) {
    switch(c) {
    case 'r': return R;
    case 's': return S;
    case 'p': return P;
    default : return static_cast<uint64_t>(0);
    }
  };
  
  uint64_t total = 0;
  N_TIMES(k, K) {
    bool same_flag = false;
    uint64_t counter = 0;
    uint64_t point = get_point(U[k]);
    
    for (uint64_t n = k + K; n < N; n += K) {
      same_flag = U[n] == U[n - K];
      
      if (same_flag) {
        ++counter;
      } else {
        counter = 0;
      }
      
      if (!same_flag || ((counter & 1) == 0)) {
        point += get_point(U[n]);
      }
    }
    
    total += point;
  }
  
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,k,q;cin>>n>>k>>q;
  ll arr[n]; ll count_=q,idx;
  for(int i=0;i<n;i++) arr[i]=k;
  while(q--)
  {
    cin>>idx;arr[idx-1]++;
  }
  for(int i=0;i<n;i++)
  {
     // cout<<arr[i]<<' ';
    if(arr[i]-count_ >0) cout<<"Yes\n";
    else cout<<"No\n";
  }
  
  return 0;
}

Measured memory_bytes: 1408
X = int(input())
A = [(i**5) for i in range(0, 1000)]
res = []
for i in range(len(A)):
  a = A[i]
  for j in range(len(A)):
    b = -A[j]
    cal = a - b
    cal2 = a + b
    if cal == X:
      print(i, -j)
      exit()
    elif cal2 == X:
      print(i, j)
      exit()




Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(15)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll a,b,h,m;
int main(){FAST;
  dofloat;
cin>>a>>b>>h>>m;

ld dhr = (ld)m/2+h*30;
ld dmi = (ld)6*m;

  ld x1 = a*cos(PI/180*dhr);
  ld y1 = a*sin(PI/180*dhr);
  ld x2 = b*cos(PI/180*dmi);
  ld y2 = b*sin(PI/180*dmi);
  // cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<'\n';
  cout<<hypot(x2-x1,y2-y1);

return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 4152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
/*
int vistd[10004];
vector<int>a[10004];
vector<int>dis(10004,0);
void dfs(int k){
   if(vistd[k]==0){
    vistd[k]=1;
    for(int i=0;i<a[k].size();i++){
        if(!vistd[a[k][i]]){
/// to find the distance between each node and their children dis[a[k][i]]=dis[k]+1;
            dfs(a[k][i]);
        }
    }
   }

}
int freq[2004];
*/
int main()
{
 int n;
 cin>>n;
 map<string,int>a,w,t,r;
 while(n--){
    string s;
    cin>>s;
    if(s=="AC")a[s]++;
    else if(s=="TLE")t[s]++;
    else if(s=="WA")w[s]++;
    else if(s=="RE")r[s]++;
 }
 cout << "AC x " << a["AC"] << endl;
 cout << "WA x " << w["WA"] << endl;
 cout << "TLE x " << t["TLE"] << endl;
 cout << "RE x " << r["RE"] << endl;






}


Measured memory_bytes: 3592
n = int(input())
ord_a = ord("a")
ans = ""
now = 26
prev = 0
e = 1
num = 0
while True:
    if now >= n:
        num = n - prev -1
        break
    e += 1
    prev = now
    now += 26 ** e
ans = ""
for i in range(e):
    res,mod = divmod(num,26)
    ans = chr(mod+ord_a) + ans
    num = res
print(ans)

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

using namespace std;

int n;
int d;
int x;
int a;

int main() {
	scanf("%d%d%d", &n, &d, &x);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a);
		x += (d + a - 1) / a;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
    	public static void main(String[] args){
        	Scanner sc = new Scanner(System.in);
        	int x = sc.nextInt();
	        int y = sc.nextInt();
	        int z = sc.nextInt();
	        long[][] a = new long[x][y];
	        long[][] b = new long[y][z];
	        long[][] c = new long[x][z];
         
	        for(int i=0; i<x; i++){
        		for(int j=0; j<y; j++){
                		a[i][j] = sc.nextInt();
            		}
        	}
        	for(int i=0; i<y; i++){
            		for(int j=0; j<z; j++){
                		b[i][j] = sc.nextInt();
            		}
        	}
         
        	for(int i=0; i<x; i++){
            		for(int j=0; j<z; j++){
                		for(int k=0; k<y; k++){
                    			c[i][j] += a[i][k] * b[k][j];
                		}
            		}
        	}
        	for(int i=0; i<x; i++){
            		for(int j=0; j<z; j++){
                		System.out.print(c[i][j]);
                		if(j != z-1){
                    			System.out.print(" ");
                		}
            		}
            		System.out.println();
        	}
    	}
}

Measured memory_bytes: 45300
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<string,pair<int,int>>> nsp(n);
  for(int i=0;i<n;i++){
    string s;
    int p;
    cin >> s >> p;
    nsp[i].first = s;
    nsp[i].second = make_pair(-p,i+1);
  }

  sort(nsp.begin(),nsp.end());

  for(int i=0;i<n;i++){
    cout << nsp[i].second.second << endl;
  }
}


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

int main(){
	int a,b,c;
	cin >> a >> b >>c;
	int l = 0;
for(int t = a; t<=b; t++){
		if(c % t == 0){
		    l++;
		    }		
    
}
	
	cout << l << endl;
	return 0;
}



Measured memory_bytes: 3112
list = []
count1 = 0
count2 = 0
count3 = 0

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

if k % 2 != 0
    for i in 1..n do
        if i % k == 0
            count1 += 1
        end
    end
    p count1 ** 3
else
    for i in 1..n do
        if i % k == 0
            count2 += 1
        end
        if i % k == k/2
            count3 += 1
        end
    end
    p count2 ** 3 + count3 ** 3
end


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

int main()
{
    int n;
    long sum = 0;
    cin >> n;
    vector<int> a(n+1),b(n);
    for(int i=0;i<=n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }

    if(b[n-1] >= a[n]){
        sum = a[n];
        b[n-1] = b[n-1] - a[n];
    }
    else{
        sum = b[n-1];
        b[n-1] = 0;
    }

    

    for(int i=n-1;i>0;i--){
        if(b[i]+b[i-1] >= a[i]){
            sum = sum + a[i];
            b[i-1] = b[i-1] - max(a[i]-b[i],0);
            b[i] = max(b[i]-a[i],0);
        }
        else{
            sum = sum + b[i] + b[i-1];
            b[i-1] = 0;
            b[i] = 0;
        }
    }
    
    if(b[0]>= a[0]){
        sum = sum + a[0];
    }
    else{
        sum = sum + b[0];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  int res = 0;
  cin >> s;

  if (s.size() % 2) {
    char c = s[s.size() / 2];
    if (c == '(' || c == ')')
      res++;
  }
  for (int i = 0; i < s.size() / 2; i++)
    if (s[i] == '(') {
      if (s[s.size()-1-i] != ')')
        res++;
    } else if (s[i] == ')') {
      if (s[s.size()-1-i] != '(')
        res++;

    } else if (s[i] == 'i') {
      if (s[s.size()-1-i] != 'i')
        res++;
    } else if (s[i] == 'w') {
      if (s[s.size()-1-i] != 'w')
        res++;
    }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1180
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))

template <typename T>
void FILL_(void* ptr, size_t size, T value) {
  std::fill((T*)ptr, (T*)ptr + size, value);
}

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

int main() {
  std::ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<char> ret;

  while(n != 0)
  {
    n--;
    ret.push_back('a' + (n % 26));
    n /= 26;
  }

  for(int i=0;i<ret.size();++i)
  {
    cout << ret[ret.size() - i - 1];
  }
  cout << endl;
}

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

using namespace std;

int main()
{
    int64_t x, n, a, k = 0;
    cin >> x >> n;
    map <int64_t, int64_t> m;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        m[a]++;
    }
    while (true) {
        if (m[x - k] == 0) {
            cout << x - k;
            return 0;
        }
        if (m[x + k] == 0) {
            cout << x + k;
            return 0;
        }
        k++;
    }
    return 0;
}


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

int main() {

	int A, B, C;

	cin >> A;
	cin >> B;
	cin >> C;

	if(A == B && B == C && C == A){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main(){
int N, A, B; cin >> N >> A >> B;

int ans = 0;
for (int n = 1; n <= N; n++) {
    string S = to_string(n);
    int s = 0;
    for (int i = 0; i < S.size(); i++) {
        int tmp = S[i] - '0';
        s += tmp;
    }
    if (s >= A && s <= B) {
        ans += n;
    }
}

cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long sum[200500],a[200500];
bool can(long long x,long long y,int id)
{
	if (abs((x+a[id])-(y-a[id]))<abs(x-y)) return 1;
	else return 0;
}

long long Max(long long u,long long v,long long x,long long y)
{
	return max(max(x,y),max(u,v));
}

long long Min(long long u,long long v,long long x,long long y)
{
	return min(min(x,y),min(u,v));
}

int main()
{
	int n,i;
	scanf("%d",&n);
	sum[0]=0;
	for (i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	int j=1,k=3;
	long long ans=2100000000;
	for (i=2;i<n-1;i++)
	{
		long long p=sum[j],
		          q=sum[i]-sum[j],
		          r=sum[k]-sum[i],
		          s=sum[n]-sum[k];
		while ((can(p,q,j+1)) && (j+1<i))
		    {j++;p=sum[j];q=sum[i]-sum[j];}
		while ((can(r,s,k+1)) && (k+1<n))
		    {k++;r=sum[k]-sum[i];s=sum[n]-sum[k];}
		long long x=Max(p,q,r,s),y=Min(p,q,r,s),z=x-y;
		ans=min(ans,z);
	} 
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 3328
import itertools
from collections import defaultdict
import collections
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

n, k = map(int, input().split())
a = list(map(int, input().split()))

tf = [False] * (n + 1)
tf[1] = True
ss = [1]
cnt = 0
while cnt < max(k,n ** 2):
    if len(ss) != 1 and tf[a[ss[cnt] - 1]]:
        d = a[ss[cnt] - 1]
        break
    tf[a[ss[cnt] - 1]] = True
    ss.append(a[ss[cnt] - 1])
    cnt += 1

if len(ss) > k:
    print(ss[k])
else:
    sss = ss.index(d)
    print(ss[sss+(k -len(ss)) % (len(ss) - sss)])
    # print(ss.index(d))
    # print(ss[k % (len(ss) - ss.index(d))])

Measured memory_bytes: 33912
// 解説後
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

template <typename T>
struct Vector2 {
  Vector2& operator+=(const Vector2& other) noexcept {
    x += other.x;
    y += other.y;
    return *this;
  }

  friend Vector2 operator+(Vector2 lhs, Vector2 rhs) noexcept {
    return Vector2(lhs) += rhs;
  }

  template<typename U>
  auto dot(Vector2<U> rhs) const noexcept {
    return x * rhs.x + y * rhs.y;
  }

  auto norm2() const noexcept { return dot(*this); }

  auto norm() const noexcept { return sqrt(norm2()); }

  T x, y;
};

// L^2ノルムを最大化したいので、方向が同じベクトルを集める
int solve_F() {
  size_t N;
  std::cin >> N;

  std::vector<Vector2<double>> directions(36000);
  for (size_t i = 0; i < directions.size(); ++i) {
    const double angle = 3.14159265358979 * 2 * i / directions.size();
    directions[i].x = cos(angle);
    directions[i].y = sin(angle);
  }


  std::vector<Vector2<int64_t>> summations(directions.size());
  for (size_t i = 0; i < N; ++i) {
    Vector2<int64_t> v;
    std::cin >> v.x >> v.y;

    for (size_t j = 0; j < directions.size(); ++j) {
      if (directions[j].dot(v) >= 0.0) {
        summations[j] += v;
      }
    }
  }

  double result = 0.0;
  for (const auto& v : summations) {
    result = std::max(result, v.norm());
  }

  std::cout << std::setprecision(20) << result;
  return 0;
}

int main() { return solve_F(); }


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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define show(x) cout<<(x)<<endl
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/
set<int> m;
map<ul,ul> f;
ul a[200001];
ul n,ans;
int main() {
	FAST;
	cin>>n;
	REP(i,0,n) cin>>a[i];
	sort(a,a+n);
	REP(i,0,n) {
		if(!f.count(a[i])) f[a[i]] = 0;
		f[a[i]]++;
	}
	ans=0;
	REP(i,0,n) {
		if(!m.count(a[i]) and f[a[i]]==1)
			ans++;
		for(ul j = a[i]; j <= a[n-1]; j+=a[i])
			m.insert(j);
	}
	show(ans);
	return 0;
}


Measured memory_bytes: 61268
#include <bits/stdc++.h>
using namespace std;
int A(int a){
    if(a<=1)return 1;
    else return a*A(a-1);
}
int main(void){
    int n,a=0;
    double ans=0.0;
    cin>>n;
    int x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    for(int i=0;i<=n-2;i++){
        a+=2*A(n-2);
    }
    ans=ans*a/A(n);
    printf("%6f\n",ans);
}

Measured memory_bytes: 384
import math
MOD = 10 ** 9 + 7
H, W, A, B = map(int, input().split())
maxf = H + W

f, invf = [1] * maxf, [1] * maxf

for i in range(1, maxf):
    f[i] = i * f[i - 1] % MOD
invf[maxf - 1] = pow(f[maxf - 1], MOD - 2, MOD)
for i in range(maxf - 1, 0, -1):
    invf[i - 1] = invf[i] * i % MOD

comb = lambda a, b: f[a + b] * invf[a] * invf[b] % MOD

ans = 0
for x in range(B, W):
    ans += comb(x, H - A - 1) * comb(W - 1 - x, A - 1) % MOD
print(ans % MOD)

Measured memory_bytes: 18804