akhauriyash/Code-Regression huggingface dataset:
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

pub trait LexicalPermutation {
    fn next_permutation(&mut self) -> bool;
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }

    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        l: [usize; n],
    }
    let mut l = l;
    l.sort();
    l.reverse();
    let mut s = 0;
    for i in 0..k {
        s += l[i];
    }
    println!("{}", s);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
void solve () {
  int n, m, a, b, cur_r = 0, ans = 0;
  vector<pair<int, int>> v;
  cin >> n >> m;
  rep(i, m) {
    cin >> a >> b;
    v.emplace_back(b, a);
  }
  sort(v.begin(), v.end());
  rep(i, m) {
    if (v[i].second >= cur_r) {
      cur_r = v[i].first;
      ++ans;
    }
  }
  cout << ans << endl;
}
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int32 N, Z, W;
	int32 a[2020];
	cin >> N >> Z >> W;
	REP(i, N)
		cin >> a[i];
	cout << max(abs(W-a[N-1]), (N >= 2 ? abs(a[N-1]-a[N-2]) : 0)) << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    ok = True
    said = set()
    pre = input()
    said.add(pre)
    for i in range(1, N):
        w = input()
        if w in said:
            ok = False
            # print("double:", w)
        elif pre[-1] != w[0]:
            ok = False
            # print("invalid word:", w)
        else:
            pre = w
            said.add(w)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
def warshall_floyd(cost, num_v):
    """
    ワーシャルフロイド法
    :param cost: 隣接行列
    :param num_v: 頂点数
    :return: 各頂点からの最短距離
    """
    for k in range(num_v):
        for i in range(num_v):
            for j in range(num_v):
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
    return cost


import itertools


def abc073_d():
    n, m, r = map(int, input().split())
    *r, = map(int, input().split())
    inf = float("inf")
    cost = [[inf] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        cost[a - 1][b - 1] = c
        cost[b - 1][a - 1] = c
    for i in range(n):
        cost[i][i] = 0

    cost = warshall_floyd(cost, n)
    ans = inf
    for permutation in itertools.permutations(r):
        c = 0
        b = permutation[0]
        for i in permutation[1:]:
            c += cost[b - 1][i - 1]
            b = i
        ans = min(ans, c)
    print(ans)


if __name__ == '__main__':
    abc073_d()


Measured memory_bytes: 60632
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	aaa, bbb, ccc := min(n, y/10000), min(n, y/5000), y/1000

	for a := 0; a <= aaa; a++ {
		for b := 0; b <= bbb; b++ {
			if c := n - a - b; 0 <= c && c <= ccc && 10000*a+5000*b+1000*c == y {
				fmt.Println(a, b, c)
				return
			}
		}
	}

	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

void f(string &s, vector<string> &a, vector<string> &b){
    int l = 0;
    while(l < s.size()){
        if(s[l] != '"'){
            int r = l;
            string tmp;
            while(r < s.size() && s[r] != '"'){
                tmp += s[r++];
            }
            b.push_back(tmp);
            l = r;
        }
        else {
            string tmp;
            int r = l+1;
            while(s[r] != '"') tmp += s[r++];
            a.push_back(tmp);
            l = r+1;
        }
    }
}

int main(){
    string s, t;
    while(cin >> s && s != "."){
        cin >> t;
        vector<string> sa, ta;
        vector<string> sb, tb;
        f(s, sa, sb);
        f(t, ta, tb);
        /*for(auto &x: sa) cout << x << " ";
        cout << endl;
        for(auto &x: ta) cout << x << " ";
        cout << endl;
        for(auto &x: sb) cout << x << " ";
        cout << endl;
        for(auto &x: tb) cout << x << " ";
        cout << endl;*/
        if(sa.size() != ta.size() || sb.size() != tb.size()) puts("DIFFERENT");
        else{
            bool flag = true;
            rep(i, sb.size()){
                if(sb[i] != tb[i]){
                    puts("DIFFERENT");
                    flag = false;
                    break;
                }
            }
            if(!flag) continue;

            int cnt = 0;
            rep(i, sa.size()) cnt += (sa[i] != ta[i]);
            if(cnt == 0) puts("IDENTICAL");
            else if(cnt == 1) puts("CLOSE");
            else puts("DIFFERENT");
        }
    }
}


Measured memory_bytes: 3156
import numpy as np

def dfs(n,a,s):
  if n==0:
    return -1 if (a >= X).all()==False else s
  #print(a+A[n-1])
  x=dfs(n-1,a+A[n-1],s+C[n-1])
  y=dfs(n-1,a,s)
  return y if x==-1 else x if y==-1 else min(x,y)

N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
  c,*tmp=map(int,input().split())
  A.append(np.array(tmp))
  C.append(c)
#print(A)
print(dfs(N,np.array([0]*M),0))



Measured memory_bytes: 27312
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
typedef long long LL;
struct node{LL ans; int cnt1,cnt2;} f[N];
int x,y,z,n;
LL tot;
struct data{int a,b,c;} dat[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void check(LL x,LL y)
{
	f[0]=(node){0,0,0};
	rep(i,1,n)
	{
		f[i]=f[i-1];
		int a=dat[i].a-x,b=dat[i].b-y;
		if(a>b)
		{
			if(a>0) f[i].ans+=a,++f[i].cnt1;
		}
		else
		{
			if(b>0) f[i].ans+=b,++f[i].cnt2;
		}
	}
}

int main()
{
	x=getint(),y=getint(),z=getint(),n=x+y+z;
	rep(i,1,n) dat[i].a=getint(),dat[i].b=getint(),dat[i].c=getint();
	rep(i,1,n) tot+=dat[i].c,dat[i].a-=dat[i].c,dat[i].b-=dat[i].c;
	LL l1=-1000000000,r1=1000000000,l2,r2,mid1,mid2;
	while(l1<=r1)
	{
		l2=-1000000000,r2=1000000000,mid1=l1+r1>>1;
		while(l2<=r2)
		{
			mid2=l2+r2>>1;
			check(mid1,mid2);
			if(f[n].cnt2<=y) r2=mid2-1; else l2=mid2+1;
		}
		check(mid1,r2+1);
		if(f[n].cnt1<=x) r1=mid1-1; else l1=mid1+1;
	}
	check(r1+1,r2+1);
	printf("%lld\n",f[n].ans+(r1+1ll)*x+(r2+1ll)*y+tot);
	return 0;
}

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

void solve(long long N, long long X, std::vector<long long> L)
{

    auto count = 1;
    auto D = 0;
    for (int i = 0; i <= N - 1; ++i)
    {
        D = D + L[i];
        if (D <= X)
        {
            count += 1;
        }
    }
    cout << count << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &L[i]);
    }
    solve(N, X, std::move(L));
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define int long long
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)


int32_t main()
{
	fastio;
	int n;
	cin >> n;
	vector <vector <int> > good(n), bad(n);
	for(int i=0;i<n;i++){
		int x, y, m;
		cin >> m;
		for(int j=0;j<m;j++){
			cin >> x >> y;
			x--;
			if(y==1)
				good[i].push_back(x);
			else
				bad[i].push_back(x);
		}
	}

	int mask = (1<<n);
	int ans = 0;

	for(int i=0;i<mask;i++){
		int cur = i;
		bool poss = true;

		vector <int> face(n, -1);
		for(int j=0;j<n;j++){
			if((1<<j)&(cur)){
				face[j] = 1;
			}
			else
				face[j] = 0;
		}

		for(int j=0;j<n;j++){
			if((1<<j)&(cur)){
				for(auto z:good[j]){
					if(face[z]==0)
						poss = false;
					// face[z] = 1;
				}
				for(auto z:bad[j]){
					if(face[z]==1)
						poss = false;
					// face[z] = 0;
				}
			}
		}
		
		if(poss){
			int cnt = __builtin_popcount(cur);
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)


#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

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

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

const ll MOD = 1000000007;

string S;

#define debug(n) cout << n << endl;
// #define debug(n) ;


int main(void)
{
    cin >> S;

    const ll kSize = S.size();
    const ll kMax = 1 << (kSize - 1);
    ll insert = 0;
    ll sum = 0;

    for (ll i = 0; i < kMax; i++) {
        ll insert = i;
        ll sub = 0;
        string num = "";
        rep(j, kSize) {
            num += S[j];
            if (insert % 2 == 1) {
                sub += atoll(num.c_str());
                num = "";
            }
            insert = insert / 2;
        }
        sub += atoll(num.c_str());
        sum += sub;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 760
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>
 
struct task {
    intmax_t A;
    intmax_t B;
};
 
int compareB (const void *a, const void *b)
{
    if(((struct task *)a)->B <= ((struct task *)b)->B)
        return -1;
    if(((struct task *)a)->B > ((struct task *)b)->B)
        return 1;
}
 
int main (int argc, char const *argv[])
{
    intmax_t N;
    struct task task[(int)2e5];
    intmax_t time = 0, ans = 0;
 
    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd%jd", &task[i].A, &task[i].B);
    }
 
    qsort(task, N, sizeof(struct task), compareB);
 
    for (intmax_t i = 0; i < N; i++) {
        time += task[i].A;
        if (time > task[i].B) {
            puts("No");
            return 0;
        }
    }
 
    puts("Yes");
 
    return 0;
}

Measured memory_bytes: 6396
#include<stdio.h>
int main()
{
   int a,b,r=1;
   while(scanf("%d %d",&a,&b)!=EOF)
   {
       while(r!=0)
      {
       r=a%b;
       a=b;
       b=r;
      }
   printf("%d\n",a);
   r=1;
   }
}



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

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

const long long MOD = 1000000007;

int main(){
  int n,m;
  cin >> n >> m;
  if(n==m) cout << "Yes"<<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
def ok(last4):
	for i in range(4):
		t = list(last4)
		if i >= 1:
			t[i], t[i - 1] = t[i - 1], t[i]
		if ''.join(t).count('AGC') >= 1:
			return False
	return True

def dfs(cur, last3):
	if last3 in memo[cur]:
		return memo[cur][last3]
	if cur == n:
		return 1
	ret = 0
	for c in "ACGT":
		if ok(last3 + c):
			ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
	memo[cur][last3] = ret
	return ret


n = int(input())
mod = 10 ** 9 + 7
memo = [{} for i in range(n + 1)]

print(dfs(0, 'TTT'))

Measured memory_bytes: 3880
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    n = int(input())
    s = input()
    ans = float('-inf')
    for end in range(1,n):
        ans = max(ans, len([tmp for tmp in list(set(s[0:end])) if list(set(s[end:n])).count(tmp) > 0]))
    else:
        print(ans)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n;
  vll p(n); rep(i, n) cin >> p[i];
  sort(all(p));
  p[n-1] /= 2;
  fin(accumulate(all(p), 0))
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc054/tasks/abc054_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  auto edge = make_v<int>(N,N);
  auto nodes = make_v<int>(N-1);
  iota(nodes.begin(), nodes.end(), 1);

  REP(i,M) {
    int a,b;
    cin >> a >> b;
    edge[a-1][b-1] = edge[b-1][a-1] = 1;
  }
  int ans = 0;
  do {
    bool f = true;
    int p = 0;
    for (auto n : nodes) {
      if (!edge[n][p]) {
        f = false;
        break;
      }
      p = n;
    }
    if (f) ans++;
  } while(next_permutation(nodes.begin(),nodes.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,k,cnt=0;
	cin>>a>>b>>k;
	for(int i=500;i>0;i--){
		if((a%i==0)&&(b%i==0)){cnt++;
		}if(cnt==k){
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))


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

using namespace std;
using ll = long long;

#define MODNUM 1000000007

int main() {
	ll N, K, tmp;
	vector<ll> A;
	
	cin >> N >> K;
	for(ll i=0; i<N; i++) {
		cin >> tmp;
		A.push_back(tmp);
	}
	
	ll selfc = 0;
	ll selfg = 0;
	for(ll i=0; i<N; i++) {
		for(ll j=0; j<N; j++) {
			if(A[i] > A[j]) {
				selfc++;
				if(i < j) {
					selfg++;
				}
			}
		}
	}
	
	ll vg = ((selfg % MODNUM) * (K% MODNUM)) % MODNUM;
	ll vc = ((selfc % MODNUM) * (((K * (K-1))/2) % MODNUM)) % MODNUM;
	//printf("selfc = %lld, selfg = %lld\n", selfc, selfg);
	printf("%lld\n", (vg + vc) % MODNUM);
	
	return 0;
}


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

using namespace std;

int main(void) {
  const int mod = 100000;
  int w, h;
  while (cin >> w >> h, w) {
    int dp[210][110][2] = {};
    for (int i = 0; i < 2 * h - 1; i++) {
      if (i & 1) {
        for (int j = 0; j < w; j++) {
          if (j == 0) {
            dp[i][j][0] = 0;
            dp[i][j][1] = 1;
          } else {
            dp[i][j][0] = dp[i - 1][j - 1][1];
            if (i == 1) continue;
            dp[i][j][1] = (dp[i - 2][j][0] + dp[i - 2][j][1]) % mod;
          }
        }
      } else {
        for (int j = 0; j < w - 1; j++) {
          if (i == 0) {
            dp[i][j][0] = 0;
            dp[i][j][1] = 1;
          } else {
            dp[i][j][0] = dp[i - 1][j][1];
            if (j == 0) continue;
            dp[i][j][1] = (dp[i][j - 1][0] + dp[i][j - 1][1]) % mod;
          }
        }
      }
    }

    int ans = 0;
    ans += dp[2 * h - 2][w - 2][0];
    ans += dp[2 * h - 2][w - 2][1];
    ans += dp[2 * h - 3][w - 1][0];
    ans += dp[2 * h - 3][w - 1][1];
    ans %= mod;

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3228
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt
  val (x, y) = if(a > b) (a ,b) else (b, a)
  println(resolve(x,y))


def mod(x:Int, y:Int) : Int = x % y

def resolve(x: Int , y:Int) : Int = {
  if(y == 0) x
  else resolve(y, mod(x, y))
}
}


Measured memory_bytes: 45068
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}
int main(){
    char A;
    cin>>A;
    if(isupper(A)){
        cout<<'A'<<endl;
    }
    else{
        cout<<'a'<<endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 40000005
#define ll long long
#define ld double
#define mod 1000000007
using namespace std;
ll rev[maxn];
ll jc[maxn], bjc[maxn];
ll ksm[maxn];
ll c(ll a, ll b)
{
	if(b < 0 || b > a || a < 0) return 0;
	return jc[a] * bjc[b] % mod * bjc[a - b] % mod;
}
ll cal(int t, int m, int r)
{
	ll ans = c(t + m + r, m);
	ans = ans * bjc[t] % mod * bjc[m + r] % mod;
	return ans;
}
int main()
{
//	#define int long long
	jc[0] = 1, bjc[0] = 1;
	rev[1] = 1;
	for(int i = 2; i < maxn; i++)
	{
		int nd = mod / i + 1;
		rev[i] = nd * rev[nd * i - mod] % mod;
	}
	for(int i = 1; i < maxn; i++)
		jc[i] = jc[i - 1] * i % mod, 
		bjc[i] = bjc[i - 1] * rev[i] % mod;
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	ll ans = jc[h] * jc[w] % mod;
//	cout<<ans<<endl;
/*
	ll t1 = 0;
	ll as[200];
	for(int a = 0; a <= k; a++)
		for(int b = 0; b <= k; b++)
		{
			ll n2 = 0;
			for(int x = a; x <= k; x++)
			{
				if(a == 0 && b == 0) continue;
				int y = k - x;
				if(y < b) continue;
				ll n1 = (a + 1) * (b + 1) * c(a + b, a) * c(x + y - a - b, x - a) % mod;
				n1 = n1 * ans % mod * bjc[h - x] % mod * bjc[w - y] % mod;
				as[a + b] += n1;
				as[a + b] %= mod;
				n2 += n1, n2 %= mod;
				t1 += n1, t1 %= mod;
				//	cout<<a<<" "<<b<<" "<<x<<" "<<y<<" "<<n1<<endl;
			}
		//	cout<<a<<" "<<b<<" "<<n2<<endl;
		}
//	cout<<t1<<endl;
	t1 = 0;
	for(int a = 0; a <= k; a++)
		for(int b = 0; b <= k; b++)
		{
			if(a == 0 && b == 0) continue;
			if(a + b > k) continue;
			ll a1 = jc[a + b] % mod * (a + 1) % mod * (b + 1) % mod * ans % mod * bjc[a] % mod * bjc[b] * mod * jc[k - a - b] % mod; 
			a1 = a1 * jc[w + h - a - b] % mod * bjc[w - b] % mod * bjc[h - a] % mod * bjc[k - a - b] % mod * bjc[h + w - k] % mod;
			t1 += a1;
			t1 %= mod;
		//	cout<<a<<" "<<b<<" "<<a1<<endl; 
		}
//	cout<<t1<<endl;
*/
	ll nans = 0;
	for(int i = 1; i <= k; i++)
	{
		ll n1 = jc[w + h - i] * jc[i] % mod * bjc[h + w - k] % mod;
		ll n2 = 0;
		n2 += (i + 1) * cal(i, h, w - i) % mod; 	
		//
		//if(i >= 2) 
		n2 += cal(i - 2, h - 1, w - i + 1);
		n2 = n2 * n1 % mod;
		//cout<<i<<" "<<n2<<" "<<n1<<endl;
		nans = (nans + n2) % mod;
		//a + b
	}
	ans = ans * nans % mod;
	printf("%lld\n", ans);
	return 0;
 } 

Measured memory_bytes: 939008
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long c=0;
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=k;i<=n;i++)
        c+=n-i;
    for(int i=k+1;i+k<=n;i++)
        for(int j=i;j+k<=n;j+=i)
            if(j+i<=n)
            {
                c+=i-k;
            }
            else
                c+=n-j-k+1;
    if(k==0)
        c-=n;
    printf("%lld",c);
    return 0;
}


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

int main () {
  int n; cin >> n;
  vector<long long> f(n+1, 0);
  f[0] = 2; f[1] = 1;
  for (int i = 2; i < n+1; i++)
    f[i] = f[i-1]+f[i-2];
  cout << f[n] << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'



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

	int a, b;
	cin >> a >> b;
	if (a <= 5)
		cout << 0 << endl;
	else if (a <= 12)
		cout << b / 2 << endl;
	else
		cout << b << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int mod=1e9+7;
inline int add(int a,int b){return (a+b)>=mod?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b)>=mod?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int &a,int b){static ll r;r=(ll)a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(ll x){x%=mod;return (x<0)?x+mod:x;}
cs int N=300005;
int n,f[N][3][3];
char s[N];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=readstring(s);f[0][0][0]=1;
	for(int i=1;i<=n;i++)
	for(int x=0;x<=2;x++)
	for(int y=0;y<=2;y++){
		if(s[i]!='0'){
			if(!y)Add(f[i][x+(x!=2)][y],f[i-1][x][y]);
			else Add(f[i][x][y-1],f[i-1][x][y]);
		}
		if(s[i]!='1'){
			if(y==2)Add(f[i][x][1],f[i-1][x][y]);
			else Add(f[i][x][y+1],f[i-1][x][y]);
		}
	}int res=0;
	for(int x=0;x<=2;x++)
	for(int y=0;y<=x;y++)Add(res,f[n][x][y]);
	cout<<res;return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

int main() {

    int S, W;
    cin >> S >> W;

    if (W >= S) cout << "unsafe\n";
    else cout << "safe\n";

    return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;

    return 0;
}


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

/*
inline int factorial(int n)
{
    int x = 1;
    for (;n != 0; n--)
        x *= n;
    return x;
}

inline int factorial(int s, int n)
{
    int x = 1;
    for (;n > s; n--)
        x *= n;
    return x;
}

inline int conbination(int n, int r)
{
    return factorial(n - r, n) / factorial(r);
}

inline int homogeneous(int n, int r)
{
    return conbination(n + r - 1, r);
}
*/

int calc(int n, int k)
{
    int count = 0;

    if (k == 0)
        if (n == 0)
            return 1;
        else
            return 0;

    for (int i = 0; i <= 9; i++) {
        int tmp = n - i;
        if (tmp < 0)
            break;
        else
            count += calc(tmp, k - 1);
    }

    return count;
}

int main()
{
    for (int n; cin >> n;)
        cout << calc(n, 4) << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(0);
  int ans=1;
  rep(i,n) cin >> a.at(i);
  reverse(a.begin(),a.end());
  b.push_back(a.at(0));
  int ma=a.at(0);
  for (int i=1;i<n;i++){
    int k=a.at(i);
    //cout << k << ma << endl;
    if (k>=ma){
      ans++;
      ma=k;
      b.push_back(k);
      continue;
    }
    auto it=upper_bound(b.begin(),b.end(),k);
    
      b.at(it-b.begin())=k;
      if (it-b.begin()==b.size()-1){
        ma=b.at(b.size()-1);
      }
  }
  cout << ans << endl;
  }

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s,s1;
    cin>>s>>s1;
    ll flag=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=s1[i])
        {
            flag=1;
        }
    }
    if(flag==0)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		if(s.length() <=k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0,k) + "...");
		}


	}
}

Measured memory_bytes: 27088
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 100000000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
   ll h,w,ans=0;
   cin>>h>>w;
   
   //vvll a(h,vll(w));
   vvll c(10,vll(10));
   rep(i,10){
       rep(j,10)cin>>c.at(i).at(j);
   }
   
   for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++)c.at(i).at(j)=min(c.at(i).at(j),c.at(i).at(k)+c.at(k).at(j));
    }
}

   rep(i,h){
       rep(j,w){
     
       ll a;
       cin>>a;
       if(a==-1)continue;
       else {
          ans+=c.at(a).at(1);
          // cout<<a<<endl;
       }
       }
   }
   
   cout<<ans<<endl;
   
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int N;
  ll C, K;
  cin >> N >> C >> K;
  vector<ll> T(N);
  for (int i = 0; i < N; ++i) {
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  ll start = T[0];
  int cnt = 1;
  int result = 0;
  for (int i = 0; i < N; ++i) {
    if (C < cnt || start + K < T[i]) {
      ++result;
      cnt = 1;
      start = T[i];
    }
    if (i == N - 1) {
      ++result;
      start = T[i];
    }
    ++cnt;
  }
  cout << result << endl;
}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 2e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, d[N];
vector < int > g[N];

void dfs(int v = 1) {
  vector < int > x;
  for (auto to : g[v]) {
    dfs(to);
    x.pb(d[to]);
  }
  sort(x.begin(), x.end());
  for (auto i : x) d[v] = max(d[v], i) + 1;
  return;
  cout << "v = " << v << " " << d[v] << endl;
  for (auto i : x) cout << i << " ";
  cout << endl;
}
void solve() { 
  cin >> n;
  for (int i = 2, x;i <= n;i++) {
    cin >> x;
    g[x].pb(i);
  }
  dfs();
  cout << d[1] << endl;
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 16256
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int y,m,d;
  char a,b;
    cin >> y >> a >> m >> b >> d;
  if (m > 4){
    cout << "TBD" << endl;
  }
  else {
    cout << "Heisei" << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

const long long M=1e9+9;
typedef vector<long long> vec;
typedef vector<vec> mat;
struct Matrix{
  int N;
  mat a;
  Matrix(int n){
    N=n;
    a=mat(N,vec(N));
    for(int i=0;i<N;i++)a[i][i]=1;
  }
Matrix pow(long long b) const {
  Matrix res(N);
  Matrix d(N);
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=a[i][j];
    for(;b>0;b>>=1,d=d*d)if(b&1)res=d*res;
      return res;
  }
  Matrix operator+(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        s[i][j]=(a[i][j]+r.a[i][j])%M;
      }
    }
    return s;
  }
  Matrix operator*(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++)s[i][i]=0;
      const long long modl=8*M*M;
    for(int i=0;i<N;i++){
      for(int k=0;k<N;k++){
        for(int j=0;j<N;j++){
          s[i][j]+=a[i][k]*r.a[k][j];
          if(s[i][j]>=modl)s[i][j]-=modl;
        }
      }
      for(int j=0;j<N;j++)s[i][j]%=M;
    }
  return s;
}

vector<long long>& operator[](int i){
  return a[i];
}
};

int main(){

  int hoge=1;
  while(1){
    ll W,H,N;
    vector<ll> ev;
    map<P,bool> dame;
    cin>>W>>H>>N;
    if(W==0)break;
    rep(i,N){
      ll x,y;
      cin>>x>>y;
      y--; x--;
      dame[P(y,x)]=true;
      ev.push_back(y);
    }
    ev.push_back(0);
    ev.push_back(H-1);
    sort(all(ev));
    uni(ev);

    Matrix a(W);
    rep(i,W){
      rep(j,W){
        if(abs(i-j)<=1)a[i][j]=1;
        else a[i][j]=0;
      }
    }

    Matrix crt(W);
    rep(e,ev.size()-1){
      Matrix b(W);
      rep(i,W){
        rep(j,W){
          if(abs(i-j)<=1&&!dame[P(ev[e+1],j)])b[i][j]=1;
          else b[i][j]=0;
        }
      }
      Matrix p=a.pow(ev[e+1]-ev[e]-1);
      p=p*b;
      crt=crt*p;
    }

    printf("Case %d: %lld\n", hoge++,crt[0][W-1]);

  }
  return 0;
}



Measured memory_bytes: 3472
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		final int MOD = 1000000007;

		//入力
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		sc.close();

		//処理
		String ans = String.valueOf(a.charAt(0)) + b.charAt(0) + c.charAt(0);
		ans = ans.toUpperCase();

		//出力	
		out.println(ans);
		out.flush();
	}

	static class Pair{
		int w,v;
		public Pair(int a, int b){
			this.w = a;
			this.v = b;
		}
	}
}

Measured memory_bytes: 23892
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, x;
		int count  = 0;

		while(true) {
			n = sc.nextInt();
			x = sc.nextInt();

			if(n == 0 && x == 0) break;

			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					for(int k = j + 1; k <= n; k++) {
						if (x == i + j + k) count++;
					}
				}
			}
			System.out.println(count);
			count = 0;
		}
		sc.close();
	}
}



Measured memory_bytes: 26512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()
	s := nextString()

	ans := true
	if n%2 != 0 {
		ans = false
	} else {
		l := len(s)
		s1 := s[0 : l/2]
		s2 := s[l/2 : l]
		if !reflect.DeepEqual(s1, s2) {
			ans = false
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b; cin>>a>>b;
	int ans=max(a+max(a-1,b), b+max(b-1,a));
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, K;
	cin >> N >> K;
	VLL maj, min;
	int Z = 0, M = 0;
	for (int n = 0; n < N; n++) {
		LL a;
		cin >> a;
		if (a > 0)maj.push_back(a);
		else if (a < 0)min.push_back(a);
	}
	Z = N - (int)(maj.size() + min.size());
	M = maj.size();
	N = min.size();
	sort(maj.begin(), maj.end(), [](LL a, LL b) {
		return a > b;
	});
	sort(min.begin(), min.end(), [](LL a, LL b) {
		return a < b; }
	);
	if (M + N < K) {
		cout << 0 << "\n";
		return 0;
	}
	int n = max(0, K-M);
	int m = K - n;
	if (n % 2 == 1) {
		n++;
		m--;
	}
	bool flag = false;
	while (0 <= n && n <= N && 0 <= m && m <= M) {
		flag = true;
		if (0 <= n + 2 && n + 2 <= N && 0 <= m - 2 && m - 2 <= M) {
			if (min[n] * min[n + 1] >= maj[m - 1] * maj[m - 2]) {
				n += 2;
				m -= 2;
			}
			else break;
		}
		else break;
	}
	if (flag) {
		LL ans = 1;
		for (int mm = 0; mm < m; mm++) {
			ans = ans * (maj[mm]);
			ans %= MOD;
		}
		for (int nn = 0; nn < n; nn++) {
			LL temp = min[nn] % MOD;
			temp += MOD;
			ans = (ans * temp) % MOD;
		}
		cout << ans << "\n";
		return 0;
	}
	if (Z != 0) {
		cout << 0 << "\n";
		return 0;
	}
	n = max(0, K - M);
	m = K - n;
	if (n % 2 == 0) {
		n++;
		m--;
	}
	for (int n = 0; n < N; n++)min[n] = -min[n];
	sort(min.begin(), min.end(), [](LL a, LL b) {return a < b; });
	while (0 <= n && n <= N && 0 <= m && m <= M) {
		if (0 <= n + 2 && n + 2 <= N && 0 <= m - 2 && m - 2 <= M) {
			if (min[n] * min[n + 1] <= maj[m - 1] * maj[m - 2]) {
				n += 2;
				m -= 2;
			}
			else {
				break;
			}
		}
		else break;
	}
	LL ans = 1;
	for (int mm = 0; mm < m; mm++) {
		ans = (ans * maj[mm]) % MOD;
	}
	for (int nn = 0; nn < n; nn++) {
		ans = (ans * min[nn]) % MOD;
	}
	ans *= -1;
	ans %= MOD;
	ans += MOD;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 5024