akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#define N 100001
#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
};

Node tree[N];

int computeDepth (Node node) {
    int depth = 0;
    int parent_number;
    while (node.parent != -1) {
        depth++;
        node = tree[node.parent];
    }

    return depth;
}

string returnType(Node node) {
    if (node.parent == -1) {
        return "root";
    } else if (node.left != -1) {
        return "internal node";
    } else {
        return "leaf";
    }
}

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

    for (int i = 0; i < n; i++) {
        tree[i].parent = NIL;
        tree[i].left = NIL;
        tree[i].right = NIL;
    }

    int number;
    int degree;
    for (int i = 0; i < n; i++) {
        cin >> number;
        cin >> degree;

        int child_number;
        int left;
        for (int j = 0; j < degree; j++) {
            cin >> child_number;
            if (j == 0) tree[number].left = child_number;
            else tree[left].right = child_number;
            left = child_number;
            tree[child_number].parent = number;
        }
    }

    for (int i = 0; i < n; i++) {
        Node node = tree[i];
        cout << "node" << " " << i << ": ";
        cout << "parent = " <<  node.parent << ", ";
        cout << "depth = " << computeDepth(node) << ", ";
        cout << returnType(node) << ", ";
        cout << "[";
        int child = node.left;
        int j = 0;
        while (child != -1) {
            if (j != 0) cout << ", ";
            cout << child;
            child = tree[child].right;
            j++;
        }
        cout << "]";
        cout << endl;
    }
}


Measured memory_bytes: 4272
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

dp = [0] * (1 << n)
dp[0] = 1

for bit in range(1,1 << n):
    i = bin(bit).count('1')
    for j in range(n):
        if (bit >> j) & 1 and a[i - 1][j] :
            dp[bit] += dp[bit ^ (1 << j)]
    dp[bit] %= mod
print(dp[-1])


Measured memory_bytes: 58844
# does not contain more than K non 
# zero digits 
  
# This function returns the count of 
# required numbers from 0 to num 
def countInRangeUtil(pos, cnt, tight, num): 
  
    # Last position 
    if pos == len(num): 
  
        # If count of non zero digits 
        # is less than or equal to K 
        if cnt <= K: 
            return 1
        return 0
  
    # If this result is already computed 
    # simply return it 
    if dp[pos][cnt][tight] != -1: 
        return dp[pos][cnt][tight] 
  
    ans = 0
  
    # Maximum limit upto which we can place 
    # digit. If tight is 1, means number has 
    # already become smaller so we can place 
    # any digit, otherwise num[pos] 
    limit = 9 if tight else num[pos] 
  
    for dig in range(limit + 1): 
        currCnt = cnt 
  
        # If the current digit is nonzero 
        # increment currCnt 
        if dig != 0: 
            currCnt += 1
  
        currTight = tight 
  
        # At this position, number becomes 
        # smaller 
        if dig < num[pos]: 
            currTight = 1
  
        # Next recursive call 
        ans += countInRangeUtil(pos + 1, currCnt, currTight, num) 
  
    dp[pos][cnt][tight] = ans 
    return dp[pos][cnt][tight] 
  
# This function converts a number into its 
# digit vector and uses above function to compute 
# the answer 
def countInRange(x): 
    global dp, K, M 
  
    num = [] 
    while x: 
        num.append(x % 10) 
        x //= 10
  
    num.reverse() 
  
    # Initialize dp 
    dp = [[[-1, -1] for i in range(M)] for j in range(M)] 
    return countInRangeUtil(0, 0, 0, num) 
  
# Driver Code 
if __name__ == "__main__": 
  
    # states - position, count, tight 
    dp = [] 
    M = 100
  
    # K is the number of non zero digits 
    K = 0
  
    L = 1
    R = int(input())
    K = int(input())
    a=countInRange(R)
    K=K-1
    b=countInRange(R)
    print(a-b)
  

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

int main(){
  int N; cin >> N;
  vector<pair<int, int>> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back({a, i});
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for(int i=0; i<N; i++){
    if((A[i].second - i) % 2 != 0) ans++;
  }
  cout << (ans+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 1400
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  tmp = input.shift();
  N = parseInt(tmp.split(" ")[0]);
  M = tmp.split(" ")[1];
  S = input;
  A = "n".repeat(N).split("");
  flag = true;
  S.forEach(v => {
    t = v.split(" ").map(v => parseInt(v));
    if (A[t[0] - 1] != "n" && A[t[0] - 1] != t[1]) flag = false;
    A[t[0] - 1] = t[1];
  });
  A = A.join("");
  A = A.replace(/^nnn/, "100");
  A = A.replace(/^nn([0-9])/, "10$1");
  A = A.replace(/^n([0-9])/, "1$1");
  A = A.replace(/n/g, "0");
  A = parseInt(A);
  if (flag && (A + "").length == N) {
    console.log(A);
  } else {
    console.log(-1);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int a, b;
   cin >> a >> b;
   string sb = to_string(b);
   int tmp = a * pow(10, sb.size()) + b;
   for (int i = 1; i <= 400; i++) {
      if (tmp == i * i) {
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort()

  if n%2==0:
    for i in range(n):
      if (i//2)*2+1!=l[i]:
        return 0
    return pow(2,n//2)%mod

  else:
    if l[0]!=0:
      return 0
    l.remove(0)
    for i in range(n-1):
      if (i//2)*2+2!=l[i]:
        return 0
    return pow(2,n//2)%mod

print(main())


Measured memory_bytes: 16296
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    cin>>n;
    cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

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

    vector<tuple<int, int, int>> city_map(M);

    rep(i, M)
    {
        int p, y;
        cin >> p >> y;

        city_map[i] = make_tuple(p, y, i);
    }
    sort(ALL(city_map));

    //yを県ごとの順序に書き換え
    city_map[0] = make_tuple(get<2>(city_map[0]), 1, get<0>(city_map[0]));
    int y_order = 2;
    REP(i,1,M){
        if(get<2>(city_map[i-1]) != get<0>(city_map[i])){
            y_order = 1;
        }
        city_map[i] = make_tuple(get<2>(city_map[i]), y_order, get<0>(city_map[i]));
        y_order++;
    }

    sort(ALL(city_map));

    rep(i, M) {
        printf("%06d%06d\n", get<2>(city_map[i]), get<1>(city_map[i]));
    }
    return 0;
}

Measured memory_bytes: 2688
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let buf = buf.split_whitespace()
        .map(str::parse::<isize>).map(Result::unwrap).collect::<Vec<_>>();

    let r = *buf.get(0).unwrap();
    let c = *buf.get(1).unwrap();

    let mut elementss: Vec<Vec<isize>> = Vec::new();

    for _ in 0..r {
        let mut elements: Vec<isize> = Vec::new();

        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let buf = buf.split_whitespace().collect::<Vec<_>>();

        for i in 0..c {
            elements.push(buf.get(i as usize).unwrap().parse::<isize>().unwrap());
        }

        println!("{} {}", elements.iter().map(isize::to_string).collect::<Vec<_>>().join(" "), elements.iter().fold(0, |acc, x| acc + x));

        elementss.push(elements);
    }

    for i in 0..c {
        let mut res = 0;
        for elements in &elementss {
            res += *elements.get(i as usize).unwrap();
        }
        print!("{} ", res);
    }
    println!("{}",
        elementss.iter().fold(0, |acc, x|
            acc + x.iter().fold(0, |acc, y| acc + y)
        )
    );
}


Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
const ll mod =1e9 + 7;



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

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int S, W;
    cin >> S >> W; 
    if (S <= W) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3576
<?php

fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $k);
$n = strlen($s);

for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] != '1') {
        $not1 = $s[$i];
        break;
    }
}
$index_last1 = $i - 1;

if ($k <= 100) {
    if ($k - 1 <= $index_last1) {
        echo 1, PHP_EOL;
    } else {
        echo $not1, PHP_EOL;
    }
} else {
    echo $not1, PHP_EOL;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 

int l,r,d;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d%d",&l,&r,&d);
	printf("%d\n",r/d-(l-1)/d);
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define VI vector<int>
#define pb push_back
#define LL long long
#define mp make_pair
#define pii pair<int,int>
using namespace std;
int n, m;
const int MAXN = 1e5 + 1;
char A[MAXN+10];
int z[MAXN+10];
int M[MAXN+10];
int main(){
	scanf("%d %d %s", &n, &m, A); n++;
	for(int i = n - 1; i >= 0; i--){
		if(A[i] == '0') z[i] = i;
		else z[i] = z[i+1];
	}
	M[n-1] = 0;
	int cur = n - 1;
	while(cur > 0){
		int l = z[max(0, cur - m)];
		if(l == cur){
			printf("-1\n");
			return 0;
		}
		for(int i = l; i < cur; i++){
			if(A[i] == '0') M[i] = M[cur]+1;
		}
		cur = l;
	}
	cur = 0;
	while(cur < n - 1){
		for(int i = cur + 1; ; i++){
			if(A[i] == '0' && M[i] == M[cur]-1){
				printf("%s%d", (cur == 0)?"":" ", i-cur);
				cur = i;
				break;
			}
		}
	}
	printf("\n");
	return 0;
}

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

int N, A, B;
int P[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N >> A >> B;
    for (int i = 0; i < N; ++i) cin >> P[i];

    int first = 0;
    int second = 0;
    int third = 0;

    for (int i = 0; i < N; ++i){
        if(P[i] <= A){
            first += 1;
        }else if((A + 1 <= P[i]) && (P[i] <= B)){
            second += 1;
        }else{
            third += 1;
        }
    }

    cout << min(min(first, second), third) << endl;


}

Measured memory_bytes: 256
// @DateTime:    2020-04-27 16:40:41
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    int n;cin >> n;
    int ans = 0;
    for(int i = 1; i<= n; i++){
        int tp = 0;
        int ii =  i;
        while(ii){
            tp++;
            ii/=10;
        }
        if(tp & 1)ans++;
    }cout << ans <<endl;
    
}

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

int main() {

	string s;
	cin >> s;
	int n = (int)s.size();

	for(int i = 0; i < (n-1)/2; i++) {
		if(s[i] != s[n-i-1]) {
			cout << "No\n";
			return 0;
		}
	}

	for(int i = 0; i < (n-1)/2; i++) {
		if(s[i] != s[((n-1)/2)-i-1]) {
			cout << "No\n";
			return 0;
		}
	}

	s = s.substr(0, (n-1)/2);
	//cout << "Half is " << s << endl;

	for(int i = 0; i < (n-1)/2; i++) {
		if(s[i] != s[((n-1)/2)-i-1]) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;


long long  price;
long long  pay;
int m[]={1000,500,100};
void solve(){
	int cnt[3];
	for(int i=0;i<3;i++)cnt[i]=0;
	int money=pay-price;
	for(int i=0;i<3;i++){
		cnt[i]=money/m[i];
		money=money%m[i];
	}

	cout<<cnt[2]<<" "<<cnt[1]<<" "<<cnt[0]<<endl;
}
int main(){
	while(cin>>price>>pay&&(price&&pay)){
		
		solve();
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long k,a,b;
    cin>>k>>a>>b;
    if(k<a-3)
        cout<<k+1;
    else
        cout<<max(k+1LL,((k-a+1LL)/2LL)*(b-a)+(k-a+1LL)%2LL+a);
    return 0;
}


Measured memory_bytes: 256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
a = input()

if a[-1] == "3":
    print("bon")

elif a[-1] == "0" or a[-1] == "1" or a[-1] == "6" or a[-1] == "8":
    print("pon")

else :
    print("hon")


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    vector<int> minK(N-1);
    rep(i, N-1) repSE(j, i+1, N) {
        int minD = min(j - i, 1 + abs(X - i) + abs(j - Y));
        minK[minD - 1] ++;
    }
    rep(i, N -1) cout << minK[i] << "\n";
    return 0;
}


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

using namespace std;

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

    int n;
    cin>>n;

    if(n<1000)
        cout<<"ABC";
    else
        cout<<"ABD";
    return 0;
}


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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAXK = 105 ;
const int MAXN = 1e9 + 10 ;
const int SQRTMAXN = sqrt(MAXN)+1 ;

long long n , k ;
long long dp[MAXK][SQRTMAXN] ;
long long dpsum1[MAXK][SQRTMAXN] ;
long long dpsum2[MAXK][SQRTMAXN] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	int sqrtn = 0 ;
	for(long long i = 1ll ; i * i <= n ; ++i)
		sqrtn++ ;
	long long choices = 0 ;
	for(int j = 1 ; j <= sqrtn ; ++j)
	{
		choices = max(0ll , n / j - sqrtn) ;
		dp[1][j] = 1ll ;
		dp[2][j] = n / j ;
		dpsum1[1][j] = (dpsum1[1][j-1] + dp[1][j]) % mod ;
		dpsum2[1][j] = (dpsum2[1][j-1] + ((dp[1][j] * choices) % mod)) % mod ;
		dpsum1[2][j] = (dpsum1[2][j-1] + dp[2][j]) % mod ;
		dpsum2[2][j] = (dpsum2[2][j-1] + ((dp[2][j] * choices) % mod)) % mod ;
	}
	for(int i = 3 ; i <= k ; ++i)
	{
		for(int j = 1 ; j <= sqrtn ; ++j)
		{
			choices = max(0ll , n / j - sqrtn) ;
			dp[i][j] = (dpsum1[i-2][j-1] * choices) % mod ;
			long long x = (dpsum2[i-2][sqrtn] - dpsum2[i-2][j-1] + mod) % mod ;
			dp[i][j] = (dp[i][j] + x) % mod ;
			dp[i][j] = (dp[i][j] + dpsum1[i-1][min(n/j , sqrtn*1ll)]) % mod ;
		}
		for(int j = 1 ; j <= sqrtn ; ++j)
		{
			choices = n / j ;
			choices = max(0ll , choices - sqrtn) ;
			dpsum1[i][j] = (dpsum1[i][j-1] + dp[i][j]) % mod ;
			dpsum2[i][j] = (dpsum2[i][j-1] + ((dp[i][j] * choices) % mod)) % mod ;
		}
	}
	long long ans = 0ll ;
	for(int j = 1 ; j <= sqrtn ; ++j)
	{
		choices = n / j ;
		long long x = (dp[k-1][j] * max(0ll , choices - sqrtn)) % mod ;
 		ans = (ans + dp[k][j]) % mod ;
 		ans = (ans + x) % mod ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 77824
#include<iostream>
#include<string>
using namespace std;
string S, T; int a;
char c[101] = "00000000000abcde00000fghij00000klmno00000pqrst00000uvwxy00000z.?! 0000000000000000000000000000000000";
int main() {
	while (cin >> S) {
		T = "";
		if (S.size() % 2 == 1) {
			cout << "NA" << endl; goto E;
		}
		for (int i = 0; i < S.size() / 2; i++) {
			a = stoi(S.substr(i * 2, 2));
			if (c[a] == '0') { cout << "NA" << endl; goto E; }
			else { T += c[a]; }
		}
		cout << T << endl;
	E:;
	}
}

Measured memory_bytes: 3180
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
bool check(ll x)
{
    ll t=n;
    while(t%x==0) t/=x;
    return t%x==1;
}
int sol(ll n)
{
    int re=0;
    for(int i=2;i<=n/i;++i) if(n%i==0)
    {
        if(check(i)) ++re;
        if((ll)i*i==n) continue;
        if(check(n/i)) ++re;
    }
    return re;
}
int main()
{
    scanf("%lld",&n);
    if(n==2)
    {
        puts("1");
        return 0;
    }
    int an=2;
    an+=sol(n);
    an+=sol(n-1);
    printf("%d\n",an);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

const int MAX_N = 1010;

int A[MAX_N][MAX_N];
int node_number[MAX_N][MAX_N];

vector<int> graph[MAX_N * MAX_N];
int state[MAX_N * MAX_N];

bool dfs(int node, vector<int>& tsorted_node) {
    if (state[node] == GRAY) return false;
    if (state[node] == BLACK) return true;
    bool res = true;
    state[node] = GRAY;
    rep(i, 0, graph[node].size()) {
        res &= dfs(graph[node][i], tsorted_node);
    }
    tsorted_node.push_back(node);
    state[node] = BLACK;
    return res;
}

vector<int> tsort(int n) {
    bool is_ok = true;
    vector<int> res;
    rep(i, 0, n) {
        if (state[i] == BLACK) continue;
        is_ok &= dfs(i, res);
    }
    if (is_ok) {
        reverse(all(res));
        return res;
    }
    else return vector<int>(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    rep(i, 0, N) rep(j, 0, N - 1) {
        cin >> A[i][j];
        A[i][j]--;
    }
    rep(i, 0, N) rep(j, 0, N) node_number[i][j] = -1;
    int number = 0;
    rep(i, 0, N) rep(j, 0, N - 2) {
        if (node_number[i][A[i][j]] < 0) node_number[i][A[i][j]] = node_number[A[i][j]][i] = number++;
        if (node_number[i][A[i][j + 1]] < 0) node_number[i][A[i][j + 1]] = node_number[A[i][j + 1]][i] = number++;
        graph[node_number[i][A[i][j]]].push_back(node_number[i][A[i][j + 1]]);
    }
    vector<int> nodes = tsort(N * (N - 1) / 2);
    if (nodes.size() == 0) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> dist(nodes.size(), 0);
    rep(i, 0, nodes.size()) {
        rep(j, 0, graph[nodes[i]].size()) {
            dist[graph[nodes[i]][j]] = max(dist[graph[nodes[i]][j]], dist[nodes[i]] + 1);
        }
    }
    int ans = 0;
    rep(i, 0, dist.size()) {
        ans = max(ans, dist[i]);
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 55796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
signed main(){
  int n,a,b;
  cin >> n >> a >> b;
  if(a < b && n >= 2){
    cout << b*(n-2) - a*(n-2) + 1 << endl; 
  }
  else if(a == b){
    cout << 1 << endl;
  }
  else cout << 0 << endl;
}

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

int main(){
    int n,c;
    cin >> n >> c;
    int d[c][c];
    for(int i=0; i<c; i++){
        for(int j=0; j<c; j++){
            cin >> d[i][j];
        }
    }
    int color[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> color[i][j];
            color[i][j]--;
        }
    }
    long long x[c],y[c],z[c];
    fill(x,x+c,0);
    fill(y,y+c,0);
    fill(z,z+c,0);
    for(int i=0; i<c; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<n; k++){
                if((j+k)%3 == 0){
                    x[i] += d[color[j][k]][i];
                }
                else if((j+k)%3 == 1){
                    y[i] += d[color[j][k]][i];
                }
                else z[i] += d[color[j][k]][i];
            }
        }
    }
    pair<int,int> minx[3],miny[3],minz[3];
    for(int i=0; i<3; i++){
        auto p = min_element(x,x+c);
        minx[i] = make_pair(p-x,*p);
        auto q = min_element(y,y+c);
        miny[i] = make_pair(q-y,*q);
        auto r = min_element(z,z+c);
        minz[i] = make_pair(r-z,*r);
        *p = 1000000000;
        *q = 1000000000;
        *r = 1000000000;
    }
    long long ans = 1000000000;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(minx[i].first == miny[j].first) continue;
            for(int k=0; k<3; k++){
                if(minx[i].first == minz[k].first) continue;
                if(miny[j].first == minz[k].first) continue;
                long long t = 0;
                t += minx[i].second + miny[j].second + minz[k].second;
                if(t < ans) ans = t;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        v[x] = i;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << v[i] << " " ;
    }
    return 0;
}

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

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> h(N);

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

  int count = 0;

  for (int i = 0; i < N; i++) {
    if (K <= h[i]) {
      count++;
    }
  }

  cout << count << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define M 1000000007
#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int a,b,m;cin>>a>>b>>m;
	int ref[a+1],mic[b+1],i;
	for(i=1;i<=a;i++)
		cin>>ref[i];
	for(i=1;i<=b;i++)
		cin>>mic[i];
	int o=*min_element(ref+1,ref+a+1)+*min_element(mic+1,mic+b+1);
	while(m--)
	{
		int x,y,c;cin>>x>>y>>c;
		o=min(o,ref[x]+mic[y]-c);
	}
	cout<<o<<endl;
}

Measured memory_bytes: 1792
def calc(num):
    ans = 0
    for i in str(num):
        ans += int(i)
    return ans


n, a, b = map(int, raw_input().split(" "))
lis = []
for i in xrange(n):
    tmp = calc(i + 1)
    if a <= tmp  and tmp <= b:
        lis.append(i + 1)

print sum(lis)


Measured memory_bytes: 2948
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>

using namespace std;

int n;
const double th = M_PI * 60.0 / 180.0;
double cos60, sin60;

void printPair(pair<double, double> p) {
	cout << fixed << setprecision(8) << p.first << " " << p.second << endl;
}
void koch(int d, pair<double, double> p1, pair<double, double> p2) {
	if (d == 0) return;
	pair<double, double> s = pair<double, double>((2.0 * p1.first + 1.0 * p2.first) / 3.0, (2.0 * p1.second + 1.0 * p2.second) / 3.0);
	pair<double, double> t = pair<double, double>((1.0 * p1.first + 2.0 * p2.first) / 3.0, (1.0 * p1.second + 2.0 * p2.second) / 3.0);
	pair<double, double> u = pair<double, double>((t.first - s.first) * cos60 - (t.second - s.second) * sin60 + s.first, (t.first - s.first) * sin60 + (t.second - s.second) * cos60 + s.second);

	koch(d-1, p1, s);
	printPair(s);

	koch(d-1, s, u);
	printPair(u);

	koch(d-1, u, t);
	printPair(t);

	koch(d-1, t, p2);
}
int main()
{
	cos60 = cos(th);
	sin60 = sin(th);
	cin >> n;
	pair<double, double> p1 = pair<double, double>(0, 0);
	pair<double, double> p2 = pair<double, double>(100, 0);
	printPair(p1);
	koch(n, p1, p2);
	printPair(p2);

	return 0;
}

Measured memory_bytes: 1240
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];

        for (int i=0; i<num-1; i++) {
            int bossNum = sc.nextInt() - 1;
            array[bossNum]++;
        }

        for (int i: array) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 60516
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

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

const int dx8[] = {-1, 0, 1, 0,1,1,-1,-1};
const int dy8[] = {0, -1, 0, 1,1,-1,1,-1};

vector<ll> arr,rank1 ;
unordered_map<ll,ll> m ;

ll p( ll x)
{


    if(x==arr[x])
         return x;
    return arr[x]=p(arr[x]);
}
void join(ll x ,ll y )
{

    x=p(x),y=p(y);
    if(rank1[x]<rank1[y]) arr[x]=y ;
    else if(rank1[x]>rank1[y]) arr[y] =x;
    else
    {
        rank1[y]++;
        arr[x]=y ;
    }
}

void solve()
{
 ll n;
 cin >>n ;
 vector<pair<ll,pair<ll,ll> > > ans,ans2;

 arr.clear();
 rank1.clear();
 for(ll i=0;i<n;i++)
 {
     rank1.pb(0);
     arr.pb(i);
 }

 for( ll i =0  ;i<n;i++)
 {
     ll x ,y ;
     cin>> x >> y ;
     ans.pb({x*-1,{i,y}});
     ans2.pb({y*-1,{i,x}});
 }
 sort(ans.begin(),ans.end());
 stack<ll > s;
 for(ll i=n-1 ;i>=0 ;i--)
 {
     while(!s.empty() && ans[i].ss.ss> ans[s.top()].ss.ss)
     {
         join(ans[i].ss.ff,ans[s.top()].ss.ff);
         s.pop();
     }
     s.push(i);

 }


 sort(ans2.begin(),ans2.end());
 stack<ll > s2;
 for(ll i=n-1 ;i>=0 ;i--)
 {
     while(!s2.empty() && ans2[i].ss.ss> ans2[s2.top()].ss.ss)
     {
         join(ans2[i].ss.ff,ans2[s2.top()].ss.ff);
         s2.pop();
     }
     s2.push(i);

 }
 stack<ll> s3;
 for(ll i=0 ;i<n ;i++)
 {
     while(!s3.empty() && ans[i].ss.ss< ans[s3.top()].ss.ss)
     {
         join(ans[i].ss.ff,ans[s3.top()].ss.ff);
         s3.pop();
     }
     s3.push(i);

 }


 stack<ll > s4;
 for(ll i=0 ;i<n ;i++)
 {
     while(!s4.empty() && ans2[i].ss.ss< ans2[s4.top()].ss.ss)
     {
         join(ans2[i].ss.ff,ans2[s4.top()].ss.ff);
         s4.pop();
     }
     s4.push(i);

 }



 m.clear();
  for(ll i =0;i<n;i++)
  {

      m[p(i)]++;
  }
  for(ll i=0;i<n;i++)
  {
    cout << m[p(i)] << endl;

  }



}



int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     solve();
}


Measured memory_bytes: 10760
//IrohaandHaiku.cpp (A)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  bool flag = false;
  if(A[0] == 7&&A[1] == 5&&A[2] == 5) flag =true;
  if(A[0] == 5&&A[1] == 7&&A[2] == 5) flag =true;
  if(A[0] == 5&&A[1] == 5&&A[2] == 7) flag =true;
  if(flag) printf("YES\n");
  else printf("NO\n"   );

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = 700;
  rep(i,3){
    if(s[i]=='o') ans+=100;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(i%2==0&&a[i]%2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
/* -- template -- */

const int MAX = 1000100;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i)%MOD;//拡張euclid互除法によるi!の逆元計算
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD)%MOD;
}

int Ss[2020];

int main() {
    string S;
    cin >> S;
    int cur = 1, sum = 0;
    rep(i, S.size()) {
        sum = (sum + (S[S.size() - 1 - i] - '0') * cur % 2019) % 2019;
        cur = (cur * 10) % 2019;
        Ss[sum]++;
    }
    ll ans = 0;
    rep(i, 2020) {
        if(i == 0)
            ans += Ss[i];
        ans += (Ss[i]) * (Ss[i] - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Stream;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.function.Function;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] ABC = new int[]{in.nextInt(), in.nextInt(), in.nextInt()};
            Map<Integer, List<Integer>> collect = Arrays.stream(ABC).mapToObj(Integer::valueOf).collect(Collectors.groupingBy(Function.identity()));
            out.println(collect.getOrDefault(5, new ArrayList<>()).size() == 2 && collect.getOrDefault(7, new ArrayList<>()).size() == 1 ? "YES" : "NO");
        }

    }
}



Measured memory_bytes: 27856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  int x4=0, x2=0, x1=0;
  rep(i,N){
    if(A[i]%2==0) {
      if(A[i]%4==0) x4++;
      else x2++;
    }
    else x1++;
  }
  x2 %= 2;
  if(x1+x2 > x4+1) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static StringTokenizer st;
	public static void main(String[] args) throws IOException {
		int l = readInt();
      	double s = l*1.0/3;
      	System.out.println(s*s*s);
	}
	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}
	static long readLong () throws IOException {
		return Long.parseLong(next());
	}
	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}
	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}
	static char readCharacter () throws IOException {
		return next().charAt(0);
	}
	static String readLine () throws IOException {
		return br.readLine().trim();
	}
}





Measured memory_bytes: 22996
//28
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int a[25];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int r=32;
    for(int t=0;r;t++){
      if(t%2){
	r-=a[t/2%n];
      }else{
	r-=(r-1)%5;
      }
      if(r<0){
	r=0;
      }
      cout<<r<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int x,t;
	cin>>x>>t;
	cout<<max(0,x-t)<<endl;
}


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

int main ()
{
    int n,x,t;
    cin>>n>>x>>t;
    int y=n/x;
    int ans=0;
    ans=(n%x==0)?y*t:(y+1)*t;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
//#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
    int n,rem,i;
    bool flag=false;
    cin>>n;
    while(n!=0){
        rem=n%10;
        if(rem==7){
            flag=true;
            break;
        }
        n=n/10;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a>=13) {
		cout << b;
	}
	else if (a>=6&&a<=12) {
		cout << b / 2;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };

ll MOD = 10000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int a, b, d; cin >> a >> b >> d;
		if (a == 0) break;
		bool swapped = false;
		if (a < b) {
			swap(a, b);
			swapped = true;
		}
		for (int z = 0; ; z++)
			for (int x = 0; x <= z; x++) {
				int y = z - x;
				if (a * x + b * y == d || abs(a * x - b * y) == d) {
					if (swapped) swap(x, y);
					cout << x << ' ' << y << endl;
					goto L;
				}
			}
L:
		a;
	}
}

Measured memory_bytes: 1160
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

if a+b+c+d == 7:
  print('%d+%d+%d+%d=7' % (a, b, c, d))
elif a+b+c-d == 7:
  print('%d+%d+%d-%d=7' % (a, b, c, d))
elif a+b-c+d == 7:
  print('%d+%d-%d+%d=7' % (a, b, c, d))
elif a+b-c-d == 7:
  print('%d+%d-%d-%d=7' % (a, b, c, d))
elif a-b+c+d == 7:
  print('%d-%d+%d+%d=7' % (a, b, c, d))
elif a-b+c-d == 7:
  print('%d-%d+%d-%d=7' % (a, b, c, d))
elif a-b-c+d == 7:
  print('%d-%d-%d+%d=7' % (a, b, c, d))
elif a-b-c-d == 7:
  print('%d-%d-%d-%d=7' % (a, b, c, d))


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

int p2(int a){
    int ret = 0;
    while(a%2 == 0){
        a /= 2;
        ret++;
    }
    return ret;
}

int main(){
    int n1=0, n2=0, n0=0, n;
    scanf("%d", &n);
    while(n--){
        int a;
        scanf("%d", &a);
        int p = p2(a);
        if(p==0)
            n0++;
        else if(p == 1)
            n1++;
        else
            n2++;
    }
    if(n0 == 0 || (n0 <= n2+1 && n1==0)){
        cout<<"Yes";
        return 0;
    }
    if(n0>n2){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, c = LI()
clock_pos = []
value = []
for i, j in LIR(n):
    clock_pos += [i]
    value += [j]




arr = [0]
counter_arr = [0]
round_arr = [0]
round_counter_arr = [0]
ret = 0
counter_ret = 0
for i in range(n):
    ret += value[i]
    a = arr[i - 1]
    arr.append(max(arr[i], ret - clock_pos[i]))
    round_arr.append(ret - clock_pos[i] * 2)
    counter_ret += value[-i - 1]
    counter_arr.append(max(counter_arr[i], counter_ret - (c - clock_pos[-i - 1])))
    round_counter_arr.append(counter_ret - (c - clock_pos[-i - 1]) * 2)



ans = max(arr[-1], counter_arr[-1])
clock_pos = [0] + clock_pos  + [0]
for j in range(n):
    ans = max(ans, round_arr[j] + counter_arr[n - j], round_counter_arr[j] + arr[n - j])



print(ans)

Measured memory_bytes: 90076
using System;

namespace A___September_9
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            if(n[0]=='9'||n[1]=='9')
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
N, M = map(int, input().split())

AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a, b))
AB = sorted(AB, key=lambda x: x[1])

ans = 1
D = AB[0][1]
for i in range(1, M):
    if AB[i][0] >= D:
        ans += 1
        D = AB[i][1]
print(ans)


Measured memory_bytes: 57560
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	x := nextInt()
	l := nextInts(n)

	/*
		pos := 0
		cnt := 0
		for i := 0; i < n; i++ {
			if pos > x {
				break
			}
			cnt++
			pos += l[i]
		}
	*/

	pos := make([]int, n+1)
	pos[0] = 0

	for i := 0; i < n; i++ {
		pos[i+1] = pos[i] + l[i]
	}

	cnt := 0
	for i := 0; i < n+1; i++ {
		if pos[i] > x {
			break
		}
		cnt++
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 640
n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)

med2 = a.sort[(n/2-1),2]
first_med = med2.first
last_med = med2.last

a.each do |i|
  if first_med >= i
    puts last_med
  else
    puts first_med
  end
end

Measured memory_bytes: 25316
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 100001
#define int long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
const int maxn=10000000000ll;
map<int,int> e;
bool vis[10001];
int cnt,p[1001];
int n,ans,s[N],d[N],inv[N],mx;
bool tag[N];
main()
{
//	open(D);
	mx=ceil(pow(maxn,1/3.0))+3;
	re(n);
	for(int i=1;i<=n;++i)
		re(s[i]),d[i]=1;
	for(int i=2;i<=mx;++i)
	{
		if(!vis[i])
			p[++cnt]=i;
		for(int j=1,k;j<=cnt && (k=i*p[j])<=mx;++j)
		{
			vis[k]=1;
			if(i%p[j]==0)break;
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=cnt;++j)
			while(s[i]%(p[j]*p[j]*p[j])==0)
				s[i]/=p[j]*p[j]*p[j];
		++e[s[i]];
		inv[i]=s[i];
		for(int j=1;j<=cnt;++j)
		{
			if(inv[i]%(p[j]*p[j])==0)d[i]*=p[j];
			else if(inv[i]%p[j]==0)d[i]*=p[j]*p[j];
			while(inv[i]%p[j]==0)inv[i]/=p[j];
			if(d[i]>maxn)d[i]=0;
		}
		int w=sqrt(inv[i])+0.5;
		if(w*w==inv[i])d[i]*=w;
		else
		{
			if(inv[i]*inv[i]>maxn)d[i]=0;
			d[i]*=inv[i]*inv[i];
		}
	}
	if(e[1])++ans,e[1]=0;
	for(int i=1;i<=n;++i)
		ans+=max(e[s[i]],e[d[i]]),e[s[i]]=e[d[i]]=0;
	printf("%lld\n",ans);
}

Measured memory_bytes: 12928
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,q,lb,ub,dp[100010];
string s;

int main()
{
	cin>>n>>q>>s;
	rep(i,n-1)
	{
		dp[i+1]=dp[i]+(int)(s[i]=='A'&&s[i+1]=='C');
		//cout<<i+1<<' '<<dp[i+1]<<endl;
	}
	//cout<<endl;
	rep(i,q)
	{
		cin>>lb>>ub;
		//cout<<ub-1<<' '<<lb<<endl;
		cout<<dp[ub-1]-dp[lb-1]<<endl;
	}
	rt0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
signed main(){
  int N;
  cin>>N;
  int h[100010];
  for(int i=1;i<=N;i++){
    cin>>h[i];
  }
  int dp[10010];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(int i=3;i<=N;i++){
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 1152