akhauriyash/Code-Regression huggingface dataset:
// 参考 https://atcoder.jp/contests/abc134/submissions/6479320
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

long N, M;
vector<int> A, B;

void solve();
long get_sum_of_multipler(long i);
void print_ans();
void test();

int main() {
  cin >> N;
  // 1からNまでが入るようにする
  A.resize(N + 1);
  rep(i, N) { cin >> A[i + 1]; }
  // 回答も同じく1からNが入るようにする
  B.resize(N + 1);
  solve();
}

void solve() {
  // 大きい値から決めていく。Nから1まで
  for (long i = N; i >= 1; i--) {
    int sum = 0;
    // iの倍数（N以下）をすべて足して行く
    for (int j = i + i; j <= N; j += i) {
      // 値は1か0しかなくて、2で割ったときの余り(mod 2)がわかればいいので
      // ビット排他的論理和 XORを使う
      sum ^= B[j];
    }
    B[i] = sum ^ A[i];
  }

  // Bに回答が入っているので表示のための処理をする
  vector<int> ans;
  for (int i = 1; i <= N; i++) {
    // Bには1か0しかはいっていない
    if (B[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  rep(i, ans.size()) {
    printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
  }
}


Measured memory_bytes: 3064
import math

a = []
min_v = 10
min_i = 0
for i in range(5):
    v = int(input())
    a.append(v)

    r = v % 10
    if r < min_v and r > 0:
        min_v = r
        min_i = i

res = 0
for i in range(5):
    if i == min_i:
        res += a[i]
    else:
        res += math.ceil(a[i]/10)*10
        
print(res)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
def is_correct(s):
    l = 0
    for si in s:
        if si == "(": l += 1
        else: l -= 1
        if l < 0: return False
    return l == 0

N = int(raw_input())
S = raw_input()

flag = False
for i in xrange(105):
    for j in xrange(105):
        T = "("*i + S + ")"*j
        if is_correct(T):
            print T
            flag = True
            break
    if flag:
        break



Measured memory_bytes: 2568
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
using namespace std;
int main(void){
    long n,d;
    int count;
    long x,y;
    count=0;
    cin >> n >> d;
  
    //printf("%d,%d",n,d);
    //scanf("%d","%d",&n,&d);
    d = d*d;
    //printf("%ld",d);
    for(int i=0; i<n; i++){
        cin >> x >> y;
        //scanf("%d","%d",&x,&y);
        //printf("%d\n",i);
        //printf("x=%ld,y=%ld\n",x,y);
        if(x*x+y*y <= d){
            //printf("%ld",x*x+y*y);
            //printf("true\n");
            count++;
        }
    }
    printf("%d",count);
}

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

using namespace std;

string ans[] = {"AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA",
                "AKIHABAR",  "KIHBARA",  "KIHABRA",  "KIHABAR",
                "AKIHBRA",   "AKIHBAR",  "AKIHABR",  "KIHBRA",
                "KIHBAR",    "KIHABR",   "AKIHBR",   "KIHBR"};

int main() {
  string s;
  cin >> s;
  for (const auto &ss : ans) {
    if (s == ss) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>

using namespace std;
typedef long long ll;

int main() {
	int N;
	ll K;
	int Q;
	cin >> N >> K >> Q;
	vector<int> A(Q);
	for (int i = 0; i < Q; i++) cin >> A[i];
	vector<ll> p(N+1, K-Q);
	for (int i = 0; i < Q; i++) {
		p[A[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		if (p[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


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

int main() {
  while(true) {
    int total1 = 0;
    int total2 = 0;
    cin >> total1;
    if(total1 == 0) break;
    for(int i = 0; i < 9; ++i) {
      int cost;
      cin >> cost;
      total2 += cost;
    }
    cout << total1 - total2 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
# 嘘解法なおそうとおもったけどなおらん。
N, K = map(int, input().split())
A = list(map(int, input().split()))

binary = [bin(a) for a in A]
bin_K = bin(K)
ma_len = max([len(e) for e in binary] + [len(bin_K)]) - 2
B = [e[2:].zfill(ma_len) for e in binary]
bin_K = bin_K[2:].zfill(ma_len)


def greedy(C):
    result = []
    s = 0
    for i in range(len(C) - 1):
        s += C[len(C) - i - 1]["score"] * \
            max(C[len(C) - i - 1]["1"], C[len(C) - i - 1]["0"])
        result.append(s)
    return list(reversed(result)) + [0]


C = []
for i in range(ma_len):
    c = {"0": 0, "1": 0}
    for j in range(N):
        c[B[j][i]] += 1
    c["score"] = 2**(ma_len - i - 1)
    C.append(c)

latter = greedy(C)
ans = 0
former = 0
for i in range(ma_len):
    if bin_K[i] == "1":
        ans = max(ans, former + C[i]["1"] * C[i]["score"] + latter[i])
        former += C[i]["score"] * C[i]["0"]
    else:
        former += C[i]["score"] * C[i]["1"]
# print(B)
# print(bin_K)
# print(latter)
# print(C)
# print(former)
# print(ans)

print(max(ans, former))


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

const int maxN=101000;

int n,X;
int P[maxN];

int main(){
	cin>>n>>X;
	for (int i=1;i<=n;i++) cin>>P[i];
	int g=abs(X-P[1]);
	for (int i=2;i<=n;i++) g=__gcd(g,abs(X-P[i]));
	cout<<g<<endl;return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,a,b,i;
  cin>>n>>m;
  vector<int> c(n);
  for (i=0;i<m;i++) {
    cin>>a>>b;
    c.at(a-1)++;
    c.at(b-1)++;
  }
  for (i=0;i<n;i++) {
    cout<<c.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	std::map<LL, LL>index;
	rep(i, N) index[A[i]] = i;

	LL ans = 0;
	std::sort(A.begin(), A.end());
	rep(i, N) if (index[A[i]] % 2 != i % 2) ++ans;

	out << ans / 2 << std::endl;
}


Measured memory_bytes: 7296
#include<stdio.h>
int main(void)
{
	int n,x,cnt[10],i;
	while(1){
		for(i=0;i<10;i++){
			cnt[i]=0;
		}
		scanf("%d",&n);
		if(n<1)break;
		for(i=0;i<n;i++){
			scanf("%d",&x);
			cnt[x]++;
		}
		if(cnt[0]>0){
			for(i=0;i<cnt[0];i++){
				printf("*");
				if(i==cnt[0]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[1]>0){
			for(i=0;i<cnt[1];i++){
				printf("*");
				if(i==cnt[1]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[2]>0){
			for(i=0;i<cnt[2];i++){
				printf("*");
				if(i==cnt[2]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[3]>0){
			for(i=0;i<cnt[3];i++){
					printf("*");
				if(i==cnt[3]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[4]>0){
			for(i=0;i<cnt[4];i++){
				printf("*");
				if(i==cnt[4]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[5]>0){
			for(i=0;i<cnt[5];i++){
				printf("*");
				if(i==cnt[5]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[6]>0){
			for(i=0;i<cnt[6];i++){
				printf("*");
				if(i==cnt[6]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[7]>0){
			for(i=0;i<cnt[7];i++){
				printf("*");
				if(i==cnt[7]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[8]>0){
			for(i=0;i<cnt[8];i++){
				printf("*");
				if(i==cnt[8]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[9]>0){
			for(i=0;i<cnt[9];i++){
				printf("*");
				if(i==cnt[9]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1000
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha

void alpha()
{	
	
	int k;
	cin>>k;

	queue<int> q;
	loop(i,1,10) q.push(i);
	int x;

	while(k--){
		if(k==0) {
			cout<<q.front();
			return;
		}

		x = q.front();
		q.pop();

		if(x%10!=0) q.push(10*x + x%10 - 1);
		q.push(10*x + x%10);
		if(x%10!=9) q.push(10*x + x%10 + 1);
	}


}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc)
{
    for (auto e : vc)
        cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc)
{
    for (auto vc : vvc)
    {
        for (auto e : vc)
            cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp)
{
    for (auto pT : vp)
        cout << pT.first << " " << pT.second << endl;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int target = i;
        int sum = 0;
        while (target > 0) {
            sum += target % 10;
            target /= 10;
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def pri(a):
    n = len(a)
    for i in range(n):
        if i != n - 1:
            print(a[i], end=' ')
        else:
            print(a[i], end='')
    print('')


def insertSort(a):
    n = len(a)
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v


a = list(input().split())
# print(a)
insertSort(a)
pri(a)



Measured memory_bytes: 5560
'use strict'

const main = (input) => {
    const N = parseInt(input.split(' ')[0])
    const K = parseInt(input.split(' ')[1])
    const L = N - 1
    console.log(K * Math.pow(K - 1, L))
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7496
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

//---------------------------------------------------
//a


#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

int main(void)
{
  LL n;
  LL a;
  int flag = 0;
  LL sum = 0;
  LL sumback = 0;
  scanf("%lld", &n );
  for (LL i = 0; i < n; i++) {
    scanf("%lld", &a);

    if (a == 0) {
      printf("0\n");
      return 0;
    }

    if (i != 0) {
      sumback = sum;
      sum *= a;
    }else{
      sum = a;
      sumback = sum;
    }

    if (sum > 1000000000000000000 || sum < 0) {
      flag = 1;
    }
    if (sum < sumback) {
      flag = 1;
    }
  }
  if (flag == 0) {
    printf("%lld\n",sum );
  }else{
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 1708
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b;
    rep(i, n) cin >> a[i];
    for(int i = n-1; i >= 0; i -=2){
        b.push_back(a[i]);
    }
    int j = n % 2;
    for(;j < n; j += 2){
        b.push_back(a[j]);
    }
    rep(i, n) cout << b[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n - 1);
  REP(i, n) {
    cin >> a[i];
    a[i]--;
  }
  REP(i, n) { cin >> b[i]; }
  REP(i, n - 1) { cin >> c[i]; }

  ll ans = 0;
  REP(i, n) {
    ans += b[a[i]];
    if (i == n - 1) break;
    if (a[i] + 1 == a[i + 1]) ans += c[a[i]];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int W,N,i,a,b,dm;
        int w[30];

        scanf("%d",&W);
        scanf("%d",&N);

        for(i=0;i<W;i++){
                w[i]=i+1;
        }
        for(i=0;i<N;i++){
                scanf("%d,%d",&a,&b);

                //swap(w[a-1],w[b-1]
                dm = w[a-1];
                w[a-1]=w[b-1];
                w[b-1]=dm;
        }

        for(i=0;i<W;i++){
                printf("%d\n",w[i]);
        }

        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N >> M >> K;
  int ans =min(N+M, min(N+K,M+K));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3536
#include <iostream>
using namespace std;
int main() {
  int X,Y,i,leg,flag=0;
  cin >> X >> Y ;
  for (i=0;i<=X;i++){
    leg=i*2+(X-i)*4;
    if(leg==Y){
      flag=1;
    }else if(leg<Y){
      break;
    }else{
      continue;
    }
  }
if(flag==1){
  cout << "Yes";
}else{
  cout << "No";
}
}

Measured memory_bytes: 3668
from collections import defaultdict
import bisect as bs
MOD = 10**9 + 7
L = int(input())
S = input()
dic, l_dic = defaultdict(list), {}
for i in range(L):
    dic[S[i]].append(i)
ans = 0
for key in dic:
    l_dic[key] = len(dic[key])
for i in range(L):
    sub = 1
    for key in dic:
        if key == S[i]:
            continue
        sub = sub * (l_dic[key] - bs.bisect_right(dic[key], i) + 1) % MOD
    ans = (ans + sub) % MOD
print(int(ans))

Measured memory_bytes: 45552
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll a, b, q;
  cin >> a >> b >> q;
  
  vector<ll> s(a + 2), t(b + 2);
  s[0] = t[0] = -INF;
  s[a + 1] = INF;
  t[b + 1] = INF;
  for (int i = 0; i < a; i++){
    cin >> s[i + 1];
  }
  for (int i = 0; i < b; i++){
    cin >> t[i + 1];
  }


  for (int i = 0; i < q; i++){
    ll x;
    cin >> x;
    
    ll A = s[lower_bound(s.begin(), s.end(), x) - s.begin()];
    ll B = t[lower_bound(t.begin(), t.end(), x) - t.begin()];
    ll C, D;
    if (A == x)
      C = x;
    else 
      C = s[lower_bound(s.begin(), s.end(), x) - s.begin() - 1];
    if (B == x)
      D = x;
    else 
      D = t[lower_bound(t.begin(), t.end(), x) - t.begin() - 1];
    cout << min(max(A, B) - x, min(x - min(C, D), min(B - C + min(B - x, x - C), A - D + min(A - x, x - D)))) << endl;
  }
  
  

  return 0;
}


Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final String s = fs.next();
        int res = (int) 1e9;
        for (int i = 3; i <= s.length(); i++) {
            res = Math.min(res, Math.abs(753 - Integer.parseInt(s.substring(i - 3, i))));
        }
        System.out.println(res);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

struct Prime {
  int n;
  set<int> pri;
  Prime() : n(0) {}
  Prime(int n) : n(n) {
    vector<bool> f(n, true);
    f[0] = f[1] = false;
    for (int i = 2; i < n; i++) {
      if (!f[i]) continue;
      pri.insert(i);
      for (int j = i * 2; j < n; j += i) {
        f[j] = false;
      }
    }
  }
};

void solve() {
  auto prime = Prime(100010);
  vi32 sums(100001);
  for (int i = 1; i <= 100000; i += 2) {
    if (prime.pri.count(i) && prime.pri.count((i + 1) / 2)) sums[i] = 1;
  }
  rep(i, 100000) sums[i + 1] += sums[i];
  int q;
  cin >> q;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    cout << sums[r] - sums[l - 1] << endl;
  }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
const int mod=1e9+7;
ll sum[maxn];
int main(){
	int n,k;scanf("%d%d",&n,&k);ll ans=0;
	for(int i=k;i<=n+1;i++){
		ll now=(1ll*(n-i+1)*i+1)%mod;ans=(ans+now)%mod;
	}printf("%lld\n",ans);
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int A, B, C; cin >> A >> B >> C;
    if(A <= C && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      int t = p[i];
      p[i] = p[j];
      p[j] = t;
      bool flag = true;
      for (int k = 0; k < N - 1; k++) {
        if (p[k + 1] < p[k]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cout << "YES\n";
        // for (int i : p) {
        //   cout << i << " ";
        // }
        return 0;
      }
      t = p[i];
      p[i] = p[j];
      p[j] = t;
    }
  }
  cout << "NO\n";
  return 0;
}

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

int main(){
    int a,b;
    char op;

    while(1){
    cin >> a >> op >> b;

    if(op=='+'){
        cout << a + b << endl;
    }
    else if(op=='-'){
        cout << a - b << endl;
    }
    else if(op=='*'){
        cout << a * b << endl;
    }
    else if(op=='/'){
        cout << a / b << endl;
    }else{
        break;
    }
    }
    return 0;
}


Measured memory_bytes: 3120
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N;

	cin >> N;

	vector<int> vec(N);
	for (int i = 0; i < N;i++) {
		cin >> vec.at(i);
	}
	int count = 0;
	int a = 1;
	for (int i = 0; i < N + 1;i++) {
		a = vec.at(a - 1);
		count = count + 1;
		if (a==2) {
			break;
		}
	}
	if (count > N) {
		cout << -1 << endl;
	}
	else {
		cout << count << endl;
	}

}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0,sum=a+b+c;
	while(cnt<1000){
		if(a%2==1||b%2==1||c%2==1)break;
		a=(sum-a)/2;
		b=(sum-b)/2;
		c=(sum-c)/2;
		cnt++;
	}
	if(cnt>990)cnt=-1;
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)

int main()
{
    int N, K; cin >> N >> K;
    vector<int> H(N); for (auto& h : H) cin >> h;
    sort(H.begin(), H.end());
    int ans = numeric_limits<int>::max();
    REP(i, N-K+1) {
        ans = min(ans, H[i+K-1] - H[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    unsigned long long  a[6]={};
    unsigned long long  min=10000000000000001;
    for(int i=0; i<6; i++) {
        cin >> a[i];
        if(i!=0) {
            if(min>a[i]) min = a[i];
        }
    }
    
    if(a[0]%min) cout << 5+a[0]/min << endl;
    else cout << 5+a[0]/min-1 << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,q;
  cin >> n >> q;
  
  string s;
  cin >> s;
  
  vector<int> cont(q),aaa(n);
  
  for(int i = 0 ; i < n - 1 ; i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'C'){
      s.at(i) = 'a';
    }
  }
  
  int count = 0;
  for(int i = 0 ; i < s.size() ; i++){
    if(s.at(i) == 'a'){
      count++;
    }
    aaa.at(i) = count;
  }
  
  for(int i = 0 ; i < q ; i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    int z = aaa.at(y) - aaa.at(x) + 1;
    if(s.at(x) != 'a'){
      z--;
    }
    if(s.at(y) == 'a'){
      z--;
    }
    if(z < 0){
      z = 0;
    }
    cont.at(i) = z;
  }
  
  for(int i = 0 ; i < q ; i++){
    cout << cont.at(i) << endl;
  }
}
  
  
    

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<queue>

#define rep(i, n) for(int i; i<(n); i++)
typedef long long ll;
using namespace std;
using pint = pair<int,int>;

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

int H, W;
string field[110];
int dist[110][110];


int main(){
    cin >> H >> W;
    int wnum = 0;
    for(int i=0; i<H; i++){
        cin >> field[i];
        for(int j=0; j<W; j++){
            if(field[i][j]=='.') wnum++;
        }
    }
    memset(dist, -1, sizeof(dist));
    dist[0][0] = 1;
    queue<pint> que;
    que.push(pint(0,0));
    while(!que.empty()){
        pint cur = que.front();
        que.pop();
        int x=cur.first;
        int y=cur.second;
        for(int dir=0; dir<4; dir++){
            int nx = x+dx[dir];
            int ny = y+dy[dir];
            if(nx < 0 || nx >=H || ny<0 || ny >=W) continue;
            if(field[nx][ny] == '#') continue;
            if(dist[nx][ny] == -1){
                dist[nx][ny] = dist[x][y]+1;
                que.push(pint(nx,ny));
            }
        }
    }
    if(dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << wnum-dist[H-1][W-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string N;
    std::cin >> N;
    
    for (int i = 0; i < N.length(); ++i) {
        if (N[i] == '7') {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3040
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: -int(x), input().split()))

heapq.heapify(a)
for _ in range(m):
    p = heapq.heappop(a)
    heapq.heappush(a, -(-p // 2))
print(-sum(a))


Measured memory_bytes: 14180
import std.stdio;

void main() {
	int k, n;
	readf(" %s %s", &k, &n);

	auto a = new int[n];

	foreach (ref e;a) {
		readf(" %s", &e);
	}

	int max = 0;

	foreach (i;0..a.length - 1) {
		auto d = a[i + 1] - a[i];
		if (d > max) {
			max = d;
		}
	}
	auto d = k - a[$ - 1] + a[0];
	if (d > max) {
		max = d;
	}

	writeln(k - max);
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << (a-c)*(b-d) << endl;
}

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


Measured memory_bytes: 7724
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdbool.h>




int main() {
	int i,j,cnt=0,n,k;
	double ans=0;
	
	scanf("%d%d",&n,&k);
	for (i = 1; i <= n; i++) {
		cnt = 0;
		for (j = i;  j< k; j*=2) {
			cnt++;
		}ans += 1 / pow(2, cnt);
	}
	printf("%.12lf", ans/n);
	return 0;
}

Measured memory_bytes: 256
from numpy import cumsum
n, c = [int(item) for item in input().split()]
stc = [[int(item) for item in input().split()] for _ in range(n)] 
stc.sort(key=lambda x: (x[2], x[0]))

timeline = [0] * (10**5 + 1)
prev_c = -1 
for s, t, c in stc:
    if prev_c != c:
        prev_t = -100
    if prev_t != s:
        timeline[s-1] += 1
        timeline[t] += -1
    else:
        timeline[s] += 1
        timeline[t] += -1
    prev_t = t
    prev_c = c

print(max(cumsum(timeline)))

Measured memory_bytes: 38788
n = int(input())

AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(n)]

AB = sorted(AB, reverse=True)
CD = sorted(CD, key=lambda x: x[1])

for i in range(n):
    for j in range(len(CD)):
        if AB[i][0] < CD[j][0] and AB[i][1] < CD[j][1]:
            CD.pop(j)
            break
            
print(n - len(CD))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N; cin>>N;
  int A[N];
  set<int>S;
  rep(i,N){
    cin>>A[i];
    S.insert(A[i]);
  }
  cout<<(S.size()==N? "YES":"NO")<<endl;
}

Measured memory_bytes: 13748
import itertools
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
factorial=list(itertools.permutations(list(range(n))))
result=[]
for i in range(len(factorial)):
    distance=0
    for j in range(n-1):
        distance+=((xy[factorial[i][j+1]][0]-xy[factorial[i][j]][0])**2+(xy[factorial[i][j+1]][1]-xy[factorial[i][j]][1])**2)**(1/2)
    result.append(distance)
print(sum(result)/len(result))

Measured memory_bytes: 15660
/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(false); cin.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL n, k;
	cin >> n >> k;
	if(n % k == 0){
		cout << "0" << endl;
	}
	else{
		cout << min(n % k, k - (n % k)) << endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
 for(int i=0;i<n;++i)
  cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;++i)
  sum+=a[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include<math.h>
using namespace std;

#define SIZE 1001

int main(){
	char buf[SIZE];

	fgets(buf,SIZE,stdin);

	for(int i=0;buf[i] != '\0' && buf[i] != '\n';i++){
		if(buf[i]-3 <= 64){
			printf("%c",90-(64-(buf[i]-3)));
		}else{
			printf("%c",buf[i]-3);
		}
	}
	printf("\n");

    return 0;
}

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

using namespace std;

int main() {
    long long n;
    cin>>n;
    
    long long i,tot=0;
    for(i=1;i<=n;++i)
    {
        long long temp;
        cin>>temp;
        
        if(temp%2==1&&i%2==1)
        {
            tot++;
        }
    }
    
    cout<<tot<<endl;
}

Measured memory_bytes: 3672
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    if(X < A) out.println(0);
    else out.println(10);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 23124
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;

struct Color{
    long color, cost;
}

void main()
{
    long N = scanElem;
    long C = scanElem;
    long[][] cGrid;
    long[][] grid;
    foreach(i; 0..C) cGrid ~= scanArray;
    foreach(i; 0..N) grid ~= scanArray;
    
    long[][3] colors;
    colors[0].length=C;
    colors[1].length=C;
    colors[2].length=C;
    foreach(y; 0..N)
    {
        foreach(x; 0..N)
        {
            auto idx = (x+1+y+1)%3;
            colors[idx][grid[y][x]-1]++;
        }
    }
    long res=long.max;
    foreach(c0; 0..C)
    {
        foreach(c1; 0..C)
        {
            if(c0==c1)continue;
            foreach(c2; 0..C)
            {
                if(c0==c2 || c1==c2)continue;
                long t;
                foreach(l; 0..C) t+=cGrid[l][c0]*colors[0][l];
                foreach(l; 0..C) t+=cGrid[l][c1]*colors[1][l];
                foreach(l; 0..C) t+=cGrid[l][c2]*colors[2][l];
                res = min(res, t);
            }
        }
    }
    writeln(res);
}

void scanValues(TList...)(ref TList list)
{
    auto lit = readln.splitter;
    foreach (ref e; list)
    {
        e = lit.fornt.to!(typeof(e));
        lit.popFront;
    }
}

T[] scanArray(T = long)()
{
    return readln.split.to!(long[]);
}

void scanStructs(T)(ref T[] t, size_t n)
{
    t.length = n;
    foreach (ref e; t)
    {
        auto line = readln.split;
        foreach (i, ref v; e.tupleof)
        {
            v = line[i].to!(typeof(v));
        }
    }
}

T scanElem(T = long)()
{
    char[] res;
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        res ~= cast(char) c;
        c = getchar;
    }
    return res.strip.to!T;
}

template fold(fun...) if (fun.length >= 1)
{
    auto fold(R, S...)(R r, S seed)
    {
        static if (S.length < 2)
        {
            return reduce!fun(seed, r);
        }
        else
        {
            import std.typecons : tuple;

            return reduce!fun(tuple(seed), r);
        }
    }
}

struct Factor
{
    long n;
    long c;
}

Factor[] factors(long n)
{
    Factor[] res;
    for (long i = 2; i ^^ 2 <= n; i++)
    {
        if (n % i != 0)
            continue;

        int c;
        while (n % i == 0)
        {
            n = n / i;
            c++;
        }
        res ~= Factor(i, c);
    }
    if (n != 1)
        res ~= Factor(n, 1);

    return res;
}

bool isPrime(long n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    for (long i = 3; i ^^ 2 <= n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
#define ww first
#define vv second
using namespace std;

typedef long long lld;
typedef pair <int, lld> pii;
const int NN = 1e2 + 5;
const int MM = 1e5 + 5;
lld dp[NN][MM];
pii aa[NN];
int nn, ss;
lld resu;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
        cin >> nn >> ss;
        for (int ii = 1; ii <= nn; ++ii) cin >> aa[ii].ww >> aa[ii].vv;
        sort(aa + 1, aa + nn + 1);
        for (int ii = 1; ii <= nn; ++ii) {
            for (int jj = 1; jj <= ss; ++jj) {
                if (jj + aa[ii].ww > ss) break;
                int zz = jj + aa[ii].ww;
                if (dp[ii - 1][jj] != 0)
                    dp[ii][zz] = max(dp[ii][zz], dp[ii - 1][jj] + aa[ii].vv);
            }
            for (int jj = 1; jj <= ss; ++jj)
                dp[ii][jj] = max(dp[ii][jj], dp[ii - 1][jj]);
            if (aa[ii].ww <= ss) dp[ii][aa[ii].ww] = max(dp[ii][aa[ii].ww], aa[ii].vv);
        }
        for (int ii = 1; ii <= nn; ++ii)
        for (int jj = 1; jj <= ss; ++jj)
            resu = max(resu, dp[ii][jj]);
        cout << resu;
    return 0;
}


Measured memory_bytes: 79360
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000000000000ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define mod 998244353
#define S second
#define F first
#define x(i) t[i].x
#define y(i) t[i].y
#define zz p<<1
#define yy p<<1|1
#define Set(a,v) memset(a,v,sizeof(a))
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const int MAXN=1000010,INV=(mod+1)>>1;
int n,maxx,top;
int a[MAXN],s[MAXN];
int v[MAXN],p[MAXN],mu[MAXN];
inline void prepare()
{
	mu[1]=1;
	rep(2,maxx,i)
	{
		if(!v[i])
		{
			p[++top]=i;
			v[i]=i;mu[i]=-1;
		}
		rep(1,top,j)
		{
			if(p[j]>maxx/i)break;
			v[p[j]*i]=p[j];
			if(v[i]==p[j])break;
			mu[p[j]*i]=-mu[i];
		}
	}
	rep(1,maxx,i)
	{
		int ww=maxx/i;
		rep(1,ww,j)s[i]=(s[i]+(ll)j*a[i*j])%mod;
	}
}
signed main()
{
	//freopen("1.in","r",stdin);
	get(n);int cnt1=0,cnt2=0;
	rep(1,n,i){int get(x);++a[x];maxx=max(maxx,x);}
	prepare();int ans=0;
	rep(1,maxx,i)
	{
		cnt1=(cnt1+(ll)a[i]*a[i]%mod*i)%mod;
		cnt2=(cnt2+((ll)a[i]*(a[i]-1)/2)%mod*i)%mod;
		int ww=maxx/i;
		rep(1,ww,j)
		ans=(ans+(ll)mu[j]*j*j%mod*i%mod*s[(i*j)]%mod*s[(i*j)])%mod;
	}
	ans=(ll)(ans-cnt1+mod)*INV%mod;
	ans=(ans+cnt2)%mod;put(ans);
	return 0;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
string s;
int c=99999,f=0;
int main()
{
	cin>>s;
	int l=s.length();
	for(int i=0;i<=l-1;i++)
	{
		if(s[i]=='C') {c=i;break;}

	}
	for(int i=0;i<=l-1;i++)
	if(s[i]=='F') f=i;
	//cout<<c<<" "<<f<<endl;
	if(c<f) cout<<"Yes";
	else cout<<"No";
	
}

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

int main() {
	char a;
	int o=0;
	rep(i, 4) {
		cin >> a;
		if (a == '2') o++;
	}
	cout << o << endl;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
    int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	rep(i, tx - sx) cout << 'R';
	rep(i, ty - sy) cout << 'U';
	rep(i, tx - sx) cout << 'L';
	rep(i, ty - sy) cout << 'D';
	cout << 'D';
	rep(i, tx - sx + 1) cout << 'R';
	rep(i, ty - sy + 1) cout << 'U';
	cout << 'L';
	cout << 'U';
	rep(i, tx - sx + 1) cout << 'L';
	rep(i, ty - sy + 1) cout << 'D';
	cout << 'R' << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5, maxw=35;

int n;
multiset<int> v[maxw];
map<int,int> er;

int lowbit(int x) {return x&(-x);}

int find(int x)
{
	fd(i,30,0) if ((1<<i)&x) return 1<<i;
}

int main()
{
	fo(i,0,30) er[1<<i]=i;
	
	scanf("%d",&n);
	fo(i,1,n)
	{
		int x;
		scanf("%d",&x);
		v[er[lowbit(x)]].insert(x);
	}
	
	int ans=0;
	fo(i,0,30)
	{
		while (v[i].size()>=2)
		{
			multiset<int>::iterator it=v[i].end(); it--;
			int now=*it; v[i].erase(it);
			int need=((LL)find(now)<<1)-now;
			multiset<int>::iterator k=v[i].lower_bound(need);
			if (k!=v[i].end() && *k==need)
			{
				ans++;
				v[i].erase(k);
			}
		}
	}
	
	printf("%d\n",ans);
}

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

using namespace std;

int main(){
  string str;
  cin >> str;
  int size = str.size();
  long black = 0, count = 0;
  
  for(int i=0; i<size; i++){
    if(str[i]=='B') black++;
    else count += black;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  string num;
  cin >> num;
  int A,B,C,D;
  A = num.at(0) - '0';
  B = num.at(1) - '0';
  C = num.at(2) - '0';
  D = num.at(3) - '0';
  int o[2];
  int a,b,c,d;
  o[0] = 1;
  o[1] = -1;
  char O[2];
  O[0] = '+';
  O[1] = '-';
    for(b=0;b<=1;b++)
      for(c=0;c<=1;c++)
        for(d=0;d<=1;d++)
          if(A+B*o[b]+C*o[c]+D*o[d] == 7){
          goto OK;
          }
  OK:;
  cout << A << O[b] << B << O[c] << C << O[d] << D << "=7";
}

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


int main()
{
   int W,a,b ;
   scanf("%d",&W);
   scanf("%d",&a);
   scanf("%d",&b);
   if( b> W+a )
   {
        cout<< b-W-a;
   }
   else
   {
         if( a > b+W  )
         {
            cout<< a-W-b;
         }
         else
         {
            cout<<0;
         }

   }
    return 0;
}



Measured memory_bytes: 256