akhauriyash/Code-Regression huggingface dataset:
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
int dp[N][N];
void solve()
{
    int n,m;
    cin>>n>>m;
    rep0(i,n){
        rep0(j,n){
            dp[i][j]=mod;
        }
    }
    vector<pair<pair<int,int>,int>>v;
    rep0(i,m){
        int x,y,c;
        cin>>x>>y>>c;
        --x;--y;
        dp[x][y]=c;
        dp[y][x]=c;
        v.pb({{x,y},c});
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]); 
            }
        }
    }
    int ans=0;
    for(auto p:v){
        if(dp[p.f.f][p.f.s]<p.s) ans++;
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3708
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;

int main()
{
    char n[70];
    int a,i;
    while(~scanf("%s",n))
    {
        if(n[2]==n[3]&&n[4]==n[5])
            printf("Yes\n");
        else
            printf("No\n");
    }






}


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

#define ll long long
#define endl "\n"

vector<ll> adj[100005];
ll vis[100005];
ll n, m;

void add(ll x, ll y) {
  adj[x].push_back(y);
  adj[y].push_back(x);
}

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

int main() {
  ll t;
  // cin >> t;
  t = 1;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 5988
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#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 int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    int min = INF;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }
    int chokudai = 1;
    rep(i, N){
        if(a[i] == chokudai) chokudai++;
    }
    if(chokudai == 1){
        cout << -1 << endl;
    }else{
        cout << N - chokudai + 1 << endl;
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 1024
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  int q,f1,f2;

  cin >> q;
  
  for(ii=0;ii<q;ii++){
    cin >> f1;
    if(f1 == 0){
      cin >> f2;
      ret.push_back(f2);
    }
    else if(f1 == 1){
      cin >> f2;
      cout << ret[f2] << endl;
    }
    else{
      ret.pop_back();
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 3848
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int main(){
	int n;
	
	while(cin>>n){
		if(n==0)break;
		
		int mem[n],min=0;
		
		for(int i=0;i<n;i++){
			cin>>mem[i];
			min+=mem[i];
		}
		
		for(int i=0;i<(1<<n);i++){
			int po=0,go=0;
			
			for(int j=0;j<n;j++){
				if(i>>j&1)po+=mem[j];
				else go+=mem[j];
			}
			if(abs(go-po)<min)min=abs(go-po);
		}
		cout<<min<<endl;
	}
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=5+5e5;
int n,q;
int c[N];
ll ta[N];
int lowbit(int x){ return x&-x;}
void add(int x,int v){ for(int i=x;i<=n;i+=lowbit(i)) ta[i]+=v;}
ll sum(int x){ ll ret=0; for(int i=x;i>0;i-=lowbit(i)) ret+=ta[i]; return ret;}
vector<pair<int,int>> p[N];
unordered_map<int,int> now;
ll ans[N];
int main(){
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>c[i];
    for(int i=1;i<=q;i++){
        int l,r; cin>>l>>r;
        p[r].push_back({l,i});
    }
    for(int i=1;i<=n;i++){
        if(now[c[i]]) add(now[c[i]],-1);
        now[c[i]]=i;
        add(now[c[i]],1);
        for(auto v:p[i]){
            int l=v.first;
            ans[v.second]=sum(i)-sum(l-1);
        }
    }
    for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
}

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

C = N//4
D = N//7
count = 0
for c in range(0,C+1):
    for d in range(0,D+1):
        if (4*c) + (7*d) == N:
            count += 1

if count > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint H, W;
	cin >> H >> W;
	vector<vector<char>>A(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
		}
	}
	rep(i, H) {
		rep(j, W) {
			cout << A[i][j];
		}
		cout << endl;
		rep(j, W) {
			cout << A[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3628
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
count = defaultdict(int)

for i in a:
    count[i] += 1
ans = 0
for i in count:
    ans += count[i]*(count[i]-1)//2
for i in a:
    print(ans-(count[i]-1))

Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
constexpr P NG = {-1, -1};
int main()
{
    for (int H, W;;) {
        cin >> W >> H;
        if (W == 0 and H == 0) { break; }
        vector<string> p(H);
        for (int i = 0; i < H; i++) { cin >> p[i]; }
        p.push_back(string(W, '0'));
        auto in = [&](const int y, const int x) { return y >= 0 and y <= H and x >= 0 and x < W; };
        auto dfs = [&](auto&& self, const int y, const int x) -> pair<P, vector<P>> {
            constexpr int d[] = {-1, 0, 1, 0, -1};
            queue<P> q;
            const char ch = p[y][x];
            q.push({y, x}), p[y][x] = '.';
            vector<P> cell{{y, x}};
            while (not q.empty()) {
                const int y = q.front().first, x = q.front().second;
                q.pop();
                for (int t = 0; t < 4; t++) {
                    const int newy = y + d[t], newx = x + d[t + 1];
                    if (not in(newy, newx) or p[newy][newx] != ch) { continue; }
                    p[newy][newx] = '.', q.push({newy, newx}), cell.push_back({newy, newx});
                }
            }
            P ans = {0, 4};
            for (const auto& c : cell) {
                ans.first += c.second;
                if (not in(c.first - 1, c.second) or p[c.first - 1][c.second] == '.') { continue; }
                const auto sub = self(self, c.first - 1, c.second);
                const auto info = sub.first;
                if (info == NG) { return {NG, {}}; }
                const auto ucell = sub.second;
                int l = W + 1, r = -1;
                for (const auto& c : cell) {
                    for (const auto& u : ucell) {
                        if (c.first - 1 == u.first and c.second == u.second) { l = min(l, c.second), r = max(r, c.second); }
                    }
                }
                if ((2 * l - 1) * info.second < 2 * info.first and 2 * info.first < (2 * r + 1) * info.second) {
                    ans.first += info.first, ans.second += info.second;
                } else {
                    return {NG, {}};
                }
            }
            return {ans, cell};
        };
        const auto ans = dfs(dfs, H, 0);
        cout << (ans.first == NG ? "UN" : "") << "STABLE" << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
print(n-k+1)


Measured memory_bytes: 3316
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    r = I()
    print(r**2)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
def lcm(x, y):
	return (x*y) // gcd(x, y)
aa = a[0]
for i in a[1:]:
	aa = lcm(aa,i)
if aa-max(a) <= 0:
	aa += aa
s = 0
for i in a:
	s += (aa-1)%i
print (s)


Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,a,b;
    cin>>n;
    a=n/100;
    b=n%100;
    if(b%5==0){
        b=b/5;
    }
    else{
        b=b/5+1;
    }
    if(a>=b){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    // 入力
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<pair<int, int>> edges(m);
    vector adjs(n, vector<tuple<bool, int, int>>());
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edges[i] = {a, b};
        adjs[a].emplace_back(true, i, b);
        adjs[b].emplace_back(false, i, a);
    }

    // 接続行列の方程式を解く
    vector used(n, false);
    vector sol(m, false); // solution vector

    // もとの出次数 mod 2
    auto deg = [&adjs](int v) -> bool {
        auto num = count_if(adjs[v].begin(), adjs[v].end(), [](auto p) {
            return get<0>(p);
        });
        return num % 2 != 0;
    };
    auto dfs = [&](auto self, int v) -> bool {
        used[v] = true;
        bool ret = deg(v);
        for (auto &[b, e, u] : adjs[v])
        {
            if (used[u])
            {
                continue;
            }
            bool s = self(self, u);
            sol[e] = s; // mod 2 なので符号は気にしなくてOK
            ret = ret ^ s;
        }
        return ret;
    };

    if (dfs(dfs, 0))
    {
        cout << -1 << "\n";
        return 0;
    }

    // 出力
    rep(e, m)
    {
        auto [a, b] = edges[e];
        if (sol[e])
        {
            swap(a, b);
        }
        ++a;
        ++b;
        cout << a << ' ' << b << '\n';
    }

    return 0;
}


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

int main() {
  int N; cin >> N;
  
  int64_t ans = 0;
  for (int i = 0; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n; ll T,E;
ll x[N];
ll f[N];
typedef long long ll;
struct data{
	ll x,y;int id;
	data(ll x=0,ll y=0,int id=0):x(x),y(y),id(id){}
}t[N];int u,v;


int main()
{
	scanf("%d%lld%lld",&n,&E,&T);
	for(int i=1;i<=n;++i){
		scanf("%lld",&x[i]);
	}
	x[n+1]=E;
	f[0]=x[1];
	/*
	f[i]=min(f[j]+(x[i]-x[j+1])*2+T (x[i]-x[j+1])<=T)
	*/
	u=v=1;t[1]=data(x[1],f[0]-x[1]+T,0);
	
	ll Lmin=1000000000000000000;
	int j=0;
	for(int i=1;i<=n;i++){
		while(u<=v&& 2ll*x[i]-2ll*t[u].x > T ) ++u;
		while(j<i&&2ll*x[i]-2ll*x[j+1] > T){
			Lmin=min(Lmin,f[j]-3ll*x[j+1]);
			++j;
		}
		f[i]=Lmin+3*x[i];
		
		if(u<=v){
			
			f[i]=min(f[i],1ll*x[i]+t[u].y);
		}
		f[i]+=x[i+1]-x[i];
		data newnode=data(x[i+1],f[i]-x[i+1]+T,0);
		//cout<<i<<"::>>>"<<newnode.y<<" "<<f[i]<<" "<<2*x[i+1]<<' '<<T<<endl;
		while(u<=v&&newnode.y <= t[v].y)--v;
		t[++v]=newnode;
//		for(int j=u;j<=v;j++)cout<<t[j].y<<" ";puts("");
//		cout<<i<<" , "<<f[i]<<endl;
	}
//	puts("");
	printf("%lld\n",f[n]);
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 100005
using namespace std;
typedef long long ll;
ll a[N],b[N],sumb[N]= {0};
int main()
{

    ll n,y;
    while(scanf("%lld%lld",&n,&y)==2)
    {
        ll imax=-111111,sum=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%lld%lld",&a[i],&b[i]);
            if(a[i]>imax)
                imax=a[i];
        }
        int num=0;
        sort(b+1,b+1+n);
        for(int i=n; i>=1; i--)
        {
            if(imax<=b[i]&&y>0)
            {
                y=y-b[i];
                num++;
            }
        }
        y=y-sum;
        int r=y/imax;
        if(r>0)
        {
            if(r*imax<y)
                r++;
            num+=r;
        }
        printf("%d\n",num);
    }

}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
S=list(input())
s=[]
ans=[0]*(len(S))

def calc(i,l):
    if l[0]=="R":
        ans[len(l)-1+i]+=(len(l)-len(l)//2)
        ans[len(l)+i]+=len(l)//2
    else:
        ans[i]+=(len(l)-len(l)//2)
        ans[i-1]+=len(l)//2


for index,item in enumerate(S):
    if len(s)==0 or s[-1]==item:
        s.append(item)
    else:
        calc(index-len(s),s)
        s.clear()
        s.append(item)

calc(len(S)-len(s),s)

print(*ans)


Measured memory_bytes: 7844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = 1;
        while (true) {
            int n = input.nextInt();
            if (n == 0) break;
            System.out.println(String.format("Case %d: %d", count++, n));
        }
    }
}

Measured memory_bytes: 51644
N = int(input())
bit = []
for i in range(32):
    b = (N >> i) & 1
    if i % 2 == 0:
        bit.append(b)
        if b:
            N -= 1 << i
    else:
        bit.append(((N >> i) & 1))
        if b:
            N += 1 << i
while bit and bit[-1] == 0:
    bit = bit[:-1]
if not bit:
    bit = [0]
print(*bit[::-1], sep='')

Measured memory_bytes: 3064
<?php
  fscanf(STDIN, "%d", $N);
  $n = floor(sqrt($N));
  $ans = 0;
  for($i=2;$i<$n;$i++){
    $k = 1;
    while(!(pow($i, $k) <= $N && $N < pow($i, $k + 1))){
      $k++;
    }
    $ans = max(pow($i, $k), $ans);
  }
  echo max($n*$n, $ans);
?>

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>

using namespace std;


int main(){

	int n;
	while(1){
		cin>>n;if(n==0)break;
		int P[105]={};
		for(int i=0;i<n;i++){
			cin>>P[i];}

		sort(P,P+n);
		int C=0;
		int x;
		cin>>x;
		int H=(n-1)/2;
		int L=n,S=0;
		while(S<L){
			//cout<<L<<" "<<S<<endl;
			if (L==S){
				//cout<<"%";
				C++;break;
			}
			if (P[H]==x){C++;break;}

			if(P[H]<x){S=H+1;
			H=(S+L-1)/2;C++;//cout<<"#";//cout<<H<<endl;//break;
			}
			else if(P[H]>x){L=H;
				H=(S+L-1)/2;C++;//cout<<"$";//cout<<H;//break;
			}
			
		}
		cout<<C<<endl;
	}
	return 0;
}
		

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

int main() {
    int A, B, Bt;
    cin >> A >> B;
    Bt = B * 10; 
    for (int i = 0; i < 9; i++) {
        if ((int)(Bt * 0.08) == A) {
            cout << Bt << endl;
            return 0;
        }
        Bt ++;
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < n; i++){
        int count = 0;

        for(char c = 'a'; c <= 'z'; c++){
            bool left = false, right = false;

            for(int j = 0; j < i; j++){
                if(s[j] == c){
                    left = true;
                }
            }

            for(int k = i; k < n; k++){
                if(s[k] == c){
                    right = true;
                }
            }

            if(left && right) count++;
        }
        if(ans < count) ans = count;
    }
    cout << ans << endl;
        return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e10

using namespace std;
using edge = tuple<int,int,int>;

int n, m, p;
vector<vi> adj;
vector<edge> edges;
vector<bool> ok;

void dfs(int v)
{
    ok[v] = true;
    for(auto u:adj[v]){
        if (ok[u]) continue;
        dfs(u);
    }
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n>>m>>p;
    adj.resize(n+1);
    ok.resize(n+1, false);
    edges.resize(m);
    rep(i, m){
        int a, b, c; cin>>a>>b>>c;
        adj[b].pb(a);
        edges[i] = make_tuple(a, b, c-p);
    }
    dfs(n);

    bool loop = false;
    vll dist(n+1, -INF);
    dist[1] = 0;
    rep(i, n){
        rep(j, m){
            int from, to, score;
            tie(from, to, score) = edges[j];
            if (!ok[to]) continue;
            if (dist[from]!=-INF && dist[to]<dist[from]+score){
                dist[to] = dist[from]+score;
                if (i==n-1) loop = true;
            }
        }
    }
    if (loop){
        cout << "-1\n";
    }else{
        cout << max(0ll, dist[n]) << "\n";
    }
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<map>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){

    int n,m;
    cin>>n>>m;
   vector<pair<int,int>> s[n];
    int si=1;
    int ansm[m+1];
   rep(i,m){
        int p,m;
        cin>>p>>m;
        ansm[i+1]=p;
        s[p-1].push_back(make_pair(m,si));
        si++;
    }

     rep(i,n)   sort(s[i].begin(),s[i].end());
    
    int ans[m+1];
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].size();j++){
            int h=s[i][j].second;
            ans[h]=j+1;
        }
    }
    /*for(int i=1;i<m+1;i++){
        cout<<ansm[i]<<ans[i]<<endl;
    }*/
    for(int i=1;i<m+1;i++){
        printf("%06d",ansm[i]);
        printf("%06d",ans[i]);
        cout<<endl;
    }
   
return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
int main(void){
   int H,W,K;
   scanf("%d %d %d", &H, &W, &K);
   int dp[101][9] = {0};
   dp[0][0] = 1;
   for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
         for (int k = 0; k < (1 <<W-1); k++) {
            int flag = 1;
            for (int l = 0; l < W-2; l++) {
               if(((k >> (l+1)) & 1) && ((k>>(l)) & 1)) flag = 0;
            }
            if (flag) {
               if (j >= 1 && ((k>>(j-1)) & 1)) {
                  dp[i+1][j-1] += dp[i][j];
                  dp[i+1][j-1] %= MOD;
               } else if (j <= W-2&&((k>>j)&1)) {
                  dp[i+1][j+1] += dp[i][j];
                  dp[i+1][j+1] %= MOD;
               } else {
                  dp[i+1][j] += dp[i][j];
                  dp[i+1][j] %= MOD;
               }
            }
         }
      }
   }
   printf("%d\n",dp[H][K-1]);
   return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
typedef long long int ll;
static const int MAX_K = 100000;
static const int INF = INT_MAX;
struct edge{int to, cost;};

int K;
vector<edge> G[MAX_K];
int dist[MAX_K];

void bfs(int s){
	dist[s] = 1;
	deque<int> dqa;
	dqa.push_front(s);
	while(!dqa.empty()){
		int u = dqa.front(); dqa.pop_front();
		for(int v = 0; v < G[u].size(); v++){
			if(dist[u] + G[u][v].cost < dist[G[u][v].to]){
				dist[G[u][v].to] = dist[u] + G[u][v].cost;
				if(G[u][v].cost == 0) dqa.push_front(G[u][v].to);
				else dqa.push_back(G[u][v].to);
			}
		}
	}
	return ;
}

int main(){
	cin >> K;
	fill(dist, dist + K, INF);
	for(int i = 1; i < K; i++){
		G[i].push_back((edge){(i + 1) % K, 1});
		G[i].push_back((edge){(i * 10) % K, 0});
	}
	bfs(1);
	cout << dist[0] << endl;
	return 0;
}

Measured memory_bytes: 6272
from collections import deque

n = int(input())
V = [[] for i in range(n+1)]

a = [0]*(n-1)
for i in range(n-1):
    A,B = map(int,input().split())
    V[A].append(B)
    V[B].append(A)

c = list(map(int,input().split()))
c = sorted(c, reverse=True)
ans = sum(c[1:])


L = [0]*n
for i in range(1,n+1):
    L[i-1] = [i, len(V[i])]
    
L.sort(key= lambda val : val[1], reverse=True)

q = deque([])
d = [-1] + [0]*n
j = 0

q.append(L[0][0])
d[L[0][0]] = c[0]
j += 1

while q:
    x = q.popleft()
    for y in V[x]:
        if d[y] <= 0:
            q.append(y)
            d[y] = c[j]
            j += 1

print(ans)
for i in range(1,n+1):
    print(d[i],end="")
    print(" ",end="")

Measured memory_bytes: 12788
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
#include <iostream>
#include <string.h>
#include <algorithm>
using  namespace  std;

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#ifdef Cyberdebut
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef pair <int, int> pii;
ll gcd(ll a, ll b){return a ? gcd(b%a,a):b;}
ll pow_mod(ll x, ll n, ll mod){ll ret=1LL;while(n){if(n&1)ret=ret*x%mod;x=x*x%mod;n>>=1;}return ret;}
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<62)-1;
const ll mod = 1e9+7;
const int N = 1e5+5;

int n;

int  main(){
    int a = 0, b = 0, c = 0;
    cin>>n;
    for(int i=1; i<=n; i++){
        int x;
        cin>>x;
        if(x%4 == 0)a++;
        else if(x%2 == 0)b++;
        else c++;
    }
    if(b)c++;
    if(a >= c-1)puts("Yes");
    else puts("No");
    return 0;
}


// lower_bound()
// __builtin_popcount()
// ios::sync_with_stdio(false);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// const double eps=1e-12;
// #pragma comment(linker,"/STACK:102400000,102400000")


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    ll n,x;cin>>n>>x;
    vector<ll>l(n);
    rep(i,n){
        ll a;cin>>a;
        l[i]=abs(a-x);
    }
    ll ans=l[0];
    rep(i,n-1){
        ans=gcd(ans,l[i+1]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin>>N>>M;
    if(N>=2&&M>=2) cout<<(N-2)*(M-2)<<"\n";
    else if(N==1&&M==1) cout<<1<<"\n";
    else if(N>=2) cout<<N-2<<"\n";
    else cout<<M-2<<"\n";
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

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

	int c = 0;

	for (int i = 0; i < s.size(); i++)
		if (s[i] != t[i])
			c++;

	cout << c;

	return 0;
}

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

int main(){
    int n;
    string x;
    int ptime;
    list<int> a;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> x;
        if(x=="insert"){
            int tmp=0;
            cin >> tmp;
            a.push_front(tmp);
        }
        if(x=="delete"){
            int tmp=0;
            cin >> tmp;
            for(list<int>::iterator itr = a.begin(); itr != a.end(); ++itr) {
                if (*itr==tmp){
                    a.erase(itr);
                    break;
                }
            }
        }
        if(x=="deleteFirst"){
            a.pop_front();
        }
        if(x=="deleteLast"){
            a.pop_back();
        }
    }
    for(list<int>::iterator itr = a.begin(); itr != a.end();) {
        cout << *itr ;
        ++itr;
        if (itr!=a.end()){
            cout << " ";
        }
    }
    cout << endl ;
    return 0;
}


Measured memory_bytes: 34300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

const int MAX_V = 1e5;
vector<int> es[3*MAX_V];
vector<int> d(3*MAX_V, inf);

void add_edge(int u, int v){
    rep(i, 3){
        int j = (i+1)%3;
        es[i*MAX_V+u].pb(j*MAX_V+v);
    }
}

void dijkstra(int s){
    priority_queue<pii, vector<pii>, greater<pii> > que;
    d[s] = 0;
    que.push(pii(0, s));
    while(!que.empty()){
        pii p = que.top();
        que.pop();
        int i = p.second;
        if(d[i] < p.first) continue;
        for(auto &e: es[i]){
            if(d[e] > d[i]+1){
                d[e] = d[i]+1;
                que.push(pii(d[e], e));
            }
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        add_edge(u, v);
    }
    int S, T; cin >> S >> T; S--, T--;
    dijkstra(S);
    if(d[T] == inf) cout << -1 << endl;
    else cout << d[T]/3 << endl;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a > b){
        swap(a, b);
    }
    if(a <= b - 1){
        cout << 2 * b - 1 << endl;
    }
    else{
        cout << a + b << endl;
    }
    return 0;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>
#include <fstream>
#include <cstdio>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define mem(a, b) memset(a, (b), sizeof(a))
#define loop(a,b,c) for(int a = b ;a<c;a++)
#define pb(a) push_back(a)
#define MAXN 1000000000
#define fi first
#define se second
using namespace std;

ll max(ll a, ll b){
    if(a>b) return a;
    return b;
}

ll min(ll a, ll b){
    if(a>b) return b;
    return a;
}

int main(){


     ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

     

     string s;
     cin>>s;

     string check = "";

     int cnt = 1;

     rep(i,0,s.size()){

        if(s[i] == '/' || i == (s.size())){
            if(cnt == 1){
                //cout<<check<<endl;
                if(check>"2019"){
                    cout<<"TBD"<<endl;
                    return 0;
                }
                cnt++;
                check  ="";
            }else if(cnt == 2){
               // cout<<check<<endl;
                if(check>"04"){
                    cout<<"TBD"<<endl;
                    return 0;
                }

                cnt++;
                check  ="";
            }else if(cnt == 3){
                //cout<<check<<endl;
                if(check>"30"){
                    cout<<"TBD"<<endl;
                    return 0;
                }

            }
        }else{
            check+=s[i];
        }

     }


     cout<<"Heisei"<<endl;
    


     return 0;
}















































Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
  long start, end, radix;
  cin >> start >> end >> radix;

  long cnt= start != 0 ? (end / radix) - ((start-1) / radix) : end/radix+1;


  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int solve(int x, int y, int z, int k)
{
    for (int i = 0; i < k; i++) {
        x *= 2;
    }
    return x + y + z;
}

int main(int argc, char const* argv[])
{
    int a, b, c, k, ans;
    std::cin >> a >> b >> c;
    std::cin >> k;
    if (a >= b and a >= c) {
        ans = solve(a, b, c, k);
    } else if (b >= c) {
        ans = solve(b, c, a, k);
    } else {
        ans = solve(c, a, b, k);
    }
    std::cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100000];
long long sum[100001];
long long sum2[100001];

int main() {
    int n, k, i;
    long long ans = 0;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i];
        sum2[i + 1] = sum2[i];
        if (a[i] > 0) sum2[i + 1] += a[i];
    }
    
    for (i = 0; i + k <= n; i++) {
        ans = max(ans, sum2[i] - sum2[0] + sum2[n] - sum2[i + k] + max(sum[i + k] - sum[i], 0LL));
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
long long n,now,k,ans,cnt=0,tmp;
int main(){
  cin >> n >> now;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i]=abs(a[i]-now);
  }
  ans=b[0];
  for(int i=0;i<n;i++){
    ans=__gcd(b[i],ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, M;
vector<vector<ll>> edges;
vector<ll> check;

bool isBiparateGraph() {
	check.resize(N, -1);
	stack<pll> st;
	st.push(pll(0, 0));   //頂点、色
	while (!st.empty()) {
		pll cur = st.top();
		st.pop();
		if (check[cur.first] == -1) {
			check[cur.first] = cur.second;
			for (ll ch : edges[cur.first]) {
				st.push(pll(ch, 1 - cur.second));
			}
		}
		else {
			if (check[cur.first] != cur.second) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	edges.resize(N);
	for (ll m = 0; m < M; m++) {
		ll a, b;
		cin >> a >> b;
		edges[--a].push_back(--b);
		edges[b].push_back(a);
	}
	bool isb = isBiparateGraph();
	if (isb) {
		ll zero = 0, one = 0;
		for (ll n = 0; n < N; n++) {
			if (check[n] == 0)zero++;
			else one++;
		}
		cout << zero * one - M << endl;
		return 0;
	}
	else {
		cout << N * (N - 1) / 2 - M << endl;
		return 0;
	}
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
//union find
namespace UnionFind {
	template <typename T>
	void init(vector<T> &u) {
		for(int i = 0; i < u.size(); i++) {
			u[i].parent = i;
		}
	}
	template <typename T>
	int root(vector<T> &u, int x) {
		if(x < 0 || u.size() <= x) return -1;
		else if (x == u[x].parent) return x;
		else return u[x].parent = root(u, u[x].parent);
	}
	template <typename T>
	bool connect(vector<T> &u, int a, int b) {
		a = root(u, a), b = root(u, b);
		if(a == b || a < 0 || b < 0) return false;
		u[b].parent = a;
		return true;
	}
}; using namespace UnionFind;

struct Node {
	int parent;
};
using P = pair<int, int>;
int main() {
    int N, K, L;
	cin >> N >> K >> L;
	vector<Node> a(N);
	init(a);
	vector<Node> b(N);
	init(b);
	for(int i = 0; i < K; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		connect(a, x, y);
	}
	for(int i = 0; i < L; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		connect(b, x, y);
	}
	map<P, int> m;
	for(int i = 0; i < N; i++) {
		P p = {root(a, i), root(b, i)};
		if(!m.count(p)) {
			m[p] = 0;
		}
		m[p]++;
	}
	for(int i = 0; i < N; i++) {
		cout << (i ? " " : "") << m[{root(a, i), root(b, i)}];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

double calc(double h, double x, double r) {
    return h + sqrt(r * r - x * x);
}


int main() {
    int rad, n;
    while (cin >> rad >> n, rad + n) {
	vector<int> X1(n), X2(n), Y(n);
	for (int i = 0; i < n; i++) {
	    cin >> X1[i] >> X2[i] >> Y[i];
	}
	double l = 0, r = 1000, ans = 0.0;
	while (abs(l - r) >= 1e-6) {
	    double mid = (l + r) / 2;
	    vector<bool> H(rad * 2, false);
	    for (int x = -rad; x < rad; x++) {
		if (max(calc(mid - rad, x, rad), calc(mid - rad, x + 1, rad)) <= 0) {
		    H[x + rad] = true;
		}
	    }
	    
	    
	    for (int i = 0; i < n; i++) {
		for (int x = -rad; x < rad; x++) {
		    if (X1[i] <= x && x < X2[i]) {
			double mn = min(Y[i] - calc(mid - rad, x, rad), Y[i] - calc(mid - rad,  x + 1, rad));
			if (mn >= 0) {
			    H[rad + x] = true;
			}
		    }
		}
	    }
	    bool ok = true;
	    for (int i = 0; i < rad * 2; i++) {
		ok &= H[i];
	    }
	    if (ok) {
		ans = mid;
		l = mid;
	    }
	    else {
		r = mid;
	    }
	}
	cout << fixed << setprecision(10) << ans << endl;
    }
    return 0;
}



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

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

    int a,b;
    cin >> a >> b;
  
  int count = 0;

    for(int i=a; i<=b; i++){
      if(i%k==0){
        count++;
        break;
      }
    }
  if(count == 1){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
      
}


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

using namespace std;

int def(string ma, string mi)
{
	for (int i = 0; i < 8; i++)
	{
		if (ma == mi)
			return i;
		mi[mi.size() - 1]++;
		for (int j = mi.size() - 1; j >= 0; j--)
		{
			if (mi[j] != '9' + 1)
				break;
			else if (j - 1 > 0)
				mi[j - 1]++;
			else
				mi.insert(0, "1");
		}
	}
	if (ma == mi)
		return 8;
	return 9;
}

int main()
{
	string n;
	cin >> n;
	int ans = 8, size = n.size();
	for (int i = 1; i < size; i++)
		if (size % i == 0)
		{
			string mi = n.substr(0, i), ma = n.substr(0, i);
			for (int j = 0; j < size; j += i)
			{
				ma = max(ma, n.substr(j, i));
				mi = min(mi, n.substr(j, i));
			}
			ans = min(ans, def(ma, mi));
		}
	int ma = 0, mi = 10, cnt = 0;
	while (cnt < size)
	{
		int tmp;
		if (n[cnt] == '1' && cnt + 1 < size)
		{
			tmp = 10 + (n[cnt + 1] - '0');
			cnt++;
		}
		else
			tmp = n[cnt] - '0';
		cnt++;
		ma = max(ma, tmp);
		mi = min(mi, tmp);
	}
	ans = min(ans, ma - mi);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3360
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
long long a[100];
int main(){
	int n;
	cin>>n;
	a[0] = 2,a[1] = 1;
	for(int i = 2;i <= 86;i++)
	{
		a[i] = a[i - 1] + a[i - 2];
	}
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, M;
	cin >> N >> M;
	int ans = 1;
	for (int A = 1; A * A <= M; A++) {
		if (M % A != 0)continue;
		int B = M / A;
		if (A * N <= M)ans = max(ans, A);
		if (B * N <= M)ans = max(ans, B);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input());l=list(map(int,input().split()));p=[0]*n;d=[0]*n;p[0]=l[0]
for i in range(1,n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if(i&1)else d[i-1],l[i]+d[i-2])
print(d[-1])

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

using namespace std;
using int_vec = vector<int>;


void print(const int_vec& v) {
    auto it = v.begin();
    for (; it != v.end()-1; ++it) {
        cout << *it << " ";
    }
    cout << *it << endl;
}

int merge(int_vec& v, int_vec& left, int_vec& right) {
    int c = 0;
    auto it = v.begin();
    auto l = left.begin();
    auto r = right.begin();
    while (l != left.end() && r != right.end()) {
        if (*l <= *r) {
            *it++ = *l++;
        } else {
            *it++ = *r++;
        }
        ++c;
    }
    if (l != left.end()) {
        copy(l, left.end(), it);
        c += distance(l, left.end());
    } else {
        copy(r, right.end(), it);
        c += distance(r, right.end());
    }
    return c;
}

int merge_sort(int_vec& v) {
    if (v.size() <= 1) {
        return 0;
    }

    auto mid = v.begin() + distance(v.begin(), v.end()) / 2;
    auto left = int_vec(v.begin(), mid);
    auto right = int_vec(mid, v.end());
    auto x = merge_sort(left);
    auto y = merge_sort(right);
    auto z = merge(v, left, right);
    return x + y + z;
}

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

    int_vec v;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    auto c = merge_sort(v);
    print(v);
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 8572
import math

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

a, b = map(int, input().split())

c = math.gcd(a, b)
print(len(set(prime_factorize(c)))+1)

Measured memory_bytes: 9008
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

int main() {

	int k, x;

	cin >> k >> x;

	if (500 * k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 1e6 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int r;
    cin >> r;
    cout << 2.0L * PI * r; 
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3804
#C
from math import factorial
N=int(input())
p=10**9+7
# fac=[1]

# for i in range(1,N+1):
#     fac.append( (fac[-1]*i)%p)
    
if N==1:
    ans=0
else:
    total = pow(10,N,p)
    #0がない
    no_zero = pow(9,N,p)
    no_nine = pow(9,N,p)
    no_both = pow(8,N,p)
    ans= total-(no_zero+no_nine)+no_both
    ans %= p
    #print(total,no_zero,no_both)

print(ans)

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

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define REP(i,a,b) for(int i = a ; i <= b ; ++i) 
# define Rep(i,a,b) for(int i = a ; i < b ; ++i) 
# define Rrep(i,a,b) for(int i = b ; i >= a ; --i) 
# define FOR(i,b) for(int i = 0 ; i <= b ; ++i)
# define For(i,b) for(int i = 0 ; i < b ; ++i)
# define Rfor(i,b) for(int i = b ; i >= 0 ; --i)

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

const ll inf = 1e18 ; 
const int MxN = 200005; 
const int mod = 1e9+7 ; 

void pe(int a) { cout << a << "\n" ; }
void pe(ll a) {	cout << a << "\n" ; }
void pe(string a) {	cout << a << "\n" ; }
void ps(int a) {	cout << a << ' ' ; }
void umax(int &a,int &b) { a = max(a,b); } ; 
void umax(ll &a , ll &b) {a = max(a,b);} ; 
void umin(int &a,int &b) { a = min(a,b);} ; 
void umin(ll &a , ll &b) {a = min(a,b);} ; 

ll nCr(ll n,ll r){
	ll res=1;
	if(r>n) return 0;
	if(r>n-r) r=n-r;
	for(ll i=0;i<r;i++) {
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}




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

	int n ; 
	cin >> n ; 

	vt<int> a(n) ; 
	int ans = 0 ;
	For(i,n) cin >> a[i] ; 
	For(i,n) {
		Rep(j,i+1 ,n) {
			Rep(k,j+1,n) {
				if(a[i] ==a[j]  || a[j] == a[k] || a[i] ==a[k] ) 
					continue; 
				if(a[i]+a[j] > a[k] && a[i] + a[k] > a[j] && a[j]+a[k] > a[i]) 
					++ans ; 
			}
		}
	}
	pe(ans) ;
	return 0 ; 	
}




Measured memory_bytes: 3660
a,b,c=(int(x) for x in input().split())
k=int(input())

n=0

  
while k>n and b<=a:
    b=b*2
    n=n+1
    
while k>n and c<=b:
  c=c*2
  n=n+1
     
      
if c>b>a:
  print('Yes')
else:
  print('No')
    
    


Measured memory_bytes: 9184
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  
  int N, K;
  cin >> N >> K;
  int num[N];
  for(int i=0;i<N;i++) num[i] = 0;

  int l;
  for(int i=0;i<N;i++){
    cin >> l;
    num[l-1]++;
  }
  sort(num, num+N);

  int ans;
  int sum = 0;
  for(int i=0;i<K;i++){
    sum += num[N-1-i];
  }

  ans = max(0, N - sum);
  cout << ans <<endl;
  
  return 0;
}

Measured memory_bytes: 1024