akhauriyash/Code-Regression huggingface dataset:
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

bool dp[81][81][6400 * 4 + 10];
bool calced[81][81];
ll H, W;
VV<ll> A, B;
void calc(ll h, ll w);
void update(ll ph, ll pw, ll h, ll w);

bool in_range(ll h, ll w) {
    return 0 <= h && h < H &&
           0 <= w && w < W;
}
    
ll fix_diff(ll n) { return n + 6400 * 2; };

void update(ll ph, ll pw, ll h, ll w) {
    if(!in_range(ph, pw)) return;
    calc(ph, pw);
    for(ll diff = -6400 * 2; diff <= 6400 * 2; diff++) {
        ll fd = fix_diff(diff);
        if(!dp[ph][pw][fd]) continue;
        dp[h][w][fix_diff(diff + A[h][w] - B[h][w])] = true;
        dp[h][w][fix_diff(diff - A[h][w] + B[h][w])] = true;
    }
}

void calc(ll h, ll w) {
    if(calced[h][w]) return;
    update(h - 1, w, h, w);
    update(h, w - 1, h, w);
    calced[h][w] = true;
}

int main() {
    cin >> H >> W;
    A = make_v<ll>(0, H, W);
    B = A;
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++) cin >> A[i][j];
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++) cin >> B[i][j];

    dp[0][0][fix_diff(A[0][0] - B[0][0])] = true;
    dp[0][0][fix_diff(B[0][0] - A[0][0])] = true;
    calced[0][0] = true;
    calc(H - 1, W - 1);
    ll ans = 5e15;
    for(ll diff = -6400 * 2; diff <= 6400 * 2; diff++) {
        if(dp[H - 1][W - 1][fix_diff(diff)]) chmin(ans, abs(diff));
    }

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


Measured memory_bytes: 163072
class Queue(object):
    def __init__(self, _max):
        if type(_max) != int:
            raise ValueError
        self._array = [None for i in range(0, _max)]
        self._head = 0
        self._tail = 0
        self._cnt = 0

    def enqueue(self, value):
        if self.is_full():
            raise IndexError
        self._array[self._head] = value
        self._cnt += 1
        if self._head + 1 >= len(self._array):
            self._head = 0
        else:
            self._head += 1

    def dequeue(self):
        if self.is_empty():
            raise IndexError
        value = self._array[self._tail]
        self._cnt -= 1
        if self._tail + 1 >= len(self._array):
            self._tail = 0
        else:
            self._tail += 1
        return value

    def is_empty(self):
        return self._cnt <= 0

    def is_full(self):
        return self._cnt >= len(self._array)


def round_robin(quantum, jobs):
    queue = Queue(100000)
    total = 0
    for job in jobs:
        queue.enqueue(job)

    while not queue.is_empty():
        name, time = queue.dequeue()
        if time > quantum:
            total += quantum
            queue.enqueue((name, time - quantum))
        else:
            total += time
            print("{0} {1}".format(name, total))


if __name__ == "__main__":
    n, quantum = input().split()
    jobs = [input().split() for i in range(0, int(n))]
    jobs = [(job[0], int(job[1])) for job in jobs]
    round_robin(int(quantum), jobs)

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

int main(void){
    int n, a, f;
    cin >> n;
    a = 10;
    f = 0;

    for(int i = 0; i < 3; ++i){
        if(n % a == 7)f = 1;
        n /= a;
    }
    if(f == 1)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
    int k,x;
    cin >>  k >> x;
    for (int i = x-(k-1);i<= x ;i++){
        cout << i<<" ";
    }
    for (int i = x+1 ;i<=x+(k-1) ;i++){
        cout << i<<" ";
    }
    cout <<endl;
    return 0;
}


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

using namespace std;

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

	vector < int >A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	int sum = accumulate(A.begin(), A.end(), 0);

	if (sum > N) {
		cout << -1 << endl;
	} else {
		cout << N - sum << endl;
	}

	return 0;
}


Measured memory_bytes: 3644
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "20\n2\n5\n" => "84",
    "10\n1\n2\n" => "13",
    "100\n4\n16\n" => "4554",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: u32,
        a: u32,
        b: u32,
    }

    let ans: u32 = (1..n + 1)
        .filter(|x| {
            let sum = x.to_string()
                .chars()
                .map(|c| (c as u8 - b'0') as u32)
                .sum();

            a <= sum && sum <= b
        })
        .sum();
    
    ans.to_string()
}

Measured memory_bytes: 4352
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let x = sc.read();
    let ans = (2..x).map(|a| {
        let mut t = a * a;
        if t > x {
            return 1;
        }
        while t * a <= x {
            t *= a;
        }
        t
    }).max().unwrap_or(1);
    println!("{}", ans);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
from math import factorial as f

N, A, B = map(int, input().split())
v = list(map(int, input().split()))

v.sort()


sum_v = 0
for i in range(N-A+1, N):
    sum_v += v[i]

i_max = N+1
count_max = 1
sum_max = 0

max_nums = []
if A == 1:
    current_num = -1
    current_count = 0
else:
    current_num = v[N-A+1]
    current_count = v[N-A+1:].count(v[N-A+1])
for i in range(N-A, N-B-1, -1):
    if v[i] == current_num:
        current_count += 1
    else:
        current_num = v[i]
        current_count = 1
    count = N-i
    sum_v += v[i]
    if sum_v * count_max > sum_max * count:
        count_max = count
        sum_max = sum_v
        max_nums = [(v[i], current_count)]
    elif sum_v * count_max == sum_max * count:
        if v[i] not in max_nums:
            max_nums.append((v[i], current_count))

def count(vi):
    return v.count(vi)

def c(n, k):
    return f(n)//(f(k)*f(n-k))

ans = 0
for vi, cc in max_nums:
    ans = ans + c(count(vi), cc)
    # print(vi, count(vi), cc)

print(sum_max/count_max)
print(ans)


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

int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  //vector<int> l(N);

  /*for (int i=0; i<N; i++) {
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());*/
  /*int ans = 0;
  for (int i=0; i<B; i++) {
    ans += 
  */
  S[K-1] += 32;
  cout << S << endl;
}

Measured memory_bytes: 256
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int, read().split())
AB = zip(m, m)

MOD = 10 ** 9 + 7

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N + 1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

fact = [1] * (N + 10)
for n in range(1, N + 10):
    fact[n] = n * fact[n - 1] % MOD
fact_inv = [1] * (N + 10)
fact_inv[-1] = pow(fact[-1], MOD - 2, MOD)
for n in range(N + 9, 0, -1):
    fact_inv[n - 1] = fact_inv[n] * n % MOD

size_d = [0] * (N + 1)
dp_d = [1] * (N + 1)

for v in order[::-1]:
    dp_d[v] *= fact[size_d[v]]
    dp_d[v] %= MOD
    p = parent[v]
    s = size_d[v] + 1
    size_d[p] += s
    dp_d[p] *= fact_inv[s] * dp_d[v]
    dp_d[p] %= MOD

size_u = [N - 2 - x for x in size_d]
dp_u = [1] * (N + 1)

for v in order[1:]:
    p = parent[v]
    x = dp_d[p]
    x *= dp_u[p]
    x *= fact_inv[size_d[p]]
    x *= fact[size_d[v] + 1]
    x *= pow(dp_d[v], MOD - 2, MOD)
    x *= fact[size_u[v]]
    x *= fact_inv[size_u[p] + 1]
    dp_u[v] = x % MOD

for xd, xu, sd, su in zip(dp_d[1:], dp_u[1:], size_d[1:], size_u[1:]):
    su += 1
    x = xd * xu * fact[sd + su] * fact_inv[sd] * fact_inv[su] % MOD
    print(x)


Measured memory_bytes: 88308
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  bool b;
  b = prev_permutation(a.begin(), a.end());
  if (b){
    for (int i = 0; i < n; i++){
      cout << a[i];
      if (i < n - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
  next_permutation(a.begin(), a.end());
  for (int i = 0; i < n; i++){
    cout << a[i];
    if (i < n - 1){
      cout << ' ';
    }
  }
  cout << endl;
  b = next_permutation(a.begin(), a.end());
  if (b){
    for (int i = 0; i < n; i++){
      cout << a[i];
      if (i < n - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<int> t(101, 0);
  if(b < c || d < a){
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  if(a < c) ans = (b < d) ? b-c : d-c;
  else ans = (b < d) ?  b-a : d-a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc138/tasks/abc138_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, a: [f64; n]
    };
    println!("{:.9}", 1.0f64/a.into_iter().map(|ai| 1.0f64/ai).fold(0.0f64, |a,c|a+c));
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<string>
#include<cctype>
using namespace std;
   int counter[30];
int main(){
    char mozi;
    while( cin >>mozi){
            if (mozi=='\n')break;
            mozi = tolower( mozi);
        int num = mozi -'a';
        if(num<=25&&num>=0)counter[num]++;
    }
    cout << "a : " << counter[0] << endl;
    cout << "b : " << counter[1] << "\n";
    cout << "c : " << counter[2] << "\n";
    cout << "d : " << counter[3] << "\n";
    cout << "e : " << counter[4] << "\n";
    cout << "f : " << counter[5] << "\n";
    cout << "g : " << counter[6] << "\n";
    cout << "h : " << counter[7] << "\n";
    cout << "i : " << counter[8] << "\n";
    cout << "j : " << counter[9] << "\n";
    cout << "k : " << counter[10] << "\n";
    cout << "l : " << counter[11] << "\n";
    cout << "m : " << counter[12] << "\n";
    cout << "n : " << counter[13] << "\n";
    cout << "o : " << counter[14] << "\n";
    cout << "p : " << counter[15] << "\n";
    cout << "q : " << counter[16] << "\n";
    cout << "r : " << counter[17] << "\n";
    cout << "s : " << counter[18] << "\n";
    cout << "t : " << counter[19] << "\n";
    cout << "u : " << counter[20] << "\n";
    cout << "v : " << counter[21] << "\n";
    cout << "w : " << counter[22] << "\n";
    cout << "x : " << counter[23] << "\n";
    cout << "y : " << counter[24] << "\n";
    cout << "z : " << counter[25] << "\n";
return 0 ;
}

Measured memory_bytes: 1144
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF 99999999

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef unordered_map<int,Edges> Graph;

void shortestPath(Graph &g, int s,
    unordered_map<int,Weight> &dist, unordered_map<int,int> &prev) {
  for(auto &f:g)dist[f.first]=INF; dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev.find(e.dst) != prev.end()) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

char buf[1001];
int W;
int coor(int x,int y){return (y)*(W+2)+x;}
int main(){
	int H,N,X1,Y1,X2,Y2;
	scanf("%d%d%d%d%d%d%d",&W,&H,&N,&X1,&Y1,&X2,&Y2);
	H*=2,W*=2;
	X1=coor(X1*2,Y1*2),X2=coor(X2*2,Y2*2);
	vector<vector<int> >m(H+1);
	for(auto &&e:m)e.resize(W+1);
	for(int i=0;i<N;i++){
		int x,y,t,l;
		scanf("%d%d%d%s",&x,&y,&t,buf);
		l=strlen(buf);
		x=2*x+1,y=2*y+1;
		for(int j=0;j<t;j++){
			for(int k=0;k<l;k++){
				int c=buf[k];
				if(c=='L'&&1<x)m[y][x-1]++,x-=2;
				if(c=='U'&&1<y)m[y-1][x]++,y-=2;
				if(c=='R'&&x<W-1)m[y][x+1]++,x+=2;
				if(c=='D'&&y<H-1)m[y+1][x]++,y+=2;
			}
		}
	}
	Graph g;
	for(int h=0;h<=H;h+=2)for(int w=0;w<=W;w+=2){
		int a=coor(w,h),b;
		if(h<H)b=coor(w,h+2),g[a].push_back(Edge(a,b,m[h+1][w])),g[b].push_back(Edge(b,a,m[h+1][w]));
		if(w<W)b=coor(w+2,h),g[a].push_back(Edge(a,b,m[h][w+1])),g[b].push_back(Edge(b,a,m[h][w+1]));
	}
	unordered_map<int,Weight> dist;
	unordered_map<int,int> prev;
	shortestPath(g,X1,dist,prev);
	printf("%d\n",dist[X2]);
}

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

typedef unsigned long long ull;
typedef long long ll;

const int M = (int)1e6;
const int N = (int)5e5;
const int inf = 0x3f3f3f3f;
const ll mod = (ll)1e9 + 7;
const double eps = 1e-6;

bool is_prime[M + 5];
int prime[M + 5], cnt;
int v[M + 5];//最小质因子

void init()
{
    memset(is_prime, 1, sizeof(is_prime));
    is_prime[0] = is_prime[1] = 0;
    for(int i = 2; i <= M; ++i)
    {
        if(is_prime[i])
        {
            prime[++cnt] = i;
            v[i] = i;
        }
        for(int j = 1; j <= cnt && i * prime[j] <= M; ++j)
        {
            is_prime[i * prime[j]] = 0;
            v[i * prime[j]] = prime[j];
            if(i % prime[j] == 0)
            {
                break;
            }
        }
    }
}

int n, a[M + 5];
bool used[M + 5];
vector <int> vec;

bool divide(int n)
{
    vec.clear();
    int x;
    while(n > 1)
    {
        x = v[n];
//        printf("x = %d used[x] = %d\n", x, used[x]);
        if(used[x]) return 0;
        vec.push_back(x);
        n /= x;
    }
    for(auto x: vec) used[x] = 1;
    return 1;
}

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    init();
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        assert(a[i] <= M);
    }
    int flag = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(!divide(a[i]))
        {
            flag = 1;
            break;
        }
    }
    if(!flag) puts("pairwise coprime");
    else
    {
        int d = a[1];
        for(int i = 2; i <= n; ++i) d = gcd(d, a[i]);
        if(d == 1) puts("setwise coprime");
        else       puts("not coprime");
    }
    return 0;
}


Measured memory_bytes: 12868
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, readline().split())

e_IN = [[] for _ in range(N+1)]
e_OUT = [[] for _ in range(N+1)]

for _ in range(M):
    l, r, d = map(int, readline().split())
    e_OUT[l].append((r, d))
    e_IN[r].append((l, d))

posx = [-1] * (N + 1)


def dfs(v):
    #　0<=x<=10**9に注意
    node = [v]
    posx[v] = 0
    diameter = 0
    while node:
        s = node.pop()
        ds = posx[s]
        for t, dt in e_OUT[s]:
            dist = ds + dt
            if posx[t] != -1:
                if posx[t] != dist:
                    return False
                else:
                    continue
            posx[t] = dist
            node.append(t)
            diameter = max(diameter, dist)
    if diameter <= 10 ** 9:
        return True
    else:
        return False


ans = "Yes"
for i in range(N + 1):
    if len(e_IN[i]) == 0:
        posx[i] = 0
        bl = dfs(i)
        if not bl:
            ans = "No"
            break

if - 1 in posx:
    ans = "No"

print(ans)

Measured memory_bytes: 69636
def ok(N, A):
    return all([a <= N - 1 for a in A])


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    while not ok(N, A):
        n = 0
        # 「全てに1を足して、特定のものからN+1を引く」で等価な操作になる
        for i in range(N):
            c = A[i] // N
            n += c
            A[i] -= c * (N + 1)
        for i in range(N):
            A[i] += n
        ans += n
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N;
    cin >> N;
    vector<pair<ll, int>> a; 
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            int cnt = 0;
            while(N % i == 0) {
                N = N / i;
                cnt++;
            }
            a.push_back({i, cnt});
        }
    }
    if (N != 1) {
        a.push_back({N, 1});
    }
    int res = 0;
    for (auto &it : a) {
        ll p = it.first;
        int k = it.second;
        int sum = 0;
        for (int i = 1; i + sum <= k; i++) {
            sum += i;
            res++;
        }
    }
    cout << res <<endl;
    
    

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
long long a,b,k;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>k;
    cin>>a>>b;
    if (a/k<b/k || a%k==0 || b%k==0) cout<<"OK";
    else
    cout<<"NG";
    
    
}

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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  vector<int> ans(n);
  int cnt = 0;
  rep(ri,2){
    rep(i,n){
      if(s[i] == 'R' )cnt++;
      else
      {
        ans[i] += cnt/2;
        ans[i-1] += (cnt+1)/2;
        cnt=0;
      }
    }

    reverse(ans.begin(),ans.end());
    reverse(s.begin(),s.end());
    rep(i,n){
      if(s[i] == 'L')s[i] = 'R';
      else s[i] = 'L';
    }

  }
  rep(i,n)
  {
   printf("%d%c",ans[i], i==i-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <utility>

int count[200000];

int main() {
	int n, m;
	std::cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int a, b;

		std::cin >> a >> b;
		if (a > b)
			std::swap(a, b);

		if (a == 1)
			++count[b - 1];
		if (b == n)
			++count[a - 1];
	}

	for (auto&& e : count) {
		if (e >= 2) {
			std::cout << "POSSIBLE" << std::endl;

			return 0;
		}
	}

	std::cout << "IMPOSSIBLE" << std::endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
int main(){
	int ans = 0, n, b, j = 2, maxx;
	bool isprime;
	std::cin >> n;
	for (int i = 0; i<n; i++){
		isprime = true;
		std::cin >> b;
		maxx = (int)sqrt(b);
		for (int l = 2; l<=maxx; ++l){
			if (b%l == 0){
				isprime = false;
				break;
			}
		}
		if (isprime)++ans;
		isprime = true;
	}
	std::cout << ans << "\n";
}

Measured memory_bytes: 3080
#include <iostream>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		if(a%3==0||b%3==0||(a+b)%3==0)
			cout<<"Possible\n";
		else
			cout<<"Impossible\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 

int main()
{
    int s;
    std::cin >> s;
    int list[1000000];
    int index = 0;
    int a_i;
    int a_pre = s;
    list[0] = s;
    index = index + 1;
    bool search_flag = false;
    while( true){
        if ( a_pre % 2 == 0){
            a_i = a_pre / 2;
        } else {
            a_i = 3 * a_pre + 1;
        }
        list[index] = a_i;
        index = index + 1;
        for ( int i = 0; i< index-1; ++ i ){
            if ( list[i] == a_i) {
                search_flag = true;
                break;
            }
        }
        if (search_flag==true){
            break;
        } 
        a_pre = a_i;

    }
    std::cout << index << std::endl;
    return 0;
}



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

int main(void){
    // Your code here!　t 
    string S, T;
    cin >> S >> T;
    int j;
    int k =  -1;
    if(int(S.length()) - int(T.length()) >= 0){
        for(int i = 0; i <= int(S.length()) - int(T.length()); i++){
            bool equal = true;
            j = 0;
            while(j < T.size()){
                if(S[i + j] == T[j]){
                    j++;
                } else if(S[i+j] == '?'){
                    j++;
                } else{
                    equal = false;
                    break;
                }
            }
        
            if(equal){
                k = i;
            }
        }
    }

    if(k == -1){
        cout << "UNRESTORABLE";
    } else{
        for(int i = 0; i < S.length(); i++){
            if(k <= i && i < k + T.length()){
                cout << T[i-k];
            } else if(S[i] == '?'){
                cout << "a";
            } else{
                cout << S[i];
            }
        }
    }
    
    cout << endl;
}


Measured memory_bytes: 256
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

$n = (int)input();
$maxv = -2000000000;
$minv = (int)input();

for ($i = 1; $i < $n; $i++) {
    $R = (int)input();
    $maxv = max($maxv, $R - $minv);
    $minv = min($minv, $R);
}

echo "{$maxv}\n";


Measured memory_bytes: 9244
#import sys
#input = sys.stdin.readline
from collections import deque
def main():
    S = input()
    N = len(S)
    ANS = [0]*N
    C = []
    now = "R"
    c = 0
    for i in range(N):
        if now == S[i]:
            c += 1
        else:
            C.append(c)
            now = S[i]
            c = 1
    C.append(c)
    t = len(C)
    NOW = [0]*t
    r = 0
    l = 0

    for i in range(t//2):
        r = (C[i*2]+1)//2 + C[i*2+1]//2
        l = (C[i*2])//2 + (C[i*2+1]+1)//2
        NOW[i*2] = r
        NOW[i*2+1] = l
    d = deque(NOW)
    ANS = [0]*N
    now = "R"
    for i in range(N):
        if now == "R" and S[i] == "L":
            ANS[i-1] = d.popleft()
            ANS[i] = d.popleft()
        now = S[i]
    print( " ".join( map( str, ANS)))
if __name__ == '__main__':
    main()

    


Measured memory_bytes: 12900
//D. Coloring Dominoes
#include<stdio.h>

#define mod 1000000007

int n,cnt2,cnt3,i;
long long ans=1;
char g[2][53];

int main(){
	scanf("%d%s%s",&n,g[0],g[1]);
	if(g[0][0]==g[1][0])cnt3++,i=1;
	else cnt2++,cnt3++,i=2;
	for(;i<n;){
		if(g[0][i]==g[1][i]&&g[0][i-1]==g[1][i-1])cnt2++,i++;
		else if(g[0][i]==g[1][i])i++;
		else if(g[0][i-1]==g[1][i-1])cnt2++,i+=2;
		else cnt3++,i+=2;
	}
	for(i=0;i<cnt3;i++)ans=ans*3%mod;
	printf("%lld\n",(ans<<cnt2)%mod);
	return 0;
}


Measured memory_bytes: 128
n,q=map(int,input().split())
s=input()

ac_count=[]
ac=0

for i in range(n-1):
    if s[i:i+2]=='AC':
        ac+=1
    ac_count.append(ac)
    
for i in range(q):
    l,r=map(int,input().split())
    if l==1:
        print(ac_count[r-2])
    else:
        print(ac_count[r-2]-ac_count[l-2])

Measured memory_bytes: 6104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

int main(){

	int h,w;
	char field[51][51];
	int dp[51][51];
	const int INF=100000000;
	while(cin>>h>>w&&!(h==0&&w==0)){
		for(int i = 0; i < 51; i++)
			fill(dp[i],dp[i]+51,INF);
		for(int i =0 ; i < h; i++)
			for(int j = 0; j < w; j++)
				cin>>field[i][j];
		dp[0][0]=field[0][0]-'0';
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(i-1>=0){
					dp[i][j]=min(dp[i-1][j]+(int)(field[i][j]-'0'),dp[i][j]);
				}
				if(j-1>=0){
					dp[i][j]=min(dp[i][j-1]+(int)(field[i][j]-'0'),dp[i][j]);
				}
			}
		}
		cout<<dp[h-1][w-1]<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

N, L = l_inpl()
aji = []

for i in range(N):
    aji.append(L+i)

r = INF
for a in aji:
    if abs(r) > abs(a):
        r = a

print(sum(aji)-r)

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

int top, S[1000];

void push(int x){
    S[++top] = x;
}

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

int main(){
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3160
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def med(a):
    return sorted(a)[1]

def simu(a):
    while len(a) > 1:
        a = [med([a[i], a[i + 1], a[i + 2]]) for i in xrange(len(a) - 2)]
    return a[0]

#for ele in it.permutations(xrange(1, 8)):
#    if simu(ele) == 2:
#        print ele

N, x = map(int, raw_input().split())
d = x - N
if 1 < x <= 2*N - 2:
    print "Yes"
    ans = [(i + d)%(2*N - 1) + 1 for i in xrange(2*N - 1)]
    print "\n".join(map(str, ans))
    #print simu(ans)
else:
    print "No"


Measured memory_bytes: 22688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class Program
{
    private string S;
    private void Scan()
    {
        S=Console.ReadLine();
    }
    
    private void Calc()
    {
        Console.WriteLine(S.Count(c=>c=='1'));
    }
    
    public void Solve()
    {
        Scan();
        Calc();
    }
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int r;
    cin >> r;
    cout << 3 * r* r<< endl;
}



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

int main(){
    string s, t, ans;
    int same;
    
    cin >> s >> t;
    ans = "No";
    
    for ( int i = 0; i < s.size(); i++ ) {
        same = 0;
        for ( int j = 0; j < s.size(); j++ ) {
            if (s[(i+j)%s.size()] == t[j]) {
                same++;
            }
        }
        
        if ( same == s.size() ) {
            ans = "Yes";
        }
    }
    
    cout << ans << endl;
    
    return (0);
}


Measured memory_bytes: 3628
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	int s4 = 0, s2 = 0, s1 = 0;
	rep(i, n){
		int t;
		cin>>t;
		if(t%4==0) s4++;
		else if(t%2==0) s2++;
		else s1++;
	}
	if(s4>=s1 || (s4==s1-1 && s2==0)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static double INF=1e19;
	static double eps=1e-9;
	
	static class State implements Comparable<State>{
		int n1, n2;
		double timer;
		State(int n1, int n2, double timer){
			this.n1=n1;
			this.n2=n2;
			this.timer=timer;
		}
		public int compareTo(State s) {
			if(this.timer>s.timer) {
				return 1;
			}
			else {
				return -1;
			}
		}
	}
	
	static double calc(double A, double B, double C) {
		if(A!=0 && B*B-4*A*C>eps) {
			if((-1*B-Math.sqrt(B*B-4*A*C))/(2*A)>eps) {
				return (-1*B-Math.sqrt(B*B-4*A*C))/(2*A);
			}
			else if((-1*B+Math.sqrt(B*B-4*A*C))/(2*A)>eps) {
				return (-1*B+Math.sqrt(B*B-4*A*C))/(2*A);
			}
		}
		if((Math.abs(A)<eps && B!=0) && -1*C/B>eps) {
			return -1*C/B;
		}
		return INF;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				
				double[] time=new double[n];//流れ星消滅の時間
				double[] px=new double[n];
				double[] py=new double[n];
				double[] pz=new double[n];
				double[] vx=new double[n];
				double[] vy=new double[n];
				double[] vz=new double[n];
				double[] r=new double[n];
				double[] vr=new double[n];
				int[] c=new int[n];
				Arrays.fill(c, 1);
				
				for(int i=0; i<n; i++) {
					px[i]=sc.nextDouble();
					py[i]=sc.nextDouble();
					pz[i]=sc.nextDouble();
					vx[i]=sc.nextDouble();
					vy[i]=sc.nextDouble();
					vz[i]=sc.nextDouble();
					r[i]=sc.nextDouble();
					vr[i]=sc.nextDouble();
				}
				PriorityQueue<State> pq=new PriorityQueue<>();
				
				for(int i=0; i<n; i++) {
					if(vr[i]!=0) {
						time[i]=r[i]/vr[i];
					}
					else {
						time[i]=INF;
					}
					pq.add(new State(i, i, time[i]));
				}
				
				for(int i=0; i<n; i++) {
					for(int j=i+1; j<n; j++) {
						double A=-Math.pow(vr[i]+vr[j], 2)+Math.pow(vx[i]-vx[j], 2)+Math.pow(vy[i]-vy[j], 2)+Math.pow(vz[i]-vz[j], 2);
						double B=2*((vr[i]+vr[j])*(r[i]+r[j])+(vx[j]-vx[i])*(px[j]-px[i])+(vy[j]-vy[i])*(py[j]-py[i])+(vz[j]-vz[i])*(pz[j]-pz[i]));
						double C=-Math.pow(r[i]+r[j], 2)+Math.pow(px[i]-px[j], 2)+Math.pow(py[i]-py[j], 2)+Math.pow(pz[i]-pz[j], 2);
						//System.out.println("A="+A+" B="+B+" C="+C);
						pq.add(new State(i, j, calc(A, B, C)));
						//System.out.println("i="+i+" j="+j+" calc"+calc(A,B,C));
					}
				}
				while(! pq.isEmpty()) {
					State state=pq.poll();
//					if(time[state.n1]<state.timer || time[state.n2]<state.timer) {
//						//消滅できない
//						continue;
//					}
					if(c[state.n1]>0 && c[state.n2]>0) {
						c[state.n1]=0;
						c[state.n2]=0;
						time[state.n1]=state.timer;
						time[state.n2]=state.timer;
					}

				}
				for(int i=0; i<n; i++) {
					System.out.printf("%.12f\n", time[i]);
				}
			}
		}
	}
}


Measured memory_bytes: 112868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin>>n;
    vi h(n);
    rep(i,n) cin>>h[i];
    int i=0;
    int cnt=0;
    bool ok = false;
    while(i<n){
        while(h[i]==0 && i<n){
            i++;
            if(i==n) ok = true;
        }
        if(ok) break;
        
        int ni = i;
        while(h[ni]>0 && ni<n){
            h[ni]--;
            ni++;
        }
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
input_num = int(input())
operate_list = [[[0]*10 for i in range(3)] for j in range(4)]

    
for i in range(input_num):
    b,f,r,v = map(int, input().split())
    operate_list[b-1][f-1][r-1] += v
    

for ridge in operate_list[:-1]:
    for floor in ridge:
        for room in floor:
            print(' ', end='')
            print(room, end='')
        print('')
    print('####################')
    
for floor in operate_list[-1]:
    for room in floor:
        print(' ', end='')
        print(room, end='')
    print('')


Measured memory_bytes: 5636
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scn=new Scanner(System.in);
    int n=scn.nextInt();
    int k=scn.nextInt();
    ArrayList<Integer> p=new ArrayList<>();
    
    for(int i=0;i<n;i++){
      p.add(scn.nextInt());
    } 
    Collections.sort(p);
    int ans=0;
    for(int i=0;i<k;i++){
      ans+=p.get(i);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 39080
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val as = in.readLine().split("\\s+").map(_.toInt)

    val sum = as.sum

    out.println(
      if (n < sum) {
        -1
      } else {
        n - sum
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 54960
#input
n, a, b = map(int, input().split())

#output
mod = pow(10, 9) + 7

def cmb(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= (n-i)
        res %= mod
        fac *= (i+1)
        fac %= mod
    return res*pow(fac, mod-2, mod) % mod

answer = pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)
print(answer % mod)

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

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

  int64_t N, K;
  cin >> N >> K;
  int64_t A[N], F[N];
  rep(i, N){
    cin >> A[i];
  }
  sort(A, A+N);
  reverse(A, A+N);

  rep(i, N){
    cin >> F[i];
  }
  sort(F, F+N);

  pair<int64_t, int64_t> P[N];
  rep(i, N){
    P[i].first = A[i]*F[i];
    P[i].second = F[i];
  }
  sort(P, P+N);
  int64_t num = 0;
  int64_t left = -1, right = P[N-1].first, middle;
  while(right - left >= 2){
    middle = (left+right)/2;
    num = 0;
    for(int64_t i=0;i<N;i++){
      num += max((int64_t)0, ((P[i].first + P[i].second - 1)-middle)/P[i].second);
    }
    if(num > K) left = middle;
    else right = middle;
  }


  cout << right << endl;
}

Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args)
    {
	    Set<Integer> set = new HashSet();
	    int a = getInput();
        do {
            set.add(a);
            a = f(a);
        } while (!set.contains(a));
        System.out.println(set.size() + 1);
        return;
    }

    private static int f(int n)
    {
        if (n % 2 == 0) {
            return n / 2;
        } else {
            return 3 * n + 1;
        }
    }

    private static int getInput()
    {
        int ret = 0;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            ret = Integer.parseInt(br.readLine().trim());
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
        return ret;
    }

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  vector<int> D(N+1);
  rep(i, N) D[i+1] = D[i]+L[i];
  cout << upper_bound(all(D), X) - begin(D) << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	int x, y;

	cin >> x >> y;

	if (x%y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << x << endl;
	}
	

	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iomanip>
#include<iostream>
using namespace std;
#define N 10000

int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	double q=(double)a/(double)b;
	//printf("%d %d %.8lf\n",a/b ,a%b ,q);
	cout<<a/b<<" "<<a%b<<" "<<fixed<<setprecision(8)<<q<<endl;
}


Measured memory_bytes: 3304
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  string s;
  cin >> s;
  rep(i, 0, s.size()) {
      if(i % 2) {
          if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
              cout << "No" << endl;
              return 0;
          }
      } else {
          if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
              cout << "No" << endl;
              return 0;
          }
      }
  }
  cout << "Yes" << endl;


}


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>


namespace n91 {

void main_() {
  std::string s;
  std::cin >> s;
  u64 ans = 0;
  u64 a_cnt = 0;
  for (usize i = 0; i != s.size();) {
    if (s[i] == 'A') {
      ++a_cnt;
      ++i;
      continue;
    }
    if (s[i] == 'C') {
      a_cnt = 0;
      ++i;
      continue;
    }
    if (i + 1 == s.size()) {
      break;
    }
    if (s[i + 1] == 'C') {
      ans += a_cnt;
      i += 2;
    } else {
      a_cnt = 0;
      ++i;
    }
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 640