akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1E+09 + 7;
const ll INF = 5E18;
const int MAX_N = 50;

int N, K;
P X[MAX_N + 1], Y[MAX_N + 1];
int sum[MAX_N + 1][MAX_N + 1];

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

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        ll x, y;
        cin >> x >> y;
        X[i] = P(x, y);
        Y[i] = P(y, x);
    }

    sort(X + 1, X + N + 1);
    sort(Y + 1, Y + N + 1);
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
            if (X[i].first == Y[j].second)
                sum[i][j]++;
        }
    }

    /*
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cout << "i = " << i << ", j = " << j << ", sum = " << sum[i][j] << "\n";
        }
    }
    */
    ll ans = INF;
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            ll rx = X[j].first;
            ll lx = X[i].first;
            for (int k = 1; k <= N; k++) {
                for (int l = k + 1; l <= N; l++) {
                    ll uy = Y[l].first;
                    ll ly = Y[k].first;
                    if (sum[j][l] - sum[j][k - 1] - sum[i - 1][l] + sum[i - 1][k - 1] >= K) {
                        ans = min(ans, (rx - lx) * (uy - ly));
                    }
                }
            }
        }
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

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

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

  int ans = 0;
  if (A > B)
    ans += A--;
  else
    ans += B--;
  if (A > B)
    ans += A--;
  else
    ans += B--;
  cout << ans << endl;
}

Measured memory_bytes: 256
NK = input().split()
N = int(NK[0])
K = int(NK[1])

# N = 1000000000
# K = 1

def func(N,K):
    prev = N 

    while(1):
        N = abs(N-K)
        if prev<=N:
            return prev
        prev = N


def fun(N,K):
    N = (N % K) 
    return N  

S=fun(N,K)
T = func(S,K)
# print('S',S)
# print('T',T)
print(T)


Measured memory_bytes: 3060
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, a, b) = InputLine.to_ia

  m = n / (a + b)
  k = n % (a + b)
  l = [k, a].min

  puts ((m * a) + l).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <stdio.h>


int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}

	return 0;
}


Measured memory_bytes: 2100
#include <iostream>

using namespace std;

int main() {
    int n,l;
    cin >> n >> l;
    int ans = INT_MAX;
    for (int i=0; i<n; i++) {
        int c,t;
        cin >> c >> t;
        if (t > l) continue;
        ans = min(ans, c);
    }

    if (ans != INT_MAX) {
        cout << ans << endl;
    } else {
        cout << "TLE" << endl;
    }
}

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

int main() {
    int n, t, a, h[1000];
    int target;
    float temp;
    float temp_sa;
    cin >> n;
    cin >> t >> a;
    for (int i=0;i<n;i++) {
      cin >> h[i];
    }

    temp_sa = 3.402823e+38;
    target = 0;
    for (int i=0;i<n;i++) {
      temp = (float)t - (float)h[i] * 0.006;
      if (temp_sa > abs((float)a - temp)) {
        target = i+1;
        temp_sa = abs((float)a - temp);
      }
    }

    cout << target << endl;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int dp[2001][2001];
int32_t main() {
    nitin;
    dp[0][0]=1;
    for(int i=1;i<=2000;i++)
    {
        for(int j=3;j<=2000;j++)
        {
            dp[i][j]=(dp[i][j]+dp[i][j-1]+dp[i-1][j-3])%mod;
        }
    }
    int ans=0;
    int s;
    cin>>s;
    for(int i=1;i<=2000;i++)
    {
        ans=(ans+dp[i][s])%mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(15,vector<int>(15));
    rep(i,15) {
        rep(j,15) {
            v[i][j] = -1;
        }
    }
    rep(i,n) {
        int a;
        cin >> a;
        rep(j,a) {
            int x,y;
            cin >> x >> y;
            x--;
            v[i][x] = y;
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++) {
        vector<int> d(n,0);
        rep(j,n) {
            if((i >> j) & 1) {
                d[j] = 1;
            }
        }
        bool ok = true;
        rep(j,n) {
            if(d[j] == 1) {
                rep(k,n) {
                    if(v[j][k] == -1) {
                        continue;
                    }
                    if(v[j][k] != d[k]) {
                        ok = false;
                    }
                }
            }
        }
        if(ok) {
            ans = max(ans,__builtin_popcount(i));
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

bool isRed[MAX_N] = {}; // 赤がある可能性がある
int Ball[MAX_N] = {};   // ボールの合計
int N, M;

int main()
{
    cin >> N >> M;
    isRed[0] = true;
    REP(i, N) {
        Ball[i] = 1;
    }
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(isRed[x]) {
            if(Ball[x] == 1) {
                isRed[x] = false;
            }
            isRed[y] = true;
        }
        Ball[x]--;
        Ball[y]++;
    }
    int ans = 0;
    REP(i, N) {
        if(isRed[i]) { ans++; }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 768
import queue

n,m = list(map(int, input().split()))
puted = [0]*(n+1)

ab = [[] for i in range(n+1)]
for i in range(m):
	a,b = list(map(int, input().split()))
	ab[a].append(b)
	ab[b].append(a)

q = queue.Queue()
flg = [-1]*n
flg[0] = 0
q.put(1)

while not q.empty():
	item = q.get()
	for i in ab[item]:
		if puted[i]==0:
			flg[i-1]=item
			q.put(i)
			puted[i]=1

if -1 in flg:
	print("No")
	exit()

print("Yes")
for i in range(1,len(flg)):
	print(flg[i])


Measured memory_bytes: 35308
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h, a;
    cin >> h >> a;

    int ans = 0;

    while(h > 0){
        ans++;
        h -= a;
    }

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


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		sc.close();

		int ans;
		if (x >= 0 && y >= 0) {
			if (x >= y && y == 0) {
				ans = 1 + x - y;

			} else if (x >= y) {
				// 反転して+1して反転
				ans = 2 + x - y;
			} else {
				// +1する
				ans = y - x;
			}
		} else if (x >= 0 && y < 0) { // x正 y負
			if (Math.abs(x) >= Math.abs(y)) { // 2 -1
				// 反転してから+1
				ans = 1 + (y - (-x));
			} else { // 1 -2
				// 絶対値をあわせてから反転
				ans = Math.abs(y) - x + 1;
			}

		} else if (x < 0 && y >= 0) {
			// x負 y正
			if(Math.abs(x) <= Math.abs(y)) {
				//反転してから+1
				ans = 1 + y - (-x);
			}else if(y==0){
				ans = Math.abs(x)-y;
			}else {
				ans = Math.abs(x)-y + 1;
			}

		} else {
			// x負 y負
			if (x >= y) { // -1 -2
				// 反転して絶対値あわせて反転
				ans = Math.abs(y) - Math.abs(x) + 2;
			} else { // -2 -1
				ans = y - x;
			}

		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N=1<<18;
ll Mi[555555],A[555555];
class StarrySkyTree{
public:
  void init(){fill(Mi,Mi+555555,0);fill(A,A+555555,0);}
  void add(int a,int b,int x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return 1<<30;if(a<=l&&r<=b)return Mi[k]+A[k];
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return min(left,right)+A[k];
  }
};

StarrySkyTree t;
int main() {
  int n,T;
  cin >> n >> T;
  t.init();
  while(T--) {
    int x,y,l,r;
    cin >> y;
    if(!y) {
      cin >> l >> r >> x;
      t.add(l-1,r,x);
    } else {
      cin >> x;
      cout << t.getMin(x-1,x) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 11744
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int n,m,a[1000],b,i,j,x,c;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a[i],&b);
	}
	sort(a,a+m,greater<int>());
	c=0;
	for(i=0;i<m-1;i++){
		if(a[i]<n){
			c+=n-a[i];
		}
	}
	printf("%d\n",c);
	return 0;
}



Measured memory_bytes: 2780
library = """
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder":
    cdef cppclass fenwick_tree[T]:
        fenwick_tree() except +
        fenwick_tree(int n) except +
        void add(int p, T x)
        T sum(int l, int r)
cdef class DSU:
    cdef dsu *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new dsu(n)
    def __dealloc__(self):
        del self._thisptr
    cpdef int merge(self, int a, int b):
        return self._thisptr.merge(a, b)
    cpdef bool same(self, int a, int b):
        return self._thisptr.same(a, b)
    cpdef int leader(self, int a):
        return self._thisptr.leader(a)
    cpdef int size(self, int a):
        return self._thisptr.size(a)
cdef class BIT:
    cdef fenwick_tree[long] *_thisptr
    def __cinit__(self, int n = 0):
        if n == 0:
            self._thisptr = new fenwick_tree[long]()
        else:
            self._thisptr = new fenwick_tree[long](n)  
    def __dealloc__(self):
        del self._thisptr
    cpdef void add(self, int p, long x):
        self._thisptr.add(p, x)
    cpdef long sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""
import os,sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('atcoder.pyx','w').write(library)
    os.system('cythonize -i -3 -b atcoder.pyx')
 
# ↑ここまでライブラリ↓ここから解法
 
import sys
import atcoder
input = sys.stdin.buffer.readline
n, q = map(int, input().split())
dummy = atcoder.BIT()
bit = atcoder.BIT(n)
*map(bit.add, range(n), map(int, input().split())),
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t: res.append(bit.sum(u, v))
    else: bit.add(u, v)
print('\n'.join(map(str, res)))

Measured memory_bytes: 49944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int refill = sc.nextInt();
        int x = 800 * refill;
        int y = 200 * (refill / 15);
        
        System.out.println(x - y);
    }
}

Measured memory_bytes: 21460
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main() {
  double r;
  cin >> r;
  std::cout << fixed;
  cout<< setprecision(6) <<(r * r * M_PI);
  cout << " "; 
  cout<< setprecision(6) <<(2 * r * M_PI);
  cout << endl;
}


Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b - 1) / 2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, arr[100003];
int main(){
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&arr[i]);
    }
    sort(arr+1,arr+1+n);
    printf("%d",arr[n/2+1]-arr[n/2]);
    return 0;
}


Measured memory_bytes: 640
import numpy as np
import copy

S = input()
K = int(input())

A = np.zeros(1)
j = 0 

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        A[j] += 1
    else:
        j += 1
        A = np.append(A, 0)
A += 1

if np.size(A) == 1:
    ans = (len(S) * K) // 2
    
else:
    B = copy.deepcopy(A)
    if S[0] == S[-1]:
        B[0] += A[-1]
        B = np.delete(B, np.size(A)-1)
        ans = np.sum(A // 2) + np.sum(B // 2) * (K-1)
    else:
        ans = np.sum(A // 2) * K

print(int(ans))

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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  string a = "";
  for (int i = 0; i < n; i++) {
    a.push_back(s.at(i));
    a.push_back(t.at(i));
  }

  cout << a << endl;
}

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

int main() {
  int A, B, K;
  cin >> K;
  cin >> A;
  cin >> B;
  
  if (K <= (B - A)) {
    cout << "OK";
  } else {
    for (int i = A; i <= B; i++) {
      if (i % K == 0) {
		cout << "OK";
        return 0;
      }
    }
    cout << "NG";
  }
}

Measured memory_bytes: 3592
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const LL INF = (1 << 30);

//毎回変える定数
#define N_MAX 200
const int MOD = 1000000007;

//素因数分解
template<typename T>
vector<T> prime_factorization(T n) 
{
	vector<T> res;
	T check = 2;

	while (check*check <= n) {
		if (n%check == 0) {
			n /= check;
			res.push_back(check);
		}
		else {
			check++;
		}
	}
	if (n != 1) res.push_back(n);
	sort(res.begin(), res.end());
	return res;
}


//繰り返し累乗法
template<typename T>
T mod_pow(T x, T n, T mod) {
	T res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}














//上に、ライブラリを作成していく。
//問題に応じて、以下を調整する。


//サブ関数
//入力
void input(LL& n,LL& m)
{
	cin >> n >> m;
}


//出力
void output(LL n,LL m)
{
	cout << mod_pow(n, m, (LL)MOD) << endl;
}

//デバッグ
void debug(){
	int N;
	cin>>N;
}


//メイン関数
int main(){
	LL n, m;
	input(n,m);
	output(n,m);
	debug();
	
	return 0;
}



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

int main()
{
    int x;
    cin>>x;
    int kakudo=360;
    if(360%x==0){
        cout<<360/x<<endl;
    }else{
        while(true){
            kakudo+=360;
            if(kakudo%x==0){
                cout<<kakudo/x<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b, c;
	
	cin >> a >> b >> c;
	cout << a*b/2 << endl;

	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
const ll MOD = (int)(1e9+7);

const int MAX_N = 212345;
ll inv[MAX_N];
ll fact[MAX_N];
ll fact_inv[MAX_N];

int main2() {
  int N, M; cin >> N >> M;
  if (N > M) swap(N, M);
  // N <= M
  if (M - N >= 2) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  (ans *= fact[N]) %= MOD;
  (ans *= fact[M]) %= MOD;
  if (N == M) ans = (ans * 2) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {
  int N = MAX_N;
  inv[1] = 1;
  for (int i = 2; i < N; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < N; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  string d;cin>>d;
    ll a=0,b=0,c=0;
    rep(i,d.size()){
      if(d[i]=='a')a++;
      else if(d[i]=='b')b++;
      else c++;
    }
    if(max({a,b,c})-min({a,b,c})<=1)cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 27092
#!/usr/bin/env python3
import sys
INF = float("inf")
import math
import collections


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def solve(A: int, B: int):
    As = factorial(A)
    Bs = factorial(B)
    counter = 1
    for key in As:
        if key in Bs:
            counter += 1
    print(counter)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n + 1);
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int pos = 1;
	map<ll, ll> mp;
	ll len = 0;
	ll i;
	mp[1] = 0;
	for (i = 1; i <= k; ++i) {
		pos = a[pos];
		if (i == k) {
			cout << pos;
			return 0;
		}
		if (mp[pos]) {
			len = i - mp[pos];
			break;
		}
		else
			mp[pos] = i;
	}
	k -= mp[pos];
	k %= len;
	for (i = 0; i < k; ++i) {
		pos = a[pos];
	}


	cout << pos;
	return 0;
}


Measured memory_bytes: 14756
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)
//    val a = 2
//    val b = 1

    if (b == 1) {
        print("0")
        return
    }

    var i = 1
    while (true) {
        var emptySocketNum = i*(a-1) + 1
        if (emptySocketNum >= b) {
            print(i)
            return
        } else {
            i++
        }
    }
}

Measured memory_bytes: 36032
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();
        Map<Long, Long> map = new HashMap<>();
        while (p % 2 == 0) {
            map.put(2L, map.getOrDefault(2L, 0L) + 1);
            p /= 2;
        }
        for (long i = 3; i <= Math.sqrt(p); i += 2) {
            while (p % i == 0) {
                map.put(i, map.getOrDefault(i, 0L) + 1);
                p /= i;
            }
        }
        if (p > 2) {
            map.put(p, map.getOrDefault(p, 0L) + 1);
        }
        long ans = 1;
        for (Long key : map.keySet()) {
            ans *= Math.pow(key, map.get(key) / n);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	int d = 0;
	vector<int> num(n);
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		++num[a];
		d = max(d, a);
	}
	auto no = []() {
		printf("Impossible\n");
		exit(0);
	};
	for (int i = (d - 1) / 2; i >= 0; --i)
		if (num[i] > 0) no();
	if (num[(d + 1) / 2] != 1 + d % 2) no();
	for (int i = d; i > (d + 1) / 2; --i)
		if (num[i] < 2) no();
	printf("Possible\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n, t;
	cin >> n >> t;
	if (!cin) return false;
	vii v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].second >> v[i].first;
	}

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

	int pos = 0;
	int mincoste = INT_MAX;
	while (pos < n && v[pos].first <= t) {
		if (v[pos].second < mincoste) mincoste = v[pos].second;
		++pos;
	}
	if (mincoste == INT_MAX) cout << "TLE\n";
	else cout << mincoste << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<P> edge;
  int d = n;
  if(n & 1) --d;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if(j <= i || j == d) continue;
      edge.push_back({i,j});
     }
     --d;
  }

  cout << edge.size() << endl;
  for (auto e : edge) {
    cout << e.first << " " << e.second << endl;
  } 
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける


ll k,x,y;

int main(){
  ll ans=0;
  string n;
  cin >> n >> k;
  ll nl=n.length();

  vi a(nl);
  REP(i,nl){
    a[i]=n[nl-1-i]-48;
  }

  vvvi dp = vvvi(nl, vvi(4, vi(2, 0)));
  REP(i,nl){
    dp[i][0][0]=1;
    dp[i][0][1]=1;
  }

  dp[0][1][0]=a[0];
  dp[0][1][1]=9LL;
  
  dp[0][2][0]=0;
  dp[0][2][1]=0;
  dp[0][3][0]=0;
  dp[0][3][1]=0;

  for(ll j=1;j<4;j++){
    for(ll i=1;i<nl;i++){
      if (a[i]!=0){
        dp[i][j][0]=dp[i-1][j-1][0]+(a[i]-1LL)*dp[i-1][j-1][1]+dp[i-1][j][1];
      }else{
        dp[i][j][0]=dp[i-1][j][0];
      }
      dp[i][j][1]=dp[i-1][j][1]+9LL*dp[i-1][j-1][1];
    }
  }

  cout<<dp[nl-1][k][0]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, M;

bool check(int x) {
  return M/x >= N;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  int ans = -1;
  for (int i = 1; i*i <= M; i++) {
    if (M % i != 0) continue;
    if (check(i)) chmax(ans, i);
    if (i*i != M && check(M/i)) chmax(ans, M/i);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdin = func() *bufio.Scanner {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanWords)
	return stdin
}()

func main() {
	// 入力
	N := intConvert(readString())
	K := intConvert(readString())

	// 計算量O(N) 期待値スライスの作成
	var piExpectValues []float64
	for i := 0; i < N; i++ {
		pi := intConvert(readString())
		piExpectValue := expectValueCalculation(pi)
		piExpectValues = append(piExpectValues, piExpectValue)
	}

	// 期待値の論理和を計算する。
	var piExpectValueCumulativeSums []float64
	piExpectValueCumulativeSums = append(piExpectValueCumulativeSums, piExpectValues[0])
	for i := 1; i < len(piExpectValues); i++ {
		cumulativSum := piExpectValueCumulativeSums[i-1] + piExpectValues[i]
		piExpectValueCumulativeSums = append(piExpectValueCumulativeSums, cumulativSum)
	}

	// 隣接するK個の期待値の合計最大値を計算する
	expectValueMaxSum := piExpectValueCumulativeSums[0]
	if N == K {
		expectValueMaxSum = piExpectValueCumulativeSums[N-1]
	} else {

		for i := 1; i < N-K; i++ {
			priExpectValueMaxSum := piExpectValueCumulativeSums[i+K] - piExpectValueCumulativeSums[i]
			if expectValueMaxSum < priExpectValueMaxSum {
				expectValueMaxSum = priExpectValueMaxSum
			}
		}
	}

	// 出力
	fmt.Printf("%f", expectValueMaxSum)
}

// readString() スペース区切りで読み込んだ文字列を返す
func readString() string {
	stdin.Scan()
	return stdin.Text()
}

// intConver(string) 文字列をintに直す
func intConvert(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return n
}

// expectValueCalculation() 1からPまでのP種類の目が等確率で出るサイコロの出目の期待値を計算する
func expectValueCalculation(num int) float64 {
	var priExpectValue float64
	priExpectValue = (1.0 + float64(num)) / 2.0
	return priExpectValue
}


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

int main(){
    int N;cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++)cin>>a.at(i);
    sort(a.begin(),a.end());
    if(N%2){
        if(a.at(0)!=0){
            cout<<0<<endl;
            return 0;
        }
        else a.erase(a.begin());
    }

    int count=0;
    for(int i=1;i<=int(N/2);i++){
        if(a.at(i*2-2)==i*2-(N+1)%2 and a.at(i*2-1)==i*2-(N+1)%2){
            count++;
        }
        else{
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    for(int i=0;i<count;i++){
        ans*=2;
        ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INP (a<<50)
using namespace std;
int main()
{
    int a,b,c,i,j;
    cin>>a>>b;
    int s[a+5],ss[b+5];
    long long int sss[a+5][b+5];
    for(i=1; i<=a; i++)
    {
        cin>>s[i]>>ss[i];
    }
    memset(sss,0,sizeof(sss));
    for(i=1; i<=a; i++)
    {
        for(j=1; j<=b; j++)
        {
            if(s[i]<=j)
            {
                sss[i][j]=max(sss[i-1][j],sss[i-1][j-s[i]]+ss[i]);
            }
            else
                sss[i][j]=sss[i-1][j];
        }
    }
    cout<<sss[a][b]<<endl;
    return 0;
}


Measured memory_bytes: 82304
while gets
  w=$_.to_f
  case
  when w<=48 then puts "light fly"
  when w<=51 then puts "fly"
  when w<=54 then puts "bantam"
  when w<=57 then puts "feather"
  when w<=60 then puts "light"
  when w<=64 then puts "light welter"
  when w<=69 then puts "welter"
  when w<=75 then puts "light middle"
  when w<=81 then puts "middle"
  when w<=91 then puts "light heavy"
  when 91<w then puts "heavy"
  end
end

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, K; cin >> N >> K;
    vector<pair<int, int>> M(N);
    set<int> S;
    for(int i = 0; i < N; i++) {
        int A; cin >> A;
        A--;
        S.insert(A);
        M[A].second = A;
        M[A].first++;
    }
    sort(M.begin(), M.end());
    int ans = 0;
    int i = 0;
    while(S.size() > K) {
        if(M[i].first != 0) {
            ans += M[i].first;
            S.erase(M[i].second);
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    int count = 0;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    for(int i = 0; i < N; i += 2){
        if(a[i] % 2 == 1) count++;
    }

    cout << count << endl;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    for (;;) {
        int n, m, p;
        cin >> n >> m >> p;

        if (!n && !m && !p)
            break;

        vector<int> vv(n + 1);
        int ttl = 0;
        rep(i, 1, n + 1) cin >> vv[i], ttl += vv[i];
    
        if (vv[m] == 0) {
            cout << 0 << endl;
        } else {
            cout << (ttl * (100 - p) / vv[m]) << endl;
        }
    }
}


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

struct edge{
    int to,cost;
};

const int INF  = 10000000;

int k;

vector<edge> g[100001];

int d[100001];

void dijkstra(int s){
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>> > que;
    fill(d,d+k,INF);
    d[s] = 0;
    que.push(make_pair(0,s));

    while(!que.empty()){
        pair<int,int> p = que.top(); que.pop();
        int dijkstra_tmp = p.second;
        if(d[dijkstra_tmp] < p.first){
            continue;
        }
        for(int i=0; i < g[dijkstra_tmp].size(); i++){
            edge e = g[dijkstra_tmp][i];
            if(d[e.to] > d[dijkstra_tmp] + e.cost){
                d[e.to] = d[dijkstra_tmp] + e.cost;
                que.push(make_pair(d[e.to],e.to));
            }
        }
    }
}

int main() {

    cin >> k;

    edge e;

    for(int i=0; i<k-1; i++){
        e.cost = 1;
        e.to = i+1;
        g[i].push_back(e);
        e.cost = 0;
        e.to = (i*10)%k;
        g[i].push_back(e);
    }

    e.cost = 1;
    e.to = 0;
    g[k-1].push_back(e);
    e.cost = 0;
    e.to = ((k-1)*10)%k;
    g[k-1].push_back(e);

    dijkstra(1);

    cout << d[0] + 1 << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int X, N;
    scanf("%d %d", &X, &N);

    if (N == 0)
    {
        printf("%d", X);
        return 0;
    }

    int p[110], t = 1;
    bool flag2 = false;

    for (int i = 0; i < N; i++)
        scanf("%d", &p[i]);

    for (int i = 0; i < N; i++)
    {
        if (X == p[i])
        {
            flag2 = true;
            break;
        }
    }
    if (!flag2)
    {
        printf("%d", X);
        return 0;
    }

    int check;
    bool flag = false;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            check = X - t;
            for (int j = 0; j < N; j++)
            {
                if (p[j] == check)
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                flag = false;
                continue;
            }
            else
            {
                printf("%d", check);
                return 0;
            }
        }
        else
        {
            check = X + t;
            for (int j = 0; j < N; j++)
            {
                if (p[j] == check)
                {
                    flag = true;
                    break;
                }
            }
            t++;
            if (flag)
            {
                flag = false;
                continue;
            }
            else
            {
                printf("%d", check);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define int long long int
#define inf 100000000000
#define hell (int)(998244353)

using namespace std;

void solve(){
    int n,m;
    cin>>n>>m;
    int x=(n+m);
    cout<<(x*(x-1))/2-n*m;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(M);
    READAR(A,N);
    vector<bool> ans(N,true);
    FORI(i,0,M)
    {
        READV(a);
        READV(b);
        a--;
        b--;
        if(A[a]<=A[b])
        {
            ans[a]=false;
        }
        if(A[a]>=A[b])
        {
            ans[b]=false;
        }
    }
    ll ans1=count(ans.begin(),ans.end(),true);
    cout<<ans1<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 4552
import sys
input = sys.stdin.readline

def slove():
    n, k = map(int,input().split())
    p = map(int,input().split())
    p = sorted(p)
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)

if __name__ == "__main__":
    slove()
    

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

typedef long long ll;
const int maxn = 105;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int mod;
inline int add(int x, int y) {return x + y > mod ? x + y - mod : x + y;}
inline int sub(int x, int y) {return x < y ? x - y + mod : x - y;}
inline void inc(int &x, int y) {x += y; if (x >= mod) x -= mod;}
inline void dec(int &x, int y) {x -= y; if (x < 0) x += mod;} 

int n, m, t;
int c[maxn][maxn], pw[maxn][maxn * maxn], f[2][maxn][maxn], tr[maxn][maxn];

void init()
{
	for (int i = 0; i <= n; ++i)
		for (int j = c[i][0] = 1; j <= i; ++j)
			c[i][j] = add(c[i - 1][j - 1], c[i - 1][j]);
	for (int i = 0; i <= t; ++i)
		for (int j = pw[i][0] = 1; j <= n * m; ++j) pw[i][j] = (ll)pw[i][j - 1] * i % mod;
}

int main()
{
	n = gi(); m = gi(); t = gi(); mod = gi();
	if (n < m) swap(n, m);
	init();

	int cur = 0;
	f[0][0][0] = 1;
	for (int k = 1; k <= t; ++k) {
		cur ^= 1; memset(f[cur], 0, sizeof(f[cur]));
		for (int j = 0; j <= m; ++j)
			for (int i = 0; i <= n; ++i) tr[j][i] = (ll)pw[k][i * (m - j)] * pw[t - k + 1][i * j] % mod;
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j)
				if (f[cur ^ 1][i][j]) {
					for (int l = 0; l + i <= n; ++l)
						f[cur][i + l][j] = (f[cur][i + l][j] + (ll)f[cur ^ 1][i][j] * c[i + l][i] % mod * tr[j][l]) % mod;
				}
		cur ^= 1; memset(f[cur], 0, sizeof(f[cur]));
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j) tr[i][j] = (ll)pw[k][j * (n - i)] * pw[t - k + 1][i * j] % mod;
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j)
				if (f[cur ^ 1][i][j]) {
					for (int l = 0; l + j <= m; ++l)
						f[cur][i][j + l] = (f[cur][i][j + l] + (ll)f[cur ^ 1][i][j] * c[j + l][j] % mod * tr[i][l]) % mod;
				}
		cur ^= 1; memset(f[cur], 0, sizeof(f[cur]));
		for (int j = 0; j <= m; ++j)
			for (int i = 0; i <= n; ++i) tr[j][i] = (ll)pw[k][i * (m - j)] * pw[t - k][i * j] % mod;
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j)
				if (f[cur ^ 1][i][j]) {
					for (int l = 0; l + i <= n; ++l)
						if (~l & 1) f[cur][i + l][j] = (f[cur][i + l][j] + (ll)f[cur ^ 1][i][j] * c[i + l][i] % mod * tr[j][l]) % mod;
						else f[cur][i + l][j] = (f[cur][i + l][j] + (ll)(mod - f[cur ^ 1][i][j]) * c[i + l][i] % mod * tr[j][l]) % mod;
				}
		cur ^= 1; memset(f[cur], 0, sizeof(f[cur]));
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j) tr[i][j] = (ll)pw[k][j * (n - i)] * pw[t - k][i * j] % mod;
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j)
				if (f[cur ^ 1][i][j]) {
					for (int l = 0; l + j <= m; ++l)
						if (~l & 1) f[cur][i][j + l] = (f[cur][i][j + l] +  (ll)f[cur ^ 1][i][j] * c[j + l][j] % mod * tr[i][l]) % mod;
						else f[cur][i][j + l] = (f[cur][i][j + l] + (ll)(mod - f[cur ^ 1][i][j]) * c[j + l][j] % mod * tr[i][l]) % mod;
				}
	}
	printf("%d\n", f[cur][n][m]);
	
	return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;
public class Main {
  public static void main( String[] args ) {
	  Scanner scan = new Scanner(System.in);
	  int N = scan.nextInt();
	  int A = scan.nextInt();
	  int B = scan.nextInt();
	  int Ncpy = N;
	  int digit = 1;	//桁数
	  while( true ) {
		  if( Ncpy < 10 ) {
			  break;
		  }else {
			  Ncpy /= 10;
			  digit++;
		  }
	  }
	  int hoge = 0;
	  int digit5 = 0;
	  int digit4 = 0;
	  int digit3 = 0;
	  int digit2 = 0;
	  int digit1 = 0;
	  int hoge2 = 0;
	  int hoge3 = 0;
	  int sum = 0;
	  for( int i = 1; i <= N; i++ ) {
		  hoge2 = i;
		  digit5 = i / 10000;
		  hoge2 = hoge2 % 10000;
		  digit4 = hoge2 / 1000;
		  hoge2 = hoge2 % 1000;
		  digit3 = hoge2 / 100;
		  hoge2 = hoge2 % 100;
		  digit2 = hoge2 / 10;
		  digit1 = i % 10;
		  hoge3 = digit5 + digit4 + digit3 + digit2 + digit1;
		  if( A <= hoge3 && hoge3 <= B ) {
			  sum += i;
		  }
	  }
	  System.out.println(sum);
  }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 
lli mod=1000000007;
lli power(lli x, lli y,lli p) 
{ 
    lli res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
lli modInverse(lli n, lli p) 
{ 
    return power(n, p-2, p); 
} 
lli nCrModPFermat(lli n, lli r,lli p) 
{ 
   if (r==0) 
      return 1; 
    lli fac[n+1]; 
    fac[0] = 1; 
    for (lli i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
int main()
{

 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,m,k;
    cin>>n>>m>>k;
    lli sum=0;
    for(lli i=0;i<=n-2;i++)sum=sum % mod+((((n-i-1)*(n-i))/2)*m*m)%mod;
    for(lli i=0;i<=m-2;i++)sum=sum % mod+((((m-i-1)*(m-i))/2)*n*n)%mod;
    sum=sum*(nCrModPFermat(n*m-2,k-2,mod));
	cout<<sum%mod;
    return 0;
}

Measured memory_bytes: 1792