akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;

lint gcd(lint m,lint n){
  if(n==0)return m;
  else return gcd(n,m%n);
}

lint lcm(lint m,lint n){
  return m/gcd(m,n)*n;
}

lint pow_mod(lint a,lint b,lint p){
  if(b==0)return 1;
  if(b%2==0){
    lint d=pow_mod(a,b/2,p);
    return (d*d)%p;
  }else{
    return (a*pow_mod(a,b-1,p))%p;
  }
}

//x / a mod p=x * inv_mod(a,p) 
lint inv_mod(lint a,lint p){
  return pow_mod(a,p-2,p);//(a^(p-2))mod p
}


int main(){
  int N;
  cin>>N;
  int A[N];
  REP(i,N)cin>>A[i];
  map<lint,lint> K;
  REP(i,N){
    int a=A[i];
    FOR(j,2,1001){
      lint k=0;
      while(a%j==0){
        k++;
        a/=j;
      }
      if(k>0)K[j]=max(k,K[j]);
    }
    if(a!=1)K[a]=1;
  }
  // REP(i,100)cerr<<i<<" "<<K[i]<<endl;
  lint temp=1;
  for(auto e:K){
    lint j=e.first;
    REP(k,e.second){
      temp*=j;
      temp%=p;
    }
  }
  lint ans=0;
  REP(i,N){
    ans+=temp*inv_mod(A[i],p);
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


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

signed main(void)
{
	int n, sum, ans;
	string s;
	map<char, int> mp;
	cin >> n >> s;
	ans = 0;
	rep(i, n) mp[s[i]]++;
	rep(i, n)
	{
		string x, y;
		map<char, int> st;
		sum = 0;
		x = s.substr(0, i);
		rep(j, x.size()) st[x[j]]++;
		for(auto p : st)
		{
			if (mp[p.first] - p.second != 0)
				sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    int a,b;
    cin >> a >> b;
    
    cout << a*b << " " << 2*a+2*b << endl;

    return 0;
    
}



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

int main() {
  int N;
  cin >> N;
  int ans = 100;
  for (int i = 0; i < N; i++){
    int A;
    cin >> A;
    int count = 0;
    while (A % 2 == 0){
      A /= 2;
      count++;
    }
    if (count < ans){
      ans = count;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections
import math

N=math.factorial(int(input()))
MOD=10**9+7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c=collections.Counter(prime_factorize(N))
L=list(c.values())
L=[i+1 for i in L]
ans=1
for i in L:
    ans=ans*i%MOD
print(ans)

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int n, m;
  std::cin >> n >> m;

  std::vector<int> nodes(n, 0);

  for (int i=0; i<m; i++) {
    int a, b;
    std::cin >> a >> b;
    nodes[a-1]++; nodes[b-1]++;
  }

  bool ans = std::all_of(nodes.begin(), nodes.end(),
                         [](int n) {return n%2==0;});

  std::cout << (ans ? "YES" : "NO") << std::endl;

  return 0;
}


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

namespace AtCoder04
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] z = Console.ReadLine().Split(' ');
            int a = int.Parse(z[0]);
            int b = int.Parse(z[1]);
            if (b % a == 0)
            {
                Console.WriteLine(a+b);
            }
            else Console.WriteLine(b-a);
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer>[] graph = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
			graph[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < n - 1; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			graph[a].add(b);
			graph[b].add(a);
		}
		boolean[] arr = new boolean[n + 1];
		ArrayDeque<Integer> deqA = new ArrayDeque<>();
		ArrayDeque<Integer> deqB = new ArrayDeque<>();
		ArrayDeque<Integer> nextA = new ArrayDeque<>();
		ArrayDeque<Integer> nextB = new ArrayDeque<>();
		int countA = 0;
		int countB = 0;
		deqA.add(1);
		deqB.add(n);
		while (deqA.size() > 0 || deqB.size() > 0) {
			while (deqA.size() > 0) {
				int p = deqA.poll();
				if (arr[p]) {
					continue;
				}
				arr[p] = true;
				countA++;
				nextA.addAll(graph[p]);
			}
			while (deqB.size() > 0) {
				int p = deqB.poll();
				if (arr[p]) {
					continue;
				}
				arr[p] = true;
				countB++;
				nextB.addAll(graph[p]);
			}
			ArrayDeque<Integer> tmp = deqA;
			deqA = nextA;
			nextA = tmp;
			tmp = deqB;
			deqB = nextB;
			nextB = tmp;
		}
		if (countA > countB) {
			System.out.println("Fennec");
		} else {
			System.out.println("Snuke");
		}
	}
}


Measured memory_bytes: 100660
#include <iostream>
#include <string>
#include <cmath>
#include <list>
#include <algorithm>

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int p[4];
    for (int j = 0; j < 4; j++) {
        p[j] = stoi(s.substr(j, 1));
    }

    for (int i = 0; i < 8; i++) {
        int b[3];
        for (int j = 0; j < 3; j++) {
            b[j] = i & (int) pow(2, j);
        }

        int calc = p[0];

        for (int j = 0; j < 3; j++) {
            if (b[j] == 0) {
                calc += p[j + 1];
            } else {
                calc -= p[j + 1];
            }
        }

        if (calc == 7) {
            cout << p[0];
            for (int j = 0; j < 3; j++) {
                if (b[j] == 0) {
                    cout << "+";
                } else {
                    cout << "-";
                }
                cout << p[j + 1];
            }
            cout << "=7";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;
	if (x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) {
		std::cout << "Yes\n";
	}
	else
	{
		std::cout << "No\n";
	}
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<set>
#include<algorithm>
#define L long long
#include<string.h>
#include <math.h>
using namespace std;
typedef long long ll;
int a[100002];
int main()
{
      int m,x;
      scanf("%d",&x);
   if(x==5||x==3||x==7)
    printf("YES\n");
   else
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions

N = int(input())
T = [int(input()) for i in range(N)]


def lcm(a,b):
    return (a * b) // fractions.gcd(a,b)

ans = 1
for t in T:
    ans = lcm(ans,t)

print(ans)


Measured memory_bytes: 5588
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)

int main(void) {
	int num = 0, qw = 0;
	cin >> num >> qw;	
	string word;
	vector<string> name(num,word);
	vector<pair<int, char>> alp;
	long int count = 0;
	int max = 2;
	cin >> word;
	alp.push_back(make_pair(1, word[0]));
	rep(0, num - 1) {
		cin >> word;
		char al = word[0];
		for (int p = 0; p < alp.size(); p++) {
			if (al == alp[p].second) {
				alp[p].first++;
				break;
			}
			else if (p == alp.size() - 1) {
				alp.push_back(make_pair(1, al));
				break;
			}
		}
	}
	sort(alp.begin(), alp.end(), greater<pair<int,char>>());
	rep(0, alp.size()) {

		
		for (int m = 0; m < num; m++) {
			char al;
			if(alp[0].first != 0)	 al = alp[0].second;
			else break;
			int check = 0;
			for (int p = 0; p < max; p++) {
				for (int q = 0; q < name[p].size(); q++) {
					if (name[p][q] == al || name[p].size() == qw) break;
					else if (q == name[p].size() - 1) {
						name[p].push_back(al);
						alp[0].first--;
						sort(alp.begin(), alp.end(), greater<pair<int, char>>());
						check = 1;
						break;
					}
				}
				if (check == 1) break;
				if (name[p].empty()) {
					name[p].push_back(al);
					alp[0].first--;
					sort(alp.begin(), alp.end(), greater<pair<int, char>>());
					max++;
					break;
				}
			}
		}
	}
	rep(0, name.size()) {
		if (name[i].size() == qw) count++;
	}
	cout << count << endl;
}

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

#define MOD 1000000007
#define PI 3.1415926535897932384
#define fastio std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long

signed main(){

    fastio;
    
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    int i = 0;
    while(i < n-1){
        int cnt = 0;
        while(a[i] == a[i+1]){
            cnt++;
            i++;
        }
        ans += (cnt+1)/2;
        i++;
    }
    cout << ans;
    return 0;
}
 

Measured memory_bytes: 256
maxx = 2000001;
maxnum = 10010;

n=int(input())
A=[int(x) for x in input().split()]  
A.insert(0,0) 
B=[-1 for x in range(n)]
C=[0 for x in range(maxnum)]



for a in A[1:]:
    C[a]+=1
for i in range(1,maxnum): # 累加和
    C[i]+=C[i - 1]
    
for j in range(1,n+1):
    B[C[A[j]]-1]=A[j]
    C[A[j]]-=1

lens=len(B)    
for i in range(0,lens-1):
    print(B[i],end=' ')
print(B[lens-1])




Measured memory_bytes: 224204
#include <stdio.h>

int main(void){
	int N;
	
	scanf("%d",&N);
	
	if(N==1){
		printf("Hello World");
	}
	if(N==2){
		int A,B;
		scanf("%d",&A);
		scanf("%d",&B);
		printf("%d\n",A+B);
	}
		
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(){
  uint len;
  std::cin >> len;
  if (len % 2 == 1){
    std::cout << "No" << std::endl;
    return 0;
  }
  std::string str;
  std::cin >> str;
  if (str.substr(0, len / 2) == str.substr(len / 2, len /2)){
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

using ll = long long;

ll n, x;

int main()
{
	scanf("%lld %lld", &n, &x);
	ll ans = 0;
	while (x > 0)
	{
		if (n % x == 0)
		{
			ans += (n / x - 1) * x;
			break;
		}
		else
		{
			ans += n / x * x;
			ll n1 = n % x;
			ll x1 = (x + (n % x)) % (n % x);
			n = n1; x = x1;
		}
	}
	printf("%lld", ans * 3);
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
constexpr int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &a) { return (os << a.x); }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    s[i] = s[i] + n;
    if (s[i] > 'Z') s[i] -= 'Z' - 'A' + 1;
  }
  cout << s << endl;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B;
  cin >> A >> B;

  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


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

struct e{int a,b;};
int A=500,n,a[20],b[20],T,p,q;
e v[20];
stack<int> s;
#define R(i,n) for(int i=0;i<(n);i++)

signed main(){
  cin>>n;
  R(i,n)cin>>a[i];
  R(i,n)cin>>b[i];
  R(i,1<<n){
    T=0;
    R(j,n)v[j]={(i>>j)&1?b[j]:a[j],j};
    R(j,n){
      p=j;
      while(p&&v[p].a<v[p-1].a)swap(v[p],v[p-1]),T++,p--;
    }
    R(j,n)if(((i>>v[j].b)+v[j].b-j)&1)s.push(v[j].a*500+j);
    if(s.size()&1)T=500,s.pop();
    while(s.size()){
      p=s.top();s.pop();q=s.top();s.pop();
      T+=((p-q)&1?p-q:500);
    }
    if(A>T)A=T;
  }
  cout<<(A<500?A:-1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P_;
typedef pair <int,P_> P;

struct tree{
	int idx;
	int v;
};

bool comp(const tree &a,const tree &b){
	return a.v < b.v;
}

int N;
int n;
tree dat[2][1<<19];

//配列、木:0オリジン
//n_:元の数列の要素数
//n:修正後の配列要素数 木のサイズ:2*n-1
void init(int n_){
	n=1;
	while(n<n_)n*=2;
	for(int i=0;i<2*n-1;i++) rep(j,0,2){
		dat[j][i].v=INF;
		dat[j][i].idx=i-n+1;
	}
}

void update(int i,int x){
	int u = i%2;
	i += n-1;
	dat[u][i].v = x;
	while(i>0){
		i = (i-1)/2;
		dat[u][i] = min(dat[u][i*2+1],dat[u][i*2+2],comp);
	}
}

//[a,b)のmin 節点k[l,r)について調べる
tree find(int u,int a,int b,int k=0,int l=0,int r=n){
	if(r<=a || b<=l){
		return (tree){INF,INF};
	}else if(a<=l && r<=b){
		return dat[u][k];
	}else{
		tree t1 = find(u,a,b,2*k+1,l,(l+r)/2);
		tree t2 = find(u,a,b,2*k+2,(l+r)/2,r);
		return min(t1,t2,comp);
	}
}

priority_queue<P,vector<P>,greater<P>> que;

//[l,r)
void push(int l,int r){
	if(r-l<2)return;
	que.push(P(find(l%2,l,r).v,P_(l,r)));
}

int main()
{
	cin >> N;
	init(N+1);
	rep(i,0,N){
		int p;
		cin >> p;
		update(i,p);
	}
	push(0,N);
	vector<int> ans;

	while(!que.empty()){
		P R = que.top();que.pop();
		int l = R.second.first;
		int r = R.second.second;
		tree t1 = find(l%2,l,r);
		tree t2 = find((l+1)%2,t1.idx,r);
		ans.push_back(t1.v);
		ans.push_back(t2.v);
		push(l,t1.idx);
		push(t1.idx+1,t2.idx);
		push(t2.idx+1,r);
	}
	rep(i,0,ans.size()){
		if(i!=0)cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 11148
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  char a,b;
  cin >> a >> b;
  int ret = a - b;
  if(ret > 0) {
    cout << ">" << endl;
  } else if(ret < 0) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    double R; scanf("%lf", &R);
    printf("%.10lf\n", 2.0 * PI * R);
}

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

typedef long long ll;

using namespace std;

int a[110];

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i = 1 ; i<=n ; i++){
		cin>>a[i];
	}
	for(int j = 1 ; j<=n ; j++){
		if(j == 1)
			cout<<a[j];
		else
			cout<<" "<<a[j];
	}
	cout<<endl;
	//由小到大插入排序 
	for(int i = 2 ; i<=n ; i++){
		for(int j = 0 ; j<=i-1 ; j++){
			if(a[i]<a[j]){            //找到已经排序的序列中第一个比待插入元素大的 
				int t = a[i];
				for(int k = i ; k>=j+1 ; k--){    //把待插入大的都向后意一位 
					a[k] = a[k-1]; 
				}
				a[j] = t;                         //插入空 
			
				break;
			}
		}
		for(int j = 1 ; j<=n ; j++){
			if(j == 1)
				cout<<a[j];
			else
				cout<<" "<<a[j];
		}
		cout<<endl;
	}
	return 0;
}




Measured memory_bytes: 3180
#include <stdio.h>

int main(){
	int i;
	scanf("%d", &i);
	if (i == 25){
		printf("Christmas\n");
	}else if (i == 24){
		printf("Christmas Eve\n");
	}else if (i == 23){
		printf("Christmas Eve Eve\n");
	}else{
		printf("Christmas Eve Eve Eve\n");
	}
}

Measured memory_bytes: 128
#include<stdio.h>
#include <stdlib.h>
int main(void){
 int num,day,q,sum;
	scanf("%d %d %d",&num,&day,&q);
	int a[num];
	sum=q;
	for(int i=0;i<num;i++){
	scanf("%d",&a[i]);
	sum+=((day-1)/a[i]+1);
}
	printf("%d",sum);
	
	return 0;
}

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

int main(){
  
  int N, A;
  cin >> N >> A;
  
  if(N % 500 == 0)
    cout << "Yes" << endl;
  else if(N % 500 != 0 && N % 500 < A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lg long long
int fr[200005],nex[200005],vi[200005],wi[200005],tot=0,d[200005],vis[200005];
void add(int x,int y,int z){
	vi[++tot]=y;wi[tot]=z;nex[tot]=fr[x];fr[x]=tot;
}
queue<int> Q;
int spfa(){
	memset(d,0x3f,sizeof d);d[1]=0;
	Q.push(1);
	while(!Q.empty()){
		int x=Q.front();Q.pop();vis[x]=0;
		for(int i=fr[x];i;i=nex[i]){
			if(d[vi[i]]>d[x]+wi[i]){
				d[vi[i]]=d[x]+wi[i];
				if(!vis[vi[i]]){
					 vis[vi[i]]=1;
					 Q.push(vi[i]);
				}
			}
		}
	}
	return d[0]+1;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)add(i%n,(i+1)%n,1),add(i%n,i*10%n,0);
	printf("%d",spfa());
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define int long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;	

void dfs(int v,vector<int>graph[],vector<bool>&seen,vector<int>&in_edges,vector<int>&dp){
	if(seen[v]) return ;
	seen[v]=true;
	for(int child : graph[v]){
		dp[child] = max(dp[child],dp[v]+1);
		in_edges[child]--;
		if(in_edges[child]==0) dfs(child,graph,seen,in_edges,dp);
	}
}

signed main(){IOS;
	int n , m ; cin>> n>> m;
	vector<int>in_edges(n+1,0);
	vector<bool>seen(n+1,false);
	vector<int>graph[n+1];
	for(int i=0;i<m;i++){
		int a,b; cin>>a>>b; 
		a--;b--;
		graph[a].push_back(b);
		in_edges[b]++;
	}
	for(int i=0;i<n;i++){
		graph[n].push_back(i);
		in_edges[i]++;
	}
	vector<int>dp(n+1,0);
	dfs(n,graph,seen,in_edges,dp);
	cout<<(*max_element(dp.begin(),dp.begin()+n))-1<<endl;
	return 0;
}


Measured memory_bytes: 10612
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d = []
for i, j in enumerate(x):
    if x[-1] != j:
        d.append(x[i + 1] - x[i])
d.sort()
r = 0
for k in range(m - n):
    r += d[k]
print(r)

Measured memory_bytes: 13968
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000

struct rect {
    int height;
    int left;
};

static struct rect stack[NUM_MAX+10];
static int sidx = 0;

void push(struct rect r) { stack[sidx++] = r; }
struct rect pop(void) { return stack[--sidx]; }
struct rect peek(void) { return stack[sidx-1]; }

int is_empty(void) { return !sidx; }

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX+1];
    fget_array(arr, num);
    arr[num] = 0;

    int right;
    int64_t ans = 0;
    for(right = 0; right < num+1; right++) {
        struct rect r = {arr[right], right};
        while(!is_empty()) {
            struct rect top = peek();
            if(top.height < r.height) break;
            ans = max(ans, (int64_t)top.height*(right-top.left));
            r.left = top.left;
            pop();
        }
        push(r);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2852
package main

import "fmt"

func divs(n int) []int {
	r := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
			if i*i != n {
				r = append(r, n/i)
			}
		}
	}
	return r
}
func cols(n int) int {
	cnt := 0
	for n > 0 {
		cnt++
		n /= 10
	}
	return cnt
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var N, ans int
	fmt.Scan(&N)
	ds := divs(N)
	for _, v := range ds {
		ans = max(cols(v), cols(N/v))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    string ans = "";
    ans += s[0];
    for(int i = 1; i < s.size(); i++)
    {
        if(ans.size() > 0 && ans.back() == 'S' && s[i] == 'T') ans.pop_back();
        else ans += s[i];
    }
    cout << ans.size() << endl;
    return 0;
}



Measured memory_bytes: 916
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int i,x,n;
	cin>>n;
	vector<int>a(200007,0);
	for0(i,n-1){
		cin>>x;
		a[x]++;
		}
	for1(i,n) cout<<a[i]<<nw;
	return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int n;
int a, b, c, d;
int ans=0;
vector<P> v, w;;

int main(){
  cin >> n;
  REP(i, n){
    cin >> a >> b;
    v.push_back(P(a, b));
  }
  REP(i, n){
    cin >> c >> d;
    w.push_back(P(c, d));
  }

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

  REP(i, n){
    int s,t, itr;
    s = w[i].first;
    t = w[i].second;

    int max=-1;
    bool b = false;
    REP(j, v.size()){
      if((v[j].first<s) && (v[j].second<t) && (v[j].second>max) ){
        itr = j;
        max = v[j].second;
        b = true;
      }
    }

    if(b){
      ans += 1;
      v.erase(v.begin() + itr);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
struct data{
	int to,col,length;
};
struct node{
	int id,col,length,cnt;
};
int n,q,all,cnt[N],dep[N],len[N],ans[N],f[N][20];
vector<data>G[N];
vector<node>Q[N];

void dfs(int x,int fa){
	dep[x]=dep[fa]+1; f[x][0]=fa;
	for (int i=0;i<G[x].size();i++){
		int y=G[x][i].to;
		if (y!=fa) dfs(y,x);
	}
}

int LCA(int x,int y){
	if (dep[x]<dep[y]) swap(x,y);
	int step=dep[x]-dep[y];
	for (int i=0;i<=18;i++) 
		if ((1<<i)&step) x=f[x][i];
	if (x==y) return x;
	for (int i=18;i>=0;i--)
		if (f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}

void query(int x){
	for (int i=0;i<G[x].size();i++){
		data y=G[x][i];
		if (y.to==f[x][0]) continue;
		++cnt[y.col]; len[y.col]+=y.length; all+=y.length;
		query(y.to);
		--cnt[y.col]; len[y.col]-=y.length; all-=y.length;
	}
	for (int i=0;i<Q[x].size();i++){
		node now=Q[x][i];
		ans[now.id]+=now.cnt*(all-len[now.col]+cnt[now.col]*now.length);
	}
}

int main(){
	scanf("%d%d",&n,&q);
	int x,y,col,length;
	for (int i=1;i<n;i++){
		scanf("%d%d%d%d",&x,&y,&col,&length);
		G[x].push_back({y,col,length});
		G[y].push_back({x,col,length});
	}
	dfs(1,0);
	for (int i=1;i<=18;i++)
		for (int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	for (int i=1;i<=q;i++){
		scanf("%d%d%d%d",&col,&length,&x,&y);
		int lca=LCA(x,y);
		Q[x].push_back({i,col,length,1});
		Q[y].push_back({i,col,length,1});
		Q[lca].push_back({i,col,length,-2});
	}
	query(1);
	for (int i=1;i<=q;i++) printf("%d\n",ans[i]);
}


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

int main()
{
	int x = 0, h = 0, m = 0, s = 0;
	cin >> x;
	//h
	h = x / 3600;
	x %= 3600;
	m = x / 60;
	x %= 60;
	s = x;



	cout << h << ":" <<  m << ":" << s << "\n";
	return 0;
}

Measured memory_bytes: 1168
# -*- coding: utf-8 -*-

tmp = input()
tmp = input().split()
num = len(tmp)
min = int(tmp[0])
#print (min)
for j in tmp:
	d = int(j)
	n = 0
	while(d % 2 == 0):
		n=n+1
		d=d/2
	if(min>n):
		min=n
#	print(n)
print(min)


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

using namespace std;

using ll = long long;

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

    int n, res = 0;
    string s;
    cin >> n >> s;
    for (int i = 0, x = 0; i < n; ++i) {
        if (s[i] == 'I') ++x;
        else --x;
        res = max(res, x);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(h, w int, c []string) []string {
        out := make([]string, 2*h)

        for i := 0; i < h; i++ {
                out[2*i] = c[i]
                out[2*i+1] = c[i]
        }
        return out
}

func main() {
        var h, w int
        fmt.Scan(&h, &w)
        c := make([]string, h)
        for i := range c {
                fmt.Scan(&c[i])
        }
        for _, t := range solution(h, w, c) {
                fmt.Println(t)
        }
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) printf("%d\n", v)

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string S; cin >> S;
  int ans = 1000;
  rep(i, S.length()-2) {
    int n = (S[i]-'0')*100+(S[i+1]-'0')*10+S[i+2]-'0';
    ans = min(ans, abs(n - 753));
  }
  out(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,a,b,c,d;
string s;

int main(){
	cin>>n>>a>>b>>c>>d;
	a--,b--,c--,d--;
	cin>>s;
	for(int i=a;i<max(c,d)-1;i++){
		if(s[i]=='#'&&s[i+1]=='#'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(c<d){
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=b-1;i<d;i++){
		if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int n, i, a, min = 100000000, max = -100000000;
  long long sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a < min)
      min = a;
    if (a > max)
      max = a;
    sum += a;
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}

Measured memory_bytes: 600
#include<cstdio>

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

using namespace std;

bool visited[100];
int adj[100][100],deg[100],ans,cnt;

void dfs(int u){
	if(ans<cnt) ans=cnt;

	cnt++;
	rep(i,deg[u]){
		int v=adj[u][i];
		if(!visited[v]){
			visited[v]=true;
			dfs(v);
			visited[v]=false;
		}
	}
	cnt--;
}

int main(){
	for(int m;scanf("%d",&m),m;){
		bool adjm[100][100]={},flg[100]={};
		rep(i,m){
			int a,b; scanf("%d%d",&a,&b);
			a--, b--;
			adjm[a][b]=adjm[b][a]=flg[a]=flg[b]=true;
		}

		int f[100],n=0;
		rep(i,100) if(flg[i]) { f[i]=n++; deg[f[i]]=0; }

		rep(i,100) rep(j,100) if(adjm[i][j]) adj[f[i]][deg[f[i]]++]=f[j];

		ans=0,cnt=1;
		rep(u,n-1){
			visited[u]=true;
			dfs(u);
			visited[u]=false;
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

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


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define ll long long
#define mk make_pair
#define reg register
#define PI pair<int, int>
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)

using namespace std;

#define N 200005

int n;
int fa[N];
set<int> s[N];
map<PI, int> mp;
queue<PI> q;

int find(reg int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

inline char gc() {
    static const int BS = 1 << 22;
    static unsigned char buf[BS], *st, *ed;
    if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
    return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void read(T &x) {
    x = 0; bool f = 0; char c = gc();
    while (c < '0' || c > '9') {if (c == '-') f = 1; c = gc();}
    while ('0' <= c && c <= '9') {x = (x << 3) + (x << 1) + (c ^ 48); c = gc();}
    if (f) x = -x;
}
#undef gc

int main() {
    read(n);
    rep (i, 1, n) fa[i] = i;
    reg int u, v;
    rep (i, 1, 2 * n - 2) {
        read(u), read(v);
        s[u].insert(v), s[v].insert(u);
        ++mp[mk(u, v)], ++mp[mk(v, u)];
        if (mp[mk(u, v)] == 2) q.push(mk(u, v)); 
    }
    set<int> :: iterator it;
    while (!q.empty()) {
        reg int x = q.front().first, y = q.front().second;
        q.pop();
        u = find(x), v = find(y);
        s[u].erase(v), s[v].erase(u);
        if (s[u].size() < s[v].size()) swap(u, v);
        for (it = s[v].begin(); it != s[v].end(); ++it) {
            reg int to = *it;
            mp[mk(to, v)] = mp[mk(v, to)] = 0;
            s[to].erase(v), s[to].insert(u);
            ++mp[mk(to, u)], ++mp[mk(u, to)];
            if (mp[mk(to, u)] == 2) q.push(mk(to, u));
            s[u].insert(to);
        }
        fa[v] = u;
        s[v].clear();
    }
    reg int cnt = 0;
    rep (i, 1, n) {
        if (fa[i] == i) ++cnt;
    }
    if (cnt == 1) 
        puts("YES");
    else puts("NO");
    return 0;
}


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

int main(){
    int x;
    cin>>x;
    int rem = x%10;
    if(rem == 3){
        cout<<"bon";
    }
    else if(rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9){
        cout<<"hon";
    }
    else{
        cout<<"pon";
    }
    return 0;
}

Measured memory_bytes: 3644
if __name__ == '__main__':
    n, a, b = input().split()
    N, A, B = int(n), int(a), int(b)

    ans_max = min(A, B)

    if (A + B) <= N:
        ans_min = 0
    else:
        ans_min = max((A + B - N), 0)

    print('{0} {1}'.format(ans_max, ans_min))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pi 3.141592653589793238

int main( )
{
     FIO;
     int r;
     float ans;
     cin>>r;
     ans =(float) 2*pi*r;
     cout<<fixed<<setprecision(20)<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3804
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();

        int N;
        cin >> N;

        int A, B;
        cin >> A >> B;

        int a = 0, b = 0, c = 0;

        for (int i = 0; i < N; ++i) {
            int tmp;
            cin >> tmp;
            if (tmp <= A) {
                a++;
            } else if (tmp <= B) {
                b++;
            } else {
                c++;
            }
        }

        int ans = min({a, b, c});

        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
//#define REPR(i, n) for(int i = n; i >= 0; i--)
//#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 1e9
//#define ALL(v) v.begin(), v.end()

using namespace std;
//typedef long long ll;

int main() { //int argc, const char * argv[]
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, ans=0, a, b, tmp;
    cin >> N;
    int C[10][10] = {0};

    REP(i, N){
        tmp = i+1; 
        b = tmp % 10;
        while (tmp)
        {
            a = tmp % 10;
            tmp /= 10;
        }
        C[a][b]++;
    }

    REP(i, 10){
        REP(j, 10){
            ans += C[i][j] * C[j][i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int main(){
	int N,K;
	cin >> N >> K;
	int c[26] = {};
	for(int i = 0 ; i < N ; i++){
		string t;
		cin >> t;
		c[t[0]-'A']++;
	}
	vector< pair<int,int> > w;
	for(int i = 0 ; i < 26 ; i++){
		w.push_back({c[i],i});
	}
	int ans = 0;
	while(true){
		sort(w.rbegin(),w.rend());
		int ok = 0;
		for( auto &e : w ){
			if( e.first ){
				ok++;
				e.first--;
			}
			if( ok == K ) break;
		}
		if( ok == K ){
			ans++;
		}else break;
	}
	cout << ans << endl;

}





























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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        const int N = 3009;
       



        void solve(){
            cin >> x;
            cout << 1 - x << endl;
        }

        


        int main(){
            ios_base::sync_with_stdio(false);

           

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 3632
words = lambda t : list(map(t, input().split()))
n,m = words(int)

dp = [-1] * (2**n)
dp[0] = 0

def to_bits(xs):
    bits = 0
    for x in xs:
        bits += 2**(x-1)
    return bits

costs = []
bits = []
for i in range(m):
    c,k = words(int)
    costs.append(c)
    ys = words(int)
    bits.append(to_bits(ys))

#print(costs)
#print(bits)

for cur in range(2**n):
    if dp[cur] == -1:
        continue
    #print(dp)
    for c,b in zip(costs, bits):
        next = cur | b
        if dp[next] == -1 or dp[next] > dp[cur] + c:
            dp[next] = dp[cur] + c

print(dp[2**n-1])


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a-2*b) << endl;
}

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

int main() {
  int K,N;
  cin >> K >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  vector<int> dis(N);
   for(int i=0;i<N-1;i++){
    dis[i] = vec[i+1] - vec[i];
   }
  dis[N-1] = K - vec[N-1] + vec[0];
  sort(dis.begin(), dis.end());
  cout << K - dis[N-1] <<endl;
}


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

ll gcd(ll c, ll d){
    if (d == 0) return c;
    return gcd (d, c % d);
}

ll lcm(ll c, ll d){
    return c / gcd(c, d) * d;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll koubai = lcm(c, d);

    ll ans = 0;
    ll count = b - a + 1;

    ll canc,cand,cancd;

    canc = (b / c) - ((a - 1) / c);
    cand = (b / d) - ((a - 1) / d);
    cancd = (b / (koubai)) - ((a - 1) / (koubai));

    ans += count - (canc + cand - cancd);

    cout << ans << endl;

}

Measured memory_bytes: 256
using System;

namespace AtCoder.ABC094
{
    class d
    {
        static long[] factorial = new long[100001];
        static void Main(string[] args)
        {
            factorial[0] = 0;
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = Array.ConvertAll(spl, new Converter<string, int>(s => int.Parse(s)));
            var max = 0;
            for (var i = 0; i < N; ++i)
            {
                if (max < A[i]) max = A[i];
            }
            var min = max;
            var minVal = 0;
            for(var i = 0; i < N; ++i)
            {
                if (Math.Abs(max / 2 - A[i]) < min && A[i] != max) {
                    min = Math.Abs(max / 2 - A[i]);
                    minVal = A[i];
                }
            }
            Console.WriteLine("{0:D} {1:D}", max, minVal);
        }

        private static long Factorial(int v)
        {
            if (factorial[v] > 0) return factorial[v];
            if (v == 1) return 1;
            factorial[v] = v * Factorial(v - 1);
            return factorial[v];
        }
    }
}


Measured memory_bytes: 22240
import java.io.*;
import java.util.StringTokenizer;

/*
 *      /\\\        /\\\      /\\\\\\\\\      /\\\\\\\\\\\   /\\\\\\\\\\\\\     /\\\        /\\\      /\\\\\\\\\      /\\\        /\\\
 *      \/\\\       \/\\\    /\\\\\\\\\\\\\   \/////\\\///   \/\\\/////////\\\  \/\\\       \/\\\    /\\\\\\\\\\\\\   \/\\\       \/\\\
 *       \//\\\      /\\\    /\\\/////////\\\      \/\\\      \/\\\       \/\\\  \/\\\       \/\\\   /\\\/////////\\\  \//\\\      /\\\
 *         \//\\\    /\\\    \/\\\       \/\\\      \/\\\      \/\\\\\\\\\\\\\\   \/\\\\\\\\\\\\\\\  \/\\\       \/\\\   \//\\\    /\\\
 *           \//\\\  /\\\     \/\\\\\\\\\\\\\\\      \/\\\      \/\\\/////////\\\  \/\\\/////////\\\  \/\\\\\\\\\\\\\\\    \//\\\  /\\\
 *             \//\\\/\\\      \/\\\/////////\\\      \/\\\      \/\\\       \/\\\  \/\\\       \/\\\  \/\\\/////////\\\     \//\\\/\\\
 *               \//\\\\\       \/\\\       \/\\\      \/\\\      \/\\\       \/\\\  \/\\\       \/\\\  \/\\\       \/\\\      \//\\\\\
 *                 \//\\\        \/\\\       \/\\\   /\\\\\\\\\\\  \/\\\\\\\\\\\\\/   \/\\\       \/\\\  \/\\\       \/\\\       \//\\\
 *                   \///         \///        \///   \///////////   \/////////////     \///        \///   \///        \///         \///
 */
public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(),"Main",1<<27).start();
    }
    @Override
    public void run() {
        try{
            FastReader sc = new FastReader();
            String s = sc.next();
            if(s.contains("7")){
                System.out.println("Yes");
            }
            else{System.out.println("No");}

        }
        catch (Exception e){}
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

#define ff first
#define ss second
#define endl '\n'

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

	string s, t;
	cin >> s >> t;

	cout << t << s << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int[] X = new int[M];
		for (int i = 0; i < M; i++) {
			X[i] = in.nextInt();
		}
		Arrays.sort(X);
		int[] d = new int[M - 1];
		for (int i = 0; i < M - 1; i++) {
			d[i] = X[i + 1] - X[i];
		}
		Arrays.sort(d);
		int ans = 0;
		for (int i = 0; i < d.length - (N - 1); i++) {
			ans += d[i];
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 48756
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Comparator;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int n = scanner.nextInt();
    int l = scanner.nextInt();
    
    ArrayList<String> word = new ArrayList<>();
    
    // n回データを取得し格納する
    for(int i = 0; i < n; i++) {
      word.add(scanner.next());
    }
    
    // 自然順序（Stringであれば辞書順）にソート
    word.sort(Comparator.naturalOrder());
    
    // listの中の要素を区切らずに連続して出力
    for(String w: word) {
      System.out.print(w);
    }
  }
}


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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    ll c = 0;
    for (int i = 0; i < (s.length()/2); i++) {
        if (s[i] != s[s.length() - i - 1]) {
            c++;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
from networkx import*
N, K = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(N)]
G = MultiDiGraph()
s = 2 * N * (N + 1)
t = s + 1
G.add_node(s, demand = -K*N)
G.add_node(t, demand = K*N)
G.add_nodes_from([i for i in range(s - 1)], demand = 0)
G.add_weighted_edges_from([(s, t, 10 ** 9)], capacity = N * K)
G.add_weighted_edges_from([(s, i, 0) for i in range(2*N*N, N*(2*N+1))], capacity = K)
G.add_weighted_edges_from([(i, t, 0) for i in range(N*(2*N+1), 2*N*(N+1))], capacity = K)
for i in range(N):
    G.add_weighted_edges_from([(2*N*N+i, i*N+j, 0) for j in range(N)], capacity = 1)
    G.add_weighted_edges_from([(N*N+i*N+j, N*(2*N+1)+j, 0) for j in range(N)], capacity = 1)
for i in range(N):
    G.add_weighted_edges_from([(i*N+j, N*N+i*N+j, 10**9-A[i][j]) for j in range(N)], capacity = 1)
    
mcf = min_cost_flow(G)
ans = 0
B = [["."] * N for _ in range(N)]
for a in mcf:
    for b in mcf[a]:
        v = mcf[a][b][0]
        if v and b == a + N*N and 0 <= a < N*N:
            i, j = a // N, a % N
            ans += v * A[i][j]
            B[i][j] = "X"
print(ans)
for b in B:
    print("".join(b))

Measured memory_bytes: 68424
d=int(input())
c=list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
last = [0 for i in range(26)]
dcl_init = -sum(c)
dcl = dcl_init
satis = 0
for i in range(1,d+1):
  dcl += dcl_init
  ans = 0
  satis_temp = satis - dcl + c[0] + s[i-1][0]
  for j in range(1,26):
    if satis_temp < satis - dcl + c[j] + s[i-1][j]:
      satis_temp = satis - dcl + c[j] + s[i-1][j]
      ans = j
  satis = satis_temp
  dcl += c[ans]
  print(ans+1)

Measured memory_bytes: 9508
from math import pi as PI
from math import cos, sin

A, B, H, M = map(int, input().split())

thetaA = (H / 12) + (M / 60) * (1 / 12)
thetaB = (M / 60)

thetaA *= 2 * PI
thetaB *= 2 * PI

P = complex(A * cos(thetaA), A * sin(thetaA))
Q = complex(B * cos(thetaB), B * sin(thetaB))

print(abs(P - Q))


Measured memory_bytes: 9516