akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int mod=1000000007;
int b[210];
int kt[210];
int c[10];
long long dp[1100][1100];
long long C[1100][1100];
long long fact[1100];
long long inv[1100];
long long factinv[1100];
long long ks[1100];
int calc(vector<int>v){
	int n=v.size();
	for(int i=0;i<v.size();i++){
		kt[i]=0;
		int tmp=v[i];
		while(tmp){
			tmp/=10;
			kt[i]++;
		}
		if(kt[i]==0)kt[i]++;
	}
	for(int i=0;i<n;i++){
		ks[i]=0;
		for(int j=0;j<=i;j++){
			ks[i]=(ks[i]+fact[i]*factinv[i-j])%mod;
		}
	}
	for(int i=0;i<10;i++)c[i]=0;
	for(int i=0;i<n;i++)c[kt[i]]++;
	long long ret=0;
	for(int i=1;i<=5;i++){
		if(!c[i])continue;
		for(int j=0;j<1100;j++)for(int k=0;k<1100;k++)dp[j][k]=0;
		dp[0][0]=1;
		for(int j=1;j<=5;j++){
			int has=c[j];
			if(i==j)has--;
			while(has--){
				for(int k=n-1;k>=0;k--)for(int l=0;l<810;l++){
					if(!dp[k][l])continue;
					dp[k+1][l+j]=(dp[k+1][l+j]+dp[k][l]*(k+1))%mod;
				}
			}
		}
		long long sum=0;
		for(int j=0;j<n;j++)if(i==kt[j])sum+=v[j];
		for(int j=0;j<810;j++){
			for(int k=0;k<n;k++){
			//	if(dp[k][j]*sum%mod*ks[n-k-1])printf("%d %d %d: %lld %lld %lld\n",i,j,k,dp[k][j],ks[n-k-1],dp[k][j]*sum%mod*ks[n-k-1]%mod);
				ret=(ret+dp[k][j]*sum%mod*ks[n-k-1])%mod;
			}
			sum=sum*10%mod;
		}
	}
	return (int)ret;
}
int main(){
	C[0][0]=1;
	fact[0]=1;
	inv[1]=1;
	for(int i=2;i<1100;i++)inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	factinv[0]=1;
	for(int i=1;i<1100;i++)factinv[i]=factinv[i-1]*inv[i]%mod;
	for(int i=1;i<1100;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=0;i<1050;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=(C[i+1][j]+C[i][j])%mod;
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%mod;
		}
	}
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	bool zr=false;
	vector<int>tmp;
	for(int i=0;i<a;i++){
		if(!b[i])zr=true;
		else tmp.push_back(b[i]);
	}
	int ret=0;
	if(zr){
		ret=mod-calc(tmp);
		tmp.push_back(0);
	}
	ret=(ret+calc(tmp))%mod;
	printf("%d\n",ret);
}

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

const int N = 5e5 + 5;
long long arr[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    long long k;
    cin>>n>>k;
    for(int i = 0 ; i<n ; ++i)
    {
        cin>>arr[i];
    }

    sort(arr , arr+n);
    long long l = -1e18 , r = 1e18;

    while(l<r)
    {
        long long mid = l + (r-l)/2;
        long long sum = 0;
        for(int i = 0 ; i<n ; ++i)
        {
            if(arr[i] == 0)
            {
                if(mid>=0) sum += n-1;
            }
            else
            {
                if(arr[i] > 0)
                {
                    if(mid <= 0)
                    {
                        long long rem = mid/arr[i];
                        int idx;
                        if(abs(mid)%abs(arr[i])==0) idx = upper_bound(arr , arr+n, rem) - arr;
                        else idx = lower_bound(arr , arr+n, rem) - arr;
                        idx--;
                        sum += (idx+1) - (arr[i] < rem);
                        if(abs(mid)%abs(arr[i])==0) sum -= arr[i] == rem;
                    }
                    else
                    {
                        long long rem = mid/arr[i];
                        int idx = upper_bound(arr , arr+n, rem) - arr;
                        idx--;
                        sum += (idx+1) - (arr[i] <= rem);
                    }
                }
                else
                {
                    if(mid <= 0)
                    {
                        long long rem = mid/arr[i];
                        int idx;
                        if(abs(mid)%abs(arr[i])==0) idx = lower_bound(arr , arr+n, rem) - arr;
                        else idx = upper_bound(arr , arr+n, rem) - arr;
                        sum += n - idx - (arr[i] > rem);
                        if(abs(mid)%abs(arr[i])==0) sum-= arr[i] == rem;
                    }
                    else
                    {
                        long long rem = mid/arr[i];
                        int idx = lower_bound(arr , arr+n, rem) - arr;
                        sum += n - idx - (arr[i] >= rem);
                    }
                }
            }
        }
        sum/=2;
        if(sum >= k) r = mid;
        else l = mid+1;
    }

    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A;
  std::string B;
  std::cin >> A >> B;

  B.erase(1, 1);
  std::cout << A * std::stoi(B) / 100 << std::endl;
  return 0;
}

Measured memory_bytes: 3628
BIG_NUM = 2000000000
 
 
N = int(input())
x = 0
 
for i in range(1,N+1):
 
    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()


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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;

	int ans = 0, up;

	for (int a = 1; a < n; a++) {
		up = n / a;

		ans += up;
		if (a * up == n)
			ans--;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3664
n=int(input())
s=input()

#初期化
ind=1
while 2**ind<=n:
    ind+=1
s+="*"*(2**ind-n)
seg=[]
seg2=[]

from collections import deque
tmp=deque([s])
while len(tmp)>0:
    t=tmp.popleft()
    cnt=0
    for ss in t:
        if ss!="*":
            cnt=cnt|2**(ord(ss)-97)
    seg.append(cnt)
    seg2.append(t)
    if len(t)>1:
        tmp.append(t[:len(t)//2])
        tmp.append(t[len(t)//2:])

#セグ木が出来た！
#print(seg)
#print(seg2)

q=int(input())

def change(i,s):
    #i文字目をsに変更する
    #nの親は(n-1)//2
    #nの子は2n+1,2n+2
    global n,seg,ind
    ii=len(seg)-2**ind+i-1
    seg[ii]=2**(ord(s)-97)
    p=(ii-1)//2
    while 1:
        seg[p]=seg[2*p+1]|seg[2*p+2]
        if p==0:
            break
        p=(p-1)//2

    #print(seg)

from collections import deque


def count(l,r):
    global n,seg,s
    #nの親は(n-1)//2
    #nの子は2n+1,2n+2

    d = deque([(1,len(s),0)])
    ans=0

    while len(d)>0:
        tmp=d.popleft()
        #print(tmp)
        ll,rr,i=tmp[0],tmp[1],tmp[2]
        if l<=ll and rr<=r:
            ans=ans|seg[i]
        elif (ll<=l and l<=rr) or (ll<=r and r<=rr):
            d.append((ll,ll+(rr-ll)//2,2*i+1))
            d.append((ll+(rr-ll)//2+1,rr,2*i+2))

    return str(bin(ans)).count("1")


result=[]


for _ in range(q):
    b,i,c=map(str,input().split())
    if b=="1":
        #i文字目をcに変更
        change(int(i),c)
    else:
        #l文字目からr文字目までに含まれる数
        result.append(count(int(i),int(c)))

for item in result:
    print(item)










    
         


Measured memory_bytes: 189292
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 998244353
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
bool mycompare(ll a,ll b){
    return a>b;
    }
int dp[100005];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast;
    int n,k;
    cin>>n>>k;
    vi a(n);
    fri(0,n)
        cin>>a[i];
    memset(dp,0,sizeof dp);
    dp[0]=0;
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0 && dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    dp[k]?cout<<"First":cout<<"Second";

}


Measured memory_bytes: 3900
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int pseudo = ((A+9)/10 + (B+9)/10 + (C+9)/10 + (D+9)/10 + (E+9)/10) * 10;
  // cout << pseudo << endl;
  int res = 10;
  if (A%10 != 0 && A%10 <= res) res = A%10;
  if (B%10 != 0 && B%10 <= res) res = B%10;
  if (C%10 != 0 && C%10 <= res) res = C%10;
  if (D%10 != 0 && D%10 <= res) res = D%10;
  if (E%10 != 0 && E%10 <= res) res = E%10;
  int ans = pseudo - (10 - res);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n,a,b;
ll pow_mod(ll a, ll n)
{
    if(n == 0) return 1;
    ll x = pow_mod(a, n/2);
    ll ans = x * x % mod;
    if(n % 2 == 1) ans = ans *a % mod;
    return ans%mod;
}

ll C(ll n,ll m) {
    if(n < m) return 0;
    ll res = 1;
    for(ll i=1; i<=m; i++) {
        ll a = (n+i-m)%mod;
        ll b = i%mod;
        res = res*(a*pow_mod(b,mod-2)%mod)%mod;
    }
    return res;
}

ll Lucas(ll n,ll m) {
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}
int main()
{
	//freopen("input.txt","r",stdin);
	cin>>n>>a>>b;
	if(n==2 and a==1 and b==2) cout<<0<<endl;
	else if(n==3 and a==2 and b==3) cout<<3<<endl;
	else
	{
		//cout<<pow_mod(2,n)<<endl<<Lucas(n,a)<<endl<<Lucas(n,b)<<endl;
	cout<<(pow_mod(2,n)+mod+mod-Lucas(n,a)-Lucas(n,b)-1LL)%mod<<endl; 
	
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::map<int, int> mp;
	for (size_t i = 0; i < n; i++) {
		int temp;
		std::cin >> temp;
		auto itr = mp.find(temp);
		if (itr != mp.end()) {
			mp[temp]++;
		}
		else {
			mp[temp] = 1;
		}
	}

	ll ans = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->first < itr->second) {
			ans += (itr->second - itr->first);
		}
		if (itr->first > itr->second) {
			ans += itr->second;
		}
	}

	std::cout << ans << '\n';
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    auto s = vector<vector<int>>(n + 1);
    for (int i = 2; i <= n; i++) {
        int a_i;
        cin >> a_i;
        s[a_i].emplace_back(i);
    }

    for (int i = 1; i <= n; i++) {
        cout << s[i].size() << "\n";
    }
    return 0;
}


Measured memory_bytes: 13924
N,K = map(int,input().split())
a = list(map(int,input().split()))
A = []
for l in range(N):
    ans = 0
    for r in range(l,N):
        ans += a[r]
        A.append(ans)
bi = 0
while 2**bi <= max(A):
    bi += 1
bi -= 1

def funk(x,L):
    if x == -1:
        return L
    M = []
    b = 2**x
    for i in L:
        if i&b == b:
            M.append(i)
    if len(M) >= K:
        return funk(x-1,M)
    else:
        return funk(x-1,L)

B = funk(bi,A)
ans = B[0]
for i in B[:K]:
    ans &= i
print(ans)

Measured memory_bytes: 33180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

int main(void) {
    LL X, Y;
    cin >> X >> Y;

    LL ans = 0;
    for(LL i = X; i <= Y; i *= 2) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		//double x = (c * e - f * b) / (a * e - d * b);
		double y = (c * d - f * a) / (b * d - a * e);
		double x = (- b * y + c) / a;
		
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1292
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int>num;
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int x;cin>>x;
		num.push_back(x); 
	}
	for(int i=0;i<N;i++)
	{
	num.push_back(num[i]-1);
	num.push_back(num[i]+1);
    }
    sort(num.begin(),num.end());
    //for(int i=0;i<num.size();i++) cout<<num[i]<<endl;
    int time,Max=-1,tmp=-999;
    for(int i=0;i<num.size();i++)
    {
    	if(tmp!=num[i])
    	{
    		time=1;
    		tmp=num[i];
    	}
    	else{
    		time++;
    	}
    	if(time>Max)
    	Max=time;
    }
    cout<<Max<<endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
const double pi=3.14159265359;
const int mod = 1e9 + 6;
//Actual Code Is At The Top
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int32_t main()
{   
	very_slow
//	no_of_test(x)
	{
     int x;
	 cin>>x;
	 if(x==0)
	 {
		 cout<<1<<'\n';
	 }
	 else
	 {
		 cout<<0<<'\n';
	 }
	 
	}
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  for(int i=1; i<=B; i++){
    if(i*A%B==C){
      cout << "YES" << endl;
      return 0;
    }
  }cout << "NO" << endl;
}

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

int dt[101][101];
int d[101];

int n;
int t=0;
void bfs(int s){
	queue<int> que;
	d[s]=0;
	que.push(s);
	while(!que.empty()){
		int nxt=que.front();que.pop();
		for(int i=1;i<=n;i++){
			if(dt[nxt][i]&&d[i]==-1){
				que.push(i);
				d[i]=d[nxt]+1;
			}
		}
	}
}
int main(){
	int fi, v, g;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		d[i]=-1;
	for(int i=1;i<=n;i++){
		scanf("%d %d",&fi,&v);
		for(int j=1;j<=v;j++){
			scanf("%d",&g);
			dt[fi][g]=1;
		}
	}
	d[1]=0;
	bfs(1);
			
	for(int i=1;i<=n;i++){
		printf("%d %d\n",i,d[i]);
	}
	return 0;
}

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


int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3916
N = int(input())

ans = 0
temp = N
fact = []

if N == 1:
    print(0)
    exit()
for i in range(2, int(N ** 0.5 + 2)):
    if temp % i == 0:
        n = 0
        while temp % i == 0:
            temp //= i
            n += 1
        fact.append(n)
if temp != 1:
    fact.append(1)

ans = 0
for f in fact:
    n = f
    i = 1
    while True:
        n -= i
        i += 1
        if n < 0:
            break
        ans += 1

print(max(ans, 1))

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

using namespace std;

#define int long long

signed main(){
    int N;
    scanf("%lld",&N);
    for(int h = 1 ; h <= 3500 ; h++){
        for(int w = 1 ; w <= 3500 ; w++){
            if((4*h*w-N*w-N*h) != 0&&(N*h*w)%(4*h*w-N*w-N*h)==0 && (N*h*w)/(4*h*w-N*w-N*h) > 0 ){
                printf("%lld %lld %lld\n",h,(N*h*w)/(4*h*w-N*w-N*h),w);
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int n,flag=0,max=0;
	cin>>n;
	while(n--)
	{
	    int d1,d2;
	    cin>>d1>>d2;
	    if(d1==d2)
        {
          flag++;
          if(flag>=3)
            max++;
        }
	    else
	    flag=0;
	}   
	if(max>0)
	cout<<"Yes";
	else
	cout<<"No";
	
	return 0;
}


Measured memory_bytes: 3652
<?php

$stdin = fopen('php://stdin', "r");
fscanf($stdin, "%d", $n);
$arr = array_map('intval', explode(' ', fgets($stdin)));

sort($arr);

$midI = count($arr) / 2; // 中間のindex これ以上の値が出たら
$c = $arr[$midI] - $arr[$midI-1];
# echo sprintf("%d %d\n", $arr[$midI-1], $arr[$midI]);
echo "$c\n";

Measured memory_bytes: 35640
#include <iostream>
#include <vector>

using namespace std;

int d, g;
int p[10];
int c[10];

void dumpbin(int bit) {
    for (int i = d; i > 0; --i) {
        cout << (((bit >> (i - 1)) & 1) ? '1' : '0');
    }
}

int main(){
    cin >> d >> g;

    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }

    int minans = 10000;
    for (int bit = 0; bit < (1 << d); ++bit) {
        int ans = 0;
        int cs = 0;
        for (int i = d; i > 0; --i) {
            if ((bit >> (i - 1)) & 1) {
                ans += p[i - 1];
                cs += p[i - 1] * i * 100 + c[i - 1];
            }
        }
        // cout << ans << endl;
        // cout << cs << endl;
        for (int i = d; i > 0; --i) {
            if ((bit >> (i - 1)) & 1) continue;
            int score = i * 100;
            int rest = g - cs;
            int mx = p[i - 1] - 1;
            if (rest <= 0) break;
            int num;
            if (mx * score >= rest) {
                num = (rest + score - 1) / score;
            } else {
                num = mx;
            }
            ans += num;
            cs += num * score;
            // cout << score << " " << num << endl;
        }
        if (cs >= g && ans < minans) minans = ans;
        // dumpbin(bit);
        // cout << " ans = " << ans << endl;
    }
    cout << minans << endl;
}

Measured memory_bytes: 888
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    int N, M;
    cin >> N >> M;

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> ans(N, -1);
    queue<int> que;

    ans[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int nv : G[v]) {
            if (ans[nv] != -1) {
                continue;
            }

            ans[nv] = v + 1;
            que.push(nv);
        }
    }

    bool isok = true;
    for (int v = 1; v < N; v++) {
        if (ans[v] == -1) {
            isok = false;
            break;
        }
    }

    if (isok) {
        cout << "Yes" << endl;
        for (int v = 1; v < N; v++) {
            cout << ans[v] << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> a(n); rep(i,n) cin >> a[i];
  vector<int> M(n); //max

  M[0] = a[0];
  for(int i = 1;i<n;++i) M[i] = max(M[i-1],a[i-1]);
  
  //rep(i,n) cout << M[i] << endl;
  ll sum = 0;
  rep(i,n){
    if(a[i]<M[i]) sum+=M[i]-a[i];
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 4752
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))

exhaustive_dict = {}

def create_exhastive_list(head, sum):
    for i in range(head, N):
        sum += A[i]
        exhaustive_dict[sum] = 1
        create_exhastive_list(i+1, sum)
        sum -= A[i]

head = 0
sum = 0
create_exhastive_list(head, sum)

for target in M:
    if target in exhaustive_dict.keys():
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5644
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 2000;

int n,m;
ll mod = INF;
ll dp[maxn+1][maxn+1]={0};
ll sum[maxn+1][maxn+1]={0};
ll s[maxn+1],t[maxn+1];

int main(){
    
    cin >> n>>m;
    rep(i,n)cin >> s[i+1];
    rep(i,m)cin >> t[i+1];
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i]==t[j]){
                dp[i][j]=(sum[i-1][j-1]+1)%mod;
            }else{
                dp[i][j]=0;
            }
            sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod;
            if(sum[i][j]<0)sum[i][j]+=mod;
        }
    }
    
    cout << (sum[n][m]+1)%mod<<endl;
    
    return 0;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
           string s;
           cin>>s;
           int  n=s.size();
           for(int i=0;i<(n-1)/2;i++){
                   if(s[i]!=s[(n-1)/2 -1-i]){
                           cout<<"No";
                           return 0;
                   }
                   if(s[(n+3)/2-1+i]!=s[(n+3)/2-1+(n-1)/2 -1-i]){
                           cout<<"No";
                           return 0;
                   }
           }
           for(int i=0;i<n;i++){
                   if(s[i]!=s[n-1-i]){
                           cout<<"No";
                           return 0;
                   }
           }
           cout<<"Yes";
         
}

        


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> grid(h, 15);
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        grid[y] ^= (1 << x);
    }
    vector<array<int, 16>> dp(h);
    for (auto &&i : dp) fill(i.begin(),i.end(), -INF<int>);
    dp[0][grid[0]] = 0;
    for (int i = 1; i < h; ++i) {
        for (int S = 0; S < 16; ++S) {
            if(dp[i-1][S] < 0) continue;
            for (int T = grid[i]; ; T = grid[i]&(T-1)) {
                chmax(dp[i][T], dp[i-1][S]);
                if((S&3) == 3 && (T&3) == 3) chmax(dp[i][T^3], dp[i-1][S]+1);
                if((S&6) == 6 && (T&6) == 6) chmax(dp[i][T^6], dp[i-1][S]+1);
                if((S&12) == 12 && (T&12) == 12) chmax(dp[i][T^12], dp[i-1][S]+1);
                if((S&15) == 15 && (T&15) == 15) chmax(dp[i][T^15], dp[i-1][S]+2);
                if(!T) break;
            }
        }
    }
    cout << *max_element(dp.back().begin(),dp.back().end()) << "\n";
    return 0;
}


Measured memory_bytes: 3596
# coding:utf-8

S = input()
DAY_OF_WEEK = ('SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT')

for i, day_of_week in enumerate(DAY_OF_WEEK):
	if(day_of_week == S):
		print(7-i)
		break

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = (a + b)/2;
        
        if((a + b) % 2 == 1){
            x = x + 1;
            System.out.println(x);
        }else{
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 21840
N, X = list(map(int, input().split()))
ans = N
a, b = sorted([X, N - X])
while True:
    if b % a == 0:
        ans += (int(b / a) * 2 - 1) * a
        break
    else:
        ans += int(b // a) * a * 2
        a, b = b % a, a

print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
  int n, m, l = 0;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    l += a;
  }
  if (l > n) {
    cout << -1 << endl;
  } else {
    cout << n - l << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)

	L := getInt()

	x := float64(L * L * L)
	fmt.Printf("%g\n", x/27)
}


Measured memory_bytes: 640
X = gets.to_i
ans = 0
(1..(Math.sqrt(X).to_i)).each do |n|
  if n == 1
    ans = [ans, 1].max
    next
  end
  m = 2
  while n ** m <= X
    ans = [ans, n ** m].max
    m += 1
  end
end
puts ans


Measured memory_bytes: 1788
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string s,t; cin >> s >> t;
    SORT(s); SORT(t); REVERSE(t);
    cout << (s<t ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x=0,k=0;
  cin >> k >>x;
  for(int i=(x-k+1);i<k+x;i++){
   if(k+x-1 != i) cout << i << " ";
   else cout << i << endl;
  }
}


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

int main(){

  long long int K;
  scanf("%lld", &K);

  std::cerr << "Answer: " << std::endl;
  if(K%2 ==1){
    std::cout << ((K-1)*(K+1))/4 << std::endl;
  }
  else{
    std::cout << (K*K)/4 << std::endl;
  }

  return 0;
}


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

using namespace std;

int main()
{
	for (;;)
	{
		string	Card;
		cin >> Card;
		if (Card == "-")		break;

		size_t	CSize = Card.size();
		Card += Card;

		int		SCnt;
		cin >> SCnt;
		int		sum = 0;
		int		h;
		for (int i = 0; i < SCnt; i++)
		{
			cin >> h;
			sum += h;
		}

		sum %= CSize;

		cout << Card.substr(sum, CSize) << endl;
	}

	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template <bool P = 0> struct SegmentTree {
  #define lson L, R, N[u].l
  #define rson L, R, N[u].r
  #define OUT R <= N[u].L || N[u].R <= L
  #define IN  L <= N[u].L && N[u].R <= R
  struct Node { int L, R, l, r;
    LL maxV, idx;
  };
  vector<Node> N; int p, n; vector<int> rt;
  inline void init(int _n) { N.resize(_n * (P ? 40:4));
    n = _n; p = 1; rt.assign(1, build(0, n));
  }
  inline int copy(Node u) { return N[p] = u, p++; }
  int build(int L, int R) {
    int u = copy({L, R}), M = (L + R) >> 1;;
    if (R - L == 1) return N[u].idx = L, u;
    return pull(u, build(L, M), build(M, R));
  }
  inline int push(int u) {
    return u;
  }
  inline int pull(int u, int l, int r) {
    if (!l || !r) return l ? l : r;
    N[u].L = N[l].L; N[u].R = N[r].R;
    push(N[u].l = l); push(N[u].r = r);
    if (N[l].maxV >= N[r].maxV)
      N[u].idx = N[l].idx;
    else
      N[u].idx = N[r].idx;
    N[u].maxV = max(N[l].maxV, N[r].maxV);
    return u;
  }
  int m(int L, int R, int u, LL v) {
    if (OUT) return u; push(u);
    if (P) u = copy(N[u]);
    if (IN) return N[u].maxV = v, u;
    return pull(u, m(lson, v), m(rson, v));
  }
  int q(int L, int R, int u) {
    if (OUT) return 0; push(u); if (IN) return u;
    return pull(copy(N[u]), q(lson), q(rson));
  }
  inline void modify(int L, int R, int ver, LL v) {
    rt[ver] = m(L, R, rt[ver], v);
  }
  inline Node& query(int L, int R, int ver) {
    if (!P) p = 2 * n; return N[q(L, R, rt[ver])];
  }
  inline int lb(int x, LL v, int ver) {
    if (!P) p = 2 * n; return lb_q(x, v, rt[ver]);
  }
  int lb_q(int x, LL v, int u) {
    if (N[u].R - N[u].L == 1)
      return (N[u].maxV >= v) ? u : 0;
    if (N[N[u].l].R > x) {
      int left = lb_q(x, v, N[u].l);
      if (left && N[left].maxV >= v)
        return left;
    }
    return lb_q(x, v, N[u].r);
  }
};
SegmentTree solver;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, q; cin >> n >> q;
    solver.init(n);
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v;
        solver.modify(i, i + 1, 0, v);
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; LL v; cin >> x >> v; x--;
            solver.modify(x, x + 1, 0, v);
        } else if (t == 2) {
            int l, r; cin >> l >> r; l--;
            cout << solver.query(l, r, 0).maxV << '\n';
        } else {
            int x; LL v; cin >> x >> v; x--;
            int res = solver.lb(x, v, 0);
            if (res == 0) {
                cout << n + 1 << '\n';
            } else {
                cout << solver.N[res].idx + 1 << '\n';
            }
        }
    }
}

Measured memory_bytes: 28228
#include <stdio.h>
char map[8][8];
void boom(int x,int y){
    if(x>7||y>7||x<0||y<0)return;
    if(map[x][y]=='0')return;
    map[x][y]='0';
    for(int i=1;i<=3;i++){
        boom(x+i,y);
        boom(x-i,y);
        boom(x,y+i);
        boom(x,y-i);
    }
    return;
}
int main(){
    int t,x,y;
    scanf("%d",&t);
    for(int j=1;j<=t;j++){
        for(int i=0;i<8;i++)scanf("%s",map[i]);
        scanf("%d%d",&x,&y);
        printf("Data %d:\n",j);
        boom(y-1,x-1);
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++)printf("%c",map[i][j]);
            printf("\n");
        }
    }
}

Measured memory_bytes: 2612
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    int maxi = a; maxi = max(maxi, b); maxi = max(maxi, c);
    a = maxi - a;
    b = maxi - b;
    c = maxi - c;

    int odd = 0;
    if(a % 2 != 0) odd++;
    if(b % 2 != 0) odd++;
    if(c % 2 != 0) odd++;

    int res = 0;
    if(odd == 0){
        res = (a + b + c) / 2;
    }
    else if(odd == 1){
        res = (a + b + c + 3) / 2;
    }
    else if(odd == 2){
        res = (a + b + c) / 2;
    }

    cout <<  res << endl;
}

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

int main(){

	int X;
	cin >> X;
	bool isPrime = true;

	for(int i=X; ;++i){
		isPrime = true;
		if(i==2){isPrime=true;}
		else if(i%2==0){isPrime=false;}
		else{
			for(int j=2; j<=sqrt(i); ++j){
				if(i%j==0){isPrime=false; break;}
			}
		}
		if (isPrime){cout<<i<<endl; break;}
	}

	return 0;
}


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

int main() {
	int N;
	int count = 0;
	string S;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> S;

		if (S == "Y") {
			count++;
			break;
		}
	}
	if (count == 1) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e6+5;
int const inf = 1e18;

void solve(){
    int i,j,l;
    int n;
    int a,b,c;
    cin>>a>>b>>c;
    j = max(a,b);
    if(c%j == 0) cout<<c/j<<endl;
    else cout<<c/j + 1<<endl;
}   

int32_t main(){
    IOS;
    int t;
    t = 1;
    // pre();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

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

int main(){
  string s;
  bool ans=false;
  cin >>s;
  for(int i=0;i<s.size()-1;i++){
    if (s.at(i)=='A' && s.at(i+1)=='C'){
      ans=true;
    }}
    if (ans){
      cout <<"Yes"<<endl;
    }
    else{
      cout <<"No"<<endl;
    }}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String ns = sc.next();
    String[] s = ns.split("");
    String answer = "";
    int count = 0;
    for (int i = 0; i < s.length; i++) {
      if (i % 2 == 0) {
        answer += s[i];
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 63496
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	//A
	public static void main(String[] args){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if((Math.abs(b - a )<=d && Math.abs(c-b)<= d)||Math.abs(c-a) <= d)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  ll N, M;
  cin >> N >> M;
  cout << (1900 * M + (N-M) * 100) * pow(2, M) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    ll n;
    cin >> n;
    bool ans = false;
    vector<ll> a(n);
    vector<ll> prime_num(1000100, 0);
    ll number = 1;
    rep(i, n) {
        cin >> a[i];

        if (i == 0)
            number = a[i];
        else
            number = gcd(number, a[i]);

        prime_num[a[i]]++;
    }

    for (ll i = 2; i < 1000100; i++) {
        ll cnt = 0;
        for (ll j = i; j <= 1000100; j += i) {
            cnt += prime_num[j];
        }
        if (cnt >= 2) {
            ans = true;
        }
    }

    if (number == 1) {  // gcd=1;

        if (ans == true) {
            cout << "setwise coprime\n";
        } else {
            cout << "pairwise coprime\n";
        }
    } else {
        cout << "not coprime\n";
    }

    return 0;
}

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

int main(){
    int n,m,r;
    int town[8];
    cin >> n >> m >> r;
    for(int i = 0; i < r; i++){
        cin >> town[i];
    }
    int cost[201][201] = {};
    for(int i = 0; i < 201; i++){
        for(int j = 0; j < 201; j++){
            if(i==j)cost[i][j] = 0;
            else cost[i][j] = 100000000;
        }
    }
    for(int i = 0; i < m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        cost[a][b] = cost[b][a] = c;
    }
    for(int k=1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    sort(town,town+r);
    int res = 1000000000;
    do{
        int tmp = 0;
        for(int i = 0; i < r - 1; i++){
            tmp += cost[town[i]][town[i+1]];
        }
        res = min(res, tmp);
    }while(next_permutation(town,town+r));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ts = [abs(t - x*0.006 - a) for x in h]

now = ts[0]
ans = 1
for i in range(n):
    if ts[i] < now:
        ans = i+1
        now = ts[i]

print(ans)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int x;
    cin >> x;
    for(int i=100; i<=x; i+=100)
    {
        int rem = x-i;
        if(rem<=(i/100)*5)
        {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
A = []
for _ in range(3):
  a,b,c = map(int,input().split())
  A.append([a,b,c])
B = [[1]*3 for i in range(3)]
N = int(input())
for _ in range(N):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == A[i][j]:
        B[i][j] = 0
Answer = 'No'
for i in range(3):
  if sum(B[0])*sum(B[1])*sum(B[2])==0:
    print('Yes')
    exit()
  if (B[0][0]+B[1][0]+B[2][0])*(B[0][1]+B[1][1]+B[2][1])*(B[0][2]+B[1][2]+B[2][2])==0:
    print('Yes')
    exit()
  if (B[0][0]+B[1][1]+B[2][2])*(B[2][0]+B[1][1]+B[0][2])==0:
    print('Yes')
    exit()
print(Answer)

Measured memory_bytes: 3064
#include<cstdio>
#include<iomanip>
#include<iostream>

using namespace std;
const int ma=1e5;
int a[ma];
#define rep(i,n) for(int i=0;i<n;i++)
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    int sum=0,val=0;
    rep(i,n){scanf("%d",a+i);sum+=a[i];if(i%2)val+=a[i];}
    int res[ma];
    res[0]=sum-2*val;
    rep(i,n-1)res[i+1]=2*a[i]-res[i];
    rep(i,n)printf(i==0?"%d":" %d",res[i]);

}

Measured memory_bytes: 2176
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int)1e4 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n;
int fib[MAXN];

void work(){
    fib[0]=fib[1]=1;
    for(int i=2;i<=44;i++) fib[i]=fib[i-1]+fib[i-2];
    scanf("%d",&n);
    printf("%d\n",fib[n]);
}

int main(){
    work();
    return 0;
}




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

#define pb push_back
#define all(a) a.begin(), a.end()

using ll = long long;
using pii = pair<int, int>;

const int N = 83;
int A[N][N], B[N][N];
bool dp[N][N][N * N * 2];

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int H, W; cin >> H >> W;
    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            cin >> A[i][j];
    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            cin >> B[i][j];
    dp[1][1][abs(A[1][1] - B[1][1])] = true;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            for (int k = 0; k < N * N * 2; ++k) {
                if (dp[i][j][k]) {
                    if (i + 1 <= H) {
                        int d1 = abs(A[i + 1][j] - B[i + 1][j]);
                        dp[i + 1][j][k + d1] = true;
                        dp[i + 1][j][abs(k - d1)] = true;
                    }
                    if (j + 1 <= W) {
                        int d2 = abs(A[i][j + 1] - B[i][j + 1]);
                        dp[i][j + 1][k + d2] = true;
                        dp[i][j + 1][abs(k - d2)] = true;
                    }
                }
            }
        }
    }
    int ans = 0;
    while (!dp[H][W][ans])
        ++ans;
    cout << ans << "\n";
}

Measured memory_bytes: 90880
#include<bits/stdc++.h>
int main(){
    int N,i,sum=0,L[200];
    std::cin>>N;
    for(i=0;i<N*2;++i)std::cin>>L[i];
    std::sort(L,L+i);
    for(i=0;i<N*2;i+=2)sum+=L[i];
    std::cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

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


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	int N, T;
	cin >> N >> T;
	vi A(N);
	REP(i, N) {
		cin >> A[i];
	}

	vi d(N);
	int mina = A[0], maxa = A[0], maxd = 0, ans = 0;
	FOR(i, 1, N - 1) {
		if (A[i] < mina) {
			mina = maxa = A[i];
		}
		else if (maxa < A[i]) {
			maxa = A[i];
			if (maxd < maxa - mina) {
				maxd = maxa - mina;
				ans = 1;
			}
			else if (maxd == maxa - mina) {
				ans++;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
h, w, k = map(int, input().split())
s = [list(input()) for _ in range(h)]

n = h

final = 10000000

for ii in range(2**(n-1)):
    ans = 0
    op = [0]*(n-1)
    cnt = 1
    for j in range((n-1)):
        if (ii >> j) & 1:
            op[j] = 1
            cnt += 1
            ans += 1
    
    opp = [0]
    for i in range(n-1):
        opp.append(opp[-1]+op[i])
    h_block = [0]*cnt
    for j in range(w):
        err = False
        tmp = [0]*cnt
        for i in range(h):
            if s[i][j] == '1':
                tmp[opp[i]] += 1
        if max(tmp) > k:
            err = True
            break
        if any(tmp[i] + h_block[i] > k for i in range(cnt)):
                ans +=1
                h_block = tmp[:]
        else:
            for i in range(cnt):
                h_block[i] += tmp[i]
    if err:
        continue
    final = min(final,ans)

print(final)

Measured memory_bytes: 49500