akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX1 10000
#define MAX2 500


int line_search(int p[], int N1, int key){
	
	for(int i=0;i<N1;i++){
		if(p[i]==key){
			int tmp=p[i];
			for(int j=i;j<N1-1;j++){
				p[j]=p[j+1];
			}
			p[N1-1]=tmp;
			return i;
		}
	}
	
	return -1;
}

int main(void){
	
	int N1,N2,key;
	int p[MAX1];
	int cnt=0;
	
	scanf("%d",&N1);
	
	for(int i=0;i<N1;i++){
		scanf("%d",&p[i]);
	}
	
	scanf("%d",&N2);
	
	for(int i=0;i<N2;i++){
		scanf("%d",&key);
		
		int ans=line_search(p,N1,key);
		if(ans!=-1){
			cnt++;
		}
	}
	
	printf("%d\n",cnt);
	
	
	return 0;
	
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long LU;
const LL mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL n, num, ans = 0;
    cin >> n;
    num = n;
    while (n % 2 == 0 && num)
    {
        num /= 5;
        ans += num / 2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rep1(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  string s; cin >> s;
  ll ans=0;
  for(auto c:s){
    if(c=='-')ans--;
    else ans++;
  }
  cout << ans;
  return 0;
}


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


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

int N;
ll L[110];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> L[i];
    
    int ans = 0;

    for (int i = 0; i < N-2; i++) {
        for (int j = i+1; j < N-1; j++) {
            for (int k = j+1; k < N; k++) {
                if (L[i] + L[j] > L[k] && L[k] + L[j] > L[i] && L[i] + L[k] > L[j]) {
                    if (L[i] != L[j] && L[i] != L[k] && L[k] != L[j]) {
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
package main
import(
  "fmt"
  "math"
)
func main(){
  var t, a, temp float64
  var i, n, ans int
  fmt.Scan(&n, &t, &a)
  tmp:=100001.0
  h:=make([]float64, n)
  for i=0;i<n;i++{
    fmt.Scan(&h[i])
    temp=t-(h[i]*0.006)
    if math.Abs(a-temp)<tmp{
      ans=i+1
      tmp=math.Abs(a-temp)
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
/// Thank you tanakh!!!
///  https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::VecDeque;

fn main() {
    input!(n: usize, m: usize, s: chars, edges: [(usize1, usize1); m]);

    let s: Vec<usize> = s.iter().map(|&c| if c == 'A' { 0 } else { 1 }).collect();
    let mut graph = vec![vec![]; n];
    let mut count = vec![vec![0; 2]; n];
    for i in 0..m {
        let (from, to) = edges[i];
        graph[from].push(to);
        graph[to].push(from);
        count[from][s[to]] += 1;
        count[to][s[from]] += 1;
    }

    let mut vis = vec![false; n];
    let mut q = VecDeque::new();
    for i in 0..n {
        if count[i][0] == 0 || count[i][1] == 0 {
            vis[i] = true;
            q.push_back(i);
        }
    }

    while let Some(i) = q.pop_front() {
        for &next in graph[i].iter() {
            if vis[next] {
                continue;
            }
            count[next][s[i]] -= 1;
            if count[next][s[i]] == 0 {
                vis[next] = true;
                q.push_back(next);
            }
        }
    }
    for &vis in vis.iter() {
        if !vis {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 35000
import java.util.Scanner;

public class Main {

	public static void main(String[]args) {
		int x = 0;
		int y = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		for(int i = 0; i < n; i++) {
			if('I' == s.charAt(i)) {
				y += 1;
			}else if('D' == s.charAt(i)){
				y -= 1;
			}
			x = Math.max(y, x);
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stack>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define SIZE 2048

struct P{
  int x,y;
  P(int x1, int y1){x=x1,y=y1;}
};

int compress(vector<int> &x1, vector<int> &x2, int W){
  vector<int> xs;
  unsigned int size = x1.size();
  for(int i=0; i<size; i++){
    for(int d=-1; d<=1; d++){
      int tx1 = x1[i] + d, tx2 = x2[i] + d;
      if(0<=tx1 && tx1 <=W) xs.push_back(tx1);
      if(0<=tx2 && tx2 <=W) xs.push_back(tx2);
    }
  }
  sort(all(xs));
  xs.erase(unique(all(xs)), xs.end());
  int end = 0;

  for(int i=0; i<size; i++){
    x1[i] = find(all(xs), x1[i]) - xs.begin();
    x2[i] = find(all(xs), x2[i]) - xs.begin();
    if(end<x2[i])
      end = x2[i];
  }
  return xs.size()-1;
}

void dfs(bool Map[SIZE][SIZE], P start, int W, int H){
  static const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
  stack<P> st;
  st.push(start);
  while(st.size()){
    P s = st.top();
    st.pop();
    rep(i, 4){
      P t = P(s.x+dx[i], s.y+dy[i]);
      if(t.y>=0 && t.x>=0 && t.y<H && t.x<W && Map[t.y][t.x]==false){
	Map[t.y][t.x]=true;
	st.push(t);
      }
    }
  }
}

bool board[SIZE][SIZE];

int main(){
  int W,H,N;
  while(cin>>W>>H, W|H){
    cin>>N;    
    vector<int> x1, x2, y1, y2;
    rep(i,N){
      int a, b, c, d;
      cin>>a>>b>>c>>d;
      x1.push_back(a);y1.push_back(b);
      x2.push_back(c);y2.push_back(d);
    }

    W = compress(x1, x2, W);
    H = compress(y1, y2, H);
    memset(board, 0, sizeof(board));
    rep(i, N){
      for(int y=y1[i]; y<y2[i]; y++){
	memset(board[y]+x1[i], 1, x2[i]-x1[i]);
      }
    }

    int count = 0;
    rep(y, H){
      rep(x, W){
	if(board[y][x]==false){
	  count++;
	  dfs(board, P(x, y), W, H);
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 7640
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int N,M;

#define VMAX 100000

vvi V(VMAX+1);//vertex
vi D(VMAX+1);//depth

int dfs(int p){//parent 後置でD設定
	if(D[p]>0) return D[p];
	if(V[p].size()<=0) return 0;
	for(auto c:V[p]){
		D[p] = max(D[p], dfs(c)+1);
	}
	return D[p];
}

int main(){
	cin>>N>>M;

	for(int i=0; i<M; i++){
		int x,y; cin>>x>>y;
		V[x].push_back(y);
	}

	for(int p=1; p<=N; p++){
		if(D[p]<=0) D[0] = max(D[0], dfs(p));
	}
	cout<< D[0] <<endl;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int[] arr = new int[x];
		for(int i = 0; i<x;i++)arr[i]=sc.nextInt();
		boolean works = true;
		int max = arr[0]-1;
		for(int i = 1;i<arr.length;i++) {
			int temp;
			if(arr[i]==max)temp=arr[i];
			else {
				temp = arr[i]-1;	
			}
			if(temp>=max)max = temp;
			else if(temp<max) {
				works = false;
				break;
			}
		}
		
		System.out.println(works?"Yes":"No");

	}

}


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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

ll p5(ll x) {
    return x * x * x * x * x;
}

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

    ll x;
    cin >> x;
    for (int a = -1000; a <= 1000; a++) {
        for (int b = -1000; b <= 1000; b++) {
            ll c = p5(a) - p5(b);
            if (c == x) {
                cout << a << ' ' << b;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;cin>>s;
    int n=s.length();
    int ans=1000;
    for(int i=0;i<=n-3;i++){
        int a=s[i]-'0';
        int b=s[i+1]-'0';
        int c=s[i+2]-'0';
        int x=100*a+10*b+c;
        ans=min(ans,abs(753-x));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, M, K = map(int, readline().split())
    if N == 0:
        return False
    def root(x):
        if prt[x] == x:
            return x
        prt[x] = y = root(prt[x])
        return y
    def unite(x, y):
        px = root(x); py = root(y)
        if px == py:
            return 0
        if px < py:
            prt[py] = px
        else:
            prt[px] = py
        return 1
    E = []
    for i in range(M):
        u, v, w, l = readline().strip().split()
        u = int(u); v = int(v); w = int(w)
        if l == "A":
            E.append((w, u-1, v-1, 0))
        else:
            E.append((w, u-1, v-1, 1))
    E.sort()
    U = [0]*M
    cnt = 0; ec = 0
    ans = 0
    *prt, = range(N)
    for i, (w, u, v, d) in enumerate(E):
        if unite(u, v):
            U[i] = 1
            if d == 0:
                cnt += 1
            ec += 1
            ans += w
    if ec != N-1:
        write("-1\n")
        return True


    if cnt < K:
        m = 0
    else:
        m = 1

    que = deque()
    used = [0]*N; zeros = [0]*N

    G = [[] for i in range(N)]
    for i in range(M):
        if not U[i]:
            continue
        w, u, v, d = E[i]
        if d == m:
            G[u].append((v, 0, -1))
            G[v].append((u, 0, -1))
        else:
            G[u].append((v, w, i))
            G[v].append((u, w, i))

    for t in range(abs(K - cnt)):
        s = 10**18; p = q = -1
        for i in range(M):
            if U[i]:
                continue
            wi, ui, vi, di = E[i]
            if di != m:
                continue
            que.append((ui, 0, -1))
            used[:] = zeros
            used[ui] = 1
            while que:
                u, r, j = que.popleft()
                if u == vi:
                    wj = r
                    break
                for v, w, k in G[u]:
                    if used[v]:
                        continue
                    if k != -1 and r < w:
                        que.append((v, w, k))
                    else:
                        que.append((v, r, j))
                    used[v] = 1
            que.clear()
            if wi - wj < s and j != -1:
                s = wi - wj
                p = i; q = j
        if p == -1:
            write("-1\n")
            return True
        wq, uq, vq, dq = E[q]
        g = G[uq]
        for i in range(len(g)):
            if g[i][0] == vq:
                g.pop(i)
                break
        g = G[vq]
        for i in range(len(g)):
            if g[i][0] == uq:
                g.pop(i)
                break
        wp, up, vp, dp = E[p]
        G[up].append((vp, 0, -1))
        G[vp].append((up, 0, -1))
        U[p] = 1; U[q] = 0
        ans += s
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 6068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,a,b;
    cin>>n>>a>>b;
    ll tmp=n/(a+b);
    cout<<a*tmp+min(a,n-(a+b)*tmp)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << '\n';
}


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

int a[1010101];
int main() {
    int n;
    cin >> n;
    rep(i,n) scanf("%d", &a[i]);

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    if(ggg != 1){
        puts("not coprime");
        return 0;
    }

    //エラトステネスの篩
    const int P_MAX = 1000005;
    vi pmn(P_MAX);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = 3*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    vi cnt(P_MAX,0);
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                puts("setwise coprime");
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    puts("pairwise coprime");
}


Measured memory_bytes: 14904
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,x,ans=0;
ll l,r;
int main(){
	cin>>a>>b>>x;
	if(a!=0)l=(a-1)/x;
	else l=-1;
	r=b/x;
    ans=r-l;
    cout<<ans<<endl;
    return 0;
}

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int n, m, k;
        cin >> n >> m >> k;
        bool ans = false;
        for (int nn = 0; nn <= n; nn ++) {
                for (int mm = 0; mm <= m; mm ++) {
                        if (nn * (m - mm) + mm * (n - nn) == k) ans = true;
                }
        }
        cout << (ans ? "Yes" : "No") << endl;
        return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

// for (int i = 0; i < l.size(); i++) {
    //     for (int j = 0; j < l.size(); j++) {
    //         for (int k = 0; k < l.size(); k++) {
    //             int disA, disB, disC;
    //             if (i == j || j == k || k == i) continue;
    //             else {
    //                 disA = abs(A-l[i]);
    //                 disB = abs(B-l[j]);
    //                 disC = abs(C-l[k]);
    //                 DIS = min(DIS, disA+disB+disC);
    //             }
    //         }
    //     }
    // }

int main() {
    int N;
    cin >> N;
    vector<int> ABC(3);
    for (int i = 0; i < 3; i++) {
        cin >> ABC[i];
    }
    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }

    //全ての竹に対して，Aに使うかBに使うかCに使うか使わないかの四分岐
    //4進数のbit演算，2ビットを使ってやる

    int ans = INF;

    for (int bit = 0; bit < (1 << (2*N)); bit++) {
        vector<vector<int>> vec(4); 
        vector<int> cost(3); // A, B, Cに関するコスト

        for (int i = 0; i < N; i++) {
            vec[(bit >> (2*i)) & 3].push_back(l[i]);
        }

        //vec[i]のサイズが0の時continue
        bool ok = true;
        for (int i = 0; i < 3; i++) {
            if (vec[i].size() == 0) ok = false;
        }
        if (!(ok)) continue;

        //cost計算
        for (int i = 0; i < 3; i++) {
            cost[i] += 10 * (vec[i].size()-1);
            cost[i] += abs(ABC[i] - accumulate(vec[i].begin(), vec[i].end(), 0));
        }

        ans = min(ans, accumulate(cost.begin(), cost.end(), 0));
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, D;
  cin >> N >> D;
  D *= D;

  int ans = 0;
  REP(i, N){
    int x, y;
    cin >> x >> y;

    if(x*x+y*y <= D) ans++;
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3648
from heapq import heappush,heappop

def main():
    inp1=list(map(lambda x:int(x),input().split()))
    cards=list(map(lambda x:int(x),input().split()))
    cards_heap=[]
    for i in cards:
        heappush(cards_heap,i)

    N=inp1[0]
    M=inp1[1]
    B=[]
    C=[]
    for i in range(M):
        changes=list(map(lambda x:int(x),input().split()))
        B.append(changes[0])
        C.append(changes[1])

    cb=zip(C,B)
    cb=sorted(cb,reverse=True)


    for C,B in cb:
        for _ in range(B):
            a=heappop(cards_heap)
            if C>a:
                heappush(cards_heap,C)
            else:
                heappush(cards_heap,a)
                break

    print(sum(cards_heap))

if __name__=="__main__":
    main()

Measured memory_bytes: 24056
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, m, a, b;
    string s;
    cin >> n >> m >> s;
    vector<int> va(n, 0), vb(n, 0);
    vector<vector<int> > v(n);
    map<pair<int, int> , int> mp;
    for(int i=0;i<m;i++){
    	cin >> a >> b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    queue<int> q;
    for(int i=0;i<n;i++){
    	int maki = v[i].size();
    	for(int j=0;j<maki;j++){
    		int to = v[i][j];
    		mp[{i, to}] = j;
    		if(s[to] == 'A') va[i]++;
    		else vb[i]++;
    	}
    	if(va[i] == 0 || vb[i] == 0) q.push(i);
    }
    while(!q.empty()){
    	int now = q.front();
    	q.pop();
    	int maki = v[now].size();
    	for(int i=0;i<maki;i++){
    		int to = v[now][i];
    		if(to == -1) continue;
    		v[now][i] = -1;
    		v[to][mp[{to, now}]] = -1;
    		if(s[now] == 'A'){
    			va[to]--;
    			if(va[to] == 0) q.push(to);
    		}else{
    			vb[to]--;
    			if(vb[to] == 0) q.push(to);
    		}
    	}
    }
    bool ans = false;
    for(int i=0;i<n;i++) for(auto& j: v[i]) if(j != -1) ans = true;
    if(ans) cout << "Yes" << endl;
    else cout << "No"  << endl;
    return 0;
}



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

int main(){
	char S[101];
	char key[]="keyence";
	scanf("%s",S);
	int L=strlen(S);
	
	for(int i=0;i<L;i++){
		for(int j=i;j<L;j++){
			char s[101];
			int c=0;
			for(int k=0;k<L;k++){
				if(i<=k && k<j)continue;
				s[c]=S[k];
				c++;
			}
			s[c]='\0';
			if(strcmp(s,key)==0){
				printf("YES\n");
				return 0;
			}
		}
	}
	
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
s_dict = dict()
for i in range(n):
    a = input()
    if a in s_dict:
        s_dict[a] += 1
    else:
        s_dict.update({a : 1})
maxi = max(s_dict.values())
ans_lst = []
for key, value in s_dict.items():
    if value == maxi:
        ans_lst.append(key)
ans_lst.sort()
for i in ans_lst:
    print(i)

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

int main()
{
  int arr[3];
  cin >> arr[0] >> arr[1] >> arr[2];
  int av[3];
  av[0] = abs(arr[1] - arr[0]);
  av[1] = abs(arr[2] - arr[1]);
  av[2] = abs(arr[2] - arr[0]);
  sort(av, av + 3);
  int sum = av[0] + av[1];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(998244353)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> a, ok_a(m+1, false);
    ll bf = x;
    a.push_back(x);
    ok_a[x] = true;
    while(true){
        bf = (bf*bf) % m;
        if(ok_a[bf])break;
        else a.push_back(bf);
        ok_a[bf] = true;
    }
    vector<ll> b, ok_b(m+1, false);
    b.push_back(bf);
    ok_b[bf] = true;
    while(true){
        bf = (bf*bf) % m;
        if(ok_b[bf])break;
        else b.push_back(bf);
        ok_b[bf] = true;
    }
    if(n <= a.size()){
        ll ans = 0;
        rep(i, n)ans += a[i];
        cout << ans << endl;
    }else{
        n -= a.size();
        ll ans = accumulate(all(a), 0LL);
        ll s = b.size();
        ans += (n/s) * accumulate(all(b), 0LL);
        rep(i, n%s)ans += b[i];
        cout << ans << endl;
    }
}


Measured memory_bytes: 5792
def main():
    N = int(input())
    S = input()
    pre = False
    ans = 0
    for i in range(N-1):
        if pre:
            pre = False
            continue
        if (S[i] == 'O' and S[i+1] == 'X') or (S[i] == 'X' and S[i+1] == 'O'):
            ans += 1
            pre = True
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d,e,i,j,k,l=0;
cin>>a>>b;
if(a>b)
{
c=(a/b);
a=a-(c*b);
//cout<<a<<endl;
l=a;
l=min(abs(a-b),l);
//cout<<l<<endl;
a-=b;
l=min(abs(a-b),l);
cout<<l<<endl;
}
else if(a<b)
{

l=abs(a-b);
l=min(a,l);
a=a-b;
l=min(abs(a-b),l);
cout<<l<<endl;

}
else if(a==b)cout<<"0\n";

}

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

int comp;

void Marge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  static int L[250001], R[250001];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = 1000000001; R[n2] = 1000000001;

  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
      comp++;
    } else {
      A[k] = R[j];
      j++;
      comp++;
    }
  }
}

void MargeSort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    MargeSort(A, left, mid);
    MargeSort(A, mid, right);
    Marge(A, left, mid, right);
  }
}

int main() {
  int n; cin >> n;
  static int S[500000]; for (int i = 0; i < n; i++) cin >> S[i];

  MargeSort(S, 0, n);

  for (int i = 0; i < n; i++) {
    if (i == n - 1) cout << S[i] << endl;
    else cout << S[i] << " ";
  }
  cout << comp << endl;

  return 0;
}


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

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

ll arr[200005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(m);

    slld(n);


    for(i = 1; i <= n; i++)
    {
        slld(arr[i]);
    }

    arr[n + 1] = arr[1] + m;

    ll sum = 0;
    ans = mxlld;

    for(i = 1; i <= n; i ++)
    {
        sum += arr[i + 1] - arr[i];
    }

    ans = sum;

    for(i = 1; i <= n; i++)
    {
        ans = min(ans, sum - (arr[i + 1] - arr[i]));
    }

    cout << ans << endl;

}





Measured memory_bytes: 1792
import Data.List
main = interact $ unlines . map (show . railway_lines . map (read::String->Float) . splitOn ',') . lines

splitOn c xs
 | null xs = []
 | head xs == c = splitOn c (tail xs)
 | otherwise = (takeWhile (/= c)) xs : splitOn c (dropWhile (/= c) xs)

railway_lines xs = head $ findIndices (>= th) $ scanl (+) 0 sections
 where 
  th = (sum sections * v1) / (v1+v2)
  (sections,[v1,v2]) = splitAt 10 xs

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

int main(){
    string n;
    cin >> n;
    bool ans;
    if(n[0] == n[1] && n[1] == n[2]){
        ans = true;
    }else if(n[1] == n[2] && n[2] == n[3]){
        ans = true;
    }else{
        ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var)\
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

uint64_t solve(int n) {
  vector<uint64_t> cache(n + 1, 0);
  cache[0] = cache[1] = 1;
  for (int i = 2; i <= n; ++i) {
    cache[i] = cache[i - 1] + cache[i - 2];
  }
  return cache[n];
}

int main() {
  int n;
  cin >> n;
  uint64_t result = solve(n);
  cout << result << endl;
}

Measured memory_bytes: 3092
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

inline int parent(int n)   { return(n / 2); }
inline int left(int n)     { return(n * 2); }
inline int right(int n)    { return(1 + n * 2); }

int main()
{
   int N;
   int h[256];

   scanf("%d", &N);
   reps(i, 1, N){
      scanf("%d", h + i);
   }

   reps(i, 1, N){
      printf("node %d: key = %d, ", i, h[i] );
      if(parent(i) > 0)printf("parent key = %d, ", h[ parent(i) ]);
      if(left(i) <= N)printf("left key = %d, ", h[ left(i) ] );
      if(right(i) <= N)printf("right key = %d, ", h[ right(i) ] );
      putchar_unlocked('\n');
   }
}




Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
vector<int> arr;

int main() {
    int n;
    cin>>n;
    int m=0,m2=0,indx1=0;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin>>temp;
        arr.push_back(temp);
        if(temp>=m){
            m2=m;
            m=temp;
            indx1=i;
        }
        else if(temp > m2 && temp != m){
            m2 = temp;
        }
    }
    for (int i = 0; i < n; ++i) {
        if(i != indx1) cout<<m<<endl;
        else{
            cout<<m2<<endl;
        }
    }
}

Measured memory_bytes: 2548
using System;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int C = int.Parse(line[2]);
            string rtn = "No";

            if(A <= C && C <= B) { rtn = "Yes"; }

            Console.WriteLine(rtn);

        }


    }

}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    char line[4];
    REP(i, 4)cin>>line[i];
    sort(line, line+4);
    cout << (line[0] == line[1] && line[2] == line[3] && line[0] != line[3]? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
ll a[51];
ll p[51];
ll init(int n){
    a[0] = 1;
    p[0] = 1;
    rep(i,n){
        a[i+1] = 2*a[i]+3;
        p[i+1] = 2*p[i]+1;
    }
}
ll burger(ll k,ll x){
    if (x == 0) return 0;
    if (k == 0) return 1;
    if (x <= a[k-1]+1) return burger(k-1,x-1);
    else return burger(k-1,x-a[k-1]-2)+p[k-1]+1;
}
int main(){
    ll n,x;
    cin >> n >> x;
    init(n);
    PRINT(burger(n,x));
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int a,zahyou=1010,bx,cy,n,gem[20],q,ans=0;
char pr;
int main(){
	while(cin>>a){
		if(a==0){
		break;}
		for(int i=0;i<a;i++){
		cin>>bx>>cy;
		gem[i]=100*bx+cy;}
	cin>>n;
	for(int j=0;j<n;j++){
	cin>>pr>>q;
	if(pr=='N'){
		for(int l=0;l<q;l++){
		zahyou+=1;
		for(int L=0;L<a;L++){
			if(zahyou==gem[L]){
			ans++;gem[L]=-1;}
		}}
	}else
	if(pr=='S'){
		for(int l=0;l<q;l++){
		zahyou-=1;
		for(int L=0;L<a;L++){
			if(zahyou==gem[L]){
			ans++;gem[L]=-1;}
		}}}else
	if(pr=='W'){
		for(int l=0;l<q;l++){
		zahyou-=100;
		for(int L=0;L<a;L++){
			if(zahyou==gem[L]){
			ans++;gem[L]=-1;}
		}}}else{
		{
		for(int l=0;l<q;l++){
		zahyou+=100;
		for(int L=0;L<a;L++){
			if(zahyou==gem[L]){
			ans++;gem[L]=-1;}
		}}}}}
	if(ans==a){
		cout<<"Yes"<<endl;}else{
		cout<<"No"<<endl;}
	zahyou=1010;ans=0;}

return 0;}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine().replace("\n", "");
        sc.close();

        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Character.getNumericValue(num.charAt(i));
        }

        if (Integer.parseInt(num) % total == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int memo[1000][15][30];
int n;


int main(){
  int i,j,k,m,count =0;
  cin >> n;
  for(i=1;i<1000;i++){
    for(j=1;j<=10;j++){
      if(i%3==0)for(k=1;k<=20;k++){
	  memo[i][j][k]=count;
	  count++;
	}
      else if(j%2==1)for(k=1;k<=20;k++){
	  memo[i][j][k]=count;
	  count++;
	}
      else for(k=1;k<=19;k++){
	  memo[i][j][k]=count;
	  count++;
	}
    }
  }
  for(i=0;i<n;i++){
    cin >> j >> k >> m;
    cout << 196470-memo[j][k][m] << endl;
  }
  return 0;
}



Measured memory_bytes: 4872
N,T = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()

Tmax = T+3001
dp = [[0 for _ in range(Tmax)] for _ in range(N+1)]
for i in range(N):
  for j in range(Tmax):
    a,b = AB[i]
    if j-a >= 0:
      dp[i+1][j] = max(dp[i][j],dp[i][j-a]+b)
    else:
      dp[i+1][j] = dp[i][j]

maxB = [0 for _ in range(N-1)] + [AB[N-1][1]]
for i in range(N-2,-1,-1):
  maxB[i] = max(AB[i][1],maxB[i+1])
ans = 0
for i in range(1,N):
  ans = max(dp[i][T-1]+maxB[i],ans)
print(ans)

Measured memory_bytes: 180740
#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 <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define 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(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#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()
using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


int N, A, B;
vector<int>v[300030];
set<int>st;
map<int, int>mp;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	bool debug = 0;
	cin >> N >> A >> B;
	if (N<(A + B - 1) || N>A*B) {
		print(-1); return 0;
	}
	REP(i, A) {
		v[0].pb(i + A * B - A + 1);
	}
	FOR(i, 1, B) {
		v[i].pb(A*B - A * i - A + 1);
	}
	int nw = A + B - 1;
	int rem = N - nw;
	FOR(i, 1, B) {
		FOR(j, 1, A) {
			if (rem == 0)goto END;
			v[i].pb(A*B - A * i - A + 1 + j);
			rem--;
		}
	}
END:;
	if (debug) {
		REP(i, B) {
			REP(j, v[i].size()) {
				pe(v[i][j]);
			}cout << endl;
		}
		cout << endl;
	}
	REP(i, B) {
		REP(j, v[i].size()) {
			st.insert(v[i][j]);
		}
	}
	int c = 1;
	for (auto x : st) {
		mp[x] = c;
		c++;
	}
	REP(i, B) {
		REP(j, v[i].size()) {
			pe(mp[v[i][j]]);
		}
		//cout << endl;
	}
	cout << endl;
}

Measured memory_bytes: 47856
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int g[10][10];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = g[b][a] = 1;
	}

	VI v;
	REP(i, n) v.PB(i);
	int ans = 0;
	do {
		bool flag = true;
		if(v[0] != 0) continue;
		FOR(i, 1, n) {
			if(g[v[i]][v[i-1]] != 1) {
				flag = false;
			}
		}
		if(flag) {
			ans++;
			//for(int i: v) cout << i << " "; cout << endl;
		}
	} while(next_permutation(ALL(v)));

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


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

a, b = nm()
print(a*b)


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, k;
  cin >> n >> k;
  mint ans = 0;
  vector<mint> a(n + 2, 0);
  rep2(i, 1, n + 1) a[i + 1] = a[i] + i;
  rep2(i, k, n + 2) ans += a[n + 1] - a[n + 1 - i] - a[i] + 1;
  cout << ans << endl;
}

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

int main(){
	string S,T;
	cin >> S >> T;
	
	int d = S.size();
	bool flag = true;
	
	for(int i=0;i<d;i++){
		char e,f;
		e = S.at(i);
		f = T.at(i);
		
		if(e!=f)
			flag = false;
	}
	
	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

int main() {
  
  int n;
  cin >> n;
  
  int c=0;
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    if (a%2==0&&(a%3!=0&&a%5!=0)) {
      c=1;
      break;
    }
  }
  
  if (c==0) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int i,n;cin>>n;
  string s;
  set<string> S;
  for(i=0; i<n; ++i){ cin>>s; S.insert(s);}
  cout<<S.size()<<endl;
  return 0;
}

Measured memory_bytes: 19176
#include<bits/stdc++.h>
using namespace std;
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define ll long long  
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
 
#define md          1000000007
#define fmd         998244353 
#define M           100011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}

class BIT{
	public:
		int n;
		vector<ll> B;
		BIT(int sz){
			n=sz;
			B=vector<ll>(n+1);
		}
		void up(int x,int val=1){
			for(;x<=n;x+=x&-x)B[x]+=val;
		}
		ll get(int x){
			ll s=0;
			for(;x>=1;x-=x&-x)s+=B[x];
			return s;
		}

};
void addRange(BIT &b,int l,int r,ll val){
	if(l>r)
		return ;
	b.up(l,val);
	b.up(r+1,-val);
}
int solve(){
    ll n,i,j,k,m,x,y,z;
    cin>>n>>m;
    vector<int> a(n);
    for(i=0;i<n;++i)cin>>a[i];

    BIT b(m+11),mi(m+11);

	for(i=0;i+1<n;++i){
		if(a[i+1]>=a[i]){
			addRange(b,1,a[i],a[i+1]-a[i]);
			addRange(b,a[i+1]+1,m,a[i+1]-a[i]);

			addRange(b,a[i]+1,a[i+1],1+a[i+1]);
			addRange(mi,a[i]+1,a[i+1],-1);
		}
		else{
			ll def=(m-a[i])+(a[i+1]);
			addRange(b,a[i+1]+1,a[i],def);

			addRange(b,a[i]+1,m,a[i+1]+m+1);
			addRange(mi,a[i]+1,m,-1);

			addRange(b,1,a[i+1],a[i+1]+1);
			addRange(mi,1,a[i+1],-1);


		}
	}
	ll ans=1e17;
	for(i=1;i<=m;++i){
		ans=min(ans,b.get(i)+i*mi.get(i));
	}cout<<ans<<"\n";






	die();
 
}
void prec(){

} 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
    int t;
    t=1;;
    // prec();
    // cin>>t;
 
    while(t--){
 
        solve();
    }
 
 
 
 
 
 
#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 5276
x = int(input())

l = -(-x//105)
h = x//100
fix = l*100

for b in range(0,h+1):
    for c in range(0,h+1):
        for d in range(0,h+1):
            for e in range(0,h+1):
                for f in range(0,h+1):
                    if fix + 1*b+2*c+3*d+4*e+5*f==x:
                        print('1')
                        exit()
else:
    print('0')

Measured memory_bytes: 9080
import math
n,h = (int(i) for i in input().split())
a = []
b = [0]
for i in range(n):
 tmp1,tmp2= (int(i) for i in input().split())
 a.append(tmp1)
 b.append(tmp2)
a2 = sorted(a,reverse = True)
b2 = sorted(b,reverse = True)

count  = 0
while h > 0:
  if a2[0] > b2[0]:
    count += math.ceil(h/a2[0])
    h -= math.ceil(h/a2[0])*a2[0]
  else:
    count += 1
    h -= b2[0]
    b2.pop(0)
print(count)

Measured memory_bytes: 12776
t_hp, t_att, a_hp, a_att = gets.chomp.split.map(&:to_i)
# exitを入れることで永遠に繰り返されるのを防ぐ
while
  a_hp -= t_att
  if a_hp <= 0
    puts "Yes"
    exit
  end
  t_hp -= a_att
  if t_hp <= 0
    puts "No"
    exit
  end
end


Measured memory_bytes: 14260
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

Pi dp[1<<18];

int main(){
    int N; cin >> N;
    vector<int> A(1<<N);
    rep(i,1<<N){
        cin >> A[i];
        dp[i] = {A[i],-1};
    }

    rep(i,N)rep(j,1<<N){
        if(j>>i&1){
            if(dp[j^(1<<i)].first > dp[j].first){
                dp[j].second = max(dp[j].first,dp[j^(1<<i)].second);
                dp[j].first = dp[j^(1<<i)].first;
            }
            else dp[j].second = max(dp[j].second,dp[j^(1<<i)].first);
        }
    }

    int ans = -1;
    repr(i,1,1<<N){
        ans = max(ans,dp[i].first+dp[i].second);
        cout << ans << endl;
    }

}
    



Measured memory_bytes: 6144
N = int(input())

prime_dict = {}

while N > 1:
  pn = 2
  tmp = N
  while pn * pn <= tmp:
    while tmp % pn == 0:
      tmp = tmp / pn
      prime_dict[pn] = prime_dict.get(pn, 0) + 1
    pn += 1
  if tmp > 1:
    prime_dict[tmp] = prime_dict.get(tmp, 0) + 1
  N -= 1

cnt = 1  
for key in prime_dict.keys():
  cnt *= prime_dict[key]+1
  
print(cnt % (10**9+7))

Measured memory_bytes: 3064