akhauriyash/Code-Regression huggingface dataset:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
t=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        t+=1
print(t)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;
    vector<deque<int>> v(n, deque<int>(n - 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            cin >> v[i][j];
            v[i][j]--;
        }
    }

    int remain = n;
    vector<int> last(n);
    while (true) {
        bool found = false;
        for (int i = 0; i < n; i++) {
            if (v[i].empty())continue;

            int to = v[i][0];
            if (v[to][0] == i) {
                found = true;

                v[i].pop_front();
                if (v[i].empty())remain--;
                v[to].pop_front();
                if (v[to].empty())remain--;

                int day = max(last[i], last[to]);
                day++;
                last[i] = day;
                last[to] = day;
            }
        }
        if (remain == 0 || !found)break;
    }

    int ret = 0;
    for (int i = 0; i < n; i++)ret = max(ret, last[i]);
    cout << (remain == 0 ? ret : -1) << endl;
    return 0;
}

Measured memory_bytes: 4608
n = int(input().rstrip())
if n<3:
    print(0)
else:
    a = n//3
    ans = 1
    MOD = 1_000_000_007
    fact = [0]*2001
    inv = [0]*2001
    factinv = [0]*2001
    fact[0] = 1
    fact[1] = 1
    inv[0] = 1
    inv[1] = 1
    factinv[0] = 1
    factinv[1] = 1
    for i in range(2,2001):
        fact[i] = (fact[i-1]*i)%MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        factinv[i] = factinv[i - 1] * inv[i] % MOD
    for i in range(2,a+1):
        m = n-(i*3)
        ans = (ans + ((fact[m+i-1]*factinv[m]) %MOD*factinv[i-1])%MOD )%MOD
    print(ans)

Measured memory_bytes: 9356
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const int WinHand(const int t)
{
    if (t == 0) return 2;
    else return t - 1;
}

int main()
{
    int N, K; cin >> N >> K;
    int ps[3]; cin >> ps[0] >> ps[1] >> ps[2];
    vector<int> ts(N);
    for (int i = 0; i < N; ++i)
    {
        char ch; cin >> ch;
        switch (ch)
        {
        case 'r':
            ts[i] = 0;
            break;
        case 's':
            ts[i] = 1;
            break;
        case 'p':
            ts[i] = 2;
            break;
        }
    }
    // 最初のK回は勝ち続ければよい
    int ans = 0;
    vector<int> hands(N, -1);
    for (int i = 0; i < K; ++i)
    {
        ans += ps[WinHand(ts[i])];
        hands[i] = WinHand(ts[i]);
    }
    // K回目以降について，K回前に出した手以外の手で勝てるならば勝つ
    // 勝てる手が出せない場合は，次に勝てるような手を出しておく
    for (int i = K; i < N; ++i)
    {
        int prev = hands[i - K];
        int win = WinHand(ts[i]);
        if (win != prev)
        {
            ans += ps[win];
            hands[i] = win;
        }
        else
        {
            if (i + K < N)
            {
                int next = WinHand(ts[i + K]);
                hands[i] = (next + 1) % 3;
            }
            else
            {
                hands[i] = (prev + 1) % 3;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<string> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	vector<string> b(m);
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	
	bool yes = false;
	for(int i = 0; i + m <= n; ++i) {
		for(int j = 0; j + m <= n; ++j) {
			bool match = true;
			
			for(int k = 0; k < m; ++k) {
				if( a[i + k].substr(j, m) != b[k] ) match = false;
			}
			
			if( match ) yes = true;
		}
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var lss=sc.intarr;
        int n = lss[0];

        var s = sc.str;

        int ans = 0;

        for(int i = 0; i < n; ++i)
        {
            int sum = 0;
            var a = new HashSet<int>();
            var b = new HashSet<int>();

            for (int j = 0; j < i; ++j)
            {
                a.Add(s[j]-'a');
            }

            for (int k = i; k < n; ++k)
            {
                b.Add(s[k]-'a');
            }
            for(int l = 0; l < 26; ++l)
            {

                    
                    if (a.Contains(l) && b.Contains(l))
                    {
                        sum++;
                    }
                
            }
            ans = Math.Max(sum, ans);
        }
        wr.wri(ans);
    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//提出コード↓

int p, q, r, ma;



int main() {
	cin >> p >> q >> r;
	ma = max(p, max(q, r));
	cout << p + q + r - ma << endl;

	return 0;
}



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

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

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

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

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

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

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

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

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        d_list: [usize; n],
    }
    let set = d_list.iter().collect::<HashSet<&usize>>();
    println!("{}", set.len());
}


Measured memory_bytes: 4352
def rect(W,H,x,y):
    ans = [0]*2
    ans[0] = W*H/2
    if x == W/2 and y == H/2:
        ans[1] = 1
    else:
        ans[1] = 0
    return ans

W,H,x,y = map(int,input().split())

a = rect(W,H,x,y)
print(*a)

Measured memory_bytes: 3060
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
template<typename T> void debug(T x)
{
    cout<<"value="<<x<<endl;
    return;
}
signed main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    ll s=read();
    if(s<=1000000000) cout<<0<<' '<<0<<' '<<0<<' '<<s<<' '<<1<<' '<<0<<endl;
    else if(s==1e18) cout<<0<<' '<<0<<' '<<0<<' '<<1000000000<<' '<<1000000000<<' '<<0<<endl;
    else{
        ll s1=s/1000000000;
        s1++;
        ll s2=s1*1000000000-s;
        cout<<0<<' '<<0<<' '<<s1<<' '<<1<<' '<<s2<<' '<<1000000000<<endl;
    }
	return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    counts = [0] * 100000
    a.sort()
    for v in a:
        counts[v] += 1
    ret = 0
    for i in range(len(counts) - 2):
        ret = max(ret, counts[i] + counts[i + 1] + counts[i + 2])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15208
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,p=1,q=1;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>n;
    cout<<n*n<<endl;
    return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, c, x, y;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    int cnt = min(x, y);
    x -= cnt; y -= cnt;
    ans += min(a + b, c + c)*cnt;
    ans += min(a, c + c)*x;
    ans += min(b, c + c)*y;
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x,y = na()
ans = [0]*(n-1)

for j in range(1,n+1):
    for i in range(1,j):
        a = min(abs(i-j), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        ans[a-1] += 1

print(*ans, sep='\n')


Measured memory_bytes: 45916
use std::io;
use std::str::FromStr;

fn main() {
    let input: Vec<u32> = reads(&get_line());
    let answer = if input[0] + input[1] >= input[2] {
        "Yes"
    } else {
        "No"
    };
    println!("{}", answer);
}

fn get_line() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).expect("read error");
    inp.trim().to_string()
}

fn reads<T>(input: &str) -> Vec<T>
where
    T: FromStr,
    T::Err: std::fmt::Debug,
{
    input
        .trim()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect()
}


Measured memory_bytes: 4352
<?php

$plans = [
    0 => [0, 0, 0]
];

fscanf(STDIN, "%d", $n);

for ($i = 1; $i <= $n; ++$i) {
    list($t, $tx, $ty) = fscanf(STDIN, "%d %d %d");
    list($pt, $px, $py) = $plans[$i - 1];

    $movable = $t - $pt;
    $moved = abs($tx - $px) + abs($ty - $py);
    if ($movable >= $moved && ($movable - $moved) % 2 == 0) {
        $plans[$i] = [$t, $tx, $ty];
    } else {
        echo "No" .PHP_EOL;
        return;
    }
}

echo "Yes" . PHP_EOL;

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  l.reverse()

  ans=0
  a=l[0]
  c=0

  for x in l[1:]:
    if a<=x:
      c+=1
    else:
      ans=max(ans,c)
      c=0
    a=x
  ans=max(ans,c)
  return ans

# main()
print(main())


Measured memory_bytes: 16708
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

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

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		String ans = "";
		boolean pl = true;
		if(N==0)ans +="0";
		while(N!=0) {
			if(N%2!=0) {
				ans+="1";
				N += pl?-1:1;
			}else {
				ans+="0";
			}
			pl = !pl;
			N /=2;
		}
		StringBuffer ans_r = new StringBuffer(ans);
		System.out.println(ans_r.reverse().toString());
		scn.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

struct edge{int to,cap,rev;};

vector<edge> g[2010];
bool used[2010];

void addEdge(int from,int to,int cap){
	edge e;
	e.to=to;e.cap=cap;e.rev=g[to].size();
	g[from].push_back(e);
	e.to=from;e.cap=0;e.rev=g[from].size()-1;
	g[to].push_back(e);
}

int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=1;
	rep(i,g[v].size()){
		edge &e=g[v][i];
		if(!used[e.to]&&e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				g[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int maxFlow(int s,int t){
	int flow=0;
	for(;;){
		fill(used,used+2010,0);
		int f=dfs(s,t,INF);
		if(!f)return flow;
		flow+=f;
	}
}

int N,M,L,d[110][110],u,v,D;
pi r[1010];

int main(){
	while(cin>>N>>M>>L&&N){
		int S=L*2,G=S+1;
		rep(i,G+1)g[i].clear();
		rep(i,N)rep(j,N)d[i][j]=(i!=j)*INF;
		rep(i,M)cin>>u>>v>>D,d[u][v]=d[v][u]=D;
		rep(k,N)rep(i,N)rep(j,N)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		rep(i,L)cin>>r[i].fir>>r[i].sec,addEdge(S,i,1),addEdge(L+i,G,1);
		rep(i,L)rep(j,L)if(i!=j&&r[j].sec-r[i].sec>=d[r[i].fir][r[j].fir])addEdge(i,L+j,1);
		cout<<L-maxFlow(S,G)<<endl;
	}
}

Measured memory_bytes: 25000
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

class LargeNumber {
private:
	bool is_prime[1000 + 13];// Up to 1e6 + 13
	vector<long long> Prime_table;
public:
	vector<long long> Eratosthenes(const long long N = 1007) { // return primes up to N
		for (int i = 0; i <= N; i++)
		{
			is_prime[i] = true;
		}
		for (int i = 2; i <= N; i++)
		{
			if (is_prime[i])
			{
				for (int j = 2 * i; j <= N; j += i)
				{
					is_prime[j] = false;
				}
				Prime_table.emplace_back(i);
			}
		}
		return Prime_table;
	}

	template<typename T>
	map<T, T> Factorization(T N) const {
		map<T, T> mp;
		if (N == 1) {
			return mp;
		}

		for (int i = 0; i < Prime_table.size(); i++) {
			while (N % Prime_table[i] == 0) {
				mp[Prime_table[i]]++;
				N /= Prime_table[i];
			}
		}

		if (N > 1) mp[N]++;

		return mp;
	}


	bool isPrime(long long x) {
		if (x == 0 || x == 1) {
			return false;
		}
		return is_prime[x];
	}
};

int main() {
	int N; cin >> N;
	LargeNumber lg; lg.Eratosthenes();
	vector<int> prime_cnt(101);
	for (int i = 1; i <= N; i++) {
		map<int, int> mp = lg.Factorization(i);
		for (const auto& obj : mp) {
			prime_cnt[obj.first] += obj.second;
		}
	}
	int c2 = 0, c4 = 0, c14 = 0, c24 = 0, c74 = 0;
	for (int i = 0; i < 101; i++) {
		int c = prime_cnt[i];
		if (c > 1) c2++;
		if (c > 3) c4++;
		if (c > 13) c14++;
		if (c > 23) c24++;
		if (c > 73) c74++;
	}
	ll ans = 0;
	ans += c74;
	ans += c24 * (c2 - 1);
	ans += c14 * (c4 - 1);
	ans += (c2-2) * ((c4) * (c4 - 1) / 2);
	cout << ans << endl;
	sysp;
}

Measured memory_bytes: 3708
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int m3 = 0;
    int m1b = 0;
    int m2b = 0;
    int m3b = 0;    
    for(int m1 = 0;m1 <= a;m1++){
      for(int m2 = 0;m2 <= a-m1;m2++){
        m3 = a - m1 - m2;
        m1b = m1 * 10000;
        m2b = m2 * 5000;
        m3b = m3 * 1000;  
        if(m1b + m2b + m3b == b){
         System.out.println(m1 + " " + m2 + " " + m3); 
          System.exit(0);
        }
      }
    }
    System.out.println(-1 + " " + -1 + " " + -1);
  }
}

Measured memory_bytes: 23636
using System;

namespace ABC082A
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if ( (a + b) % 2 == 1){
                Console.WriteLine("{0}", (a + b + 1)/2);
            } else{
                Console.WriteLine("{0}", (a + b)/2);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	int n;
	cin >> n;
	vector<int> h(n),w(n);
	for(int i=0; i<n; i++) cin >> h[i] >> w[i];
	vector<vector<char> > c(4, vector<char>(4));
	for(int i=0; i<4; i++){
		for(int j=0; j<4; j++){
			cin >> c[i][j];
		}
	}
	
	vector<int> dp(1<<16, inf);
	dp[0] = 0;
	for(int i=0; i<(1<<16); i++){
		if(dp[i] == inf) continue;
		for(int s=0; s<n; s++){
			for(int y=1-h[s]; y<=2+h[s]; y++){
				for(int x=1-w[s]; x<=2+w[s]; x++){
					char color = 0;
					int newidx = i;
					for(int j=0; j<h[s]; j++){
						for(int k=0; k<w[s]; k++){
							int ny=y+j, nx=x+k;
							if(ny<0 || 4<=ny || nx<0 || 4<=nx) continue;
							if((i & 1<<(4*ny +nx)) != 0) continue;
							if(color!=0 && color!=c[ny][nx]){
								color = 0;
								j = h[s];
								break;//j,k
							}
							color = c[ny][nx];
							newidx |= 1<<(4*ny +nx);
						}
					}
					if(color != 0){
						dp[newidx] = min(dp[newidx], dp[i]+1);
					}
				}
			}
		}
	}
	cout << dp[(1<<16) -1] << endl;
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M + 1);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i);
  }
  a.at(M) = -1;
  vector<int> S(N + 1);
  S.at(0) = 1;
  if (a.at(0) == 1) {
    S.at(1) = 0;
    int x = 1;
    for (int i = 2; i <= N; i++) {
      if (i == a.at(x)) {
        S.at(i) = 0;
        x++;
      }
      else {
        S.at(i) = (S.at(i - 1) + S.at(i - 2)) % 1000000007;
      }
    }
  }
  else {
    S.at(1) = 1;
    int y = 0;
    for (int i = 2; i <= N; i++) {
      if (i == a.at(y)) {
        S.at(i) = 0;
        y++;
      }
      else {
        S.at(i) = (S.at(i - 1) + S.at(i - 2)) % 1000000007;
      }
    }
  }
  cout << S.at(N) << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
long long int dp[1001][1001];
int main(void)
{
	int D,N,x=0,i,j,k,r=0;
	int T[1001],A[1001],B[1001],C[1001];
	scanf("%d%d",&D,&N);
	for(i=1;i<=D;i++){
		scanf("%d",&T[i]);
	}
	for(i=1;i<=N;i++){
		scanf("%d%d%d",&A[i],&B[i],&C[i]);
	}
	for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			dp[i][j]=-1;
		}
	}
	for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			if(A[j]<=T[1]&&T[1]<=B[j]){
				dp[1][j]=0;
			}
			if(A[j]<=T[i]&&T[i]<=B[j]){
				for(k=1;k<=N;k++){
					if(A[k]<=T[i+1]&&T[i+1]<=B[k]){
						r=C[j]-C[k];
						if(r<0){
							r*=-1;
						}
						if(dp[i+1][k]<dp[i][j]+r){
							dp[i+1][k]=dp[i][j]+r;
						}
					}
				}
			}
		}
	}
	/*for(i=D;i>0;i--){
		for(j=1;j<=N;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/
	for(i=0;i<N;i++){
		if(x<dp[D][i]){
			x=dp[D][i];
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 3796
for(;scanf("%d%d%d",&a,&b,&c),a;){
    if(a>c)n=a,a=c,c=n;
    if(b>c)n=b,b=c,c=n;
    for(scanf("%d",&n);n;puts(r*2>hypot(a,b)?"OK":"NA"),n--)
      scanf("%d",&r);
  }
  return 0;
}

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

int main() {
    int N, X; cin >> N >> X;
    int l[N];
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }

    int sum[N+1];
    sum[0] = 0;
    for (int i = 1; i < N+1; i++)
    {
        sum[i] = sum[i-1] + l[i-1];
    }

    cout << upper_bound(sum, sum + N + 1, X) - sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

int M;
int V;
//  éAhXÉèÄçêÄ¢éÊ
int allocMem[1000001];
// ÏÌQÆæ
int refIdx[1001];
vector<string> strs;
bool isError;

int Expr(string);


void Free(string s){
  if(s=="NULL")return;
  int res=Expr(s);
  // NULL
  if(res==0)return;
  // ùÉèÄª0Ü½ÍÏÌQÆæªèÄÈµ
  if(res==-1||allocMem[res]==0){
    // error
    isError=true;
  }
  // ÌJú
  M+=allocMem[res];
  allocMem[res]=0;
  // ÏÌQÆæð³­·
  //refIdx[res]=-1;
}

int Clone(string s){
  if(s=="NULL")return 0;
  int res=Expr(s);
  // NULL
  if(res==0)return 0;
  // Error
  if(res==-1){
    isError=true;
    return -1;
  }
  int sz=allocMem[res];
  if(sz==0){
    isError=true;
    return -1;
  }
  // NULL
  if(M-sz<0)return 0;
  allocMem[V++]=sz;
  M-=sz;
  return V-1;
}

int Malloc(string s){
  int a=atoi(s.c_str());
  // s«
  if(M-a<0){
    return 0;
  }
  allocMem[V++]=a;
  M-=a;
  // èÄêÌQÆÔµ
  return V-1;
}

int Assign(string s){
  char var=s[0];
  int res=Expr(s.substr(2));
  refIdx[var]=res;
  return res;
}

int Expr(string s){
  if(s=="NULL")return 0;
  if(s[0]=='('&&s[s.size()-1]==')'){
    int cnt=1;
    bool ok=true;
    for(int i=1;i<s.size()-1;i++){
      if(s[i]=='(')cnt++;
      else if(s[i]==')')cnt--;
      if(cnt==0)ok=false;
    }
    if(ok)return Expr(s.substr(1,s.size()-2));
  }
  if(!s.compare(0,6,"malloc"))
    return Malloc(s.substr(7,s.size()-8));
  else if(!s.compare(0,5,"clone"))
    return Clone(s.substr(6,s.size()-7));
  if(s[0]>='A'&&s[0]<='Z'){
    if(s.size()==1)return refIdx[s[0]];
    return Assign(s);
  }
}

int main(){
  memset(refIdx,-1,sizeof(refIdx));
  cin>>M;
  V=1;
  string ss;
  while(cin>>ss)strs.push_back(ss);
  for(int i=0;i<strs.size();i++){
    string s=strs[i];
    if(!s.compare(0,4,"free"))Free(s.substr(5,s.size()-6));
    else Expr(s);
    if(isError){
      cout<<"Error"<<endl;
      break;
    }
  }
  if(!isError){
    for(int i=1;i<1001;i++){
      int a=refIdx[i];
      if(a!=-1&&a!=0)allocMem[a]=0;
    }
    int sum=0;
    for(int i=0;i<V;i++)sum+=allocMem[i];
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N;
string s[50];
int t[50];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i] >> t[i];
    }
    string X;
    cin >> X;
    int ans = 0;
    int x;
    for(int i = 0; i < N; i++){
        if(s[i] == X) x = i;
    }
    for(int i = x+1; i < N; i++) ans += t[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
K = int(input())

his = set()
cnt = 0
x = 7
while True:
    cnt += 1
    r = (x % K)
    if r == 0:
        print(cnt)
        break
    if r in his:
        print(-1)
        break
    his.add(r)
    x = r * 10 + 7
exit()


Measured memory_bytes: 77936
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s[100];
	int n,i,a,b;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>s[i];
	for(i=0;i<n;i++)
	{
		for(a=0;a<i;a++)
		{
			if(s[a]==s[i])
			{
				cout<<"No";
				return 0;
			}
		}
	}
	for(b=1;b<=n-1;b++)
		{	
			if(s[b-1][s[b-1].size()-1]!=s[b][0])
			{
				cout<<"No";
				return 0;	
			}
		}
		cout<<"Yes";
    return 0;
}




Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if (w - v) >= 0:
         print("NO")
         exit()
else:
         if (abs(a - b) + (v - w - 1))//(v - w) <= t:
                  print("YES")
         else:
                  print("NO")


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>  pll;
typedef double db;
typedef unsigned long long ull;
#define fi first
#define se second
#define pk push_back
#define mk make_pair

const ll N=1e5+10, M=1e6+10, mod=998244353, inf=0x3f3f3f3f3f3f3f3f, Max=5e13;
const ll seed=233, hashmod=1e9+7;
const db esp=1e-7;

ll n,nn,ans;
db num;
ll mp[100][100];

void divide(ll x){
    ll n2=0, n5=0;
    while(x%2==0){
        n2++; x/=2;
    }
    while(x%5==0)
        n5++, x/=5;
    for(ll i=0;i<=45;i++)
        for(ll j=0;j<=45;j++)
            if(min(n2+i,n5+j)>=18&&mp[i][j])
//cout<<i<<" "<<j<<endl,
                ans+=mp[i][j];
    mp[n2][n5]++;
}

void work(){
    scanf("%lld",&n);
    for(ll i=0;i<n;i++)
        scanf("%lf",&num),
        nn=llround(1e9*num),
        divide(nn);
    printf("%lld\n",ans);
    return ;
}

int main() {
//    freopen("C:\\Users\\lenovo\\Desktop\\in.txt","r",stdin);
//freopen("C:\\Users\\lenovo\\Desktop\\out.txt","w",stdout);
//    ll t;
//    cin>>t;
//    for(ll i=1;i<=t;i++)
        work();


    return 0;
}


Measured memory_bytes: 3856
use std::cmp;

pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

#[allow(dead_code)]
impl  Scanner{
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
   fn next_string(&mut self) -> Vec<char> {
       let s : String = self.next();
       return s.chars().collect::<Vec<char>>();
   }
   fn next_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
       let mut v : Vec<T>= Vec::with_capacity(n);
       for _i in 0..n {
           v.push(self.next());
       }
       v
   }
}


fn main() {
    let mut scan = Scanner::new();
    let n:i64  = scan.next();
    let k:i64  = scan.next();
    let mut x = n;
    let mut ans = n;


    for _i in 0..4 {
        if 2*k <= x{
            x = (x - k) % k + k;
        }else{
            x = (x - k).abs();
        }
        ans = cmp::min(ans, x);
    }
    println!("{}", ans);
}


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

int main() {
  int r;
  int g;
  cin >> r >> g;
  // g = (r + a) / 2
  // g * 2 = r + a
  // a = (g * 2) - r
  cout << (g * 2) - r << endl;
}


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

const int MOD = 1e9 + 7;

class mint {
    long long x;
public:
    mint(long long x=0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


// 組み合わせ数を計算する
map<long long, vector<mint>> _combinations;
mint combination(long long n, long long r) {
    if(!_combinations.count(n)) {
        vector<mint> vec = {0, n};
        _combinations.emplace_hint(_combinations.end(), n, vec);
    }
    auto&& vec = _combinations.find(n)->second;
    if(vec.size() <= r) {
        long long i = vec.size();
        vec.resize(r + 1);
        for(; i <= r; i++) {
            vec[i] = vec[i - 1];
            vec[i] *= (n - i + 1);
            vec[i] /= i;
        }
    }

    return vec[r];
}

vector<mint> _factionals = {0,1};
mint factional(long long n) {
    if(_factionals.size() < n) {
        long long  i = _factionals.size();
        _factionals.resize(n + 1);
        for(; i <= n; i++) {
            _factionals[i] = _factionals[i - 1] * i;
        }
    }
    return _factionals[n];
}

int n,a,b;
mint result;
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20);

    cin >> n >> a >> b;
    cout << mint(2).pow(n) - 1 - combination(n, a) - combination(n, b);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main(){
	int h,w,i,j;
	cin>>h>>w;
	for(i=0;i<=w+1;i++){
		cout<<"#";
	} 
	cout<<endl;
	for(i=0;i<h;i++){
		cin>>s;
		cout<<"#"<<s<<"#"<<endl;
	}
	for(i=0;i<w+2;i++){
		cout<<"#";
	} 
	return 0;
}  

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

int main() {
  char a,b;cin>>a>>b;
  bool ans = a==b;
  cout << (ans?"H":"D") << endl;
  // cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	bool flag;
	int l=s.length();
	if(l<4)flag=false;
	else if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')flag=true;
	else flag=false;
	if(flag)cout<<"Yes";else cout<<"No"; 
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))
    P = [i-1 for i in P]
    ans = -1e19

    for si in range(N):
        index = si
        cycle =[]
        total = 0
        while True:
            index = P[index]
            cycle.append(C[index])
            total = total + C[index]
            if index == si:
                break
        cycle_length = len(cycle)
        count = 0
        for i in range(cycle_length):
            count  = count + cycle[i]
            if i+1 > K:
                break
            num = count
            if total > 0:
                cnt = (K - (i+1)) // cycle_length
                num = num + cnt*total
            ans = max(ans, num)
    print(ans)


main()


Measured memory_bytes: 84432
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	for (int i = 0; i < 7; ++i)
	{
		if(pow(2,i) <= N && N < pow(2,i+1)){
			cout << pow(2,i) << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] lines = sc.nextLine().split(" ");
        int num1 = Integer.parseInt(lines[0]);
        int num2 = Integer.parseInt(lines[1]);
        int num3 = Integer.parseInt(lines[2]);
        
        int count = 0;
        
        for(int i = num1; i <= num2;i++) {
        	if(num3 % i == 0) {
        		count++;
        	}
        }
        
        System.out.println(count);

    }
}

Measured memory_bytes: 26168
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
typedef pair<string, string> pss;

int n;
int a[110];
bool dp[10100];

int main()
{
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}

	dp[0] = true;

	for (int i = 0; i < n; i++) {
		for (int j = 10010; j >= 0; j--) {
			if (dp[j]) {
				dp[j + a[i]] = true;
			}
		}
	}

	int mx = 0;
	for (int j = 0; j <= 10010; j++) {
		if (dp[j]) {
			if (j % 10 != 0)mx = max(mx, j);
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var N, ans int
	fmt.Scanln(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var pre, sum int
	for i := 0; i < N; i++ {
		sc.Scan()
		cur, _ := strconv.Atoi(sc.Text())
		if pre >= cur {
			sum++
			if sum > ans {
				ans = sum
			}
		} else {
			sum = 0
		}
		pre = cur
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define pb push_back
const int mod=1e9+7;

int main(){
	ll n,m;
	while(cin >> n >> m){
		m = 2 * m + 1;
		cout<<n/m+(n%m>0)<<endl;
	}

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        int cnt[8] = { 0 };
        int ans = 0;
        rep(i, n) {
                if (1 <= a[i] && a[i] <= 399) cnt[0] ++;
                else if (400 <= a[i] && a[i] <= 799) cnt[1] ++;
                else if (800 <= a[i] && a[i] <= 1199) cnt[2] ++;
                else if (1200 <= a[i] && a[i] <= 1599) cnt[3] ++;
                else if (1600 <= a[i] && a[i] <= 1999) cnt[4] ++;
                else if (2000 <= a[i] && a[i] <= 2399) cnt[5] ++;
                else if (2400 <= a[i] && a[i] <= 2799) cnt[6] ++;
                else if (2800 <= a[i] && a[i] <= 3199) cnt[7] ++;
                else ans ++;
        }
        int c = 0;
        rep(i, 8) if (cnt[i] > 0) c ++;
        if (c == 0) {
                cout << 1 << ' ' << ans << endl;
                return 0;
        }
        cout << c << ' ' << c + ans << endl;
        return 0;
}               



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    ll aSum = 0, bSum = 0;
    rep(i, 0, N)
    {
        cin >> A[i];
        aSum += A[i];
    }
    rep(i, 0, N)
    {
        cin >> B[i];
        bSum += B[i];
    }

    if (aSum < bSum)
    {
        cout << -1 << endl;
        return;
    }

    vector<int> shortages;
    priority_queue<int> excesses;
    rep(i, 0, N)
    {
        if (A[i] < B[i])
        {
            shortages.push_back(B[i] - A[i]);
        }
        else if (A[i] > B[i])
        {
            excesses.push(A[i] - B[i]);
        }
    }

    if (shortages.empty())
    {
        cout << 0 << endl;
        return;
    }

    int ans = shortages.size();

    int shortageIndex = 0;
    while (!excesses.empty())
    {
        int excess = excesses.top();
        excesses.pop();

        ++ans;

        while (excess > 0)
        {
            int& shortage = shortages[shortageIndex];
            if (shortage > excess)
            {
                shortage -= excess;
                excess = 0;
            }
            else
            {
                excess -= shortage;
                shortage = 0;
                ++shortageIndex;

                if (shortageIndex == shortages.size())
                {
                    cout << ans << endl;
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 1660
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, v[100], sum, ans;
multiset<int> mst;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> v[i];
	if (k >= n) {
		for (int i = 0; i < n; i++) {
			sum += v[i];
			if (v[i] < 0) mst.insert(v[i]);
		}
		int cnt = k - n, cur = 0;
		for (auto x : mst) {
			if (cur == cnt) break;
			sum -= x;
			cur++;
		}
		ans = max(ans, sum);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			sum = 0;
			mst.clear();
			int res = k - (n - (j - i + 1));
			if (res < 0) continue;
			for (int jj = 0; jj < n; jj++) {
				if (jj < i || jj > j) {
					sum += v[jj];
					if (v[jj] < 0) mst.insert(v[jj]);
				}
			}
			int cur = 0;
			for (auto x : mst) {
				if (cur == res) break;
				sum -= x;
				cur++;
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,chr[10000];
int go(int p,int dir){
    int cr=chr[p];
    while(chr[p]==cr){
        if(dir==-1&&p<0)break;
        if(dir==1&&p>=n)break;
        p+=dir;
    }
    return p;
}
int del(int sp){
    int u=sp,d=sp;
    while(chr[u]==chr[d]){
        int _u=go(u,-1),_d=go(d,1);
        int dif=u-_u+(_d-d);
        if(u==d)dif--;
        if(dif<4)break;
        u=_u;d=_d;
        if(u<0||d>=n)break;
    }
    int ans=u+1+(n-d);
    if(d==u)ans--;
    return ans;

}
int main(){
    while(cin>>n,n){
        for(int i=0;i<n;i++)cin>>chr[i];
        int Min=10000;

        for(int i=0;i<n;i++){
            for(int j=1;j<=3;j++){
                if(chr[i]==j)continue;
                int k=chr[i];
                chr[i]=j;
                Min=min(Min,del(i));
                chr[i]=k;
            }
        }
        cout<<Min<<endl;
    }
}

Measured memory_bytes: 1200
from collections import deque

K = int(input())
queue = deque([i for i in range(1,10)])

while K != 0:
  if K <= len(queue):
    print(queue[K-1])
    exit(0)

  K -= 1
  num = queue.popleft()

  o = int(str(num)[-1])
  for n in [o-1, o, o+1]:
    if n == -1 or n == 10: continue
    queue.append( int(str(num)+str(n)) )

Measured memory_bytes: 5960
///
// File:  alds1_6_d.cpp
// Author: ymiyamoto
//
// Created on Thu Oct 12 23:39:32 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
#define SIZE 10000

static vector<uint32_t> array;
static uint32_t T[SIZE + 1];

static uint32_t solve(uint32_t array_min)
{
  uint32_t count = 0;

  vector<bool> visited(array.size(), false);
  vector<uint32_t> array1(array);

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

  for (uint32_t i = 0; i < array1.size(); i++) {
    T[array1[i]] = i;
  }

  for (uint32_t i = 0; i < visited.size(); i++) {
    if (visited[i]) continue;
    uint32_t index = i;
    uint32_t cycle_weight = 0;
    uint32_t cycle_min = UINT32_MAX;
    uint32_t cycle_len = 0;
    while (true) {
      visited[index] = true;
      cycle_len++;
      uint32_t v = array[index];
      cycle_min = min(cycle_min, v);
      cycle_weight += v;
      index = T[v];
      if (visited[index]) break;
    }
    count += min(cycle_weight + (cycle_len - 2) * cycle_min, cycle_min + cycle_weight + (cycle_len + 1) * array_min);
  }

  return count;
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  uint32_t s = UINT32_MAX;
  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    array.push_back(val);
    s = min(s, val);
  }

  uint32_t count = solve(s);

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3144
n = gets.to_i
n.times do
  x1, y1, x2, y2, x3, y3, x4, y4 = gets.split.map(&:to_r)
  if (y1 - y2).zero?
    if (y3 - y4).zero?
      puts 'YES'
    else
      puts 'NO'
    end
  elsif (y3 - y4).zero?
    puts 'NO'
  else
    ab = 
    if (x1 - x2) / (y1 - y2) == (x3 - x4) / (y3 - y4)
      puts 'YES'
    else
      puts 'NO'
    end
  end
end




Measured memory_bytes: 6876
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[200111];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
string r;
//char r[111];

P u[1];
queue<int> q;

stack<int> s;
map<int,int> p;
vector<int> v;

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

long long f(long long x,long long y)
{
  long long p=1;
  for(;y;y/=2,x*=x,x%=mod)
    if(y%2) p*=x,p%=mod;
  return p;
}

int main()
{
  o[0]=1;
  for(int t=1;t<=200000;t++)
    o[t]=o[t-1]*t%mod;
  scanf("%d %d %d",&a,&b,&c);
  x=f(2,a);
  y=1;
  for(int t=0;t<b;t++)
    y*=(a-t),y%=mod;
  x=(x-y*f(o[b],mod-2)%mod)%mod;
  y=1;
  for(int t=0;t<c;t++)
    y*=(a-t),y%=mod;
  x=(x-y*f(o[c],mod-2)%mod)%mod;
  
  printf("%lld",(x+mod-1)%mod);
}





Measured memory_bytes: 1792