akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

long long freq[1001];
void factorize(int n) {
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      freq[i]++;
      n /= i;
    }
  }
  if (n > 1) freq[n]++;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    factorize(i);
  }
  long long ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= (freq[i] + 1) % mod;
    ans %= mod;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int max(int a, int b, int c)
{
  if (a >= b && a >= c) {
    return a;
  } else if (b >= a && b >= c) {
    return b;
  } else {
    return c;
  }
}

int gcd(int a, int b, int c, int g)
{
  int a_ = a%g;
  int b_ = b%g;
  int c_ = c%g;
  if (a/g*g - a == 0 && b/g*g - b == 0 && c/g*g - c == 0) {
    return g;
  } else {
    return gcd(a, b, c, max(a_, b_, c_));
  }
}

int main()
{
  long ans = 0;
  int K;
  scanf("%d", &K);
  for (int i = K; i > 0; --i) {
    for (int j = i; j > 0; --j) {
      for (int l = j; l > 0; --l) {
        int g = gcd(i, j, l, l);
        if (i == j && j == l) {
          ans += g;
        } else if (i == j || j == l) {
          ans += g*3;
        } else {
          ans += g*6;
        }
      }
    }
  }
  printf("%ld", ans);
}

Measured memory_bytes: 1700
#

import sys
input=sys.stdin.readline

def main():
    num="0123456789"
    A,B=map(int,input().split())
    S=input()
    sn=S[:A]+S[A+1:A+B+1]
    y=1
    for i in sn:
        if not i in num:
            y=0
            break
    if S[A]!="-":
        y=0
    if y==1:
        print("Yes")
    else:
        print("No")
    
if __name__=="__main__":
    main()


Measured memory_bytes: 38384
H,W=map(int,input().split())
s = [['.' for i in range(W+2)] for j in range(H+2)]
f=0
for i in range(H):
 s[i+1] = ['.'] + list(input()) + ['.']
for i in range(H+2):
 if f == 0:
  for j in range(W+2):
   if s[i][j] == '#':
    if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
     f = 1
     print('No')
     break
if f == 0:
 print('Yes')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		long A = Long.parseLong(line[0]);
		long B = Long.parseLong(line[1]);
		
		long fA ;
		long fB ;
		long result ;
		
		if(A>4) {
			if((A-1)%4==3) {
				fA = 0;
			}else if((A-1)%4==0) {
				fA = A-1;
			}else if((A-1)%4==1) {
				fA = 1;
			}else {
				fA = (A-1)^1;
			}
		}else {
			if ((A-1) == 0) {
				fA = 0;
			}else if((A-1) == 1){
				fA = 1;
			}else if((A-1) == 2){
				fA = 3;
			}else {
				fA = 0;
			}
		}
		
		if(B>=4) {
			if(B%4==3) {
				fB = 0;
			}else if(B%4==0) {
				fB = B;
			}else if(B%4==1) {
				fB = 1;
			}else {
				fB = B^1;
			}
		}else {
			if (B == 0) {
				fB = 0;
			}else if(B == 1){
				fB = 1;
			}else if(B == 2){
				fB = 3;
			}else {
				fB = 0;
			}
		}
		
		System.out.println(fA^fB);
	}

}


Measured memory_bytes: 23380
import java.util.Scanner;
import java.util.Arrays;

public class Main { //HDL-style Disjoint Set
	static int N; // int_maxsize > 10000 (constrain)
	static int Q; // int_maxsize > 110000 (worstcase = 10000initial set  + 100000 new set)
	static boolean Com; //com only have two kind;
	static int V1;
	static int V2;
	static int[] S;
	static Scanner scanner;
	public static void main(String[] args){
		scanner = new Scanner(System.in);
		N = scanner.nextInt();
		N = 100000;
		S = new int[N];
		reset();
		Q = scanner.nextInt();
		FSM();
	}
	//end of main
	private static void reset(){
		Com = false;
		V1 = 0;
		V2 = 0;
		for(int i = 0; i<N; i++){
			S[i]=i;
		}
	}
	//end of reset
	private static void FSM(){
		while(Q>0){
			fetch();
			dispatch();
			Q--;
		}
	}
	//end of FSM
	private static void fetch(){
		Com = (scanner.nextInt() > 0)?true:false;
		V1 = scanner.nextInt();
		V2 = scanner.nextInt();
	}
	//end of feteh
	private static void dispatch(){
		if(Com){
			same();
		}else {
			unite();
		}
	}
	//end of dispatch
	private static void unite(){
		if(S[V1] == S[V2]){
			return;
		}else{
			merge();
		}
	}
	//end of unite
	private static void same(){
		if(S[V1] == S[V2]){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
	//end of same
	private static void merge(){
		V1 = S[V1];// use variable 1 to store the set code of V1
		V2 = S[V2];// use variable 2 to store the set code of V2
		for(int i = 0; i< N;i++)
		{
			if(S[i] == V1){
				S[i] = V2;
			}else{
				continue;
			}
		}
	}
}	



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll calc(ll x, ll s, ll t) {
    return abs(x - s) + abs(s - t);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> S(1, -INF), T(1, -INF);
    REP(i, A) {
        ll s;
        cin >> s;
        S.push_back(s);
    }
    REP(i, B) {
        ll t;
        cin >> t;
        T.push_back(t);
    }
    S.push_back(INF);
    T.push_back(INF);

    REP(i, Q) {
        ll x;
        cin >> x;
        auto s0 = lower_bound(S.begin(), S.end(), x);
        auto t0 = lower_bound(T.begin(), T.end(), x);
        auto s1 = s0--;
        auto t1 = t0--;

        ll ans = std::min({calc(x, *s0, *t0), calc(x, *t0, *s0), calc(x, *s1, *t0), calc(x, *t0, *s1),
                           calc(x, *s0, *t1), calc(x, *t1, *s0), calc(x, *s1, *t1), calc(x, *t1, *s1)});

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

Measured memory_bytes: 3060
//  main.cpp
//  ABC174F2
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Binary Indexed Tree (Fenwick Tree)
//    使い方 :    BIT<int>bit
//                BIT<int> bt(n + 1); BITを初期化して
//                 bt.add(x, 1); xに1を加算
//                bt.sum(x); 0～xの累積和
template<typename T> // T: type of cost
struct BIT {
private:vector<T> array;
    const int n;
public:BIT(int _n):array(_n+1,0),n(_n) {}
    // iまでの累積和
    T sum(int i) {
        T x = 0;
        while(i>0){
            x += array[i];
            i-=i&-i; // LSBからの減算
        }
        return x;
    }
    // iからjの区間和
    T sum(int i,int j){
        T ret_i=sum(i-1);
        T ret_j=sum(j);
        return ret_j-ret_i;
    }
    // i番目にxを追加
    void add(int i, T x) {
        while(i<=n) {
            array[i] += x;
            i+=i&-i; // LSBへの加算
        }
    }
};

int main(int argc, const char * argv[]) {
    int n, q;
    cin >> n >> q;
    vector<int>c(n + 1);
    vector<int>p(n + 1, -1); // -1で初期化しておく
    vector<int> st(n + 1,0);
    // st(s)=t  左がsで右がtの矢印
    // ２回目の登場以降ならiをtとして登録
    for (int i = 1; i <= n; i++) {
        cin >> c.at(i);
        if (p.at(c.at(i)) != -1) {
            st.at(p.at(c.at(i)))=i;
        }
            p.at(c.at(i)) = i;
    }
    /*rep(i,n){
        cout<<i<<" "<<st.at(i)<<endl;
    }*/
    // クエリを整理する
    // q(l)=(r,i) q(左端)=(右端、読み込みの順番)
    int l, r;
    vector<int>len(q);
    vector<vector<P>> query(n+1,vector<P>()); // lの値によってクエリを整理する
    rep(i, q) {
        cin >> l >> r;
        query.at(l).emplace_back(r,i);
        len.at(i)=r-l+1;
    }
    /*for(int i=n-1;i>=0;i--){
        for(auto& x:query.at(i)){
            cout<<i<<" "<<x.first<<" "<<x.second<<endl;
        }
    }*/
 // BITを使う
    vector<int> cnt(q);
    BIT<int> bt(n + 1); // BITを初期化
    for (int s = n; s >= 1; s--) {
        if (st.at(s) > 0) {
            bt.add(st.at(s), 1);
        }
        for(auto& x:query.at(s)){
            cnt.at(x.second)=bt.sum(x.first);
        }
    }
    rep(i, q) {
        cout << len.at(i)-cnt.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 37172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    }



    public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;int64_t m=998244353,N,a,b,c,i,V[1<<20],f[1<<20],R[1<<20];main(){for(cin>>N;i<N;cin>>a>>b,a+=1e9,R[i++]=(a<<32)+a+b);for(sort(R,R+N);a=i--;c+=V[f[i]=a]+1)for(V[a]=c%m;a<N&R[a]<R[i]<<32;a=f[a]);cout<<(c+1)%m;}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, w; std::cin >> h >> w;
  string grid[h]; rep(i, h) std::cin >> grid[i];
  bool isPossible = true;
  int cnt = 0;
  rep(i, h) rep(j, w) cnt += (grid[i][j] == '#');
  if (cnt != h + w - 1) isPossible = false;
  vi que;
  que.pb(0);
  rep(i, que.size()) {
    int x = que[i] % w, y = que[i] / w;
    grid[y][x] = '.';
    srep(dx, -1, 2) srep(dy, -1, 2) {
      int nx = x+dx, ny = y+dy;
      if (dx * dx + dy * dy != 1) continue;
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if (grid[ny][nx] == '.') continue;
      if (nx == -1 || ny == -1) isPossible = false;
      que.pb(ny * w + nx);
    }
  }
  std::cout << (isPossible ? "Possible" : "Impossible") << "\n";
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a<b) swap(a,b);
	if((a-b)&1)
		cout<<"IMPOSSIBLE"<<endl;
	else
		cout<<(a+b)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
n,c,k=gets.split.map(&:to_i)
t=[]
n.times.each do
    t<<gets.to_i

end
#条件として最初に人が来てからk分たつもしくは乗客がc人になると発車
t.sort!
count=0
limit=t[0]+k
onbus=1
for i in 1..t.length-1
    v=t[i]
    onbus+=1
    if onbus>c || t[i]>limit
        count+=1
        onbus=1
        limit=t[i]+k
    end
    
end

if onbus>0
p count+1
else
p count
end


Measured memory_bytes: 16400
import Foundation
let n = Int(readLine()!)!
if n < 3 {
  print(0)
  exit(0)
}
let l = readLine()!.split(separator: " ").map { Int($0)! }

var count = 0
for a in 0..<n-2 {
  for b in a+1..<n-1 {
    for c in b+1..<n {
      if l[a] != l[b] && l[b] != l[c] && l[a] != l[c] && l[a] + l[b] > l[c] && l[b] + l[c] > l[a] && l[c] + l[a] > l[b] {
        count += 1
      }
    }
  }
}
print(count)

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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int K;

int main(){
    cin >> K;

    int odd = (K + 1) / 2;
    int even = K / 2;

    cout << odd * even << endl;
}

Measured memory_bytes: 256
from collections import deque

def main():
    S = input()
    Q = int(input())
    cnt = 0
    dS = deque(S)
    for _ in range(Q):
        query = input()
        if query[0] == '1':
            cnt += 1
        else:
            A, F, C = query.split()
            if cnt % 2 == 0:
                if F == '1':
                    dS.appendleft(C)
                else:
                    dS.append(C)
            else:
                if F == '1':
                    dS.append(C)
                else:
                    dS.appendleft(C)

    if cnt % 2 == 0:
        print(*dS, sep ="")
    else:
        dS.reverse()
        print(*dS, sep ="")





if __name__ == "__main__":
    main()

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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}
};

int main()
{
	std::string S;
	std::cin >> S;
	int sum{};
	int ten{1};
	std::vector<int> table;
	for (int i{(int)S.size() - 1}; i >= 0; i--)
	{
		if (isdigit(S[i])) sum = (sum + ten * (S[i] - '0')) % 13;
		else table.push_back(ten);
		ten = ten * 10 % 13;
	}
	using Mint = ModInt<>;
	using vi = std::vector<Mint>;
	using vvi = std::vector<vi>;
	vvi dp(table.size() + 1, vi(13));
	dp[0][sum] = Mint(1ll);
	for (int t_i{}; t_i < (int)table.size(); t_i++)
		for (int mod_i{}; mod_i < 13; mod_i++)
			for (int digit{}; digit < 10; digit++)
				dp[t_i + 1][(mod_i + digit * table[t_i]) % 13] += dp[t_i][mod_i];
	
	std::cout << dp.back()[5] << std::endl;

	return 0;
}

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

int main(){

int a,b,c,d,e,f;

cin >> a >> b >> c >> d >>e >> f;
if(a + 5*b + c*10 + d*50 + e*100 + f*500 >= 1000){
cout << "1\n";
}
else{
cout << "0\n";
}


return 0;
}

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

using namespace std;
using ll = long long;

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

    int rate_difference = 100 * (10 - n);

    if (n < 10) {
        cout << r + rate_difference << endl;
    }
    else {
        cout << r << endl;
    }
    return 0;
}

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

int n = 10,h,w;
int dist[10][10];
int cost[10];
vector<bool>used(10,false);
void dijkstra(int g){
  int x, y, min;
  for(x = 0; x < n; x++){
    cost[x] = INF;
    used[x] = 0;
  }
  cost[g] = 0;
  while(1){
   min = INF;
   for(x = 0; x < n; x++){
    if(!used[x] && min > cost[x]) min = cost[x];
   }
   if(min == INF) break;
   for(y = 0; y < n; y++){
    if(cost[y] == min){
     for(x = 0; x < n; x++){
      if(cost[x] > dist[x][y] + cost[y])
       cost[x] = dist[x][y] + cost[y];
       used[y] = true;
     }
    }
   }
  }
}

int main() {
  int ans = 0;
  cin >> h >> w;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++) cin >> dist[i][j];
  }
  dijkstra(1);
  for(int i = 0;i < h*w;i++){
    int a;
    cin >> a;
    if(a == -1) continue;
    ans += cost[a];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
rank = len(str(n))
first = int(str(n)[0])

ans = 0

for i in range( rank ):
    if i % 2 != 0:
        ans += 9 * 10 ** (i-1)
if rank % 2 != 0:
    ans += ( first - 1 ) * (10 ** (rank-1))
    ans += n - first * ( 10 ** (rank-1) ) + 1
print ( ans )

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
	int[] sn = new int[N+1];
	for(int i=0;i<N-1;i++){
	    sn[ sc.nextInt() ]++;
	}
	for(int i=1;i<=N;i++){
	    System.out.println(sn[i]);
	}
    }			    
}


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

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

	std::cin >> N;

	int sum = 0;
	std::string str = std::to_string(N);
	for (int i = 0; i < str.length(); ++i) {
		sum += (int)(str[i] - '0');
	}

	if (N % sum == 0) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a, b;
			String op;
			while (true) {
				a = sc.nextInt();
				op = sc.next();
				b = sc.nextInt();
				if (op.equals("?")) {
					break;
				}
				System.out.println(calc(a, op, b));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static int calc(int a, String op, int b) {
		switch (op) {
		case "+":
			return a + b;
		case "-":
			return a - b;
		case "*":
			return a * b;
		case "/":
			return a / b;
		default:
			throw new RuntimeException();
		}
	}
}

Measured memory_bytes: 26288
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	ll ans = 1;
	FOR(i, 1, n + 1)
	{
		ans *= i;
		ans %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

// friend ostream & operator << (ostream &out, const Complex &c); 
// friend istream & operator >> (istream &in,  Complex &c); 


int a[200005];
int mp[1000001];
void solve()
{
 
int n;
cin >> n;

forf(i,0,n) cin >> a[i] , mp[a[i]]++;

int an = 0;
forf(i,0,n)
{
  int is=1;
  for(int j=1;j*j<=a[i];j++)
  if(a[i]%j==0)
  {
    if(mp[j]>0)
    {
      if(j==a[i] && mp[j]>1) is=0;
      else if(j!=a[i] && mp[j]>0) is=0;
    }

    if(mp[a[i]/j]>0)
    {
      if(j==1 && mp[a[i]/j]>1) is=0;
      else if(j!=1 && mp[a[i]/j]>0) is=0;
    }

    
  }
  if(is) an++;
}

cout<<an<<endl;

}


int32_t main()
{
 // pr_init();
  fastio;
  solve();

 }
      
      

Measured memory_bytes: 12848
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;

typedef long long int ll;

int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   bool takashi=true;
   while(a>0&&c>0)
   {
       if(takashi)
       {
           c-=b;
         takashi =false;
       }
       else
       {
        a-=d;
        takashi=true;
       }

   }
   if(a>0)
   cout<<"Yes\n";
   else
    cout<<"No\n";


}


Measured memory_bytes: 3620
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	String s;

	void run(){
		for(; sc.hasNextLine();){
			s=sc.nextLine();
			solve();
		}
	}

	void solve(){
		s=s.toUpperCase().replaceAll("[^A-Z]", "");
		int n=s.length();
		TreeSet<String> set=new TreeSet<String>();
		for(int j=0; j<n; j++){
			int i;
			for(i=0; j-i>=0&&j+i<n&&s.charAt(j-i)==s.charAt(j+i); i++);
			i--;
			if(i>=1){
				set.add(s.substring(j-i, j+i+1));
			}
			for(i=0; j-i>=0&&j+i+1<n&&s.charAt(j-i)==s.charAt(j+i+1); i++);
			i--;
			if(i>=1){
				set.add(s.substring(j-i, j+i+2));
			}
		}
		// debug(set.toArray());
		// ABCBABCBBB
		// BBBBBBBBBBBBBBBBBBBBB
		// ABABABABABA
		for(Iterator<String> i=set.iterator(); i.hasNext();){
			// iツづーツ湘つキツつゥツづつ、ツつゥ
			String s=i.next();
			for(Iterator<String> j=set.iterator(); j.hasNext();){
				String t=j.next();
				if((s.length()+t.length())%2==0&&t.length()>s.length()){
					int k=(t.length()-s.length())/2;
					if(t.substring(k, t.length()-k).equals(s)){
						i.remove();
						break;
					}
				}
			}
		}
		// debug(set.toArray());
		for(; !set.isEmpty();){
			print(set.pollFirst());
			if(!set.isEmpty()){
				print(" ");
			}
		}
		println("");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
n,x,y=map(int,input().split())
ans=[0]*(n)
for i in range(1,n+1):
  for j in range(i+1,n+1):
    dist1=j-i
    dist2=abs(x-i)+abs(y-j)+1
    ans[min(dist1,dist2)]+=1
for val in ans[1:]:
  print(val)

Measured memory_bytes: 3444
k,n=map(int,input().split())
a=list(map(int,input().split()))

ans=[]
for i in range(n-1):
    ans.append(a[i+1]-a[i])

ans.append(k-a[-1]+a[0])
#print(ans)
ans.sort()

print(sum(ans[:-1]))

Measured memory_bytes: 26444
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int q;
  cin >> q;
  while (q--) {
    string x, y;
    cin >> x >> y;
    int n = x.size(), m = y.size();
    vector<vector<int> > dp(n + 1, vector<int>(m + 1));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (x[i] == y[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }
    cout << dp[n][m] << endl;
  }
  return 0;
}


Measured memory_bytes: 6772
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int n,x,y,z;
int end;
int sum;
long long dp[45][1<<18];
long long ans=1,mod=1e9+7;

int main()
{
	//freopen("haiku.txt","r",stdin);
	scanf("%d%d%d%d",&n,&x,&y,&z);
	memset(dp,0,sizeof dp);
	end=1<<x+y+z-1;
	end=end|(1<<y+z-1);
	end=end|(1<<z-1);
	sum=(1<<(x+y+z))-1;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		ans*=10;
		ans%=mod;
		for(int j=0;j<=sum;j++)
		{
			if(dp[i-1][j]==0) continue;
			for(int k=1;k<=10;k++)
			{
				int now=(j<<k)|(1<<k-1);
				now&=sum;
				if((now&end)!=end)
					dp[i][now]=(dp[i][now]+dp[i-1][j])%mod;
			}
		}
	}
	for(int j=0;j<=sum;j++)
		ans=(ans-dp[n][j]+mod)%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 92544
d=gets.to_i
a=d/100
b=d%100
if (b<1||b>12)&&(a<1||a>12)
  puts 'NA'
elsif b<1||b>12
  puts 'MMYY'
elsif a<1||a>12
  puts 'YYMM'
else
  puts 'AMBIGUOUS'
end


Measured memory_bytes: 14300
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
    if (ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum=0, p=1, i;
    for (i=0; i<strlen(str); i++) {
        sum += p*getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1+(key%(M-1)); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i=0; ; i++) {
        h = (h1(key) + i+h2(key)) % M;
        if( strcmp(H[h], str) == 0) return 1;
        else if( strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i=0; ; i++) {
        h = (h1(key) + i+h2(key)) % M;
        if( strcmp(H[h], str) == 0) return 1;
        else if( strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i=0; i<M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%s %s", com, str);
        
        if(com[0] == 'i') {
            insert(str);
        } else {
            if(find(str)) {
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17060
#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,k;
    long long int flag=999999999999999999;
    scanf("%lld %lld",&n,&k);
    if(k>=n)
        printf("unsafe\n");
    else 
        printf("safe\n");
    return 0;
}

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

using namespace std;

#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<si> vsi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vsi> vvsi;

const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;
ll mod = (int)pow(10,9)+7;
// ll mulmod(ll a, ll b, ll mod) 
// { 
//     ll res = 0; // Initialize result 
//     a = a % mod; 
//     while (b > 0) 
//     { 
//         // If b is odd, add 'a' to result 
//         if (b % 2 == 1) 
//             res = (res + a) % mod; 
  
//         // Multiply 'a' with 2 
//         a = (a * 2) % mod; 
  
//         // Divide b by 2 
//         b /= 2; 
//     } 
  
//     // Return result 
//     return res % mod; 
// } 
// bool sieve[100005];

// void sieveoferat()
// {
// 	for(ll p = 2; p*p<100005 ; p++)
// 	{
// 		if(sieve[p])
// 		{
// 			for(int j = p*p; j<100005; j+=p)
// 				sieve[j] = false;
// 		}
// 	}
// }

// void dp(sp_1, sp_2.....)
// {
// 	if()//exit statement
// 	if()//using the memoization 
// 	ll ans = //default/dummy answer
// 	//recursions
// 			//max/min
// 	return memo[][].. = ans;

// }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	//memset(memo, -1, sizeof memo);
 	// memset(sieve, true, sizeof sieve);
 	// sieveoferat();
 	ll n, l; cin>>n>>l;
 	if(l>=0)
		{
			ll count= 0;
			for(int i = 2; i<=n;i++)
		 		count+=(l+i-1);
		 	cout<<count<<endl;
		 }
	else
	{
		ll count= 0;
		if(1-l<=n)
		{
			
			for (int i = 1; i <=n; ++i)
				count+=(l+i-1);
		}
		else
		{
			for(int i = 1; i<n ;i++)
				count+=(l+i-1);
		}
		cout<<count<<endl;
	}


 	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

int A[10][10], B[10][10];
int N;
void solve() {
	REP(i, 3)REP(j, 3)cin >> A[i][j];
	cin >> N;
	REP(_, N) {
		int x; cin >> x;
		REP(i, 3)REP(j, 3) {
			if (A[i][j] == x)B[i][j] = 1;
		}
	}
	bool found = false;
	REP(i, 3) {
		bool ok = true;
		REP(j, 3)if (B[i][j] == 0)ok = false;
		if (ok)found = true;
	}
	REP(j, 3) {
		bool ok = true;
		REP(i, 3)if (B[i][j] == 0)ok = false;
		if (ok)found = true;
	}
	bool ok = true;
	REP(i, 3)if (B[i][i] == 0)ok = false;
	if (ok)found = true;
	ok = true;
	REP(i, 3)if (B[i][2 - i] == 0)ok = false;
	if (ok)found = true;
	if (found)print("Yes");
	else print("No");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int n,m1,m2;
    char d[8];
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<8;j++)cin>>d[j];
        sort(d,d+8);
        m1=atoi(d);
        sort(d,d+8,greater<int>());
        m2=atoi(d);
        cout<<m2-m1<<endl;
    }
}

Measured memory_bytes: 1188
import numpy as np

a,b,x=map(int,input().split())
S=a**2*b-x

if a**2*b/2 <= x:
    z=S*2/(a**2)
    rad=np.arctan(z/a)
else:
    z=x*2/(a*b)
    rad=np.arctan(b/z)
print(np.rad2deg(rad))


Measured memory_bytes: 15352
import numpy
n,k=map(int,input().split())
a=list(map(int,input().split()))
d=max(a)
def p(x):
    return len(bin(x))-2
e=p(k)
f=p(d)
h=[]
if e>=f:
    for i in range(n):
        l=bin(a[i])
        h.append(list("0"*(e-len(l)+2)+l[2:]))
else:
    for i in range(n):
        l=bin(a[i])
        h.append(list("0"*(f-len(l)+2)+l[2:]))
p=numpy.array(h)
p=p.T
p=p.tolist()
c=0
if k==0:
    print(sum(a))
else:
    ans=0
    for i in range(len(p)):
        o=p[i].count("1")
        if o<n/2 and k>=2**(len(p)-i-1):
            c+=(n-o)*(2**(len(p)-i-1))
            k-=2**(len(p)-i-1)
        else:
            c+=o*(2**(len(p)-i-1))
    print(c)

Measured memory_bytes: 110596
#include<cstdio>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
   int n,a[1000],ans;
    cin >> n;
    for(int i;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    ans = a[n-1]-a[0];
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
    int k, n; cin >> k >> n;
    int a[n+1], d[n+1];
    for(int i=0; i<n; ++i){cin >> a[i];}
    for(int i=0; i<n; ++i){
        if(i==n-1){
            d[i] = a[0] + (k - a[i]);
        }else{
            d[i] = a[i+1] - a[i];
        }
    }
    int ans = 1000000;
    for(int i=0; i<n; ++i){
        int D = k - d[i];
        ans = min(ans, D);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
s = [[int(i) if str.isnumeric(i) else i for i in input().split()] for i in range(n)]

k = 1
for row in s:
    row.append(k)
    k += 1

s.sort(reverse=True)
s.sort(key=lambda x: x[0])

for i in range(n):
    print(s[i][2])


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 1500

	
int str_length(char s[])
{
	int len = 0;
	
	while (s[len]) {
		len++;
	}
	
	return len;
}
void lcs( char X[], char Y[]) 
{
	int c[MAX][MAX];
	int m, n, i, j;
	int maxlcs = 0;
	
	m = str_length(X);
	n = str_length(Y);
	

	for (i = 0; i <= m; i++) {
		c[i][0] = 0;
	}
	
	for (j = 1; j <= n; j++) {
		c[0][j] = 0;
	}
	for (i = 1; i <= m; i++) {
		for (j = 1; j <= n; j++ ) {
			if (X[i-1] == Y[j-1]) {
				c[i][j] = c[i - 1][j - 1] + 1;
				
			}
			else if (c[i - 1][j] > c[i][j - 1]) {
				c[i][j] = c[i - 1][j];
			}
			else {
				c[i][j] =  c[i][j - 1];
			}
			if (maxlcs <= c[i][j]) {
				maxlcs = c[i][j];
			}
		}
	}
	printf("%d\n",maxlcs);
}


int main() 
{
	int i, n;
	char x[MAX][MAX], y[MAX][MAX];
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%s",x[i]);
		scanf("%s",y[i]);
		
	}
	
	for (i = 0; i < n; i++) {
		lcs(x[i], y[i]);
	
	}
	
    return 0;
}


Measured memory_bytes: 7620
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

/*
 public class arc086a {

 }

 */
public class Main {
  class a {
    int num;
    int cnt;

    /**
     * @param num
     * @param cnt
     */
    public a(int num, int cnt) {
      super();
      this.num = num;
      this.cnt = cnt;
    }


  }

  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int n = in.readInteger();
    int k = in.readInteger();

    int[] a = new int[n];

    Map<Integer, Integer> map = new HashMap<Integer, Integer>();

    for (int i = 0; i < n; i++) {
      a[i] = in.readInteger();
      map.put(a[i], map.getOrDefault(a[i], 0) + 1);
    }

    List<a> al = new ArrayList<a>();

    for (Integer key : map.keySet()) {
      al.add(new a(key, map.get(key)));
    }

    al.sort((a1, a2) -> a1.cnt - a2.cnt);

    if (al.size() <= k) {
      System.out.println("0");
      return;
    }

    int ans = 0;
    for (int i = 0; i < al.size() - k; i++) {
      ans += al.get(i).cnt;
    }

    System.out.println(ans);
    // end here
  }

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

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


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

int main(void){
    int a = 0, b = 0, c = 0; 

    scanf("%d%d%d", &a, &b, &c);

    /*
    if(a % 2 == 0 && b % 2 == 0 && c % 2 == 1){
        printf("NO\n");
        return 0;
    }
    */

    for(int i = 1; i <= b; i++){
        if(a * i % b == c){
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");

    return 0;

} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;

int n,m,c[5];

bool check(int x)
{
    vector<int>digit;
    while(x)
    {
        digit.push_back(x%10);
        x/=10;
    }
    reverse(digit.begin(),digit.end());
    for(int i=0;i<digit.size();i++) if(c[i+1]!=-1&&digit[i]!=c[i+1]) return false;
    return true;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(c,-1,sizeof c);
    cin>>n>>m;
    while(m--)
    {
        int pos,val;
        cin>>pos>>val;
        if(c[pos]!=-1&&c[pos]!=val) return cout<<-1,0;
        c[pos]=val;
    }
    if(n==1)
    {
        if(c[1]==-1||c[1]==0) return cout<<0,0;
    }
    int lim=1;
    for(int i=1;i<=n;i++) lim*=10;
    for(int i=lim/10;i<lim;i++) if(check(i)) return cout<<i,0;
    cout<<-1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[1010][1010];

//long longしか使わない
int main() {
	ll n;
	cin >> n;
	cout << n;
	cout << ":";
	ll target = sqrt(n);
	ll i = 2;
	while (i <= target&&n>1) {
		if (n % i == 0) {
			cout << " " << i;
			n /= i;
		}
		else {
			i++;
		}
	}
	if (n != 1) {
		cout << " " << n;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3112
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        if j==i+1:
            delta=bisect_left(ll,ll[i]+ll[i+1],lo=i+1)-i-2
            if delta>0:
                ans+=delta
            in_b=delta+i+1+1
        else:
            if in_b!=N:
                delta=bisect_left(ll,ll[i]+ll[j],lo=in_b)-j-1
            else:
                delta=N-j-1
            if delta>0:
                ans+=delta
            in_b=delta+j+1
print(ans)


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

static const int N=100;

static const int WHITE=0;

static const int GRAY=1;

static const int BLACK=2;





//用栈实现深度优先搜索


/**
 * color 标记访问状态的数组，
 * M[N][N] 邻接矩阵 如果存在定点i到顶点j的边，则M[i][j]=trul
 * Stack 栈，暂存访问过程中的顶点
**/
int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];


//按序号，获取和u相邻的v
int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

//用栈实现深度优先搜索
void dfs(int r){
    for(int i=0;i<n;i++) nt[i]=0;

    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);

        if(v!=-1){
            if(color[v]==WHITE){
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }

}

void dfs(){
    //初始化
    for(int i=0;i<n;i++){
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;

    for(int u=0;u<n;u++){
        if(color[u]==WHITE)
            dfs(u);
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    return;
}
int main(){
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;

        u--;
        for(int i=0;i<k;i++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }

    dfs();
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A,B;

int mod_pow(int b,int e,int m){
    if(e==0){
        return 1;
    }else{
        int sum = mod_pow(b,e/2,m);
        if(e%2==0){
            return (sum*sum)%m;
        }else{
            return (((sum*sum)%m)*b)%m;
        }
    }
}

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

signed main(){
	cin>>N>>A>>B;
	int ans=0;
	ans=mod_pow(2,N,MOD)-1;
	DEB(ans)END
	int s=1,k=1;
	for(int i=1;i<=A;i++){
		k*=i;
		k%=MOD;
	}
	for(int i=N;N-A+1<=i;i--){
		s*=i;
		s%=MOD;
	}
	DEB(s)DEB(k)END
	int R=s*mod_inverse(k,MOD);
	R%=MOD;
	DEB(R)END
	s=1,k=1;
	for(int i=1;i<=B;i++){
		k*=i;
		k%=MOD;
	}
	for(int i=N;N-B+1<=i;i--){
		s*=i;
		s%=MOD;
	}
	int R2=s*mod_inverse(k,MOD);
	R2%=MOD;
	int sum=R+R2;
	sum%=MOD;
	ans=(ans-sum+MOD)%MOD;
	cout<<ans<<endl;
	return 0;
}


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

#define DATASIZE (100000)

int top,stackArray[DATASIZE];

void push(int a){
    if(top==DATASIZE-1){
        return;
    }
    top++;
    stackArray[top]=a;
    return;
}

int pop(){
    top--;
    return stackArray[top+1];
}

int main(void){
    char str[100];
    int a,b;
    top=0;
    while(scanf("%s",str)!=EOF){
        if(str[0]=='+'){
            a=pop();
            b=pop();
            push(b+a);
        }else if(str[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }else if(str[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(str));
        }
    }
    printf("%d\n",pop());
    return 0;
}



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

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

    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;

    if (s == u) a--;
    else b--;

    cout << a << " " << b << endl;
    
    return 0;
}

Measured memory_bytes: 256