akhauriyash/Code-Regression huggingface dataset:
open System

let n = Console.ReadLine() |> int

let testimonies: (int * int) list list =
    [ for i in 1 .. n do
        let a = Console.ReadLine() |> int
        yield [ for j in 1 .. a do
                    let xy = Console.ReadLine().Split(' ') |> Array.map int
                    yield xy.[0] - 1, xy.[1] ] ]

let ans =
    let rec dfs is rest =
        match rest with
        | [] ->
            let honests = Set is

            let ok =
                is
                |> List.forall (fun i ->
                    testimonies.[i]
                    |> List.forall (fun testimony ->
                        let x, y = testimony
                        (y = 0 && not (honests.Contains x)) || (y = 1 && honests.Contains x)))

            if ok then List.length is else 0
        | i :: rest ->
            max (dfs is rest) (dfs (i :: is) rest)

    dfs [] [ 0 .. n - 1 ]

ans |> Console.WriteLine


Measured memory_bytes: 18504
//{{{
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define BR putchar('\n')
#define MS0(ar) memset(ar, 0, sizeof(ar))
#define MS1(ar) memset(ar, -1, sizeof(ar))
#define F first
#define S second
#define MP make_pair
#define MT make_tuple
#define IO(name) freopen(name".in", "r", stdin);freopen(name".out", "w", stdout)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef complex<double> CD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VL;

void R(int &x) { scanf("%d", &x); }
void R(LL &x) { scanf("%lld", &x); }
void R(ULL &x) { scanf("%llu", &x); }
void R(double &x) { scanf("%lf", &x); }
void R(LD &x) { scanf("%Lf", &x); }

template <typename T> void R(T &t) { cin >> t; }
template <typename A, typename B> void R(pair<A, B> &x) {
  R(x.F);
  R(x.S);
}

template <typename T> void R(vector<T> &ar) {
  for (auto &it : ar)
    R(it);
}

template <typename T, typename... Args> void R(T &t, Args &... args) {
  R(t);
  R(args...);
}

void W(const char &c) { putchar(c); };
void W(const int &x) { printf("%d", x); }
void W(const LL &x) { printf("%lld", x); }
void W(const ULL &x) { printf("%llu", x); }
void W(const double &x) { printf("%lf", x); }
void W(const LD &x) { printf("%Lf", x); }

template <typename T> void W(const T &t) { cout << t; }
template <typename T> void W(const vector<T> &ar) {
  for (size_t i = 0; i < ar.size(); ++i) {
    W(ar[i]);
    putchar(" \n"[i + 1u == ar.size()]);
  }
}
template <typename T, typename... Args>
void W(const T &t, const Args &... args) {
  W(t);
  W(args...);
}
#define BR putchar('\n')

template <typename T> void Min(T &x, T v) { x = min(x, v); }
template <typename T> void Max(T &x, T v) { x = max(x, v); }
//}}}
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int maxn = 100010;

int main() {
  string s;
  cin >> s;
  int st = 0;
  for (char c : s) if (c == 'C' && st == 0) st++; else if (c == 'F' && st == 1) st++;
  puts(st == 2 ? "Yes" : "No");
  return 0;
}



Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

int h, w, n;
pair<int, int> a[mxn];
vector<int> o[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11);
    cin >> h >> w >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    sort(a+1, a+1+n);
    for (int i = 1; i <= n; i++) {
        o[a[i].second].push_back(a[i].first);
    }
    for (int i = 1; i <= w; i++) {
        o[i].push_back(h+1);
    }

    int ans = 0, x = 1, y = 1, mnx = o[1][0];
    while (1) {
        ans++;
        if (++x == mnx) break;
        if (y<w) {
            auto it = lower_bound(begin(o[y+1]), end(o[y+1]), x);
            if (*it!=x) {
                ++y;
                mnx = min(mnx, *it);
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
long long knapSack(int W, int wt[], int val[], int n) 
{ 
    int i, w; 
    long long K[n+1][W+1]; 
    for (i = 0; i <= n; i++) 
    { 
    	for (w = 0; w <= W; w++) 
    	{ 
    		if (i==0 || w==0) 
    			K[i][w] = 0; 
    		else if (wt[i-1] <= w) 
    				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
    		else
    				K[i][w] = K[i-1][w]; 
    	} 
    } 
    return K[n][W]; 
} 
int main() 
{ 
	int n,w;
	cin>>n>>w;
	int wt[n];
	int v[n];
	for(int i=0;i<n;i++)
	cin>>wt[i]>>v[i];
	cout<<knapSack(w,wt,v,n);
	return 0; 
} 


Measured memory_bytes: 79104
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    h = list(map(int, input().split()))
    dp = [0]*(N)
    dp[1] = abs(h[1]-h[0])
    for i in range(N-2):
        dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]), dp[i+1]+abs(h[i+2]-h[i+1]))
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14356
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int max, min;
    cin >> max;
    min=max;

    for(int i=0; i<n-1; i++){
        int tmp;
        cin >> tmp;
        if(tmp<min){
            min=tmp;
        }else if(tmp>max){
            max=tmp;
        }
    }
    cout << max-min;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }
#include <atcoder/all>
using namespace atcoder;
int main()
{
    int N, M;
    cin >> N >> M;
    dsu X(N);
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        --a;--b;
        X.merge(a, b);
        // int t, u, v;
        // cin >> t >> u >> v;
        // if(t == 0) X.merge(u, v);
        // else cout << (X.same(u, v) ? 1 : 0) << endl;
    }
    auto y = X.groups();
    cout << y.size()-1 << endl;
    return 0;
}

Measured memory_bytes: 9036
from itertools import combinations

N, M = list(map(lambda x:int(x),input().split()))

def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

if N <= 1 and M <= 1:
    print(0)
elif N <= 1 and not M <= 1:
    print(nCr(M,2))
elif not N <= 1 and M <= 1:
    print(nCr(N,2))
else:
    print(nCr(N, 2) + nCr(M,2))

Measured memory_bytes: 3064
#include <cstdint>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};


int main(){
    ll n;
    cin >> n;
    vector<modint<1000000007>> A(n);
    for(ll i=0; i<n; i++){
        cin >> A[i].a;
    }
    modint<1000000007> colsum;
    modint<1000000007> taisum;
    for(ll i=0; i<n; i++){
        modint<1000000007> ai = A[i];
        colsum += ai;
        taisum += ai*ai;
    }
    cout << ((colsum*colsum -taisum)/2).a;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar  7 21:00:01 JST 2020
 **/

signed main() {
    Int a, b;
    cin >> a >> b;
    REP(i, 100000) {
        if (i * 108 / 100 - i == a && i * 110 / 100 - i == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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


int main(){
  int r,d,x1; cin>>r>>d>>x1;
  
  vector<int> x(11,x1);
  
  for(int i=1;i<11;i++){
    x[i]=r*x[i-1]-d;
    cout<<x[i]<<endl;  
  }
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

if A <= C:
    if C >= B:
        ans = 0
    elif D >= B:
        ans = B - C
    else:
        ans = D - C
else:
    if A >= D:
        ans = 0
    elif B >= D:
        ans = D - A
    else:
        ans = B - A

print(ans)



Measured memory_bytes: 2940
n, k = map(int, input().split())
d = input().split()

while True:
  ns = str(n)
  exists_dislike_number = False
  for ds in d:
    if ns.count(str(ds)) > 0:
      exists_dislike_number = True
  
  if exists_dislike_number:
    n += 1
  else:
    break

print(n)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

ll n;

ll calc(ll p) {
    ll q = 1;
    for (int i = 0; i < n; i++) {
        q = q * p;
        q %= mod;
    }
    return q;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    cin >> n;
    cout << (calc(10) + calc(8) + mod + mod - 2 * calc(9)) % mod << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

const int INF = 1000000000;

struct edge{int to,cost;};
vector<edge> G[100000];
int v,e,r;
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> > q;

int main(){
  scanf("%d %d %d",&v,&e,&r);
  for(int i=0;i<e;i++){
    int s,t,d;
    scanf("%d %d %d",&s,&t,&d);
    edge tmp;
    tmp.to = t;
    tmp.cost = d;
    G[s].push_back(tmp);
  }
  int d[v];
  fill(d,d+v,INF);
  d[r] = 0;
  q.push(P(0,r));
  while(!q.empty()){
    P p = q.top();
    q.pop();
    int nv = p.second;
    if(p.first>d[nv]) continue;
    for(int i=0;i<G[nv].size();i++){
      if(d[nv]+G[nv][i].cost<d[G[nv][i].to]){
        d[G[nv][i].to] = d[nv]+G[nv][i].cost;
        q.push(P(d[G[nv][i].to],G[nv][i].to));
      }
    }
  }
  for(int i=0;i<v;i++){
    if(d[i]==INF) printf("INF\n");
    else printf("%d\n",d[i]);
  }
  return 0;
}

Measured memory_bytes: 11180
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;
 
int main(){
    int N,A,B,C,X;
    while(~scanf("%d %d %d %d %d",&N,&A,&B,&C,&X)){
        //x' = (A × x + B) mod C
        if(N==0) break;
        int count = 0;
        vector<int> Y;
        for(int i=0;i<N;i++){
            int y;
            scanf("%d",&y);
            Y.push_back(y);
        }
 
        if(Y[0]==X && Y.size() == 1){
            goto last;
        }
         
        for(int i=0;i<Y.size();i++){
            for(int j=0;j<=100000;j++){  
                if(i==0 && Y[i]==X){
                    continue;
                }
                count++;
                X = (A*X + B) % C;
                if(Y[i]==X){
                    break;
                }
                if(count > 10000) goto last;                     
            }
        }
 
last:;
        printf("%d\n",count > 10000 ? -1 : count);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  
  int Lmax = 0, S = 0;
  for(int i = 0; i < N; i++) {
    if(L.at(i) > Lmax) {
      Lmax = L.at(i);
    }
    S = S + L.at(i);
  }
  
  if(S - Lmax > Lmax) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	var c int
	fmt.Scanf("%d %d %d", &a,&b,&c)

	var result string
	if a + b + c > 21 {
		result = "bust"
	} else {
		result = "win"
	}
	fmt.Printf("%s", result)
}

Measured memory_bytes: 512
n = int(input())
s = [int(input()) for _ in range(n)]
t = set()
i = 1
count = 0

while(i not in t):
    count += 1
    t.add(i)
    i = s[i-1]
    if i==2:
        print(count)
        break
else:
    print(-1)

Measured memory_bytes: 55896
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let r = scan.read::<i64>();
    println!("{}", r * r);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    ll n;
    cin >> n;
    ll res = 1000000000000000;
    for (ll i = 1; i*i <= n; ++i)
    if (n % i == 0)
    {
        res = min(res, i + n/i - 2LL);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
x = []
for _ in range(M):
    a, b = map(int, input().split())
    x.append([a, b])

x.sort(key=lambda x: x[1])
res = 0
right = 0
for i in range(M):
    if x[i][0] >= right:
        right = x[i][1]
        res += 1

print(res)

Measured memory_bytes: 21340
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int n,k; cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    int h; cin>>h;
    v[i]=h;
  }
  sort(v.begin(),v.end());
  int ans=v[k-1]-v[0];
  for(int i=1;i<n-k+1;i++){
    ans=min(ans,v[i+k-1]-v[i]);
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	// Code for A - Five Antennas
	A := make([]int, 6)
	for i := 0; i < 6; i++ {
		fmt.Scanf("%d", &A[i])
	}

	if A[4]-A[0] > A[5] {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}


Measured memory_bytes: 1832
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
#define EPS (1e-7)
#define DEF (1e+9 + 7)

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)





int main() {
	int primenum[200] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997 };
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	VI v(200,0);
	long long ans=1;
	
	
	
	FOR(i, 1, n) {
		int j = 0;
		int temp = i;
		while(j<168) {
			if (primenum[j] > i) break;
			if (temp%primenum[j] == 0) {
				v[j]++;
				temp /= primenum[j];
			}
			else {
				j++;
			}
			
		}
	}

	

	int i = 0;
	while (i<168) {
		if (v[i] == 0) {
			break;
		}
		ans *= (v[i] + 1);
		//cout << ans << endl;
		if (ans > DEF) {
			ans %= (long long)DEF;
		}
		i++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  int ans=0;
  rep(i,n){
    if(h[i]>=k) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#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.at(i);
  }
  int m = 0;
  int64_t s = 0;
  for (int i = 0; i < n; i++){
    m = max(m, a.at(i));
    if (m > a.at(i)){
      s += m - a.at(i);
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3996
from operator import itemgetter

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

es = []
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es.append((a, b))

es.sort(key=itemgetter(1))

ans = 0
last_cut = -1
for a, b in es:
    if a <= last_cut < b:
        continue
    last_cut = b - 1
    ans += 1
print(ans)


Measured memory_bytes: 18224
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


def way6(ball, box):
    """ball: False / box: True / constraints: 1 or more
    -> ans = combination(ball - 1, box - 1)
    """
    if ball < box:
        return 0
    return comb.combination(ball - 1, box - 1)


n, k = map(int, input().split())
MOD = 10 ** 9 + 7
comb = Combination(10 ** 4, MOD)

print(way6(n, k))


Measured memory_bytes: 6348
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int a,b;
  cin >> a >> b;
  int diff = b - a;
  cout << (diff+1)*(diff)/2 - b << endl;
  return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 998244353;
long long int mod_pow(long long int x, long long int n, long long int p) {
    long long int res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
#define rep(i, n) for (int i = 0; i < n; i++)

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

    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];

    if (d[0] != 0) {
        cout << 0 << endl;
    } else {
        bool b = true;

        ll sum = 1;
        vll cnt(n, 0);
        int idx = 0;
        for (int i = 1; i < n; i++) {
            if (d[i] == 0) {
                b = false;
                break;
            }

            cnt[d[i]]++;

            idx = max(idx, d[i]);
        }
        cnt[0] = 1;

        for (int i = 1; i <= idx; i++) {
            sum *= mod_pow(cnt[i - 1], cnt[i], mod);
            sum %= mod;
        }

        if (b) {
            cout << sum << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 1408
def sec(h,m,s):
	return 3600*h+60*m+s

def hms(sec):
	return f"{sec//3600} {(sec//60)%60} {sec%60}"

for i in range(3):
	h,m,s,H,M,S=map(int,input().split())
	print(hms(sec(H,M,S)-sec(h,m,s)))



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll LCD(ll a,ll b){
	if(a<b) swap(a,b);
	while(b){
		ll t = a%b;
		a = b;
		b = t;
	}
	return a;
}
ll solve(ll a,ll b){ //number of multiples of b before a
	return a/b;
}
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll lcm = c*(d/LCD(c,d));
	ll ret = 0;
	ret+=(solve(b,c)-solve(a-1,c));
	ret+=(solve(b,d)-solve(a-1,d));
	ret-=(solve(b,lcm)-solve(a-1,lcm));
	cout<<b-a+1-ret;
}

Measured memory_bytes: 3596
N = int(input())
a = []
for i in range(N):
    a.append(input())
a.sort()
b = []
b.append(1)
j =1
k = 0
while j < N:
  if j == N:
    break
  elif a[j-1] == a[j]:
    b[k] += 1
    j += 1
  elif a[j-1] != a[j]:
    b.append(1)
    k += 1
    j += 1
ans = 0
for c in b:
  if c %2==1:
    ans += 1
print(ans)

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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

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

int lcm(int a, int b)
{
	return (a / gcd(a, b)) * b;
}

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int x,y;
	cin>>x>>y;
	if(y%2!=0){
		cout<<"No"<<endl;
		return ;
	}
	y/=2;
	if(y<x || y>(x*2)){
		cout<<"No"<<endl;
		return ;
	}
	cout<<"Yes"<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


Measured memory_bytes: 3684
#pragma GCC optimize(100)
#include<bits/stdc++.h>
using namespace std;
map<long long,int> mp;
int main()
{
	int n;
	cin>>n;
	long long ret=0,sum=0;
	mp[0]++;
	for(int i=0;i<n;i++)
	{
		long long a;
		cin>>a;
		sum+=a;
		ret+=mp[sum];
		mp[sum]++;
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>

#define N 100
char a[N][N];
int rows,cols;

int dfs(int curX,int curY, char curChar){
	if(curX < 0 || curX >= rows)return 0;
	if(curY < 0 || curY >= cols)return 0;
	if(a[curX][curY] != curChar)return 0;

	a[curX][curY] = '0';
	dfs(curX-1,curY,curChar);
	dfs(curX+1,curY,curChar);
	dfs(curX,curY-1,curChar);
	dfs(curX,curY+1,curChar);
	return 0;
}

int main(){
	while(scanf("%d%d",&rows,&cols),rows || cols){
		int count = 0;
		int i,j;
		getchar();
		for(i = 0; i < rows; i++){
			for(j = 0; j < cols; j++)
				scanf("%c",&a[i][j]);
			getchar();
		}
		for( i = 0; i < rows; i++)
			for(j = 0; j < cols; j++)
				if(a[i][j] != '0'){dfs(i,j,a[i][j]);count++;}

		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c[110000],cnt=0;
string s;
signed main()
{
	cin>>a>>b;
	rep(i,a){
		cin>>c[i];
		if(c[i]>=b){
			cnt++;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 1024
n = int(input())
s = list(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

R,G,B = [],[],[]


for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)


base = len(R) * len(G) * len(B)

B = set(B)

ans = 0
for r in R:
    for g in G:
        y = max(r,g)
        x = min(r,g)
        
        # x < 0 < y

        tmp = int((x+y)/2)
        if (x+y)%2==0 and (tmp in B):
            ans += 1
        # x<y<0
        tmp = 2*y-x
        if tmp in B:
            ans += 1
        #0 < x < y
        tmp = 2*x-y
        if tmp in B:
            ans += 1

print(base-ans)

Measured memory_bytes: 69080
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int H, W;
int A[25][25];

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

    cin >> H >> W;
    REP(i, H) REP(j, W) cin >> A[i][j];
    int ans = 1LL << 30;
    REP(i, H) REP(j, W) {
        int sub = 0;
        REP(k, H) REP(l, W) {
            sub += A[k][l] * min(abs(i - k), abs(j - l));
        }
        ans = min(ans, sub);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3208
#include<map>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

typedef long long ll;

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

ll fast_modmul(ll a,ll b,ll m){
	return (((a*(b>>20)%m)<<20)+a*(b&((1<<20)-1)))%m;
}

ll fast_modpow(ll a,ll n,ll m){
	ll r=1;
	for(ll x=a%m;n;n>>=1,x=(x*x)%m) if(n&1) r=(r*x)%m;
	return r;
}

ll modmul(ll a,ll b,ll m){
	ll r=0;
	for(;b;b>>=1,a=(a<<1)%m) if(b&1) r=(r+a)%m;
	return r;
}

ll modpow(ll a,ll n,ll m){
	ll r=1;
	for(ll x=a%m;n;n>>=1,x=modmul(x,x,m)) if(n&1) r=modmul(r,x,m);
	return r;
}

bool Miller_Rabin(ll n){
	if(n<=1)   return false;
	if(!(n&1)) return n==2;
	if(n%3==0) return n==3;

	int s=0; // n-1 = 2^s * d (d: odd)
	ll d=n-1;
	while(!(d&1)) s++, d>>=1;

	const static ll a[]={2,3,5,7,11,13,17,19,23};
	rep(i,sizeof a/sizeof(ll)){
		if(a[i]>=n) break;

		ll x=modpow(a[i],d,n);
		if(x==1 || x==n-1) continue;
		bool b=false;
		for(int r=1;r<s;r++){
			x=modmul(x,x,n);
			if(x== 1 ) return false;
			if(x==n-1){ b=true; break; }
		}
		if(!b) return false;
	}

	return true;
}

ll Pollard_rho(ll n,int c){
	if((n&1)==0) return 2;

	ll x=2,y=2,d=1;
	while(d==1){
		x=modmul(x,x,n)+c; if(x<0) x+=n;
		y=modmul(y,y,n)+c; if(y<0) y+=n;
		y=modmul(y,y,n)+c; if(y<0) y+=n;
		d=gcd(llabs(x-y),n);
	}
	return d<n?d:-1;
}

void prime_factorize(ll n,map<ll,int> &pf){
	if(n<=1) return;
	if(Miller_Rabin(n)){ ++pf[n]; return; }

	ll d;
	for(int c=1;;c++){
		d=Pollard_rho(n,c);
		if(d!=-1) break;
	}

	prime_factorize( d ,pf);
	prime_factorize(n/d,pf);
}

void dfs(int i,ll a,const vector< pair<ll,int> > &pf,vector<ll> &res){
	if(i==pf.size()){
		res.push_back(a);
		return;
	}

	dfs(i+1,a,pf,res);
	rep(j,pf[i].second){
		a*=pf[i].first;
		dfs(i+1,a,pf,res);
	}
}

const ll M=1000000007;

int main(){
	int n; scanf("%d",&n);
	ll o[1000],p[1000];
	rep(i,n) scanf("%lld%lld",o+i,p+i);

	rep(i,n){
		rep(j,i) if(o[i]==o[j]) {
			p[j]+=p[i];
			swap(o[i],o[n-1]);
			swap(p[i],p[n-1]);
			i--;
			n--;
			break;
		}
	}

	// 多項式 Σ p[i] * x^o[i] の正の重根を求めればよい

	// 0 は答えじゃないので x^hoge で割って定数項が見えるようにする
	ll o_min=*min_element(o,o+n);
	rep(i,n) o[i]-=o_min;

	ll c; // 定数項
	rep(i,n) if(o[i]==0) c=p[i];

	map<ll,int> pf;
	prime_factorize(llabs(c),pf);

	vector<ll> d; // c の約数全体
	vector< pair<ll,int> > pf2(pf.begin(),pf.end());
	dfs(0,1,pf2,d);

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

	rep(i,d.size()){
		ll x=d[i];

		if(x>M) break; // 大きい約数はどうせ答えじゃないので見ない ( TLE がきつい!! )

		ll val1=0,val2=0;
		rep(i,n){
			ll q=llabs(p[i])%M;
			int sgn=(p[i]>0?1:-1);
			val1=(val1+sgn*fast_modmul(q,fast_modpow(x%M,o[i],M),M)+M)%M;
			if(o[i]>0){
				val2=(val2+sgn*fast_modmul(fast_modmul(o[i],q,M),fast_modpow(x%M,o[i]-1,M),M)+M)%M;
			}
		}

		if(val1==0 && val2==0){ printf("Yes %lld\n",x); return 0; }
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <string.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
  fio;
  int a;
  cin>>a;
  int b = a + a*a + a*a*a ;
  cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>


int main()
{
	int sum=0,l[10],v1,v2,i;
	double t,r;

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
			     l,l+1,l+2,l+3,l+4,l+5,l+6,l+7,l+8,l+9,&v1,&v2)!=EOF)
	{
		for(i=0;i<10;i++) sum+=l[i];
		t=(double)sum/(v1+v2);
		r=v1*t;

		for(i=0;i<10;i++){
			r-=l[i];
			if(r<=0.0){
				printf("%d\n",i+1);
				break;
			}
		}
		sum=0;
	}

	return 0;
}

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

// C - Fennec vs Monster
int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for (long long i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(H.begin(), H.end(), greater<long long>());
    if (N - K <= 0) {
        cout << 0;
        return 0;
    }
    long long countAtack = 0;
    for (long long i = K; i < N; i++) {
        // cout << H[i] << endl;   // debug
        countAtack += H[i];
    }
    cout << countAtack;
}


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

int main(){
    //nはお菓子の種類、xはグラム
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i=0; i<n; i++) cin >> m.at(i);
    int ans = 0;
    for (int i=0; i < n; i++) {
        x = x - m.at(i);
        ans++;
    }

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

    while(x > 0) {
        if( x - m.at(0) >= 0) {
            x = x - m.at(0);
            ans++;
        }
        else break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
 
int main(void){
    int i,n;
    double s[1000],m,sd;
 
    while(1){
        scanf("%d",&n);
        if(n==0) break;
 
        m=0.0;
        sd=0.0;
 
        for(i=0;i<n;i++){
            scanf("%lf",&s[i]);
            m+=s[i];
        }
        m/=n;
        for(i=0;i<n;i++){
            sd+=(s[i]-m)*(s[i]-m);
        }
        sd/=n;
 
        printf("%lf\n",sqrt(sd));
    }
 
    return 0;
}


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

int N ;
int A , T ;
int H[100005];
int main(){
	int i , j ;
	scanf("%d%d%d",&N,&T , &A);
	int x  , index = -1 ;
	double min = 10000000 ;
	for( i = 0 ; i < N ; i++ ){
		scanf("%d",&x);
		double y = abs(A-(T-x*0.006)) ;
		if( y < min ) {
			min = y ;
			index = i ;
		}
	}
	printf("%d",index+1);

	return 0 ;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    ll r = 0, b = 0;
    cin >> S;
    for(auto &c: S) {
        if(c == '1') b++;
        else r++;
    }
    cout << 2 * min(r, b) << endl;
    return 0;
}


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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a >= b && a >= c){
    for(int i = 0;i < k;i++){
      a *= 2;
    }
  }
  else if(b > a && b >= c){
    for(int i = 0;i < k;i++){
      b *= 2;
    }
  }
  else{
    for(int i = 0;i < k;i++){
      c *= 2;
    }
  }
  cout << a+b+c << endl;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

res = 0
t = 0
for i in range(N - 1):
    if H[i + 1] <= H[i]:
        t += 1
    else:
        res = max(res, t)
        t = 0

res = max(res, t)
print(res)

Measured memory_bytes: 20448
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  if(n==0){
  	cout<<0;
    return 0;
  }
  vector<int> h(n);
  for(int i=0;i<n;i++){
  	cin>>h[i];
  }
  int x=0,y=abs(h[1]-h[0]),z;
  if(n==2){
  	cout<<y;
  }
  else if(n==1){
  cout<<x;}
  else{
  for(int i=2;i<n;i++){
  	z = min(x+abs(h[i]-h[i-2]), y+abs(h[i]-h[i-1]));
    x=y;
    y=z;
  }
  cout<<z<<endl;
  }
  }

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

int main()
{
  int n;
  cin >> n;
  int x[n], y[n], h[n];

  for (auto i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  const int pos_max = 100;
  for (auto py = 0; py <= pos_max; py++) {
    for (auto px = 0; px <= pos_max; px++) {
      int interim_h = -1;
      for (auto i = 0; i < n; i++) {
	if (h[i] > 0) {
	  int guess_h = h[i] + abs(px - x[i]) + abs(py - y[i]);
	  if (interim_h == -1) {
	    interim_h = guess_h;
	  } else if (interim_h != guess_h) {
	    interim_h = -2;
	    break;
	  }
	}
      }
      if (interim_h == -2) continue;
      for (auto i = 0; i < n; i++) {
	if (h[i] == 0) {
	  int guess_h = abs(px - x[i]) + abs(py - y[i]);
	  if (interim_h > guess_h) {
	    interim_h = -2;
	    break;
	  }
	}
      }
      if (interim_h == -2) continue;
      cout << px << " " << py << " " << interim_h << endl;
      return 0;
    }
  }
}


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

string to_string(const string& s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 1e6+2;
vector<int> divs[nn];
vector<int> cnt(nn);

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

	fr(i, 0, n) {
		cin >> a[i];
		cnt[a[i]]++;

		int x = a[i];
		if(sz(divs[x])) continue;

		divs[x].push_back(1);
		for(int j = 2; j * j <= x; j++) {
			if(x % j == 0) {
				divs[x].push_back(j);
				if(j != x/j) divs[x].push_back(x/j);
			}
		}
		divs[x].push_back(x);
	}

	int ans = 0;
	fr(i, 0, n) {
		if(cnt[a[i]] > 1) continue;
		bool ok = 0;

		for(int x : divs[a[i]]) {
			if(cnt[x]) {
				if(x != a[i]) {
					ok = 1;
					break;
				}
			}
		}
		if(! ok) ans++;
	}
	cout << ans << nl;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // clock_t tStart = clock();
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 67176
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] al = new int[100002];
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(a != 0){
                al[a-1]++;
            }
            al[a]++;
            al[a+1]++;
        }
        int ans = 0;
        for(int a : al){
            ans = Math.max(ans, a);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50088
#include<bits/stdc++.h>
using namespace std;
#define MAXN 21
#define MOD 1000000007

int N, a[MAXN + 3][MAXN + 3], dp[MAXN + 3][(1 << MAXN) + 3];

int solve(int idx, int mask) {
    if (idx == -1)
        return 1;

    if (dp[idx][mask] != -1)
        return dp[idx][mask];

    int result = 0;
    for (int i = 0; i < N; i++) {
        if ((mask & (1 << i)) && a[idx][i] == 1) {
            result = (result + solve(idx - 1, mask ^ (1 << i)))%MOD;
        }
    }

    return dp[idx][mask] = result;
}

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

    memset(dp, -1, sizeof(dp));

    cout << solve(N - 1, (1 << N) - 1) << endl;
}


Measured memory_bytes: 196864
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int happy = 0;
        
        happy += X / 500 * 1000;
        X = X % 500;
        happy += X / 5 * 5;
        
        System.out.println(happy);
    }
}


Measured memory_bytes: 35668
import bisect
n,q=map(int,input().split())
s=input()
a=[]
for i in range(n-1):
  if s[i:i+2]=='AC':
    a.append(i)
for _ in range(q):
  l,r=map(int,input().split())
  print(bisect.bisect(a,r-1.5)-bisect.bisect(a,l-1.5))

Measured memory_bytes: 11048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100

int N,Z,W;
int a[2000];

// char X[100][100];
// int dp[1000000001];

int main(void){
    cin >> N >> Z >> W;
    int mx = 0;
    int mn = 1000000000;
    
    cin >> a[0];
    REP(i,1,N) {
        cin >> a[i];
        if (a[i] >= mx) mx = a[i];
        if (a[i] <= mn) mn = a[i];
    }
    
    // cout << mx << mn << a[N-1] << endl;
    // 最後のカードが最初のカードより小さければ最後はyに引かせる
    // if (a[0] > a[N-1]) 

    if (N >= 2) {
        cout << max(abs(a[N-1] - W),abs(a[N-2] - a[N-1])) << endl;
    }
    else if (N == 1) {
        cout << abs(a[0] - W) << endl;
    }
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}  

Measured memory_bytes: 3572
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
c = []
s = []
f = []
for i in range(n-1):
    a,b,z = inpl()
    c.append(a)
    s.append(b)
    f.append(z)

for i in range(n):
    if i == n-1:
        print(0)
        break
    tmp = s[i] + c[i]
    for j in range(i+1,n-1):
        if tmp <= s[j]:
            tmp = s[j] + c[j]
        elif (tmp - s[j]) % f[j] == 0:
            tmp = tmp + c[j]
        else:
            tmp = (tmp//f[j]+1)*f[j] + c[j]
    print(tmp)

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

typedef long long ll;

set<pair<int, int>> seg_pl, seg_lp;

char c[100005];

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

  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }

  int bc = 0;

  for (int i = 2; i <= n; i++)
    if (c[i] != c[i - 1]) bc++;

  while (bc && k) {
    bc -= min(bc, 2);
    k--;
  }

  // cout << "Rem" << bc << endl;

  int ans = n - 1 - bc;

  cout << ans << endl;
}

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

ll n;
ll c[200020];
vector<vector<int>> v(200200);
bool used[200020]={};

ll x[200020];

void dfs(int p, ll d){
    used[p] = true;
    d+=x[p];
    c[p] += d;
    for(auto i:v[p]){
        if(!used[i]){
            dfs(i,d);
        }
    }
}

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

    ll q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    while(q--){
        ll a,y;
        cin>>a>>y;
        a--;
        x[a]+=y;
    }
    dfs(0,0);
    ll ans = 0;
    for(int i=0;i<n;i++){
        cout << c[i] << " ";
    }
    cout<<endl;



}

Measured memory_bytes: 22656
#include <stdio.h>
#include <stdlib.h>

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

int main (void) {
	int a, b, c, k, sum = 0;
	scanf("%d", &k);
	for (c = 1; c <= k; c++) {
		for (b = 1; b <= k; b++) {
			for (a = 1; a <= k; a++) {
				sum += gcd(gcd(a, b), c);
			}
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1732