akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n , w;
    cin>>n>>w;
    
    vector <long long int> dp ( 1000 * n + 1 , 1e9 + 5 );
    
    

    
    int maxx = 0;

    int weights[n] , values[n];
    
    
    for(int i = 0 ; i < n; i++){
        cin >> weights[i] >> values[i];
        maxx += values[i];
    }

    dp[0] = 0;
    
    for(int i = 0 ; i < n ; i++){
       for(int valnow = maxx - values[i] ; valnow >= 0 ; valnow--){
           if(dp[valnow] + weights[i] <= w)
                dp[valnow + values[i]] = min (dp[valnow + values[i] ] , dp[valnow] + weights[i]);
       }
    }
    
    
    for(int i = dp.size() - 1; i >= 0  ; i-- )
    {
        if(dp[i] > 0 && dp[i] != 1e9 + 5)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
text = input()
judge_string = input()
for i in range(len(text)):
    if judge_string in text:
        print('Yes')
        break
    else :
        text = list(text)
        pop_text = text.pop()
        text.insert(0, pop_text)
        text = ''.join(text)
        if i == len(text) - 1:
            print('No')


Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, k;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vll l(N, 0), r(N, 0), nl(N, 0), nr(N, 0);
    ll count = 0, last = 0;
    rep(i, N){
        l[i] = count;
        nl[i] = last;
        if(S[i]=='x') continue;
        l[i] = ++count;
        nl[i] = last = i;
        rep(j, C){
            ++i;
            if(i>=N) break;
            l[i] = count;
            nl[i] = last;
        }
    }
    count = 0;
    last = N-1;
    irep(i, N){
        r[i] = count;
        nr[i] = last;
        if(S[i]=='x') continue;
        r[i] = ++count;
        nr[i] = last = i;
        rep(j, C){
            --i;
            if(i<0) break;
            r[i] = count;
            nr[i] = last;
        }
    }

    rep(i, N){
        if(S[i]=='x') continue;
        if(i==0){
            ll t = i+1<N? r[i+1] : 0;
            if(t<K) cout << i+1 << endl;
        }
        else if(i==N-1){
            ll t = l[i-1];
            if(t<K) cout << i+1 << endl;
        }
        else{
            ll n1 = nl[i-1];
            ll n2 = nr[i+1];
            ll t = l[n1] + r[n2];
            if(t<K) cout << i+1 << endl;
            else if(t==K && n2-n1<=C && l[n1]>0 && r[n2]>0) cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 9636
import numpy as np

n = int(input())
w = np.array(list(map(int, input().split())))

ans = np.sum(w)

for i in range(len(w)):
    a = np.sum(w[:i])
    b = np.sum(w[i:])
    
    if np.abs(a - b) < ans:
        ans = np.abs(a - b)

print(ans)

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

int main(){
    int N;
    cin >> N;
    int a[4];
    rep(i, 4){
        a[i] = N/(int)pow(10, 3-i) %10;
    }
    int sum;
    rep(i, 1<<3){
        sum =a[0];
        vector<char> c;
        rep(j, 3){
            if((i>>(2-j))%2==1){
                c.emplace_back('+');
                sum += a[j+1];
            }else{
                c.emplace_back('-');
                sum -= a[j+1];
            }
        }

        if(sum==7){
            printf("%d", a[0]);
            rep(j, 3){
                printf("%c%d", c[j], a[j+1]);
            }
            printf("=7\n");
            return 0;
        }
        
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	}
}

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

const double PI = acos(-1);

int main()
{
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double theta_h = double(H * 60 + M) / 720 * 2 * PI;
  double theta_m = double(M) / 60 * 2 * PI;
  double x_h = A * cos(theta_h);
  double y_h = A * sin(theta_h);
  double x_m = B * cos(theta_m);
  double y_m = B * sin(theta_m);
  double dx = x_h - x_m;
  double dy = y_h - y_m;
  double dist = sqrt(dx * dx + dy * dy);
  
  printf("%.10f\n", dist);
}


Measured memory_bytes: 4100
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
typedef long long ll;
using namespace std;
int n,a[100005],m;
int Abs(int x){
	if (x>=0) return x; else return -x;
}
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for (int i=0;i<n-1;i++){
		if (a[n-1]%2==0){
			if (Abs(a[n-1]/2-a[i])<Abs(a[n-1]/2-m)) m=a[i];
		}else{
			if (min(Abs(a[n-1]/2-a[i]),Abs(a[n-1]/2+1-a[i]))<min(Abs(a[n-1]/2-m),Abs(a[n-1]/2+1-m))) m=a[i];
		}
	}
	cout<<a[n-1]<<' '<<m<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1000005][2][2];
ll mod=1e9+7;
ll n;
ll fun(int pos,int z,int o)
{
    if(pos==n && z & o)
    {
        return 1LL;
    }
    if(pos==n)
    {
        return 0;
    }
    if(dp[pos][z][o]!=-1)
        return dp[pos][z][o];
    ll res=0;
    for(int i=0;i<=9;i++)
    {
        res += fun(pos+1,z|(i==0),o|(i==9));
        if(res>=mod) res %=mod;
    }
    return dp[pos][z][o]=res;
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    cout<<fun(0,0,0)<<endl;
    return 0;
}


Measured memory_bytes: 112888
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
#define f(i,x,n) for(int i=x;i<n;++i)
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int h,w;
int mx=-1;
vector<int> adj[1000];
bool vis[20][20];
int level[20][20];
string s[20];
int zrr[100005];
void fact(){
	zrr[0]=1;
	for(int i=1;i<100005;++i){
		zrr[i]=i*zrr[i-1];
		zrr[i]%=mod;
	}
}
int modexp(int x){
	int y=mod-2;
	int res=1;
	while(y>0){
		if(y&1){
			res*=x;
			res%=mod;
		}
		x*=x;
		x%=mod;
		y/=2;
	}
	return res;
}
void solve(){	
	int n; cin>>n;
	int a[n];
	f(i,0,n)  cin>>a[i];
	int ans=LLONG_MAX;
	f(i,0,105){
		int tp=0;
		f(j,0,n){
			int xp=abs(a[j]-i);
			xp*=xp;
			tp+=xp;
		}
		ans=min(ans,tp);
	}
	cout<<ans;
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e9+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pr pair<int,int>
#define ff first
#define ss second
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;
int a[N],b[N],c[N],d[N],A[N];

int get(int ans=0) {
    rep(i,k) {
        if(A[b[i]]-A[a[i]]==c[i]) ans+=d[i];
    } return ans;
}

void dfs(int i,int k,int &ans) {
    A[i]=k;
    if(i==n) {
        ans=max(ans,get());
        return ;
    }
    Rep(j,k,m) dfs(i+1,j,ans);
}

void solve(int ans=0) {
    cin>>n>>m>>k;
    rep(i,k) cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(0,1,ans);
    //看似很大的时间复杂度，但实际上可以把它想象成走台阶类的dp题
    //可以发现F[10][10]只是一个不到20000的数
    cout<<ans<<endl;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
# AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1850894#1)
V, E, r = list(map(int, input().split()))
es = [list(map(int, input().split())) for i in range(E)]

# 以下を参考にさせていただきました
# http://ti2236.hatenablog.com/entry/2012/12/07/175841

# Chu-Liu/Edmonds' Algorithm
# 最小全域有向木を再帰的に求める
# V: 頂点数, es: 辺集合, r: 根となる頂点番号
def solve(V, es, r):
    # まず、頂点vに入るものの内、コストが最小の辺を選択する
    # minsには(最小コスト, その辺のもう一方の頂点番号)
    mins = [(10**18, -1)]*V
    for s, t, w in es:
        mins[t] = min(mins[t], (w, s))
    # 根となる頂点rからは何も選択しない
    mins[r] = (-1, -1)

    group = [0]*V # 縮約した際に割り振られる頂点番号
    comp = [0]*V  # 縮約されたgroupか
    cnt = 0       # 縮約した後の頂点数

    # 縮約処理
    used = [0]*V
    for v in range(V):
        if not used[v]:
            chain = [] # 探索時に通った頂点番号リスト
            cur = v    # 現在探索中の頂点
            while not used[cur] and cur!=-1:
                chain.append(cur)
                used[cur] = 1
                cur = mins[cur][1]
            if cur!=-1:
                # 探索が根の頂点rで終了しなかった場合
                # chain = [a0, a1, ..., a(i-1), ai, ..., aj], cur = aiの場合
                # a0, ..., a(i-1)までは固有の番号を割り振り
                # ai, ..., ajまでは閉路であるため、同じ番号を割り振るようにする
                cycle = 0
                for e in chain:
                    group[e] = cnt
                    if e==cur:
                        # 閉路を見つけた
                        cycle = 1
                        comp[cnt] = 1
                    if not cycle:
                        cnt += 1
                if cycle:
                    cnt += 1
            else:
                # 探索が根の頂点rで終了した場合
                # --> 閉路を持たないため、１つずつ新しい番号を割り振っていく
                for e in chain:
                    group[e] = cnt
                    cnt += 1

    # cntがV => 閉路が存在せず、有向木が構築できている
    if cnt == V:
        # 根の頂点r以外が選択した辺のコストの和を返す
        # (+1はmins[r][0]の-1を打ち消すやつ)
        return sum(map(lambda x:x[0], mins)) + 1

    # 閉路が含まれていた場合
    # --> 閉路に含まれている頂点が選択した辺のコストの和を計算
    res = sum(mins[v][0] for v in range(V) if v!=r and comp[group[v]])

    # 再帰的に計算するグラフが持つ辺を構築
    n_es = []
    for s, t, w in es:
        # 追加する辺に繋がる頂点は、新しいグラフの頂点番号に変換する
        gs = group[s]; gt = group[t]
        if gs == gt:
            # 同じ閉路に含まれている頂点どうしをつなぐ辺の場合
            # --> 追加しない
            continue
        if comp[gt]:
            # ある閉路に含まれている頂点vに入る辺の場合
            # --> その辺のコストから、閉路においてその頂点vに入っていた辺のコストを引く
            n_es.append((gs, gt, w - mins[t][0]))
        else:
            # その他 --> 何もせず追加
            n_es.append((gs, gt, w))

    # 再帰的に求めた最小コストと、さっき計算したコストresを足したものを返す
    return res + solve(cnt, n_es, group[r])

print(solve(V, es, r))


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

int main()
{
    string s;
    cin >> s;

    int len = 0;
    int mx = 0;

    for (size_t i = 0; i < s.length(); i++)
    {
        char ch = s[i];
        if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T')
        {
            len++;
        }
        else
        {
            if (len > mx)
            {
                mx = len;
            }
            len = 0;
        }
    }
    if (len > mx)
    {
        mx = len;
    }

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 256
//解説聞いた
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#define scanf(...) scanf(__VA_ARGS__)+1
using namespace std;

int main(){
	int N, M;

	scanf("%d %d\n", &N, &M);

	vector<int> X;
	for (int i = 0; i < M; i++) {
		int tmp;
		scanf("%d", &tmp);
		X.push_back(tmp);
	}

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

	if (N >= M) {
		printf("0");
		return 0;
	}

	int count = *(X.end() - 1) - *(X.begin());

	vector<int> Xd;
	auto end = X.end();
	for (auto itr = X.begin() + 1; itr != end; itr++) {
		int tmp;
		tmp = *itr - *(itr - 1);
		Xd.push_back(tmp);
	}

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

	auto itr = Xd.begin();
	for (int i = 0; i < N - 1; i++) {
		count -= *itr;
		itr++;
	}

	printf("%d", count);

	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	int n;
	cin>>n;
	double sum=0;
	for (int i = 0; i < n; ++i){
		int a;
		cin>>a;
		sum+= 1.0/a;
	}

	cout<<1/sum<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a[100][100] = {};
	int b[100][100] = {};
	int n,m,l,i,j,k;
	long long s;
	scanf("%d %d %d\n",&n,&m,&l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j){printf(" ");}
			for(k=0,s=0;k<m;k++){
				s+=a[i][k]*b[k][j];
			}
			printf("%lld",s);
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 1010

int dp[maxn][maxn];

void solve() {
    string s1, s2;
    cin >> s1 >> s2;

    for (int i = 0; i <= s1.size(); i++) {
        for (int j = 0; j <= s2.size(); j++) {
            if (i == 0 or j == 0)
                dp[i][j] = i > j ? i : j;
            else if (s1[i - 1] == s2[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1];
            } else
                dp[i][j] = 1 + min({dp[i - 1][j - 1], dp[i][j - 1], dp[i - 1][j]});
        }
    }
    cout << dp[s1.size()][s2.size()] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 11132
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,b,c,h[100000],h2;
	int mid,low,high,flg,mx,x,x2,i;
	scanf("%d %d %d",&n,&a,&b);
	c=a-b;
	mx=-1;
	for(i=0;i<n;i++)	{
		scanf("%d",&h[i]);
		mx=max(mx,h[i]);
	}
	low=1;
	high=mx/b+1;
	while(low<=high)	{
		mid=(low+high)/2;
//		printf("low=%d high=%d mid=%d\n",low,high,mid);
		flg=1;
		x=mid;
		for(i=0;i<n;i++)	{
			h2=h[i]-b*mid;
			if(h2>0)	{
				x2=h2/c;
				if(h2%c!=0)	x2++;
//				printf("i=%d x2=%dx=%d\n",i,x2,x);
				x-=x2;
				if(x<0)	{
					flg=0;
					break;
				}
			}
		}
		if(flg!=1)	low=mid+1;
		else	high=mid-1;
	}
	printf("%d\n",low);
	return 0;
}


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

int  main()
{
	int T,x; cin >> T >> x ;


	long double ans = (long double)T / x;
	printf("%.10Lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    int A,P,ans;
    cin >> A>>P;

    ans = floor((A*3+P)/2);

    cout << ans <<endl;


    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<double> resultList = new List<double>();
            int n;
            while ((n = int.Parse(Console.ReadLine())) != -1)
            {
                double x = 1.00;
                double y = 1.00;
                for (int i = 2; i < n; i++)
                {
                    double a = x - y / Math.Sqrt(x * x + y * y);
                    double b = y + x / Math.Sqrt(x * x + y * y);
                    x = a;
                    y = b;
                }

                resultList.Add(x);
                resultList.Add(y);

            }

            foreach (double d in resultList)
            {
                Console.WriteLine(d);
            }

        }
    }
}

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

int main(){

    int n,a,b,c,count=1,minnum;

    cin >> n;

    if(n == 2){
      cin >> a >> b;
      minnum = min(a,b);
      while(count != minnum){
        if(a%count == 0 && b%count == 0){
          cout << count << endl;
        }
        count++;
      }
    }
    else{
      cin >> a >> b >> c;
      minnum = min(a,min(b,c));
      while(count != minnum){
        if(a%count == 0 && b%count == 0 && c%count == 0){
          cout << count << endl;
        }
        count++;
      }
    }

    return 0;
}

Measured memory_bytes: 3108
// AOJ ALDS1_10_A: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A

package main

import (
	"fmt"
)

func fibonacci(n int) int64 {
	f := []int64{1, 1}
	for i := 2; i <= n; i++ {
		f = append(f, f[i-2] + f[i-1])
	}
	return f[n]
}

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


Measured memory_bytes: 1120
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
    int n;
    long long ans,a1=-2,a2=-2;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=n;i>=2;i--) if(a[i]==a[i-1]) {a1=a[i],a[i]=a[i-1]=-1;break;}
    for(int i=n;i>=2;i--) if(a[i]==a[i-1]&&a[i]!=-1) {a2=a[i];break;}
    if(a1!=-2&&a2!=-2) cout<<a1*a2<<endl; else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import heapq
import sys

def check_out_of_map(pos,H,W):
    H = len(Map)
    W = len(Map[0])

    if pos[0] < 0 or pos[1] < 0:
        return False
    if pos[0] >= H or pos[1] >= W:
        return False
    return True

def bfs(s,g,Map,H,W):
    queue = []
    queue.append(s)
    dist = [[-1 for i in range(W)] for j in range(H)]
    direct = [(1,0),(-1,0),(0,1),(0,-1)]
    count = 0
    dist[s[0]][s[1]] = 0

    while queue != []:
        q = queue.pop(0)
        if q == g:
            return dist[q[0]][q[1]]
        for i in range(4):
            nextPos = (q[0]+direct[i][0],q[1]+direct[i][1])
            if check_out_of_map(nextPos,H,W) and Map[nextPos[0]][nextPos[1]] != "X":
                if dist[nextPos[0]][nextPos[1]] == -1:
                    dist[nextPos[0]][nextPos[1]] = dist[q[0]][q[1]] + 1
                    queue.append(nextPos)

H,W,N = map(int,input().split(" "))
cheese_queue = []
Map = []
for i in range(H):
    count = 0
    line = []
    while True:
        char = sys.stdin.read(1)
        if char == "S":
            s = (i,count)
        elif char.isnumeric():
            heapq.heappush(cheese_queue,(int(char),(i,count)))
        elif char == "\n":
            break
        line.append(char)
        count += 1
    Map.append(line)
count = 0
while cheese_queue != []:
    q = heapq.heappop(cheese_queue)
    count += bfs(s,q[1],Map,H,W)
    s = q[1]
print(count)

Measured memory_bytes: 38332
package main

import (
	"fmt"
	"math"
)

func min(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m > v {
			m = v
		}
	}
	return m
}

func main() {
	// Code for D - Floor Function
	var A, B int
	var N int
	fmt.Scan(&A, &B, &N)

	i := min(B-1, N)
	fmt.Println(int(math.Ceil(float64((A*i)/B))) - A*int(math.Ceil(float64(i/B))))
}


Measured memory_bytes: 1772
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] B = new int[N-1];
		int[] A = new int[N];
		for(int i=0; i<N-1; i++) {
			B[i] = sc.nextInt();
		}
		A[0]=B[0];
		A[N-1]=B[N-2];
		for(int i=1; i<N-1; i++) {
			if(B[i]>B[i-1]) {
				A[i]=B[i-1];
			}else {
				A[i]=B[i];
			}
		}
		int x=0;
		for(int i=0; i<N; i++) {
			x = x + A[i];
		}
		System.out.println(x);
	}
}



Measured memory_bytes: 21844
import sys
#import unittest
#import collections

def plan_vacation(activity, n):
	dp = [0] * 3 
	for i in xrange(3):
		dp[i] = activity[0][i]
	
	for i in xrange(1, n):
		new_dp = [0] * 3
		for j in xrange(3):
			for k in xrange(3):
				if j != k:
					new_dp[j] = max(new_dp[j], dp[k] + activity[i][j])
		dp = new_dp
	return max(dp)
	
	
def read_input():
	#Read the input N
	n = int(sys.stdin.readline())
	activity = [[0]* 3 for i in xrange(n)]
	for i in xrange(n):
		a = sys.stdin.readline().split()
		for j in xrange(3):
			activity[i][j] = int(a[j])
	
	result = plan_vacation(activity, n)
	print result
		
if __name__ == '__main__':
	 read_input()


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

int n, root;
struct trie {
    int c[27],en;
    trie (){};
};

trie a[int (1e6+5)];
int K;
void add(int ch){
    a[root].c[ch-'A' + 1] = ++K;
}

void push(string s){
    root = 1;
    for(int i = 0; i < s.length(); i++){
        if (a[root].c[s[i]-'A' + 1] == 0) add(s[i]);
        root = a[root].c[s[i]-'A' + 1];
    }
    a[root].en = 1;
}

string get(string s){
    string st;
    st.clear();
    int i = s.length() - 1;
    while (s[i] != ' ' && i >= 0) st = s[i--] + st;
    return st;
}

void nhap(){
    string st;
    cin >> st;
    push(st);
}

bool _find(string s){
    root = 1;
    for(int i = 0; i < s.length(); i++) {
        if (a[root].c[s[i]-'A' + 1] == 0) return false;
        root = a[root].c[s[i]-'A' + 1];
    }
    if (a[root].en != 0)
        return true;
    else
        return false;
}

void findd(){
    string s;
    cin >> s;
    cout << ((_find(s)) ? "yes" : "no");
    cout << '\n';
}

void solve(){
    cin >> n;
    root = 1;
    K = 1;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if (s[0] == 'i') nhap();
        else findd();
    }
}

int main(){
    
    solve();
}



Measured memory_bytes: 41204
# D - RGB Triplets

n = int(input())
s = str(input())

r = len([i for i, x in enumerate(s) if x=='R'])
g = len([i for i, x in enumerate(s) if x=='G'])
b = len([i for i, x in enumerate(s) if x=='B'])

ans = r * g * b

for i in range(n):
    for j in range(i+1, n):
        k = j+j-i
        if k >= n:
            break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int K;
int a[5010];
int c[5010];
bitset<5010> d;
int s;

int main(){
	scanf("%d%d" , &N , &K);
	repp(i,0,N){
		scanf("%d" , a + i);
		if(a[i] >= K){
			--N;
			--i;
		} else {
			s += a[i];
			++c[a[i]];
		}
	}
	if(s < K){
		printf("%d\n" , N);
		return 0;
	}
	sort(a,a+N);
	int ans = 0;
	d = 0;
	d[0] = 1;
	repm(i,N-1,-1){
		++ans;
		repm(j,a[i],0){
			if(d[K-j]){
				ans = 0;
				break;
			}
		}
		d |= (d<<a[i]);
	}
	printf("%d\n" , ans);
	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++)
using ll = long long;
using P = pair<int,string>;

int main() {
int n;
cin >> n;
for(int i = n; i >= 1 ;i--){
  int s = sqrt(i);
  if(s*s == i){
    cout << i << endl;
    return 0;
  }
}
 

 }


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string str;
  str = to_string(N);
  int i = 0;
  for (i = 0; i < 3; i++)
  {
    if(str.at(i)=='7'){
      cout << "Yes" << endl;
      break;
    }
  }
  if(i==3){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3680
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX 200010
#define MOD 998244353

typedef long long int int64;

int64 dp[MAX]={0};
int64 dp_sum[MAX]={0};

int main() {

    int n,k;
    int i,j;
    int l[20]={0};
    int r[20]={0};

    scanf("%d %d",&n,&k);

    for(j=0;j<k;j++)
    {
        scanf("%d %d",&l[j],&r[j]);
    }

    //dp
    dp[1]=1;
    dp_sum[1]=1;

    for(i=2;i<=n;i++)
    {
        for(j=0;j<k;j++)
        {
            if(i-l[j]<0)dp[i]+=0;
            else if((i-r[j]-1)<0)
            {
                dp[i]+=(dp_sum[i-l[j]]);
                dp[i]= dp[i] % MOD;
            }
            else
            {
                dp[i]+=((dp_sum[i-l[j]]-dp_sum[i-r[j]-1] + MOD) % MOD);
                dp[i]= dp[i] % MOD;
            }
        }
        dp_sum[i]=dp_sum[i-1]+dp[i];
        dp_sum[i]=dp_sum[i] % MOD;
    }

    printf("%lld",dp[n]);
}


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

int main(){
    int cnt = 1;
    rep(i,5) {
        int a;
        cin >> a;
        if (a == 0) break;
        else cnt++;
    }

    cout << cnt << endl;


}

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


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

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc121/tasks/abc121_c

n, m = map(int, input().split())

shop = []
for _ in range(n):
    a, b = map(int, input().split())
    shop.append((a, b))

shop.sort(key=lambda x: x[0])

c = 0
ans = 0
i = 0
while c < m and i < n:
    a, b = shop[i]
    if c + b >= m:
        ans += (m - c) * a
        c += (m - c)
    else:
        ans += b * a
        c += b
    i += 1
print(ans)

Measured memory_bytes: 56920
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

int main(){
  string n;
  cin>>n;
  int sum = 0;
  for(int i = 0;i<n.size();i++){
    sum += n[i] - '0';
  }
  if(stoi(n) % sum == 0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

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

int main() {
  int N, M;
  cin >> N >> M;
  int ans;
  ans = N * (N - 1) / 2 + M * (M - 1) / 2;

  cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  map<string,int> m;

  rep(i,n){
    string s;
    cin >> s;
    m[s]+=1;
  }
  int mx = 0;
  for(auto x : m){
  mx = max(mx,x.second);
  }
  for(auto x : m){
  if(x.second == mx) cout << x.first << endl;
  }
}

Measured memory_bytes: 25216
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {

        var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long A = line[0];
        long B = line[1];
        long C = line[2];
        long D = line[3];

        //ユークリッドの互除法　AとBの最大公約数を求める
        bool p = true;
        long k = 0; //最大公約数k
        long Q = Math.Max(C, D); //割られる数
        long R = Math.Min(C, D); //割る数

        while (p)
        {
            //「割られる数」/「割る数」が割り切れたら、「割られる数」と「割る数」の最大公約数は「割る数」
            long n = Q % R; //余り
            if (n == 0)
            {
                k = R;
                p = false;
            }
            else
            {
                //「割られる数」に「割る数」をセット
                Q = R;
                //「割る数」に「余り」をセット
                R = n;
            }
        }

        long s =( C * D ) / k; //CとDの最小公倍数はC*D/CとDの最大公約数

        Console.WriteLine((B - A + 1) - ((B / C - (A - 1) / C) + (B / D - (A - 1) / D) - (B / s - (A - 1) / s)));
    }

}

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

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

    sort(a.begin(), a.end(), greater<int>());
    int result = 0;
    for (int i = 0; i <= N; ++i) {
        if (i % 2 == 0) result += a[i];
        else result -= a[i];
    }
    cout << result << endl;
}

Measured memory_bytes: 3520
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int n = reader.nextInt();
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = reader.nextLong();
		}
		long total = 0;
		long must = arr[0];
		for (int i = 1; i < n; i++) {
			if (arr[i] < must) {
				total += must - arr[i];
				arr[i] = must;
			}
			must = arr[i];
		}
		System.out.println(total);
		reader.close();
	}
	
}


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

vector<vector<int>> graph;
int ans = 0;

void dfs(int k, vector<bool> &visited){
  // ベースケース
  // 全ての頂点を訪問済み
  bool ok = true;
  for(int i = 0; i < visited.size(); i++){
    if(i == k) continue;
    if(!visited.at(i)){
      ok = false;
    }
  }
  if(ok){
    ans++;
    return;
  }

  // 再帰ステップ
  // 隣接頂点が全て訪問済みとなるまでグラフを辿っていくことで、パスを列挙
  visited.at(k) = true;
  for(auto v: graph.at(k)){
      if(visited.at(v)) continue;
      dfs(v, visited);
  }
  visited.at(k) = false;
}

int main(){
  int N, M;
  cin >> N >> M;
  graph.assign(N, vector<int>());
  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    graph.at(x).push_back(y);
    graph.at(y).push_back(x);
  }
  vector<bool> visited(N, false);
  dfs(0, visited);
  cout << ans  << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int N;
int main(int argc, char const *argv[]) {
  cin >> N;
  int ans = 0;
  for (int i = 0; pow(2, i) <= N; i++) {
    ans = (int)pow(2, i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, 0, N) cin >> A[i];
	vsort(A);

	int count;
	if(N % 2  == 0) count = N / 2;
	else count = (N + 1) / 2;
	int array[count];
	memset(array, 0, sizeof(array));

	rep(i, 0, N) {
		if(A[i] == 0) {
			if(array[0] == 1) {
				cout << 0 << endl;
				return 0;
			} else {
				array[0]++;
			}
		} else {
			if(array[A[i] / 2] == 2) {
				cout << 0 << endl;
				return 0;
			} else {
				array[A[i] / 2]++;
			}
		}
	}

	int mod = 1e9 + 7;
	if(N % 2 != 0) count--;
	
	ll rsl = 1;
	rep(i, 0, count) {
		rsl = (rsl * 2) % mod;
	}

	cout << rsl << endl;


		

}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll dp[2010][2010];
ll a[2010];
ll H;
ll n,l,r;



int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,w;
    
    cin >> h >> w;
  	if(h==1 || w==1){
        cout<<1<<"\n";
        return 0;
    }
    ll p=(h+1)/2;
    ll q=h/2;
    ll ans=(p+q)*(w/2);
    if(w%2){
        ans+=p;
    }
    cout <<ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,i,j,x,rank,S,H,C,D;
  char mark;//mark:文字 x:数字
  int card[4][13];
  int a[4][13];
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf(" %c%d",&mark,&rank);
    rank -= 1;
    switch(mark){//文字を数値に変換
        case 'S':
        x = 0;
        break;
        case 'H':
        x = 1;
        break;
        case 'C':
        x = 2;
        break;
        case 'D':
        x = 3;
        break;
      }
    a[x][rank] = x * 100 + rank + 1;
  }
  
  for(x = 0; x < 4; x++){
    switch(x){//数値を文字に再変換
        case 0:
        mark = 'S';
        break;
        case 1:
        mark = 'H';
        break;
        case 2:
        mark = 'C';
        break;
        case 3:
        mark = 'D';
        break;
    }
    for(rank = 0; rank < 13; rank++){
      if(a[x][rank] != x * 100 + rank + 1){
        printf("%c %d\n",mark,rank + 1);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<ll> ps(k);
    for (int i = 1; i <= n; i++) {
        ps[i % k]++;
    }

    ll z = ps[0] * ps[0] * ps[0];

    if (k % 2 == 1) {
        cout << z << endl;
        ret();
    }

    ll h = ps[k / 2] * ps[k / 2] * ps[k / 2];

    cout << z + h << endl;

}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define f first
#define s second

#define all(s) s.begin(),s.end()
#define spresent(s,v) ((s).find(v)!=s.end())
#define present(s,v) (find(all(s),v)!=s.end())

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

#define fill_1d(a,val) fill(a,a+sizeof(a)/sizeof(a[0]),val)
#define fill_2d(a,val) fill(&a[0][0],&a[0][0]+sizeof(a)/sizeof(a[0][0]),val)

#define dout(i,s) cout<<"Case #"<<i<<": "<<s<<"\n"

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

typedef struct node{
	ll val,more=0,less=0;
	bool operator <(const node& a){
		return val<a.val;
	}
}node;


// A
// int main(){

// 	int len;
// 	  string s;
// 	  cin>>s;
// 	  len=s.size();
// 	  long long int k;
// 	  cin>>k;
// 	  ll ans=0,st=0,en=len-1;
// 	  if(s[0]==s[len-1]){
// 	    while(st<len-1 && s[st+1]==s[0])
// 	      ++st;
// 	    while(en>0 && s[en-1]==s[len-1])
// 	      --en;
// 	    if(st>=en){
// 	      return cout<<k*len/2,0;
// 	    }
// 	    ans=(k-1)*((st+1+(len-en))/2);
// 	    ans+=(st+1)/2 + (len-en)/2;
// 	    ++st;
// 	    --en;
// 	  }
// 	  while(st<en){
// 	    int j=st;
// 	    while(j<en && s[j+1]==s[st]){
// 	      ++j;
// 	    }
// 	    ans+=k*((j-st+1)/2);
// 	    st=j+1;
// 	  }
// 	  cout<<ans;
	  
// 	  return 0;

// }

// B

const int sz=205;
vi tree[sz];
bool flag=true;
int col[sz]={0};
int dist[sz][sz];

void dfs(int v, int c){
	// cout<<v<<" "<<c<<"\n";
	if(col[v] && col[v]!=c){
		// cout<<" "<<v<<" "<<c<<"\n";
		flag=false;
		return;
	}
	if(!col[v]){
		col[v]=c;
		for(int i=0;i<tree[v].size();++i){
			dfs(tree[v][i],(c&1)+1);
		}
	}
}

void bfs(int v){
	queue<int> q;
	q.push(v);
	dist[v][v]=0;
	while(!q.empty()){
		int t=q.front();
		q.pop();
		for(int i=0;i<tree[t].size();++i){
			if(dist[v][tree[t][i]]==-1){
				dist[v][tree[t][i]]=dist[v][t]+1;
				q.push(tree[t][i]);
			}
		}
	}
}

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		string s;
		cin>>s;
		for(int j=1;j<=n;++j){
			if(s[j-1]=='1'){
				tree[i].pb(j);
			}
		}
	}

	dfs(1,1);

	if(!flag)
		return cout<<-1,0;
	memset(dist,-1,sizeof(dist));
	for(int i=1;i<=n;++i){
		bfs(i);
	}
	int ma=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)
			ma=max(ma,dist[i][j]);
	}
	cout<<ma+1;
	return 0;


}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[110];
int main(){
	rep(i,0,3)scanf("%lld",a+i);
	sortup(a,3);
	printf("%lld",a[2]-a[0]);
}

Measured memory_bytes: 128
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
using ll = long long;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll mind = (1ULL << 63) - 1;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ll d = (n / i - 1) + (i - 1);
            if (mind > d) {
                mind = d;
            }
        }
    }
    cout << mind << endl;
}


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

int n, t, ans = 1000000;

int main() {
  cin >> n >> t;
  for(int i = 0; i < n; ++i) {
    int nt, c;
    cin >> c >> nt;
    if(t >= nt) ans = min(ans, c);
  }
  if(ans == 1000000)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
    int A=0;
    int i;
    int j=0;
    char buf[10];
    scanf("%s", buf);
    for(i=0; buf[i]!='\0'; i++){
        j=buf[i]-48;
        A=A+j;
    }
    if(atoi(buf)%A==0){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) (void)0
#endif


using namespace std;

inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define long long long
long  pw(long  x, long  y){long  ans = 1;for(long  i = 0; i < y; i++){ans = ans * x;}return ans;}
long  factorial(long  x){long  ans = 1; for(int i = 1 ;i < x+1; i++){ans = ans *i;}return ans;}

long  permutation(long  x, long  y){return factorial(x)/factorial(x-y);}

//long combination(long x, long y){long ans = 1;if(y == 0){return 1;}	if(x-y < y){return combination(x,x-y);}for(long i = 0; i < y; i++){	ans *= (x-i);}	for(long i = 0; i < y; i++){ans /= (i+1);	}

#define MOD 1000000007
#define INF 1000000000000

template<class T1, class T2>
long Min(T1 a, T2 b){
    return (a > b ? b : a);
}
template<class T1, class T2>
long Max(T1 a, T2 b){
    return (a < b ? b : a);
}

int main(){
  long a,b,h;
  cin >> a >> b >>h;

  cout << (a + b) * h / 2 << endl;
  return 0;

}


Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int k;
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    cin>>k;
    ll ans;
    sort(a,a+3);
    rep(i,0,k-1){
        a[2] = a[2]*2;
    }
    ans = a[0] + a[1] + a[2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
ANS = 0
SUM = 0
def dfs(arr, l):
    global SUM, ANS
    if l == N:
        for i in range(Q):
            if arr[A[i][1]-1]-arr[A[i][0]-1] == A[i][2]:
                SUM += A[i][3]
            ANS = max(SUM, ANS)
        SUM = 0
        return
    else:
        for i in range(arr[l-1], M+1):
            arr.append(i)
            l = len(arr)
            dfs(arr,l)
            arr.pop()

    return ANS

if __name__ == '__main__':
    N, M ,Q = map(int, input().split())
    A = [list(map(int, input().split())) for i in range(Q)]
    for i in range(M):
        pANS = ANS
        ARR = deque([i+1])
        dfs(ARR,1)
        ANS = max(pANS, ANS)
    print(ANS)

Measured memory_bytes: 9472
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

int gcd(int a,int b)  {
	if (a%b==0)  return(b);
	else return(gcd(b,a%b));
}

int main() {
    int N, i; cin >> N >> i;
    
    cout << (N-1)*(i-1) << endl;

    return 0;
}


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

using tlll = tuple<ll,ll,ll>;


int main() {
 
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N),G(N,1),MV(N,1e6);
    for(ll i=0;i<N;i++){
        cin >> A[i];
    }
    ll maxl=0;
    MV[N-1]=1;
    for(ll i=N-1;i>=0;i--){
        
        for(ll j=i+1;j<N;j++){
            
            if(abs(A[j]-A[i])<=K){
                
                G[i]=max(G[i],G[j]+1);
                if(maxl<G[j]+1){
                    maxl=G[j]+1;
                    MV[i]=maxl;
                    break;
                }
                if(MV[j]<=G[i]-1){
                    MV[i]=maxl;
                    break;
                    
                }
            }
            
        }
        
        
    }
    
    sort(G.begin(),G.end());
    cout << G[G.size()-1] << endl;
    
}



Measured memory_bytes: 10384
a,b,x = map(int,input().split())
import math
mild = b*a**2/2
if x < mild:
    print(90 - math.degrees(math.atan((2*x)/(a*(b**2)))))
else:
    print(math.degrees(math.atan((2*(a**2*b-x))/a**3)))


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    char a, b, ans;
    cin >> a >> b;
    if(a>b) ans = '>';
    else if(a==b) ans = '=';
    else ans = '<';
    cout << ans << endl;
}


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

using namespace std;

int main(){
    vector<int> v(101, 0);
    int x,m = 0;
    while(cin >> x){
	v[x]++;
	m = max(m, v[x]);
    }
    for(int i = 1 ; i <= 100 ; i++){
	if(m == v[i]){
	    cout << i << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main(){
int N; cin >> N;
  vector<pair<int,int>> AB(N); vector<pair<int,int>> CD(N);
  
  vector<bool> flag = {false};
  
  for(int i = 0; i < N; i++){cin >> AB[i].first >> AB[i].second;}
  
  for(int j = 0; j  <N; j++){cin >> CD[j].first >> CD[j].second;}
  
  sort(CD.begin(),CD.end());
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){
    int x = CD[i].first;
    int y = CD[i].second;
    int number = -1;
    int max_alt = -1;
    for(int j = 0; j < N; j++){
      if( AB[j].first < x && AB[j].second < y && flag[j] == false){
        if( AB[j].second > max_alt){
          max_alt = AB[j].second; number = j;}}}
    if(max_alt != -1){ flag[number] = true; //j番目のAB点が繋がる(もう使えない)
                      cnt++;}}
  
  cout<< cnt << endl; return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int fill_color(std::vector<std::vector<long long int> > &G, std::vector<std::vector<long long int> > &G_index, std::vector<long long int> &color, long long int index, long long int c, long long int K){
  
  // for all edges from index
  long long int count = 1;
  long long int col;
  for(long long int i = 0; i < G[index].size(); i++){
    if(color[G_index[index][i]] == 0){ // the vertex has not been visited yet
      col = (c + count)%K;
      if(col == 0)col = K;
      color[G_index[index][i]] = col;
      fill_color(G, G_index, color, G[index][i], col, K);
      count++;
    }
  }
  return 1;
}

int main(){
  
  
  // read problem
  long long int N, tmp1, tmp2;
  scanf("%lld", &N);
  std::vector<std::vector<long long int> > G(N);
  std::vector<std::vector<long long int> > G_index(N);
  for(long long int i = 0; i < N-1; i++){
    scanf("%lld%lld", &tmp1, &tmp2);
    G[tmp1-1].push_back(tmp2-1);
    G_index[tmp1-1].push_back(i);
    G[tmp2-1].push_back(tmp1-1);
    G_index[tmp2-1].push_back(i);
  }
  
  // solve problem
  long long int K = 0;
  for(long long int i = 0; i < N; i++){
    K = std::max(K, (long long int)G[i].size());
  }
  
  
  // construct answer
  std::vector<long long int> color(N-1);
  fill_color(G, G_index, color, 0, 0, K);


  std::cerr << "Answer:" << std::endl;
  std::cout << K << std::endl;
  for(long long int i = 0; i < N-1; i++){
    std::cout << color[i] << std::endl;
  }
   
  
  return 0;
}
  


Measured memory_bytes: 13440
#include<iostream>

using namespace std;

int main(void) {
  char date[11];
  cin >> date;
  if (date[6] <= '4' && date[5] == '0') {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
     

  return 0;
}


Measured memory_bytes: 760