akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

struct T{
	ll l,y,x;
	bool operator<(const T& b)const{
		return l<b.l;
	};
	bool operator>(const T& b)const{
		return l>b.l;
	};
};
const ll INF=0xfffffffffffffff;
ll R;
ll W1,W2,H1,H2;
ll X1,Y1,X2,Y2;
ll L1[500][500];
ll L2[500][500];
ll atu1[250001];
ll atu2[250001];
ll dp1[250001];//?¨???????????????¨?±?????????°
ll dp2[250001];
ll sz1,sz2;
ll vx[4]={1,0,-1,0};
ll vy[4]={0,1,0,-1};
bool pushed[500][500];
vector<ll> xs;
priority_queue<T,vector<T>,greater<T> > q;
void solve(ll W,ll H,ll sx,ll sy,ll L[][500],ll *atu,ll *dp,ll& sz){
	auto ok = [&](ll y,ll x){
		return 0<=x&&x<W&&0<=y&&y<H;
	};
	xs.clear();
	fill(atu,atu+250001,INF);
	memset(pushed,0,sizeof(pushed));
	rep(i,H) rep(j,W){
		xs.pb(L[i][j]);
	}
	
	sort(xs.begin(),xs.end());

	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	sz=xs.size();
	//cout<<sz<<endl;
	rep(i,sz) atu[i]=xs[i];
	rep(i,H) rep(j,W){
		L[i][j]=lower_bound(xs.begin(),xs.end(),L[i][j])-xs.begin();
	}
	ll kosu=0,now=0;
	q.push(T{0,sy,sx});
	pushed[sy][sx]=1;
	
	while(!q.empty()){
		T t=q.top();
		q.pop();
		now=max(now,t.l);
		kosu++;
		dp[now]=kosu;
		rep(i,4){
			ll ny=t.y+vy[i];
			ll nx=t.x+vx[i];
			if(ok(ny,nx)&&!pushed[ny][nx]){
				q.push(T{L[ny][nx],ny,nx});
				pushed[ny][nx]=1;
			}
		}
	}
	rep1(i,sz-1) if(dp[i]<dp[i-1]){
		dp[i]=dp[i-1];
	}
	return;
}

int main()
{while(1){
	cin>>R;
	if(!R) break;
	memset(dp1,0,sizeof(dp1));
	memset(dp2,0,sizeof(dp2));
	cin>>W1>>H1>>X1>>Y1;
	X1--;
	Y1--;
	rep(i,H1) rep(j,W1) cin>>L1[i][j];
	solve(W1,H1,X1,Y1,L1,atu1,dp1,sz1);
	cin>>W2>>H2>>X2>>Y2;
	X2--;
	Y2--;
	rep(i,H2) rep(j,W2) cin>>L2[i][j];
	solve(W2,H2,X2,Y2,L2,atu2,dp2,sz2);
	ll ans=atu2[lower_bound(dp2,dp2+sz2,R)-dp2];
	rep(i,sz1){
		if(dp1[i]>=R) ans=min(ans,atu1[i]);
		else ans=min(ans,atu1[i]+atu2[lower_bound(dp2,dp2+sz2,R-dp1[i])-dp2]);
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int x;
    cin>>x;
    if(x==3 || x==5 || x==7){cout<<"YES"<<endl;}
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3600
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

h,w,k = LI()
c = [S() for _ in range(h)]

result = 0
for i in range(1 << h):
    for j in range(1 << w):
        count = 0
        for y in range(h):
            if(i & (1 << y)):
                for x in range(w):
                    if(j & (1 << x)):
                        if(c[y][x] == '#'):
                            count += 1
        if(count == k):
            result += 1

print(result)

Measured memory_bytes: 73952
#include<stdio.h>

using namespace std;

int n, A[50];

int solve(int i,int m) {
	if (m == 0)return 1;
	if (i >= n)return 0;
	int res = solve(i + 1, m) || solve(i+1,m-A[i]);
	return res;
}

int main()
{
	int q, M, i;

	scanf("%d",&n);
	for (i = 0;i < n;i++)scanf("%d",&A[i]);
	scanf("%d",&q);
	for (i = 0;i < q;i++) {
		scanf("%d",&M);
		if (solve(0, M))printf("yes\n");
		else printf("no\n");
	}

    return 0;
}


Measured memory_bytes: 2680
// AtCoder template
// 世界はとっても美しい！
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

int k;
vector<string> ans;
void dfs(string s){
    ans.push_back(s);
    int n = s.size();
    if(n >= 11) return;
    if(s[n-1] == '0') rep(i,2) dfs(s+char(s[n-1]+i));
    else if(s[n-1] == '9') rep(i,2) dfs(s+char(s[n-1]+i-1));
    else rep(i,3) dfs(s+char(s[n-1]+i-1));
}

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

    cin >> k;
    for(char c = '1'; c <= '9'; ++c) dfs(string(1,c));
    sort(ans.begin(), ans.end(), [&](string a, string b){
        if(a.size() > b.size()) return false;
        else if(a.size() < b.size()) return true;
        else return (a < b);
    });
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 42860
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0
bf = A[0]

A.each do |a|
    ans += B[a-1]
    ans += C[a-2] if bf == a-1
    bf = a
end

puts ans

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

int main(){
	int a,b;
	while(cin >> a >> b){
		int d = 0;
		a += b;
		while(a){
			d++;
			a /= 10;
		}
		if(!d)d++;
		cout << d << endl;
	}
}

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

pys = []
for i in range(M):
    p, y = map(int, input().split())
    pys.append([p, y, i])

nums = [0] * N
ans = [''] * M
pys.sort(key=lambda x:x[1])

for p, y, i in pys:
    nums[p-1] += 1
    ans[i] = str(p).zfill(6) + str(nums[p-1]).zfill(6)

for an in ans:
    print(an)


Measured memory_bytes: 32180
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;


int evaluate(string a){
	vector<int> v;
	int temp=0;
	for(int i=0;i<a.length();i++){
		if(a[i]=='+'){
			v.pb(temp);
			temp=0;
		}else{
			temp=temp*10+(int)(a[i]-'0');
			if(i==a.length()-1){
				v.pb(temp);
			}
		}
	}
	int res=0;
	for(int x:v){
		res+=(x);
	}
	return res;
}

bool check(string a,int n){
	int cnt=0;
	for(int i=0;i<a.length();i++){
		if(a[i]=='+')
			cnt++;
	}
	if(cnt==n){
		return true;
	}
	return false;
}
set<string> s;
void generate(string a,int idx,int n){
	//cout<<a<<endl;
	if(idx>=a.length()-1){
		//cout<<a<<endl;
		return ;
	}
	if(check(a,n) || a[a.length()-1]=='+'){
		return ;
	}


	a.insert(idx+1,"+");
	s.insert(a);
	//cout<<"o -> "<<a<<endl;
	generate(a,idx+2,n);
	a.erase(a.begin()+idx+1);
	//cout<<"e -> "<<a<<endl;
	s.insert(a);
	generate(a,idx+1,n);

	return ;
}

int solve(){
	int res=0;
	for(string x:s){
		res+=(evaluate(x));
	}
	return res;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

    string a;
	cin>>a;
	if(a.length()==1){
		cout<<a[0]<<endl;
		return 0;
	}
	generate(a,0,a.length()-1);
	cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 384
import sys
from collections import deque


def topological_check(roots, out_links, in_count):
    depth = [0] * match_count
    for r in roots:
        depth[r] = 1
    q = deque(roots)
    while q:
        v = q.popleft()
        d = depth[v] + 1
        for u in out_links[v]:
            in_count[u] -= 1
            if in_count[u] == 0:
                depth[u] = d
                q.append(u)
    if any(in_count):
        return -1
    return max(depth)


n = int(input())
match_count = n * (n - 1) // 2

offsets = [0]
tmp = -2
for i in range(1, n + 1):
    offsets.append(tmp)
    tmp += n - i - 1

roots = set()
in_links = [set() for _ in range(match_count)]
out_links = [set() for _ in range(match_count)]

for i, line in enumerate(sys.stdin, start=1):
    aaa = list(map(int, line.split()))
    j = aaa[0]
    prev = offsets[i] + j if i < j else offsets[j] + i
    roots.add(prev)

    for j in aaa[1:]:
        key = offsets[i] + j if i < j else offsets[j] + i
        out_links[prev].add(key)
        in_links[key].add(prev)
        prev = key

in_count = list(map(len, in_links))
roots = {r for r in roots if in_count[r] == 0}

if not roots:
    print(-1)
    exit()

print(topological_check(roots, out_links, in_count))


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

using namespace std;

const int MOD = 1e9 + 7;

long long fact[500005], inv[500005];

long long mypow(long long x, long long y) {
	long long res = 1LL;
	while (y) {
		if (y & 1) res = res * x % MOD;
		y >>= 1;
		x = x * x % MOD;		
	}
	return res;
}

long long ncr(int x, int y) {
	if (y < 0 || y > x) return 0LL;
	return fact[x] * inv[y] % MOD * inv[x - y] % MOD;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	fact[0] = 1LL;
	for (int i = 1; i <= m; i++) fact[i] = fact[i - 1] * i % MOD;
	inv[m] = mypow(fact[m], MOD - 2);
	for (int i = m - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % MOD;
	
	long long res = 0LL;
	
	for (int i = 0; i <= n; i++) {
		long long add = ncr(n, i) * (ncr(m - i, n - i) * fact[n - i] % MOD) % MOD;
		if (i & 1) add *= - 1;
		res = (res + add + MOD) % MOD;	
	}

	res = res * (ncr(m, n) * fact[n] % MOD) % MOD; 
	
	printf("%lld\n", res);
}


Measured memory_bytes: 11524
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;

public class Main 
{
	static class Vertex
	{
		TreeSet<Integer> adjlist = new TreeSet<Integer>();
		
		int dim()
		{
			return adjlist.size();
		}
		
		public Vertex()
		{
			
		}
		
		public Vertex(int adjacentTo)
		{
			adjlist.add(adjacentTo);
		}
	}
	
	static Scanner sc = new Scanner(System.in);
	static int vn, en;
	static Vertex[] v;
	static int[] low;
	static int[] disc;
	static int[] parent;
	static boolean[] visited;
	static TreeSet<Integer> ap;
	
	static void DFS()
	{
		int time = 0;
		int pos = 0;
		Stack<Integer> queue = new Stack<Integer>();
		
		queue.push(0);
		
		int children = 0;
		int rootchildren = 0;
		
		while(!queue.isEmpty())
		{
			pos = queue.peek();
			
			if(!visited[pos])
			{
	//			System.out.println("Visit " + pos + " " + queue);
				if(pos == 0)time = 0;
				else
				{
					time = disc[parent[pos]] + 1;
				}
				Vertex v0 = v[pos];
				boolean alreadyvisited = visited[pos];
				visited[pos] = true;
				disc[pos] = time;
				low[pos] = time;
				children = 0;
				
				for(int adj : v0.adjlist)
				{
					if(parent[pos] != adj)
					{
						if(!visited[adj])
						{
							children++;
//							if(pos == 0)rootchildren++;
							
							parent[adj] = pos;
							queue.push(adj);
						}
						else
						{
							low[pos] = Math.min(low[pos], disc[adj]);
	//						System.out.println("Re " + pos + " " + adj);
						}
					}				
				}

			}
			else
			{
				pos = queue.pop();
				
				int par = parent[pos];
				if(par > 0)
				{
					low[par] = Math.min(low[par], low[pos]);
					if(par != 0 && disc[par] <= low[pos])
					{
		//				System.out.println(pos);
						ap.add(par);
					}
				}
				if(par == 0)rootchildren++;
			}

			
		}
		if(pos == 0 && rootchildren > 1)
		{
			ap.add(0);
		}

	}

	public static void main(String[] args) 
	{
		vn = sc.nextInt();
		en = sc.nextInt();
		v = new Vertex[vn];
		disc = new int[vn];
		low = new int[vn];
		parent = new int[vn];
		visited = new boolean[vn];
		ap = new TreeSet<Integer>();

		for(int i = 0; i < vn; i++)
		{
			v[i] = new Vertex();
			parent[i] = -1;
			low[i] = 999999999;
		}
		
		for(int i = 0; i < en; i++)
		{
//			System.out.println("Reading edge " + (i+1));
			int v1 = sc.nextInt();
			int v2 = sc.nextInt();
			
			v[v1].adjlist.add(v2);
			v[v2].adjlist.add(v1);
		}
		
		DFS();
//		System.out.println(ap);
//		System.out.println("Disc "+ Arrays.toString(disc));
//		System.out.println("Low "+ Arrays.toString(low));
		StringBuilder sb = new StringBuilder("");
		int i = 0;
		for(int a : ap)
		{
			i++;
			sb.append(a);
			if(i < ap.size())
			{
				sb.append("\n");
			}
		}
		if(ap.size()>0)System.out.println(sb);
	}

}



Measured memory_bytes: 76756
count = 0
list1 = []

a = int(input())
list1  = list(map(int, input(). split()))

for i in range(len(list1)):
  for n in range(len(list1) - i - 1):
    if(list1[n] > list1[n + 1]):
      tmp = list1[n]
      list1[n] = list1[n + 1]
      list1[n + 1] = tmp
      count += 1

print(" ".join(str(x) for x in list1))
print(count)

Measured memory_bytes: 7732
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	stones := make([]int, n)
	for i := 0; i < n; i++ {
		var stone int
		fmt.Scanf("%d", &stone)
		stones[i] = stone
	}

	fmt.Println(frogDP(n, stones))
}

func frogDP(n int, stones []int) int {
	if n <= 1 {
		return 0
	}

	result := make([]int, n)
	result[0] = 0
	result[1] = absoluteValue(stones[0] - stones[1])

	for j := 2; j < n; j++ {
		i := j - 1
		i2 := j - 2
		result[j] = min(
			absoluteValue(stones[i]-stones[j])+result[i],
			absoluteValue(stones[i2]-stones[j])+result[i2],
		)
	}
	return result[n-1]
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func absoluteValue(n int) int {
	if n > 0 {
		return n
	}
	return -n
}

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

int x;

int solve() {
  scanf("%d", &x);
  printf("%d\n", x/500 * 1000 + x%500/5 * 5);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 256
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;

bool kk (int j , string x )
{
  for (int i =0 ; i < SZ(x) ;i++)
  {
    if (i == j )continue ;
    if (x[i] < '0' || x[i] > '9')return false;
  }
  return true ;
}
int main ()
{
  int a , b ;
  string x ;
  cin >> a >> b >> x ;
  if (x[a] == '-' && kk (a,x))
  {
    printf ("Yes\n");
  }else
  printf ("No\n");
  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

t = sum(A)
i = N
ans = 0

for j in range(M + 1):
  while i > 0 and t > K:
    i -= 1
    t -= A[i]
  if t > K:
    break
  ans = max(ans, i + j)
  if j == M:
    break
  t += B[j]
print(ans)

Measured memory_bytes: 40352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  vector<vector<ll> > a(10, vector<ll>());
  REP(i, 1, 9) a[0].push_back(i);

  REP(i, 1, 9){
    for(ll x : a[i-1]){
      ll r = x % 10;
      if(0 <= r-1 && r-1 <= 9) a[i].push_back(x*10 + (r-1));
      a[i].push_back(x*10 + r);
      if(0 <= r+1 && r+1 <= 9) a[i].push_back(x*10 + (r+1));
    }
  }

  int cnt = 0;
  REP(i, 0, 9){
    for(ll x : a[i]){
      cnt++;
      if(cnt == k){
        cout << x << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1976
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long X, N, P[1 << 18];
long long V[1 << 18];

int main() {
	cin >> X >> N;
	for (int i = 1; i <= N; i++) { cin >> P[i]; V[P[i]] = 1; }

	long long ans = -1, minx = (1LL << 60);
	for (int i = 0; i <= 1000; i++) {
		if (V[i] == 1) continue;
		if (minx > abs(i - (int)X)) {
			minx = abs(i - (int)X);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
 private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1);

 public static void main(String args[]) {
  new Main().start();
 }

 public void start() {
  int num = 0;
  try {
  num = Integer.parseInt(reader.readLine());
  } catch(IOException e) {
   e.printStackTrace();
  }
  num = (int) Math.pow(num, 3);
  System.out.println(num);
 }

}

Measured memory_bytes: 16996
//#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
const int maxn = 1e6 + 55, mod = 1e9 + 7;
int fact[maxn], inv[maxn];
int mul(int x, int y) {
	return x*1ll*y%mod;
}
void setup() {
	fact[0] = inv[0] = 1;
	for(int i = 1; i < maxn; i++) {
		fact[i] = mul(fact[i-1], i);
		inv[i] = i > 1 ? (mod - mul(mod/i, inv[mod%i]))%mod : 1;
	}
	for(int i = 1; i < maxn; i++) inv[i] = mul(inv[i], inv[i-1]);
}
int n;
int nck(int n, int k) {
	if(k>n) return 0;
	return mul(mul(fact[n], inv[k]), inv[n-k]);
}
int f(int k) {
	return mul(mul(nck(k-1, n-1-k), fact[n-1-k]), fact[k]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	setup();
	cin >> n;
	int ans = 0;
	for(int i = 1; i < n; i++) {
		int t = (mod + f(i) - f(i-1))%mod;
		ans = (ans + 1ll * t * i)%mod;
	}
	cout << ans;
}


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

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

	vector<int> a(N + 1);
	for(int i = 1; i <= N; i++){
		cin >> a[i];
	}

	vector<int> b(N + 1);
	for(int i = N; i > 0; i--){
		int sum = 0;
		for (int j = i; j <= N; j += i)
		{
			sum += b[j];
		}
		
		if(sum % 2 != a[i]){
			b[i] = 1;
		}
		else{
			b[i] = 0;
		}
	}

	int ans = 0;
	for(int i = 1; i <= N; i++){
		ans += b[i];
	}

	cout << ans << endl;
	
	if(ans != 0){
		for(int i = 1; i <= N; i++){
			if(b[i] != 0){
				cout << i;

				if(i != N) cout << " ";
			} 
		}
	}
	
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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


    ll sum = 0 ;
    ll m = 0;

    rep(i, 5){
        ll inp, rest;
        cin >> inp;
        rest = 10 - (inp%10);
        if(rest == 10) rest = 0;

        sum += (inp + rest);
        m = max(rest, m);
    }

    cout << sum - m << endl;



    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n, m = map(int, input().split())

ans = 0
G = defaultdict(list)
vis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)


def dfs(k, cnt):
    global ans

    vis[k] = 1

    if cnt == n - 1:
        ans += 1
    else:
        for i in G[k]:
            if vis[i] == 0:
                dfs(i, cnt + 1)

    vis[k] = 0


dfs(0, 0)
print(ans)


Measured memory_bytes: 3316
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

double l[11];
double v1, v2;
char c;

int main(){
    INIT;
    while(cin >> l[0]){
        double sum = 0.0;
        sum += l[0];
        cin >> c;
        for(int i = 1;i < 10; i++){
            cin >> l[i];
            cin >> c;
            sum += l[i];
        }
        cin >> v1 >> c >> v2;
        sum /= (v1 + v2);
        sum *= v1;
        double rui = 0;
        for(int i = 1;i <= 10; i++){
            rui += l[i - 1];
            if(sum <= rui){
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3204
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int r = stdIn.nextInt();
		int c = stdIn.nextInt();
		int[][] A = new int[r][c];
		int[] b = new int[r];
		int[] b2 = new int[c];
		int sum = 0;
		for (int i=0; i<r; i++) {
			for (int j=0; j<c; j++) {
				int x = stdIn.nextInt();
				A[i][j] = x;
				b[i] += x;
				b2[j] += x;
				sum += x;
			}
		}
		for (int i=0; i<r+1; i++) {
			if(i<r)
				for (int j=0; j<c+1; j++) {
					if(j<c)
						System.out.print(A[i][j]+" ");
					else
						System.out.println(b[i]);
				}
			else
				for (int k=0; k<c; k++) {
					System.out.print(b2[k]+" ");
				}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 37692
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

typedef vector<int> vi;		typedef vector<ll> vl;
typedef pair<int, int> ii; 	typedef vector<ii> vii;

// code start here //
ld a[200005];
signed main() {
	fastio;
	int n, k; cin >> n >> k;
	rep(i, 0, n) {
		cin >> a[i];
	}
	ld pre[n + 1]; pre[0] = (ld)0;
	rep(i, 1, n + 1) {
		pre[i] = pre[i - 1] + a[i - 1];
	}
	ld Max=(ld)-10000;
	rep(i, k, n + 1) {
		Max = max(Max, pre[i] - pre[i - k]);
	}
	Max = (Max + k) / 2;
	cout << setprecision(15) << fixed << Max;
}


Measured memory_bytes: 6528
n = int(input())
a = list(map(int,input().split()))
pal =1
minabs = 10**9
for i in range(n):
    if a[i] <0:
        pal *=-1
        a[i] = -1*a[i]
    minabs = min(minabs,a[i])
if pal ==1:
    print(sum(a))
else:
    print(sum(a)-2*minabs)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


ll N, M;  // 頂点, 辺
const ll MAXN = 2505;

vll G[MAXN];
bool from1[MAXN];
void dfs(ll v){
  if(from1[v]) return;
  from1[v]=true;
  
  for(auto nv: G[v]){
    dfs(nv);
  }
  return;
}

vll rG[MAXN];
bool toN[MAXN];
void rdfs(ll v){
  if(toN[v]) return;
  toN[v]=true;
  
  for(auto nv: rG[v]){
    rdfs(nv);
  }
  return;
}

vector<tuple<ll,ll,ll>> es;
ll dist[MAXN];
ll ok[MAXN];

void bellmanford(ll s){
  fill(dist,dist+N,INF);
  dist[0]=0;
  
  bool update=true;
  ll cnt=0;
  while(update){
    update=false;
    rep(i,M){
      ll a,b,c;
      tie(a,b,c)=es[i];
      
      if(!ok[a]) continue;
      if(!ok[b]) continue;
      
      if(dist[b]>dist[a]+c){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    cnt++;
    if(cnt>N){
      cout<<-1<<endl;
      exit(0);
    }
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll p; cin>>N>>M>>p;
  
  rep(i,M){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    c=(c-p)*-1;
    es.emplace_back(a,b,c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  
  dfs(0);
  rdfs(N-1);
  rep(i,N) ok[i]=from1[i]&&toN[i];
  
  bellmanford(0);
  cout<<max(-dist[N-1],0LL)<<endl;
}

Measured memory_bytes: 896
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] a = new int[5];
    for (int i = 0; i < a.Length; i++) a[i] = cin();
    int k = cin();
    Console.WriteLine( (a.Max() - a.Min() > k) ? ":(" : "Yay!");
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13396
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

bool inside(int x, int y, int xlim, int ylim){
	return 0 <= x && x < xlim && 0 <= y && y < ylim;
}

struct puni{
	int x, y, d;
	puni(int x, int y, int d){
		this->x = x;
		this->y = y;
		this->d = d;
	}
};

int main(){
	constexpr int dd[] = {0, 1, 0, -1, 0};
	int h, w, k;
	cin >> h >> w >> k;
	string s[h];
	for(int i = 0; i < h; i++) cin >> s[i];
	queue<puni> q;
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(s[i][j] == 'S'){
		s[i][j] = '.';
		q.push(puni(i, j, 0));
	}
	int ans = 1e9, muni[h][w];
	fill(muni[0], muni[h], 1e9);
	while(!q.empty()){
		puni p = q.front();
		q.pop();
		if(muni[p.x][p.y] <= p.d || k < p.d) continue;
		muni[p.x][p.y] = p.d;
		int d = min({p.x, p.y, h - p.x - 1, w - p.y - 1});
		ans = min(ans, (d + k - 1) / k);
		for(int i = 0; i < 4; i++){
			int nx = p.x + dd[i], ny = p.y + dd[i + 1];
			if(inside(nx, ny, h, w) && s[nx][ny] == '.'){
				q.push(puni(nx, ny, p.d + 1));
			}
		}
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OUT(x) cout << (x) << endl;
#define REP(i, n) for (int i=0; i<n; ++i)

bool isOK(string s[], int i, int j, int H, int W){
    bool ret=false;
    if(s[i][j]=='.') return true;

    if(i!=0 && s[i-1][j]=='#'){
        ret=true;
    }
    if(j!=0 && s[i][j-1]=='#'){
        ret=true;
    }
    if(i!=W-1 && s[i+1][j]=='#'){
        ret=true;
    }
    if(j!=W-1 && s[i][j+1]=='#'){
        ret=true;
    }
    return ret;
}

int main(){
    int H, W;
    cin >> H >> W;
    string s[100];
    REP(i, H) cin >> s[i];
    // s[H][W]
    // 上下左右マスをみて孤立しているものを見つけたらNG
    string ans = "Yes";
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(!isOK(s, i, j, H, W)){
                ans = "No";
            }
        }
    }
    OUT(ans);
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
result = 0

for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if(500 * a + 100 * b + 50 * c == X):
        result += 1
        break

print(result)

Measured memory_bytes: 3060
s = gets.chomp
s.reverse!
len = s.size
patterns = ["dream", "dreamer", "erase", "eraser"].map(&:reverse)
pattern_len = patterns.map(&:size)

i = 0
while i < len do
  match_flag = false
  (0..3).each do |j|
    if s[i, pattern_len[j]] == patterns[j]
      i += pattern_len[j]
      match_flag = true
      break
    end
  end
  unless match_flag
    exit_flag = true
    break
  end
end


if exit_flag
  puts "NO"
else
  puts "YES"
end


Measured memory_bytes: 1916
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin

mod = 10**9+7

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

x, k, d = na()

r = 1
if x < 0:
    r = -1

a = abs(x)//d

if a > k:
    print(r*x-k*d)
else:
    res1 = r*x-a*d
    res2 = res1 - d
    if (k-a)%2==0:
        print(abs(res1))
    else:
        print(abs(res2))


Measured memory_bytes: 68228
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long double ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    ll n,k;
    cin >> n >> k;
    ll res = 0;
    rep1(i,n){
        int x = i;
        ll p = (1/n);
        while (x < k) {
            x *= 2;
            p /= 2;
        }
        res += p;
    }
    printf("%.20Lf\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,x,r,sum=0;
    cin>>n;
    x=n;
    while(n>0)
    {
        r=n%10;
        sum+=r;
        n/=10;
    }
    if(x%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class CSnack {
public:
    ll GCD(ll a, ll b) {
        if(b==0) return a;
        else return GCD(b, a%b);
    }
	void solve(std::istream& in, std::ostream& out) {
        ll a,b;
        in>>a>>b;
        ll res = a / GCD(a,b) * b;
        out<<res<<endl;
	}
};


int main() {
	CSnack solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

ll mod = pow(10, 9) + 7;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i = 0; i < y; ++i) {
        res = res * x % mod;
    }
    return res;
}
int main()
{
    ll n; cin >> n;
    ll ans = powmod(10,n);
    ans = (ans - powmod(9, n)) % mod;
    ans = (ans - powmod(9, n)) % mod;
    ans = (ans + powmod(8, n)) % mod;

    ans = (ans + mod) % mod;
    
    cout << ans << endl;


}


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
a = [int(item) for item in input().split()]

smallest_factor = [-1] * (10**6 + 10) 
for i in range(2, n+1):
    if smallest_factor[i] != -1:
        continue
    base = i
    j = 2
    while base * j <= (10**6 + 1):
        smallest_factor[base * j] = i
        j += 1

factor_count = [0] * (10**6 + 10)
is_pairwise = True
for item in a:
    if item == 1:
        continue
    pset = set() 
    while smallest_factor[item] != -1:
        pset.add(smallest_factor[item])
        item //= smallest_factor[item]
    pset.add(item)
    for p in pset:
        factor_count[p] += 1

same_p = max(factor_count)
if same_p <= 1:
    print("pairwise coprime")
elif same_p == n:
    print("not coprime")
else:
    print("setwise coprime")

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool same(int x,int y){
      if(find(x)==find(y)) return true;
      return false;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n,m;
    cin>>n>>m;
    int p[n];
    rep(i,n)cin>>p[i];
    rep(i,n)--p[i];
    UnionFind uf(n);
    rep(i,m){
      int x,y;
      cin>>x>>y;
      uf.unite(--x,--y);
    }
    
    int ans=0;
    rep(i,n){
        if(uf.same(p[i],p[p[i]]))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;

using l = long int;
using ll =long long int;
#define imax INT_MAX
#define lmax LLONG_MAX
#define pb push_back
#define ld long double
#define pii pair<l,l> 
#define pll pair<ll,ll>
#define v vector
#define vl vector<l>
#define vll vector<ll>
#define vvl vector<vector<l>>
#define vvll vector<vector<ll>>
#define vv(a) vector<vector<a>> 
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mni(a,i,j) *min_element((a).begin()+i,(a).begin()+j)
#define mxi(a,i,j) *max_element((a).begin()+i,(a).begin()+j)
#define f first
#define se second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define rep(i, begin, end) \
        for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tc l t=0;cin>>t;while(t--)

// ONLINE JUDGE START
#ifndef ONLINE_JUDGE
    // FILE
    #define file ifstream cin; cin.open("input.txt");  ofstream cout; cout.open("output.txt");
    // DEBUG
    #define debug(x) cout<<"LINE NUMBER:     "<<__LINE__<<"\t :--> \t"<<#x<<"   =   "<<x<<endl;
#else 
    #define debug(x) 
#endif

// SYSTEM
#define DeBuG(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); \
            DeBuG("%s:%.4f s\n",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))
// OVERLOADING
istream& operator >> (istream& cin,vll &a){
    for(auto &i:a)cin>>i;
    return cin;
}
ostream& operator << (ostream& cout,pll &a){
    cout<<a.f<<" "<<a.se<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vl &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,vll &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,v<pll> &a){
    for(auto &i:a)cout<<i<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vvl &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,vvll &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,unordered_map<ll,bool> &a){
    for(auto &i:a){cout<<i.f<<" "<<i.se<<"\t";}
    return cout;
}


// GLOBAL VARIABLE AND FUNTIONS
const ll inf = 1e9+7;

int main()
{
#ifndef ONLINE_JUDGE
    // file;
#endif 

    ll h,n;cin>>h>>n;
    vll arr(n);cin>>arr;
    ll sum=0;
    for(auto i:arr)sum+=i;

    cout<<(sum<h ? "No" : "Yes");

#ifndef ONLINE_JUDGE
//    cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
if N==0:
    print(0)
    exit()
ans = ""
p = True
while N!=0:
    d, m = divmod(N, 2)
    if p:
        N -= m
    else:
        N += m
    ans = str(m) + ans
    N //= 2
    p = not p
print(ans)


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 10005;
const int mod = 1e9 + 7;

string k;
int d;
int memo[N][2][105];

int dp(int pos, bool last, int modpro) {
	if (pos == k.size()) {
		return (modpro == 0);
	}
	int &ans = memo[pos][last][modpro];
	if (ans != -1) {
		return ans;
	}
	int till = (last ? k[pos] - '0' : 9);
	ans = 0;
	for (int i = 0; i <= till; i++) {
		ans += dp(pos + 1, last && (i == k[pos] - '0'), (modpro + i) % d);
		ans %= mod;
	}
	return ans % mod;
}

void solve() {
	int i, j, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> k >> d;
	memset(memo, -1, sizeof(memo));
	cout << (dp(0, 1, 0) - 1 + mod) % mod;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 17408
#include<stdio.h>

#define N 100001

int getdepth(int);

typedef struct {
  int p,l,r;
} Node;

Node Tr[N];
int id;

int main(){
  int i,n,j,s,deg,k,dep;
  
  
  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++){
    Tr[i].p = Tr[i].l = Tr[i].r = -1;
  }
  
  for(i=0 ; i<n ; i++){
    scanf("%d",&id);
    scanf("%d",&k);
    
    for(j=0 ; j<k ; j++){
      scanf("%d",&deg);
    
    if (j==0) Tr[id].l = deg;
    else Tr[s].r = deg;
    s = deg;
  Tr[s].p = id;
    }}
  
  for(i=0 ; i<n ; i++){
    dep = getdepth(i);

    printf("node %d: parent = %d, depth = %d, ",i,Tr[i].p,dep);
    
    if(dep==0) printf("root, ");
  
    else if(Tr[i].l==-1) printf("leaf, ");
  
    else printf("internal node, ");
   
    printf("[");
  
    if(Tr[i].l != -1){
      id = Tr[i].l;
      printf("%d",id);
    
      while(id != -1){
	id = Tr[id].r;
      
	if(id != -1) printf(", %d",id);
      }
    }
 
    printf("]\n");
 
  }
  return 0;
}

int getdepth(int i){
  int c = 0;

  id = Tr[i].p;

  while(id != -1){
    id = Tr[id].p;
    c++;
  }

  return c;
}
  



Measured memory_bytes: 2904
#include<iostream>

using namespace std;

int main(){
  int numbers[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;

  cin >> K;
  cout << numbers[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s, t, u;
int a, b;

int main()
{
    cin>>s>>t>>a>>b>>u;
    if (s == u)
        a--;
    else
        b--;
    cout<<a<<" "<<b<<endl;

    return 0;
}


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

using namespace std;

int main(void)
{
	int a, b;
	cin >> a >> b;
	//double c = a * 12.5;
	//double d = (a+1)*12.5;
	int c, d;
	if (a%2 == 0) {
		c = a/2 * 25;
		d = c+12;
	} else {
		d = (a+1)/2 * 25;
		c = d-12;
		d--;
	}

	int e = b * 10;
	int f = (b+1)*10;
	bool found = false;
	for (int i = c; i <= d; i++) {
		if (i >= e && i < f) {
			cout << i << endl;
			found = true;
			break;
		}
	}
	if (!found)
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S = _in[0]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    S_unit = S.replace('dream','A').replace('erase','B').replace('Aer','C').replace('Br','D')
    _ = S_unit.replace('A','').replace('B','').replace('C','').replace('D','')
    flag = 'YES' if _=='' else 'NO'
    ### ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(flag)


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

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

  vector<string> W(N);
  for (int i = 0; i < N; i++)
    cin >> W[i];

  auto b = W[0].back();
  for (int i = 1; i < N; i++) {
    if (b == W[i].front()) {
      b = W[i].back();
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  int len = W.size();
  sort(W.begin(), W.end());
  W.erase(unique(W.begin(), W.end()), W.end());
  if (len != W.size()) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

struct Union_Find {
	vector<int> par;
	vector<int> rank;

	//初期化
	void init(int n) {
		par.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	//木の根を探す
	int find(int s) {
		if (par[s] == s) {
			return s;
		}
		return par[s] = find(par[s]);
	}

	//結合
	void unite(int x, int y) {
		int a = find(x), b = find(y);
		if (a == b) {
			return;
		}
		if (rank[a] < rank[b]) {
			par[a] = b;
		}
		else {
			par[a] = b;
			if (rank[a] == rank[b]) {
				++rank[b];
			}
		}
	}

	//二つの数の根が同じかどうか
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	//サイズを返す
	unsigned int size() {
		return par.size();
	}
};

void hawawa()
{
	int n, m, ans;
	cin >> n >> m;
	ans = n;
	Union_Find uf = Union_Find();
	uf.init(n);
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		if (uf.same(x - 1, y - 1)) {
			continue;
		}
		else {
			uf.unite(x - 1, y - 1);
			ans--;
		}
	}
	cout << ans << "\n";
}


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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int k, x;
  cin >> k >> x;
  int minv = max(-1000000, x - k + 1);
  int maxv = min(1000000, x + k - 1);
  for (int i = minv; i <= maxv; i ++) {
    if (i != minv) cout << " ";
    cout << i;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,ans=99999999999999; cin>>n;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0) ans=min(ans,i+n/i-2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3684