akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int main()
{
    string s;cin>>s;
    int idx=-1;
    rep(i, s.size()){
        if (s[i]=='C'){
            idx=i;
            break;
        }
    }
    if (~idx) {
        for(int i=idx;i<s.size();++i){
            if (s[i]=='F'){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;
 
#define mp make_pair
#define pb push_back
 
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
int N,K, rec[100001], ans = 0;
vi adj[100001], A;
 
void dfs(int node) {
	if (node == 1) {
		for (int i: adj[node]) {
			dfs(i);
			if (rec[i] == K) ans++;
			else rec[node] = max(rec[node], rec[i]+1);
		}
	} else {
		for (int i: adj[node]) {
			dfs(i);
			if (rec[i] == K-1) ans++;
			else rec[node] = max(rec[node], rec[i]+1);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N >> K; A.resize(N+1);
	FOR(i,1,N+1) {
		cin >> A[i];
		if (i != 1) adj[A[i]].pb(i);
	}
	dfs(1);
	if (A[1] != 1) ans++;
	cout << ans;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;

struct edge
{
    int to;
    int cost;
};
using Graph = vector<vector<edge>>;

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
Graph G;

int lcs(string s1, string s2)
{
    int num;
    num = 0;
    int m = s1.size();
    int n = s2.size();

    s1 = ' ' + s1;
    s2 = ' ' + s2;
    int dp[1100][1100];
    rep(i, 1100)
    {
        dp[i][0] = 0;
        dp[0][i] = 0;
    }
    for (int im = 1; im <= m; im++)
    {
        for (int jn = 1; jn <= n; jn++)
        {
            if (s1[im] == s2[jn])
            {
                dp[im][jn] = dp[im - 1][jn - 1] + 1;
            }
            else
            {
                dp[im][jn] = max(dp[im - 1][jn], dp[im][jn - 1]);
            }

            num = max(num, dp[im][jn]);
        }
    }

    return num;
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> ans;
    for (int i = 0; i < n; i++)
    {
        string s1, s2;
        cin >> s1 >> s2;
        ans.push_back(lcs(s1, s2));
    }

    rep(i, n) cout << ans[i] << endl;
}

signed main()
{
    solve();
    return 0;
}



Measured memory_bytes: 12248
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn dfs(
    &cur: &usize,
    &n: &usize,
    ref abc: &Vec<i64>,
    ref l: &Vec<i64>,
    &a: &i64,
    &b: &i64,
    &c: &i64,
) -> i64 {
    if &cur == &n {
        return if vec![&a, &b, &c].iter().min().unwrap() > &&0i64 {
            (&a - &abc[0]).abs() + (&b - &abc[1]).abs() + (&c - &abc[2]).abs() - 30
        } else {
            std::i64::MAX - 20
        };
    }
    let ret0 = dfs(&(&cur + 1), &n, &abc, &l, &a, &b, &c);
    let ret1 = dfs(&(&cur + 1), &n, &abc, &l, &(&a + &l[cur]), &b, &c) + 10;
    let ret2 = dfs(&(&cur + 1), &n, &abc, &l, &a, &(&b + &l[cur]), &c) + 10;
    let ret3 = dfs(&(&cur + 1), &n, &abc, &l, &a, &b, &(&c + &l[cur])) + 10;

    return *vec![ret0, ret1, ret2, ret3].iter().min().unwrap();
}

fn main() {
    input!{
        n: usize,
        abc: [i64; 3],
        mut l: [i64; n],
    }

    let ans = dfs(&0, &n, &abc, &l, &0, &0, &0);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int n, res = 0;
  cin >> n;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) ++cnt;
    }
    if (cnt == 8) ++res;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, ans = 0;
    vector<int> p;
    cin >> n;
    p.resize(n);
    for (auto & x:p) cin >> x; 

    for (int i = 1; i < n - 1; ++i) {
        if (p[i] != max(p[i-1], max(p[i+1], p[i])) &&
            p[i] != min(p[i-1], min(p[i+1], p[i])))
            ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
'''
ITP-1_4-C
 ?¨???????
???????????´??° a, b ??¨?????????????????? op ?????????????????§???a op b ????¨??????????????????°?????????????????????????????????
????????????????????? op ??????"+"(???)???"-"(???)???"*"(???)???"/"(???)???????????¨?????????????????§????????????????????´?????????
?°???°?????\??????????????¨????????????????¨????????????¨????????????
???Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
 a op b
op ??? '?' ?????¨??? ??\?????????????????????????????????????????±???????????????????????£????????????????????????
???Output
?????????????????????????????????????¨??????????????????????????????????????????????
'''
# import
import sys

# ?????°??????????????????
for inputData in sys.stdin:
    inputList = inputData.split()
    a, op, b = int(inputList[0]), inputList[1], int(inputList[2])
    retVal = 0

    # 0?????´??? ????????????
    if op == "?":
        # exec end
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)

Measured memory_bytes: 7672
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
	int n;
	cin >> n;
	vector<vi> dp(3, vi(n+1, 0)), a(3, vi(n+1));
	for (int i = 1; i <= 2; ++i) {
		for (int j = 1; j <= n; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 2; ++i) {
		for (int j = 1; j <= n; ++j) {
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			dp[i][j] += a[i][j];
		}
	}
	cout << dp[2][n];
}
int main(){
	speed;
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    double W = Double.parseDouble(scanner.next());
	    double H = Double.parseDouble(scanner.next());
	    double x = Double.parseDouble(scanner.next());
	    double y = Double.parseDouble(scanner.next());
	    
	    double m = (double)((W * H) / 2);
	    int n = 0;
	    
	    if ((W== 2*x) && (H == 2*y)) {
	    	n=1;
	    }

        System.out.print(m + " " + n);
	}
}

Measured memory_bytes: 38892
from math import ceil

def BinarySearch(x):
    ans = sum([ceil(a/x)-1 for a in A])
    if ans <= K:
        return True
    else:
        return False

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

r = max(A)
l = 0
eps = 10**-6

while abs(r-l) > eps:

    m = (r+l)/2

    if BinarySearch(m):
        r = m
    else:
        l = m

print(ceil(r)) 


Measured memory_bytes: 220768
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <cmath>
using namespace std; 
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
int n;
vector<string>ans;
string k;
void dfs(int dep,int mx)
{
	if(dep==n)
	{
		ans.pb(k);
		return;
	}
	rep(i,0,mx+1)
	{
		k[dep]=i+'a';
		dfs(dep+1,max(i,mx));
	}
}
int main(int argc, char** argv) {
	cin>>n;
	rep(i,1,n)k+=" ";
	dfs(0,-1);
	rep(i,0,ans.size()-1)
	cout<<ans[i]<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// 偶数の時は 10 の倍数がかけられた時のみ末尾 0 が生まれる
// -> とりあえず N / 10 だけ 0 は必ず生まれる
// -> N とかける数を両方 / 10 してみると、 1 から N までの
// -> 順列の掛け算の答えの末尾 0 がいくつあるか？という問いに変わる
// -> ここから先は Yahoo! 知恵袋に書いてある（5 のべき乗で割った数を足し合わせる）
ll solve(ll n) {
    ll ret = n / 10;
    n /= 10;
    ll cur = 5;
    while(n >= cur) {
        ret += n / cur;
        cur *= 5;
    }
    return ret;
}

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

    ll N;
    cin >> N;

    // 奇数の時は末尾 0 にならない
    if(N % 2 != 0) {
        printf("0\n");
        return 0;
    }

    ll cand = solve(N);
    printf("%lld\n", cand);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void){
    int i,x,c[26]={};
    char ch;
    while ( scanf("%c",&ch) != EOF ){
        if(isupper(ch)){
            ch=tolower(ch);
        }
        x = ch - 'a';
        c[x]++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,c[i]);
    }
    return 0;
}



Measured memory_bytes: 1808
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

from collections import defaultdict
test = defaultdict(list)
test_per = defaultdict(dict)
n = int(input())
for i in xrange(n):
    nn = int(input())
    for j in xrange(nn):
        x,y = (int(x) for x in input().split())
        test[x-1].append(y)
        test_per[i][x-1] = y
ans = 0
for i in xrange(2**n):
    bini= bin(i)[2:]
    bini = '0'*(n-len(bini)) + bini
    valid = True
    for j,c in enumerate(bini):
        if c == '1':  # honnest
            for other_person in test_per[j]:
                if test_per[j][other_person] != int(bini[other_person]):
                    valid = False
                    break
        if not valid:
            break
    if valid:
        ans = max(ans, bini.count('1'))
print(ans)
            


Measured memory_bytes: 99772
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    vector<int> a(3);
    rep(i,3){
        cin >> a[i];
    }

    sort(all(a));
    for(int i = 0; i < 3; i++){
        cout << a[i] ;
        if(i < 2){
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> A;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        A.push_back(a);
    }
    int maxdist=0,pre=0;
    for(int i=0;i<n;i++){
        maxdist+=abs(A[i]-pre);
        pre=A[i];
    }
    maxdist+=abs(pre);
    int ans=0;
    for(int i=0;i<n;i++){
        int pre=i-1,after=i+1;
        ans=maxdist;
        if(pre<0){
            ans-=abs(A[0]);
            ans-=abs(A[after]-A[i]);
            ans+=abs(A[i+1]);
        }
        else if(after>=n){
            ans-=abs(A[n-1]);
            ans-=abs(A[n-1]-A[pre]);
            ans+=abs(A[pre]);
        }
        else{
            ans-=abs(A[after]-A[i]);
            ans-=abs(A[i]-A[pre]);
            ans+=abs(A[after]-A[pre]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main() {
	// your code goes here
	ll x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	if(x1==0){
		cout<<1;
	}
	else if(x2==0){
		cout<<2;
	}
	else if(x3==0){
	cout<<3;
	}
	else if(x4==0){
		cout<<4;
	}
	else{
		cout<<5;
	}
	return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;
public class Main {
	public static int[] L;

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		L = new int[N];
		for (int n = 0;n < N ;n++ ) {
			L[n] = Integer.parseInt(scan.next());
		}
		scan.close();
		System.out.println(MakingTriangle(N));
	}

	public static long MakingTriangle(int N) {
		long ans = 0;
		if (N < 3) return ans;
		for (int i = 0;i < N - 2 ;i++ ) {
			for (int j = i + 1;j < N - 1 ;j++ ) {
				for (int k = j + 1;k < N ;k++ ) {
					if ((L[i] == L[j]) || (L[j] == L[k]) || (L[k] == L[i])) continue;
					if ((L[i] + L[j] <= L[k]) || (L[j] + L[k] <= L[i]) || (L[k] + L[i] <= L[j])) continue;
					ans++;
				}
			}
		}
		return ans;
	}
}


Measured memory_bytes: 36308
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int ll

const int M = 998244353;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e9 + 100;
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

#define N 200000




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

	int n;
	cin >> n;
	int suma = 0, mb = -1;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		suma += a;
		if (a > b)
		{
			if (b < mb || mb == -1)
				mb = b;
		}
	}
	if (mb == -1)
		cout << 0;
	else
		cout << suma - mb;

}


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

int mod = 998244353;

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i, k) {
        cin >> l[i] >> r[i];
    }

    vector<int> dp(n+1);
    vector<int> dpsum(n+1);
    dp[1] = 1;
    dpsum[1] = 1;
    for (int i = 2; i <= n; ++i) {
        rep(j, k) {
            int li = i - r[j];
            int ri = i - l[j];
            if (ri < 1) {
                continue;
            }
            li = max(li, 1);
            dp[i] += (dpsum[ri]-dpsum[li-1]) % mod;
            dp[i] %= mod;
        }
        dpsum[i] = (dpsum[i-1]+dp[i]) % mod;
        dpsum[i] %= mod;
    }
    int ans = (dp[n]+mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4848
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 23;
const ll MOD = 998244353;
const int INF = 1e9+10;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}



int main() {
	setIO();

    int k, n;
    cin >> n >> k;
    vi a;
    REP(n) {
        int x; cin >> x;
        a.pb(x);
    }
    sort(a.begin(), a.end());

    int ans = 0;
    FOR(i, 0, k-1) ans += a[i];
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3660
def f(n,x,t1,t2,t3)
	(n>x)? 0 : f((n*10+3),x,t1+1,t2,t3)+f((n*10+5),x,t1,t2+1,t3)+f((n*10+7),x,t1,t2,t3+1)+(t1>0&&t2>0&&t3>0?1:0)
end
x=gets.to_i
puts f(0,x,0,0,0)

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	LL sum[n+1];
	sum[0] = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		sum[i] = sum[i-1] + a;
		dump(sum[i]);
	}
	LL ans = 10000000000;
	for (int i = 2; i <= n; i++) {
		ans = min(ans,LL(abs(sum[n] - 2*sum[i-1])));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	char c[10];
	for (int i = 0; i <= 6; i += 3) {
		cin >> c[i] >> c[i + 1] >> c[i + 2];
	}
	cout << c[0] << c[4] << c[8] << endl;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/************************************************************************************************************************************************/
void solve(){
    for(int i = 0;i < 5;i++){
        int dummy;
        cin >> dummy;
        if(dummy == 0){
            cout << i+1 << endl;
        }
    }
}



Measured memory_bytes: 3648
import sys
stdin = sys.stdin
from itertools import product

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

n, x = na()
a = na()
apre = 0
ans = 0
for ai in a:
    eat = max(0, apre + ai - x)
    ans += eat
    apre = ai - eat
print(ans)

Measured memory_bytes: 14668
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;
 
int main()
{
int n,k,m=1; cin>>n>>k;
for(int i=0;i<n;i++)
{
    if(m<k) m*=2;
    else m+=k;
 
}
cout<<m;
return 0;
}

Measured memory_bytes: 3596
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nr=(Arr.shift()).split(" ").map(Number);
   if(nr[0]==0 && nr[1]==0)break;
   var n=[];
   for(var i=0;i<nr[0];i++)n[i]=nr[0]-i;
   for(var i=0;i<nr[1];i++){
      var pc=(Arr.shift()).split(" ").map(Number);
      var p=pc[0]-1;
      var c=pc[1];
      var a=n.slice(0,p);
      var b=n.slice(p,p+c);
      var c=n.slice(-1*(n.length-p-c));
      n=b.concat(a,c);
   }
   console.log(n[0]);
}

Measured memory_bytes: 12012
#line 1 "test/aoj/GRL_1_A.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A"
#line 1 "test/aoj/../../graph/template.cpp"
#include <vector>

template< typename T >
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int f, int t) : from(f), to(t), cost(1) {}
  Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

template< typename T >
using Edges = std::vector< Edge< T > >;
template< typename T >
using Graph = std::vector< Edges< T > >;
#line 2 "test/aoj/../../graph/dijkstra.cpp"

#include <algorithm>
#include <functional>
#include <limits>
#include <queue>
#include <utility>
#include <vector>

template < typename T >
struct Dijkstra {
  using P = std::pair<T, int>; // <始点からの距離, 点のid>
  const T INF; // 十分に大きいがoverflowしない値として、型Tの最大値の半分を使う
  const int V; // 頂点数
  Graph<T> g;
  std::vector<T> dist; // 始点からの距離
  std::vector<bool> visit; // すでに探索済みの点か
  Dijkstra(Graph<T> &g): INF(std::numeric_limits<T>::max()/2), V(g.size()), g(g), dist(V), visit(V) {}
  Dijkstra(Graph<T> &g, int V): INF(std::numeric_limits<T>::max()/2), V(V), g(g), dist(V), visit(V) {}
  void init(int s) {
    std::fill(dist.begin(), dist.end(), INF);
    std::fill(visit.begin(), visit.end(), false);
    dist[s] = T(); // 始点の距離を0で初期化
    std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
    pq.push({dist[s], s});
    while (!pq.empty()) {
      P node = pq.top(); pq.pop();
      int from = node.second;
      if (visit[from]) continue;
      visit[from] = true;
      for (auto &e : g[from]) {
        if (visit[e.to]) continue;
        T d = node.first + e.cost;
        if (d >= dist[e.to]) continue;
        dist[e.to] = d;
        pq.push({d, e.to});
      }
    }
  }
};
#line 3 "test/aoj/GRL_1_A.test.cpp"

#include <iostream>
using namespace std;

typedef long long ll;

int main() {
  int V, E, root;
  cin >> V >> E >> root;
  Graph<ll> g(V);
  for (int i = 0; i < E; ++i) {
    int x, y;
    ll d;
    cin >> x >> y >> d;
    g[x].emplace_back(x, y, d);
  }
  Dijkstra<ll> di(g);
  di.init(root);
  for (int i = 0; i < V; ++i) {
    if (di.dist[i] == di.INF) cout << "INF" << endl;
    else cout << di.dist[i] << endl;
  }
}



Measured memory_bytes: 30832
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
const ll N = 1000000000000000;

vector<vector<int> > ar;
vector<int> kek;
int ans = 0;

void solve(int v, int l, int m) {
    if (v == kek.size()) {
        int lol = 0;
        for (auto & i : ar) {
            if (kek[i[1] - 1] - kek[i[0] - 1] == i[2]) {
                lol += i[3];
            }
        }
        ans = max(lol, ans);
        return;
    }
    for (int i = l; i <= m; ++i) {
        kek[v] = i;
        solve(v + 1, i, m);
    }
}

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    kek.resize(n);

    ar.resize(q);
    for (int i = 0; i < q; ++i) {
        vector<int> a(4);
        for (int h = 0; h < 4; ++h) cin >> a[h];
        ar[i] = a;
    }

    solve(0, 1, m);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

const int MAX_H = 50;

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

const char mozi[] = "BW";

int w, h;
int flg;
int cnt;

void search( int x, int y, string map[], char c, char nc );

int main()
{	
	string map[2][MAX_H];	/// Black = 0 , White = 1
	while( cin >> w >> h, w | h )
	{
		int cnt_BW[2] = { 0 };

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

		for( int idx=0; idx < 2; idx++ ) for( int i=0; i < h; i++ ) for( int j=0; j < w; j++ )
		{
			if( map[idx][i][j] != '.' ) continue;
			int BW[2] = { 0 };
			for( int k=0; k < 4; k++ )
			{
				int mx = j + dx[k];
				int my = i + dy[k];
				if( 0 <= mx && mx < w && 0 <= my && my < h )
				{
					if( map[idx][my][mx] == mozi[idx] ) BW[idx]++;
					else if( map[idx][my][mx] == mozi[(idx+1)%2] ) BW[(idx+1)%2]++;
				}
			}
			cnt = 0; flg = true;
			if( BW[idx] && !BW[(idx+1)%2] ) search( j, i, map[idx], mozi[idx], mozi[(idx+1)%2] );
			if( flg ) cnt_BW[idx] += cnt;
		}
		cout << cnt_BW[0] << " " << cnt_BW[1] << endl;
	}
	return 0;
}

void search( int x, int y, string map[], char c, char nc )
{
	if( map[y][x] == '.' )
	{
		cnt++;
		map[y][x] = c;
	}
	for( int i=0; i < 4; i++ )
	{
		int mx = x + dx[i];
		int my = y + dy[i];
		if( 0 <= mx && mx < w && 0 <= my && my < h )
		{
			if( map[my][mx] == '.' )
			{
				search( mx, my, map, c, nc );
			}
			else if( map[my][mx] == nc )
			{
				flg = false;
			}
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int a[110000];
int main()
{
    int n, c, k, i, ans, num, pre;
    while(~scanf("%d%d%d", &n, &c, &k))
    {
        for(i = 1; i <= n; ++i) scanf("%d", &a[i]);
        sort(a + 1, a + 1 + n);
        ans = 0;
        pre = 0;
        num = 0;
        for(i = 1; i <= n; ++i)
        {
            if(a[i] > pre)
            {
                ans++;
                pre = a[i] + k;
                num = 1;
                if(num == c) pre = 0;
            }else
            {
                num++;
                if(num == c) pre = 0;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 640
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;
const int M = 1e9 + 7;


void testcase() {
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n+2, 0LL);
    vector<ll> s(n+2, 0LL);
    rep (i, 1, n+1) {
    	p[i] = (p[i-1] + (ll)i) % M;
    }
    s[n] = n;
    repD (i, n-1, 0) {
    	s[i] = s[i+1] + (ll)i;
    }

    ll res = 0LL;
    rep (i, k, n+1) {
    	ll mini = p[i-1];
    	ll maxi = s[n+1-i];
    	//db2(maxi, mini);
    	res = (res + maxi - mini + 1 + M) % M;
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 6336
#include <cstdio>
int main()
{
	// freopen("CF17-QA-D.in", "r", stdin); 
	int n, m, d; 
	scanf("%d%d%d", &n, &m, &d);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			putchar("RYGB"[((i + j) / d & 1) << 1 | ((i + m - j) / d & 1)]); 
		puts(""); 
	}
	return 0; 
}


Measured memory_bytes: 384
import sys
import bisect
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce, reduce
sys.setrecursionlimit(20000000)

input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    ans = 0

    for a in range(N):

        for b in range(a+1, N-1):
            ab = L[a] + L[b]
            i = bisect.bisect_left(L, ab) - 1

            ans += i - b

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <stdio.h>

int main(void)
{
	int a, b;
	int sum;
	int ct;
	
	while (scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		ct = 0;
		
		while (1){
			ct++;
			sum /= 10;
			if (sum == 0){
				break;
			}
		}
		printf("%d\n", ct);
	}
	
	return (0);
}

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

#define sz size
#define pb push_back

const int N = 1e5 + 123;

int n, m, sum, cnt[N];
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int l, r;
		cin >> l >> r;
		cnt[l]++;
		cnt[r]--;
	}
	for(int i = 1; i < n; ++i) {
		sum += cnt[i];
		if(sum % 2 != 0) {
			cout << "NO";
			return 0;
		}
	}	
	cout << "YES";
}

Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    d = II()
    print("Christmas",end="")
    for i in range(25 - d):
        print(" Eve", end="")
    print()
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>


#define ll long long int
#define REP(i, n) for(int i=0;i<n;i++)

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  vector<int> v;

  int n, k;
  cin >> n >> k;
  v.reserve(n);

  REP(i,n) {
    int l;
    cin >> l;
    v.push_back(l);
  }

  sort(v.begin(), v.end(), greater<int>());

  int result = 0;
  REP(i,k) {
    result += v[i];
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int n,i,ans,c;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){
	cin >> a[i];
	}
	sort(a,a+n);
	ans = a[n-1];
	for(i=0;i<n-1;i++){
		ans = min(abs(2*a[i]-a[n-1]),ans);
		if(ans == abs(2*a[i]-a[n-1])){
			c = i;
		}
	}
	cout << a[n-1] << " "<< a[c] << endl;
	}
	

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,a[200005],fa[200005][19],dep[200005],dfn[200005],ti,pw[200005],iter=1e9+7,ans,stk[200005],tp,vis[200005],dp[200005][2];
vector<int> bi[200005],bi2[200005],seq[200005],all;
void dfs1(int x){dfn[x]=++ti;seq[dep[x]].push_back(x);ff(bi[x],it){dep[*it]=dep[x]+1;dfs1(*it);}}
int lca(int x,int y){if(dep[x]<dep[y])swap(x,y);int t=dep[x]-dep[y],i;fd0g(i,18)if((t>>i)&1)x=fa[x][i];if(x==y)return x;fd0g(i,18)if(fa[x][i]!=fa[y][i]){x=fa[x][i];y=fa[y][i];}return fa[x][0];}
void init(){ff(all,it)bi2[*it].clear();all.clear();}
bool cmp(int x,int y){return dfn[x]<dfn[y];}
void add(int x,int y){/*cerr<<x<<' '<<y<<endl;*/bi2[x].push_back(y);all.push_back(x);}
void ins(int x)
{
	if(tp<2){stk[++tp]=x;return;}
	int z=lca(x,stk[tp]);if(stk[tp]==z){stk[++tp]=x;return;}
	while(tp>1&&dfn[stk[tp-1]]>=dfn[z]){
		add(stk[tp-1],stk[tp]);tp--;
	}if(stk[tp]!=z){add(z,stk[tp]);stk[tp]=z;}
	stk[++tp]=x;
}
void dfs2(int x)
{
	if(vis[x]){dp[x][0]=dp[x][1]=1;return;}
	int f=1,g=0,h=0;ff(bi2[x],it){
		dfs2(*it);
		h=(1ll*g*dp[*it][1]+1ll*h*(dp[*it][0]+dp[*it][1]))%iter;
		g=(1ll*f*dp[*it][1]+1ll*g*dp[*it][0])%iter;
		f=(1ll*f*dp[*it][0])%iter;
	}dp[x][0]=(f+h)%iter;dp[x][1]=g;
}
int solve(int d)
{
	int i;init();ff(seq[d],it)vis[*it]=1;
	sort(seq[d].begin(),seq[d].end(),cmp);stk[tp=1]=1;
	ff(seq[d],it)if(*it!=1)ins(*it);
	while(tp>1){add(stk[tp-1],stk[tp]);tp--;}dfs2(1);
	ff(seq[d],it)vis[*it]=0;return dp[1][1];
}
int main()
{
	pw[0]=1;fz1(i,200000)pw[i]=2ll*pw[i-1]%iter;
	scanf("%d",&n);n++;fz(i,2,n){scanf("%d",&fa[i][0]);bi[++fa[i][0]].push_back(i);}dep[1]=1;dfs1(1);
	fz1(j,18)fz1(i,n)fa[i][j]=fa[fa[i][j-1]][j-1];
	fz1(i,n){if(seq[i].empty())break;ans=(ans+1ll*pw[n-seq[i].size()]*solve(i))%iter;}
	cout<<ans<<endl;return 0;
}

Measured memory_bytes: 53760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;
#define REP10(i, j, M) for(ll i = j; i <= M; i++)



int main() {
  IN(ll, N);
  IN(ll, K);
  vector<ll> havecandy(N,0);
  for(ll i = 0; i < K; i++){
    IN(ll, d);
  	for(ll j = 0; j < d; j++){
      ll a;
      cin >> a;
      havecandy.at(a-1) = 1;
    }
  }
  ll count = 0;
  for(ll i; i < N; i++){
    if(havecandy.at(i) == 0)
      count++;
  }
  OUT(count);
}





Measured memory_bytes: 3624
import collections
N,K,Q=[int(thing) for thing in input().split(" ")]
A_list=[int(input()) for thing in range(Q)]

c=collections.Counter(A_list)
cc={str(i):c[i] for i in c}
c=cc
for i in range(N):
    if str(i+1) in c:
        seikai=c[str(i+1)]
    else:
        seikai=0

    point=K-Q+seikai
    if point>0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 18800
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string S, T;
    in2(S, T);

    map<char, int> cs, ct;

    for (auto c : S) cs[c]++;
    for (auto c : T) ct[c]++;

    vi countS, countT;

    for (auto c : cs) countS.push_back(c.second);
    for (auto c : ct) countT.push_back(c.second);

    sort(all(countS));
    sort(all(countT));

    if (countS.size() != countT.size())
    {
        outl("No");
        return 0;
    }

    rep(i, countS.size())
    {
        if (countS[i] != countT[i])
        {
            outl("No");
            return 0;
        }
    }

    outl("Yes");
    return 0;
}


Measured memory_bytes: 3836
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, c, s, g, p[20], q[20][60], r[20][60];
ll sum[21][60];
int d[20][100][100];
bool v[100];

ll calc(int i, int d){
	int pos = lower_bound(q[i], q[i] + p[i], d) - q[i];
	ll res = sum[i][pos] + r[i][pos] * (d - q[i][pos]);
	return res;
}

int main(){
	while(cin >> n >> m >> c >> s >> g, n){
		s--; g--;
		rep(k, c) rep(i, n) rep(j, n) d[k][i][j] = i == j ? 0 : inf;
		rep(i, m){
			int a, b, e, f;
			cin >> a >> b >> e >> f;
			a--; b--; f--;
			d[f][a][b] = d[f][b][a] = min(d[f][a][b], e);
		}
		rep(i, c) cin >> p[i];
		rep(i, c){
			rep(j, p[i] - 1) cin >> q[i][j + 1];
			rep(j, p[i]){
				cin >> r[i][j + 1];
				sum[i][j + 1] = sum[i][j] + (ll)(q[i][j + 1] - q[i][j]) * r[i][j + 1];
			}
		}
		rep(it, c) rep(k, n) rep(i, n) rep(j, n)
			d[it][i][j] = min(d[it][i][j], d[it][i][k] + d[it][k][j]);
		
		memset(v, 0, sizeof(v));
		priority_queue<pair<ll, int> > q;
		q.push(mp(0, s));
		while(!q.empty()){
			int cu = q.top().second;
			ll co = q.top().first; q.pop();
			if(v[cu]) continue;
			v[cu] = 1;
			if(cu == g){
				cout << -co << endl;
				goto END;
			}
			rep(i, c) rep(j, n) if(d[i][cu][j] < inf && !v[j])
			q.push(mp(co - calc(i, d[i][cu][j]), j));
		}
		cout << -1 << endl;
		END:;
	}
	return 0;
}

Measured memory_bytes: 5020
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();

            long max = 0;
            for (Integer d : divisor(M)) {
                if (M / d.intValue() >= N) {
                    max = Math.max(max, d.intValue());
                }
            }
            System.out.println(max);
        }
    }

    public static final ArrayList<Integer> divisor(int n) {
        ArrayList<Integer> res = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.add(i);
                if (n / i != i) {
                    res.add(n / i);
                }
            }
        }
        return res;
    }
}


Measured memory_bytes: 25300