akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62592
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int h,w,k,ans = 0;
int m[110][9] = {0};


signed main(){

    cin >> h >> w >> k;
    m[1][1] = 1;

    if(w == 1){
        cout << 1 <<endl;
        return 0;
    }

    int cnt_l[9][9] = {0};
    for(int i = 1;i <= w;i++){
        for(int j = 1;j <= w;j++){
            for(int bit = 0;bit < (1<<(w-1));bit++){
                if(abs(i-j) == 1 && bit&(1<<(min(i,j)-1))){
                    int c = 1;
                    for(int k = 0;k<=w-3;k++){
                        if(bit&(1<<k) && bit&(1<<(k+1))){
                            c = 0;
                        }
                    }
                    if(c == 1)cnt_l[i][j]++;
                }else if(i == j){
                    int c = 1;
                    if(i != 1 && bit&(1<<(i-2))) c = 0;
                    if(i != w && bit&(1<<(i-1))) c = 0;
                    for(int k = 0;k<=w-3;k++){
                        if(bit&(1<<k) && bit&(1<<(k+1))){
                            c = 0;
                        }
                    }
                    if(c == 1)cnt_l[i][j]++;
                }
            }
        }
    }
    if(w == 1){
        cnt_l[1][1] = cnt_l[1][2] = cnt_l[2][1] = cnt_l[2][2] = 1;
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1;j<=w;j++){
            if(m[i][j] != 0){
                m[i][j] %= MOD;
                if(j == 1) {
                    m[i+1][j] += (m[i][j]*cnt_l[j][j])%MOD;
                    m[i+1][j+1] += (m[i][j]*cnt_l[j][j+1])%MOD;
                }else if(j == w){
                    m[i+1][j] += (m[i][j]*cnt_l[j][j])%MOD;
                    m[i+1][j-1] += (m[i][j]*cnt_l[j][j-1])%MOD;
                }else{
                    m[i+1][j] += (m[i][j]*cnt_l[j][j])%MOD;
                    m[i+1][j-1] += (m[i][j]*cnt_l[j][j-1])%MOD;
                    m[i+1][j+1] += (m[i][j]*cnt_l[j][j+1])%MOD;
                }
            }
        }
    }
    

    cout << m[h+1][k]%MOD <<endl;

    // rep(i,w){
    //     rep(j,w){
    //         cerr << cnt_l[i+1][j+1] << " ";
    //     }
    //     cerr << endl;
    // }

    

    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,k;
	int tens[5]={1,10,100,1000,10000};
	int ones[5]={0,1,11,111,1111};
	int d[10]={0};
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int piyo;
		cin>>piyo;
		d[piyo]=-1;
	}
	int ans=0;
	int maxnum;
	for(int i=9;i>0;i--){
		if(d[i]==0){maxnum=i;break;}
	}
	for(int i=4;i>=0;i--){
		int target=0;
		while(ans+target*tens[i]+maxnum*ones[i]<n  or d[target]!=0){
			if(ans==0 and target==0 and ans+target*tens[i]+maxnum*ones[i]>=n){break;}
			else{target++;}
		}
		ans+=target*tens[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(n) for (int i = 0; i < int(n); i++)
#define FOR1(m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[])
{
  int N;

  cin >> N;

  int ans = 0;
  for (int i = 1; i <= N; i+= 2) {
    int count = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0)
        count++;
    }
    if (count == 8)
      ans++;
  }

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


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] H = new int[N];
		int max = 0;
		boolean flag = true;
		
		for(int i = 0; i < N; i++) {
			H[i] = stdIn.nextInt();
			if(max < H[i]) max = H[i];
			if(max-H[i] > 1) flag = false;
		}
		
		if(flag) System.out.println("Yes");
		else System.out.println("No");

	}

}

Measured memory_bytes: 51708
import heapq

n, m = map(int, input().split())
jobs = dict()

for i in range(n):
    a, b = map(int, input().split())
    if not a in jobs.keys():
        jobs[a] = [-b]
    else:
        jobs[a].append(-b)
# print(jobs)
sum_money = 0
money_list = [0]
heapq.heapify(money_list)
for i in range(1, m+1):
    if i in jobs.keys():
        for money in jobs[i]:
            heapq.heappush(money_list, money)
    # print(money_list)
    max_money = -heapq.heappop(money_list)
    sum_money += max_money
    if max_money == 0:
        heapq.heappush(money_list, 0)
print(sum_money)


Measured memory_bytes: 26104
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t countDivisors(const size_t n)
{
	size_t count = 1;

	for (size_t i = 2; i <= n; i++) {
		if (n%i == 0) {
			count++;
		}
	}

	return count;
}

int main(void) {
	size_t N;

	scanf("%zu", &N);

	bool found = false;

	for (size_t numCakes = 0; numCakes <= N / 4; numCakes++) {
		if ((N - 4 * numCakes) % 7 == 0) {
			found = true;
			break;
		}
	}

	puts((found ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>

using namespace std;

void init(int *m) {
    m[1] = 0;
    m[2] = 1;
    for (int i = 3; i <= 1000000; i += 2)
        m[i] = 1;

    for (int i = 3; i <= 1000; i += 2) {
        if (m[i] == 0)
            continue;
        for (int j = 2; i * j <= 1000000; j++)
            m[i * j] = 0;
    }

    for (int i = 3; i <= 1000000; i++)
        m[i] += m[i-1];
}

int main() {

    #if 0
        ifstream cin("34870.in");
    #endif

    int *memo = new int[1000001];
    init(memo);

    int n;
    while (cin >> n) {
        cout << memo[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 5084
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
char c;
int a,b;
int main(){
	for(int i=1;i<=3;i++)
	{
		cin>>c;
		if(c=='A')
			a++;
		else
			b++;
	}
	if(a&&b)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int a,c,d;
    scanf("%d",&a);
    c=0;
    for(int i=0;i<a;i++){
        scanf("%d",&d);
        if(i%2==0&&d%2==1)
        c++;
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=302;

bool played[MAX_N];
queue<int> que[MAX_N];
int cnt[MAX_N];

int main(){
  int N,M,a;
  cin >> N >> M ;
  rep(i,N) rep(j,M){
    scanf("%d",&a);
    que[i].push(a-1);
  }
  if(M==1){
    cout << N << endl;
    return 0;
  }
  fill(played,played+M,true);
  int ans=INF;
  rep(i,M-1){
    fill(cnt,cnt+M,0);
    rep(j,N) cnt[que[j].front()]++;
    int _max=0,_maxj=-1;
    rep(j,M){
      if(cnt[j]>_max){
        _max=cnt[j];
        _maxj=j;
      }
    }
    ans=min(ans,_max);
    played[_maxj]=false;
    //掃除
    rep(j,N){
      while(!played[que[j].front()]) que[j].pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;

signed main() {
    int h,w;
    int m;
    cin >> h >> w >> m;
    vector<int> a(h);
    vector<int> b(w);
    int maxa = 0;
    int maxb = 0;
    vector<pair<int,int>> p(m);
    rep(i,m) {
        int x,y;
        cin >> x >> y;
        x--; y--;
        a[x]++;
        b[y]++;
        p[i]={x,y};
        maxa = max(maxa,a[x]);
        maxb = max(maxb,b[y]);
    }
    int tmp = 0;
    rep(i,h) if(a[i]==maxa) tmp++;
    int tmp2 = 0;
    rep(i,w) if(b[i]==maxb) tmp2++;
    int now = tmp*tmp2;
    int cnt = 0;
    rep(i,m) {
        int x,y;
        x = p[i].first;
        y = p[i].second;
        if(a[x]==maxa && b[y]==maxb)cnt++;
    }    
    if(now>cnt) cout << maxa+maxb << endl;
    else cout << maxa+maxb-1 << endl;
    
    return 0;
}



Measured memory_bytes: 12740
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

int main()
{
  int A,B,N;
  cin >> A >> B >> N;
  cout << N/A*B;
}


Measured memory_bytes: 256
n,d = map(int, input().split())
x = []
y = []
for i in range(n):
    a,b = map(int, input().split())
    x.append(a)
    y.append(b)
count = 0
for i in range(n):
    if (x[i]**2 + y[i]**2)**(1/ 2) <= d:
        count += 1
print(count)

Measured memory_bytes: 24852
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T &a, T b) { return a < b ? (a = b, 1) : 0; }

int main() {
    int n; cin >> n;
    long long c; cin >> c;
    vector<long long> x(n), v(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> v[i];
    long long ma = 0;
    for (int _ = 0; _ < 2; _++) {
        vector<long long> acc(n + 1);
        for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + v[i];
        for (int i = 0; i < n; i++) chmax(ma, acc[i + 1] - x[i]);
        auto calc = [&](int i) {
            return acc[n] - acc[i] - (c - x[i]) * 2;
        };
        long long rt = calc(n - 1);
        for (int i = n - 2; i >= 0; i--) {
            chmax(ma, rt + acc[i + 1] - acc[0] - x[i]);
            chmax(rt, calc(i));
        }
        for (int i = 0; i < n; i++) x[i] = c - x[i];
        reverse(begin(x), end(x));
        reverse(begin(v), end(v));
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 2560
k = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).reverse


min = 2
max = 2
f = true

a.each do |x|
  n_min = (min + x - 1) / x * x
  n_max = max / x * x + (x - 1)

  v_min = n_min / x * x
  v_max = n_max / x * x

  if v_min >= min && v_min <= max && v_max >= min && v_max <= max
    min = n_min
    max = n_max
  else
    f = false
  end
  # puts "#{x} #{min} #{max}"
end

if f
  puts "#{min} #{max}"
else
  puts -1
end


Measured memory_bytes: 10500
a=input().split(" ")
a1,a2,a3=int(a[0]),int(a[1]),int(a[2])
ans="No"
if a1!=a2 and (a1==a3 or a2==a3):
  ans="Yes"
if a1!=a3 and (a1==a2 or a2==a3):
  ans="Yes"
if a2!=a3 and (a1==a2 or a1==a3):
  ans="Yes"
  
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N,M;
  cin >> N >> M;
  int64_t K;
  cin >> K;
  vector<int64_t> A(N+1,0);
  vector<int64_t> B(M+1,0);
  int64_t sum = 0;
  for (int i = 1; i < N + 1; i++) {
    int64_t a;
    cin >> a;
    sum += a;
    A[i] = sum;
  }
  sum = 0;
  for (int i = 1; i < M + 1; i++) {
    int64_t b;
    cin >> b;
    sum += b;
    B[i] = sum;
  }

  int32_t max_book = 0;
  for (int i = N; i >=0; i--) {
    int32_t cur_book = i;
    int64_t time_left = K - A[i];
    if (time_left < 0) {
      continue;
    }
    auto it = upper_bound(B.begin(), B.end(), time_left);
    //if (it == B.end()) continue;
    cur_book += it - B.begin() - 1;
    max_book = max(max_book, cur_book);
    //cout << i << "," << time_left << "," << it - B.begin() - 1 << endl;
  }
  cout << max_book << endl;



  
  return 0;
}


Measured memory_bytes: 6364
def divisors(n):
    x = set()
    m = 1
    while m * m <= n:
        if n % m == 0:
            x.add(m)
            x.add(n // m)
        m += 1
    return x

n = int(input())
d = divisors(n)
ans = 0
for k in d:
    if k == 1:
        continue
    nn = n
    while nn % k == 0:
        nn = nn // k
    ans += nn % k == 1

d1 = divisors(n - 1)
ans += len(d1) - 1
print(ans)


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b);
    return 0;
}

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

int main(){
    int m,f,r,s[4]= {}; //{中間,期末,合計,再試}
    while(1){
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        else {
            if (m == -1){
                s[0] = -1;
                cout << "F" << '\n';
            }
            else if (f == -1){
                s[1] = -1;
                cout << "F" << '\n';
            }
            else{//全て試験受けた
                s[0] = m;
                s[1] = f;
                s[2] = m + f;
                if (r == -1){//再試受けない
                    s[3] = -1;
                    if ( s[2] >= 80){
                        cout << "A" << '\n';
                    }
                    else if ( 65 <= s[2] && s[2] < 80){
                        cout << "B"  << '\n';
                    }
                    else if ( 50 <= s[2] && s[2] < 65){
                        cout << "C" << '\n';
                    }
                    else if ( 30 <= s[2] && s[2] < 50){
                        cout << "D" << '\n';
                    }
                    else if ( s[2] < 30){
                        cout << "F" << '\n';
                    }
                }
                else{//再試受けた
                    s[3] = r;
                    if ( s[2] >= 80){
                        cout << "A" << '\n';
                    }
                    else if ( 65 <= s[2] && s[2] < 80){
                        cout << "B"  << '\n';
                    }
                    else if ( 50 <= s[2] && s[2] < 65){
                        cout << "C" << '\n';
                    }
                    else if ( 30 <= s[2] && s[2] < 50 && s[3] >=50 ){
                        cout << "C" << '\n';
                    }
                    else if (30 <= s[2] && s[2] < 50 && s[3] < 50){
                        cout << "D" << '\n';
                    }
                    else if ( s[2] < 30){
                        cout << "F" << '\n';
                    }

                }
            }
        }
        
    }
}



Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  
   string n;
   cin >> n;
  
  int ans = 0;
  
  for(int i = 0;i<3;i++){
    
    if(n[i]=='1'){
      ans += 1;
    }
     
  }
  
   cout << ans << endl;
 
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner in = new Scanner(System.in);
		final int a = in.nextInt(), b = in.nextInt();
		if (isDivisor(a, b)) {
			System.out.println(a + b);
		} else {
			System.out.println(b - a);
		}

	}

	public static boolean isDivisor(int a, int b) {
		if (b % a == 0) return true;
		else return false;
	}
}


Measured memory_bytes: 21844
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n,k,x,ans=0;
  	cin>>n>>k;
  	for(int i=0;i<n;i++)
    {
      cin>>x;
      ans+=(x>=k);
    }
  	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define SZ(a) ll((a).size())
#define REP(i, n) for (decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const ll INF = 1e18;
const ll mod = 1e9 + 7;

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  ll n, m;
  ll ans = 0;

  cin >> n >> m;
  ans = n * max(n - 1, 0LL) / 2 + m * max(m - 1, 0LL) / 2;

  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int a[7],b[7];
  for(int i=0;i<7;i++){
    scanf("%d %d",&a[i],&b[i]);
    printf("%d\n",a[i]-b[i]);
  }
 
  return 0;
}



Measured memory_bytes: 3220
n=int(input())
s=input()

e=[1 if c=='E' else 0 for c in s]
w=[1 if c=='W' else 0 for c in s]

for i in range(1,n):
  e[i] += e[i-1]
  w[i] += w[i-1]

m=e[n-1]-e[0]
for i in range(1,n):
  m=min(m,w[i-1]+e[n-1]-e[i])

print(m)


Measured memory_bytes: 27296
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct bridge {
	int from;
	int to;
	int cost;
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const bridge&l, const bridge &r) {
		return l.cost> r.cost;
	}
};
int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<pair<int,int>>hs;
		for (int i = 0; i < N; ++i) {
			int h; cin >> h;
			hs.emplace_back(h, i);
		}
		vector<vector<bridge>>bs(N);
		sort(hs.begin(), hs.end());
		for (int i = 0; i < M; ++i) {
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			bs[a].push_back(bridge{ a,b,c });
			bs[b].push_back(bridge{ b,a,c });
		}
		vector<vector<int>>sinks;
		{
			int now = hs[0].first;
			vector<int>vs(1, hs[0].second);
			for (int i = 1; i < hs.size(); ++i) {
				if (hs[i].first == now) {
					vs.push_back(hs[i].second);
				}
				else {
					sinks.push_back(vs);
					vs.clear();
					vs.push_back(hs[i].second);
					now = hs[i].first;
				}
			}
			sinks.push_back(vs);
		}
		reverse(sinks.begin(), sinks.end());
		for (int from = 0; from <= sinks.size(); ++from) {
			if (from == sinks.size()) {
				cout << 0 << endl;
				break;
			}
			bool ok = true;
			int costsum = 0;
			vector<int>status(N);

			bool isfast = true;
			for (int time = from; time < sinks.size(); ++time) {
				priority_queue <bridge, vector<bridge>,Compare>que;
				vector<int>waits;

				for (int i = 0; i <= time; ++i) {
					if (!isfast)i = time;
					for (auto island : sinks[i]) {
						waits.push_back(island);
					}
				}
				
				for (int i = 0; i < waits.size(); ++i) {
					for (auto b : bs[waits[i]]) {
						if(isfast){
							if (find(waits.begin(), waits.end(), b.to) != waits.end()) {
								que.push(b);
							}
						}
						else {
							if (status[b.to]) {
								que.push(b);
							}
						}
					}
				}
				if (que.empty()) {
					ok = false;
					break;
				}
				if(isfast){
					bridge atop(que.top());
					que.pop();
					status[atop.from] = 1;
					status[atop.to] = 1;
					waits.erase(find(waits.begin(), waits.end(), atop.from));
					waits.erase(find(waits.begin(), waits.end(), atop.to));
					costsum += atop.cost;
				}
				while (!waits.empty() && !que.empty()) {
					bridge atop(que.top());
					que.pop();
					if (status[atop.from] == 0 && status[atop.to] == 1) {
						status[atop.from] = 1;
						waits.erase(find(waits.begin(), waits.end(), atop.from));
						for (auto b : bs[atop.from]) {
							if (find(waits.begin(), waits.end(), b.to) != waits.end()) {
								que.push(bridge{ b.to,b.from,b.cost });
							}
						}
						costsum += atop.cost;
					}
				}
				if (!waits.empty()) {
					ok = false;
					break;
				}
				isfast = false;
			}
			if (!ok)continue;
			else {
				cout << costsum << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5132
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-29 11:35:01
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int dp[1000000 + 5][2];
constexpr int inf = (int)1e9;

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

  string s; cin >> s;
  s = '0' + s;
  fill(dp[0], dp[1000000 + 5], inf);
  dp[0][0] = 0;

  debug(s);
  
  int n = s.size();

  for (int i = 0; i < n; ++i) {
    dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + s[i] - '0');
    dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + s[i] - '0' + 1);
    dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 10 - (s[i] - '0'));
    dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 9 - (s[i] - '0'));
  }

  cout << dp[n][0] << endl;

  return 0;
}

Measured memory_bytes: 9160
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	string s;
	cin >> s;
	int res = 0;
	REP(i, s.size()-1){
		if(s[i] != s[i+1]){
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n;
  string x;
  double u, b = 0, ub = 0;
  cin >> n;
  rep(i,n)
  {
    cin >> u >> x;
    if (x[0] == 'J') {
      b += u;
    } else {
      ub += u;
    }
  }
  ub *= 380000;
  ub += b;
  printf("%.6lf\n", ub);
  return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $b = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  for($i=0; $i<$n-2;$i++){
    $ans += min($b[$i], $b[$i+1]);
  }

  $ans += $b[0];
  $ans += $b[$n-2];

  echo $ans;

Measured memory_bytes: 4984
from operator import itemgetter
N = int(input())
A = [ int(i) for i in input().split(" ") ]
Z =[]
for i in range(1, N+1):
    Z.append([i, A[i-1]])
Z.sort(key=itemgetter(1))
for i in range(0,N):
    print(Z[i][0],end=" ")


Measured memory_bytes: 22656
require 'bigdecimal'
require 'bigdecimal/util'
input = Array.new(6)
time = 0
min = 1000000000000000000
6.times do | i |
    input[i] = gets.chomp.to_d

    if i != 0 && min > input[i] then
        min = input[i]
    end
end
cnt = (input[0] / min).ceil
cnt += 4

puts cnt



Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		mp[A[i]]++;
	}
	for (auto m : mp) {
		if (m.first <= m.second) {
			res += m.second - m.first;
		}
		else {
			res += m.second;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
   int n ;
   cin >> n ;
    vector < pair < int , int > > a(n) ;
    for( int i = 0 ; i < n ; i++){
        cin >> a[i].ff ;
        a[i].ss = i+1;
    }
    sort(a.begin(),a.end());
    for( int i = 0 ; i < n ; i++) cout << a[i].ss << " " ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
   //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


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

#define ll long long
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define x first
#define y second
const int INF=1e6+1;

bool isp[INF];

int main(){
	ll n;
	cin>>n;
	vector<ll> pr;
	for (int i=2; i<INF; i++){
		if (!isp[i]) pr.pb(i);
		for (int j=i+i; j<INF; j+=i)
			isp[j]=1;
	}
	ll ans=0;
	ll t=n;
	for (int i=0; i<pr.size(); i++){
		ll cnt=0;
		while(t%pr[i]==0){
			t/=pr[i];
			cnt++;
		}
		ll cur=1,ret=0;
		while (cnt>=cur){
			cnt-=cur;
			ret++;
			cur++;
		}
		ans+=ret;
	}
	if (t>1) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5296
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll mygcd(ll a, ll b) {
	return a % b == 0 ? b : mygcd(b, a % b);
}
signed main()
{
	ll n = in();
	ll ans = in();
	REP(i, n - 1) {
		ll foo; scanf("%d", &foo);
		ans = mygcd(ans, foo);
	}
	cout << ans << endl;
}

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

int main(void) {
    int64_t A,B;
    char op;
    cin >> A >> op >> B;
    if(op == '+') {
        cout << A + B;
    } else {
        cout << A - B;
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = list(map(int, input().split()))
l = [0] * 4
l[0] = x_2 - (y_2 - y_1)
l[1] = y_2 + (x_2 - x_1)
l[2] = l[0] - (x_2 - x_1)
l[3] = l[1] - (y_2 - y_1)
for i in range(4):
    print(l[i], end=' ')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	char c = s[0];
	int t = 0;
	for(int i=1; i<n; i++) {
		if (s[i] != c) {
			t++;
			c = s[i];
		} else ans++; 
	}
	t++;
	int m = min(k, t/2);
	ans += min(t-1, 2*m);
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
struct UnionFind {
  int *data;
  UnionFind(int *_data, int size, bool reset = true) : data(_data) {
    if(reset) for(int i = 0; i < size; i++) data[i] = -1;
  }
  bool unionSet(int x, int y) {
    x = find(x); y = find(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
};
int main(int argc, char *argv[])
{
  // kruskal with x being unused.
  // assumption: es is sorted
  auto kruskal = [](int n, const vector<pair<int,pair<int,int>>> &es, int *ufdata, int st, vector<bool> &used) {
    UnionFind uf(ufdata, n, false);
    int sum = 0;
    for(int i = st; i < es.size(); i++) {
      const int u = es[i].second.first;
      const int v = es[i].second.second;
      if(uf.find(u) != uf.find(v)) {
        used[i] = true;
        uf.unionSet(u, v);
        sum += es[i].first;
      }
    }
    return sum;
  };
  int n, m;
  vector<pair<int,pair<int,int>>> es;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int s, d, c;
    cin >> s >> d >> c;
    es.push_back(make_pair(c, make_pair(s-1, d-1)));
  }
  sort(es.begin(), es.end());
  int mn = -1;
  int sum = 0;
  int cnt = 0;
  vector<int> ufdata(n);
  vector<bool> used(m, false);
  vector<bool> used2(m, false);
  UnionFind uf(&(ufdata[0]), n);
  {
    vector<int> ufdata2(n);
    for(int j = 0; j < n; j++) ufdata2[j] = ufdata[j];
    mn = kruskal(n, es, &(ufdata2[0]), 0, used);
  }
  int ksum = 0;
  for(int i = 0; i < m; i++) {
    vector<int> ufdata2(n);
    for(int j = 0; j < n; j++) ufdata2[j] = ufdata[j];
    if(used[i]) {
      int mni = ksum + kruskal(n, es, &(ufdata2[0]), i+1, used2);
      if(mni != mn) {
        cnt ++;
        sum += es[i].first;
      }
    }
    const int u = es[i].second.first;
    const int v = es[i].second.second;
    if(uf.find(u) != uf.find(v)) {
      uf.unionSet(u, v);
      ksum += es[i].first;
    }
  }
  cout << cnt << " " << sum << endl;
  return 0;
}




Measured memory_bytes: 3816
from collections import Counter


from operator import mul
from functools import reduce


def cmbf(n, r):
    if (n < r):
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = int(input())
A = list(map(int, input().split()))
c = [0]*(N+1)

for A_i in A:
    c[A_i] += 1

gsum = 0
for i in range(1, N + 1):
    if (c[i] != 0):
        gsum += cmbf(c[i], 2)

for i in A:
    print(gsum-(c[i]-1))



Measured memory_bytes: 26900
#ABC 087 C Candies

#どのタイミングで下にいくかっていうだけ

n = int(input())
#a = [input().split() for l in range(2)]
#print(a)
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a = []
a.append(a1)
a.append(a2)
#print(a)

ame = 0
ame_list=[]

for i in range(n):#iは1行目での右移動回数を示す
    for j in range(i+1):
        ame += a[0][j]
    for k in range(i,n):
        ame += a[1][k]
    ame_list.append(ame)
    ame = 0
print(max(ame_list))


Measured memory_bytes: 3064
#!/usr/bin/env python3

n = input()
line = input()
res = 1
data = []
for x in line.split(' '):
    data.append(int(x))
    if int(x) == 0:
        res = 0
for x in data:
    res = res * int(x)
    if pow(10, 18) < res:
        res = -1
        break
print(res)


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

int main(){
    int n,k;
    cin >> n >> k;
    double num[n+1];
    for(int i = 1; i < n+1; i++){
        int x = i;
        int count = 0;
        while(x < k){
            x = x * 2;
            count++;
        }
        num[i] = count;
    }
    double sum = 0;
    double y = n;
    for(int i = 1; i < n+1; i++){
        sum += double(1 / y) * double(1 / pow(2,num[i])); 
    }
    cout << fixed << setprecision(11) << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b;
cin>>a>>b;
ll cnt=0;
for(int i=a;i<=b;i++){
    string tmp=to_string(i);
    if(tmp.at(0)==tmp.at(4)&&tmp.at(1)==tmp.at(3)){
        cnt++;
    }
}
cout<<cnt<<endl;
}












Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])
    s = lines[1]

    return (n, s)


def solve(n, s):

    result = 'No'
    if n % 2 != 0:
        return result
    
    m = n // 2

    a = s[:m]
    b = s[m:]
    
    if a == b:
        result = 'Yes'
        

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	ll X,Y;
	cin >> X>>Y;
	cout << bitset<32>(X&Y) << endl;
	cout << bitset<32>(X | Y) << endl;
	cout << bitset<32>(X^Y) << endl;
	return 0;
}


Measured memory_bytes: 3160
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	K,N = MI()
	A = np.array(LI())
	A_LAST = K+A[0] - A[N-1]
	B = A[1:]-A[:N-1]
	B = np.sort(B)
	print(K-max(B[N-2],A_LAST))

if __name__ == '__main__':
	main()

Measured memory_bytes: 40120
# ABC077 A - Rotation
S1 = input()
S2 = input()

s1 = S1[0:1]
s2 = S1[1:2]
s3 = S1[2:3]
s4 = S2[0:1]
s5 = S2[1:2]
s6 = S2[2:3]

if s1==s6 and s2==s5 and s3==s4:
    print('YES')
else:
    print('NO')

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int A, B, C; cin >> A >> B >> C;
  int K; cin >> K; bool flag = false;
  REP(i, K) {
    if(A < B) flag = true;
    if(flag == false) {
      B *= 2;
    } else if(flag == true) {
      C *= 2;
    }
  }

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll K;
  ll X;
  IN(K,X);
  FOR(x,X-(K-1),X+K){
    printf("%lld ", x);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int H,W,K,dp[110][10],s[10][3];
signed main(){
  cin>>H>>W>>K;
  for(int bit=0;bit<(1<<(W-1));bit++){
    bool b=false;
    for(int i=0;i<W-2;i++)
      if((bit>>i)&1&(bit>>(i+1)))b=true;
    if(b)continue;
    for(int i=0;i<W;i++){
      if(i!=0 && ((bit>>(i-1))&1))s[i][0]++;
      else if(i!=W-1 && ((bit>>i)&1))s[i][2]++;
      else s[i][1]++;
    }
  }
  dp[0][0]=1;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      for(int k=0;k<3;k++)
        if(0<=j+k-1 && j+k-1<W)dp[i+1][j+k-1]=(dp[i+1][j+k-1]+dp[i][j]*s[j][k]%mod)%mod;
  cout<<dp[H][K-1]<<endl;
}

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

using namespace std;

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

    if(A*N <= B)
    {
        cout << A*N << endl;
    }
    else
    {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256