akhauriyash/Code-Regression huggingface dataset:
module mod_segment_tree
  implicit none
  type t_segment_tree
    private
    integer(8) :: deflt = 0_8
    integer :: n, p
    integer(8), pointer :: arr(:) => null()
  contains
    procedure :: init => init_segtree
    procedure :: release => release_segtree
    procedure :: update => update
    procedure :: query => query
    procedure :: default => set_default
    procedure :: change => change_default
  end type
  interface segment_tree
    module procedure :: newst
  end interface segment_tree
contains
  integer(8) function op(x,y)
    integer(8), intent(in) :: x, y
    op = max(x,y)
  end
  function newst(n) result(ret)
    integer, intent(in) :: n
    type(t_segment_tree) :: ret
    integer :: p
    p = 1
    do while (p < n)
      p = 2*p
    end do
    ret%n = n
    ret%p = p
    allocate(ret%arr(2*p-1))
    ret%arr = ret%deflt
  end
  subroutine init_segtree(this,n)
    class(t_segment_tree), intent(inout) :: this
    integer, intent(in) :: n
    integer :: p
    p = 1
    do while (p < n)
      p = 2*p
    end do
    this%n = n
    this%p = p
    allocate(this%arr(2*p-1))
    this%arr = this%deflt
  end
  subroutine release_segtree(this)
    class(t_segment_tree), intent(inout) :: this
    if (associated(this%arr)) deallocate(this%arr)
  end
  subroutine set_default(this,i)
    class(t_segment_tree), intent(inout) :: this
    integer, intent(in) :: i
    integer :: x
    x = i+this%p-1
    this%arr(x) = this%deflt
    do while (x > 1)
      x = x/2
      this%arr(x) = op(this%arr(2*x),this%arr(2*x+1))
    end do
  end
  subroutine change_default(this,deflt)
    class(t_segment_tree), intent(inout) :: this
    integer(8), intent(in) :: deflt
    this%deflt = deflt
  end
  subroutine update(this,i,v)
    class(t_segment_tree), intent(inout) :: this
    integer, intent(in) :: i
    integer(8), intent(in) :: v
    integer :: x
    x = i+this%p-1
    this%arr(x) = v
    do while (x > 1)
      x = x/2
      this%arr(x) = op(this%arr(2*x),this%arr(2*x+1))
    end do
  end
  integer(8) function query(this,a,b)
    class(t_segment_tree), intent(inout) :: this
    integer, intent(in) :: a, b
    integer :: l, r
    query = this%deflt
    l = a+this%p-1
    r = b+this%p-1
    do while (l <= r)
      if (mod(l,2) == 1) then
        query = op(query,this%arr(l))
        l = l+1
      end if
      if (mod(r,2) == 0) then
        query = op(query,this%arr(r))
        r = r-1
      end if
      l = l/2
      r = r/2
    end do
  end
end module mod_segment_tree
program flowers
  use mod_segment_tree
  implicit none
  integer :: n, h(200000) = 0, i
  integer(8) :: a(200000) = 0_8, x
  type(t_segment_tree) :: st
  read(*,*) n
  read(*,*) h(1:n)
  read(*,*) a(1:n)
  st = segment_tree(n)
  do i = 1, n
    x = st%query(1,h(i))
    call st%update(h(i),x+a(i))
  end do
  write(*,'(i0)') st%query(1,n)
end program flowers

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

int main(){
	int n, money = 100000;
	cin >> n;
	while (n--){
		money *= 1.05;
		if (money % 1000){ money = money / 1000 * 1000 + 1000; }
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());

		boolean result = false;
		for (int i = 1; i <= 9; ++i) {
			if (N % i == 0) {
				if (N / i <= 9) {
					result = true;
				}
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 22996
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << n); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

ll INF = 10000000;
//ll mod = 1000000007;//10^9+7
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
using Graph = vector<vector<int>>;//隣接リスト:G[i]にはiと隣接する頂点が入るよ。
using P = pair<int, int>;//BFSで利用。queueに入れる。
using PP = pair<int, P>; //dijkstraで利用,priority_queueに入れる。
//struct edge{int to, cost};






//番号ズレ注意！！
int main() {
    ll X, Y;
    cin >> X >> Y;
    ll x = X;
    ll ans = 1;
    while (x * 2 <= Y) {
        x = 2 * x;
        ans += 1;
    }
    print(ans);
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final int[] EVEN = new int[]{1, 2, 4, 8, 16, 32, 64};
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		for (int i = 0; i < EVEN.length; i++) {
			if (EVEN[i] <= n) {
				max = EVEN[i];
			}
		}
		System.out.println(max);
	}
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int dp[105][10], a[105];
int main(){
    memset(dp, -1, sizeof(dp));
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    dp[0][0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<10;j++){
            if(dp[i-1][j] == -1) continue;
            int nt = (j+a[i])%10;
            dp[i][nt] = max(dp[i][nt], dp[i-1][j] + a[i]);
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    int ans = 0;
    for(int j=1;j<10;j++) ans = max(ans, dp[n][j]);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
    long long N,M;
    cin >> N >> M;
    
    long long res = 0;
    if(2*N >= M){
        res = M/2;
    }
    else{
        res = N + ((M-2*N)/4);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int a,b;
	cin>>a>>b;
	int c=a*b;
	if (c%2==0){
		cout<<"Even"<<endl;
	}else{
		cout<<"Odd"<<endl;
	}
	return 0;
}

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

int a[100010],s=0;
int d[100010];

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int n=read();
    for(int i=1;i<=n;i++){
        a[i]=read();
        s+=a[i];
        d[a[i]]++;
    }
        
    int q=read();
    for(int i=1;i<=q;i++){
        int b=read(),c=read();
        s+=(c-b)*d[b];
        writeln(s);
        d[c]+=d[b];
        d[b]=0;
    }
    
    return 0;
}

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

import numpy as np

def solve():
    N, M  = map(int, input().split())
    A = set.intersection(*(set(list(map(int, input().split()))[1:]) for _ in range(N)))
    res = len(A)

    return str(res)
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 21480
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

long double dist(long double x, long double y){
    return (sqrt(x*x + y*y));
}

int solve(){
    int n, ans = 0;
    long double x, y, d;
    cin>> n>> d;
    rep(i, 0, n){
        cin>> x>> y;
        if(dist(x, y) <= d)
            ans++;
    }
    cout<< ans<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3752
N,M= map(int,input().split())
X=list(map(int,input().split()))
X.sort(reverse=False)
Y=[]
for i in range(M-1):
    Y.append(abs(X[i]-X[i+1]))

Y.sort(reverse=False)

if M - N <= 0:
    
    print(sum(Y[:0]))

else:

    print(sum(Y[:M-N]))

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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n); i > -1;i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

template<typename T>
void swap(T*,T*);

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    if(N % 2 == 0)
    {
        string s1 = s.substr(0,N/2);
        string s2 = s.substr(N/2);
        if(s1 == s2)
        {
            Yes(true);
        }
        else
        {
            Yes(false); 
        }
        
    }
    else
    {
        Yes(false);
    }
    
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N; 
    if(N >= 30) {
    	cout << "Yes\n";
    }
    else {
    	cout << "No\n";
    }
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n;
int main(void){
    cin>>n;
    int x=n/100;
    if(n%100<=x*5)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
typedef long long int ll ;


int main(){
	ios;
	int n;
	cin>>n;
	
	if(n%2==0)
		cout<<1.0/2<<'\n';
	else 
		cout<<(double)(n+1)/(2*n)<<'\n';
	return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll z=max(x,y);
    ll res = 1e18;
    for(int i = 0; i <= z; ++i){
    	ll tmp = c*i*2 + max(0LL,(x-i)*a)+max(0LL, (y-i)*b);
    	res=min(res,tmp);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
from itertools import product

S = input()

patterns = list(product(["","+"],repeat=len(S)-1))

ans = 0

for pattern in patterns:
    cnt = 0
    num = ""
    for i in range(len(pattern)+1):
        if i == 0:
            num = num + S[i]
        else:
            if pattern[i-1] == "+":
                cnt += int(num)
                num = S[i]
            else:
                num = num + S[i]
    cnt += int(num)
    ans += cnt


print(ans)

Measured memory_bytes: 3064
from collections import deque
def solve():
    n = int(input())
    a = []
    for i in range(n):
        ai = [int(j)-1 for j in input().split()]
        a.append(deque(ai))
    d = set()
    q = deque()
    for i in range(n):
        ai = a[i].popleft()
        if i < ai:
            q.append((i, ai))
        else:
            q.append((ai, i))
    ans = 0
    while q:
        ans += 1
        nxt_q = deque()
        while q:
            i, ai = q.pop()
            if (i, ai) in d:
                if a[i]:
                    ni = a[i].popleft()
                    if i < ni:
                        nxt_q.append((i, ni))
                    else:
                        nxt_q.append((ni, i))
                if a[ai]:
                    ni = a[ai].popleft()
                    if ai < ni:
                        nxt_q.append((ai, ni))
                    else:
                        nxt_q.append((ni, ai))
            else:
                d.add((i, ai))
        q = nxt_q
    if any(i for i in a):
        ans = -1
    print(ans)

solve()

Measured memory_bytes: 84056
#!/usr/bin/env python3


def solv(a, b, c, d, e, k):
    ants = [a, b, c, d, e]
    for i in range(1, len(ants)):
        for j in range(i):
            if abs(ants[i] - ants[j]) > k:
                return ':('
    return 'Yay!'


if __name__ == '__main__':

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    ans = solv(a, b, c, d, e, k)

    print(ans)


Measured memory_bytes: 3064
n=gets.to_i
as=gets.split.map(&:to_i)
count=[0,0]
2.times do |i|
  sign=-1+2*i
  sum=0
  n.times do |j|
    sum+=as[j]
    if sign==1 && sum<=0
      count[i]+=1-sum
      sum=1
    elsif sign==-1 && sum>=0
      count[i]+=1+sum
      sum=-1
    end
    sign*=-1
  end
end
puts count.min


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

struct union_find{
    vector<int> par;
    vector<int> rank;
    vector<int> siz;
    
    union_find(int N) : par(N), rank(N), siz(N){
        rep(i,N){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    
    int root(int x){
        if (par[x] == x){
            return x;
        }
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]){
            par[rx] = ry;
            siz[ry] += siz[rx];
        }
        else{
            par[ry] = rx;
            siz[rx] += siz[ry];
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        return siz[root(x)];
    }
};
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i,M){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    union_find tree(N);
    rep(i,M){
        tree.unite(A[i], B[i]);
    }
    int ans = 0;
    rep(i,N){
        ans = max(ans, tree.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 7188
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const ll MOD = 1000000007;

int main() {
  int n, m; cin >> n >> m;
  ll x[n]; rep(i,n) cin >> x[i];
  ll y[m]; rep(i,m) cin >> y[i];

  ll result = 0, x_sum = 0, y_sum = 0;
  rep(i,n) { x_sum += (2*i-(n-1)) * x[i]; x_sum %= MOD; }
  rep(i,m) { y_sum += (2*i-(m-1)) * y[i]; y_sum %= MOD; }
  result = x_sum * y_sum; result %= MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;;
int main(){
  int n,a,b;
cin >> n >>a >>b;
  int plan1,plan2;
  plan1=a*n;
  plan2=b;
  if(plan1 < plan2){
  cout << plan1;
  }
  else
    cout <<plan2;
return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
x = list(map(int,input().split()))

mean = math.ceil(sum(x) / n)

ans1 = 0
for i in range(n):
	ans1 += (x[i]-mean) ** 2

if sum(x) % n != 0:
	mean -= 1
	ans2 = 0
	for i in range(n):
		ans2 += (x[i]-mean) ** 2

	print(min(ans1,ans2))
else:
	print(ans1)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using namespace std;



// int main() {
//     int n;
//     cin >> n;
//     vector<int>a(n);
//     rep(i,n) {
//         cin >> a[i];
//     }
//     int sum = 1;
//     sort(a.begin(),a.end());
//     reverse(a.begin(),a.end());
//     for(int i = 1; i < n; i++) {
//         if(n == 1)break;
//         if(a[i] == a[i-1])continue;
//         sum++;
//     }
//     cout << sum << endl;
// }
//バケット法
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<int>num(110);
    //バケットを作る
    rep(i,n){
        num[a[i]]++;
    }
    int ans = 0;
    for(int i = 0;i <=100; i++){
        if(num[i]) ans++;
    }
    cout << ans << endl;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
	//cin >> tt;
	while (tt--)
	{
		int n; cin >> n;
		int ans = 0;
		n++;
		for (int i = 1; i < n; i++)
		{
			for(int j = 1; j < n; j++)
			{
				for(int k = 1 ; k < n; k++)
				{
					ans += __gcd(i,__gcd(j,k));
				}
			}
		}
		cout << ans;
	}
    return 0;
}


Measured memory_bytes: 3652
fun main(args: Array<String>) = yorukatsu13a()

fun yorukatsu13a() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val lrList = (1..m).map { readLine()!!.split(' ').map { it.toInt() }.let { it[0] to it[1] } }

    val answer = Math.max(
        lrList.map { it.second }.min()!! - lrList.map { it.first }.max()!! + 1,
        0
    )

    println(answer)
}


Measured memory_bytes: 62172
def solve():
  s = input()
  t = input()
  ans = 0
  alp = [[] for _ in range(27)]
  length_s = len(s)
  for i in range(length_s):
    char = ord(s[i]) - ord('a')
    alp[char].append(i + 1)
  length_t = len(t)
  import bisect
  for i in range(length_t):
    char = ord(t[i]) - ord('a')
    if alp[char]:
      if ans % length_s >= alp[char][-1]:
        ans = (ans // length_s + 1) * length_s
      index = bisect.bisect_right(alp[char], ans % length_s)
      ans += alp[char][index] - ans % length_s
    else:
      return -1
  return ans
print(solve())

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

int main(){
  int n,m;
  cin>>n>>m;
  int ans=100*(n-m)+1900*m;
  rep(i,0,m){
    ans*=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> A(Q, 0);
    vector<ll> A_count(N, K);
    rep(i, Q) cin >> A[i];
    rep(j, Q) A_count[A[j]-1]++;
    rep(x, N) A_count[x] -= Q;
    rep(k, N) {
        if (A_count[k] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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



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

  int x,y,z,k;cin>>x>>y>>z>>k;
  vector<ll> A(x), B(y), C(z);
  for(int i=0;i<x;i++)cin>>A[i];
  sort(A.rbegin(), A.rend());
  for(int i=0;i<y;i++)cin>>B[i];
  sort(B.rbegin(), B.rend());
  for(int i=0;i<z;i++)cin>>C[i];
  sort(C.rbegin(), C.rend());
  vector<ll> AB;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(AB.rbegin(), AB.rend());
  AB.resize(min(3000, x*y));

  vector<ll> ABC;
  for(int i=0;i<AB.size();i++){
    for(int j=0;j<z;j++){
      ABC.push_back(AB[i]+C[j]);
    }
  }
  sort(ABC.rbegin(), ABC.rend());
  for(int i=0;i<k;i++){
    cout<<ABC[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 44084
#include<stdio.h>
#include<string.h>

int main(){
  int sx,sy,tx,ty,cnt=0;
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  for(int i=sx;i<tx;i++)
    printf("R");
  for(int i=sy;i<ty;i++)
    printf("U");
  for(int i=tx;i>sx;i--)
    printf("L");
  for(int i=ty;i>sy-1;i--)
    printf("D");
  for(int i=sx;i<tx+1;i++)
    printf("R");
  for(int i=sy-1;i<ty;i++)
   printf("U");
  printf("LU");
  for(int i=tx;i>sx-1;i--)
    printf("L");
  for(int i=ty+1;i>sy;i--)
    printf("D");
  printf("R\n");
}

Measured memory_bytes: 128
N,M = map(int, input().split())
L = [list(map(int,input().split())) for _ in range(M)]
L.sort(key=lambda x: x[0])
funes1 = [False]*N
for a,b in L:
    if a == 1:
        funes1[b] = True
    else:
        if funes1[a]:
            if b == N:
                print('POSSIBLE')
                exit()
print('IMPOSSIBLE')

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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  int x;
  cin >> x;
  for (int y = 1; y <= x; y++) {
    int z = y * 1.08;
    if (z == x) {
      cout << y << endl;
      exit(0);
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		if(a <= b)
		{
			System.out.println(a);
		}
		else
		{
			System.out.println(a-1);
		}

	}

}


Measured memory_bytes: 35532
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 300005
#define mod 1000000007
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int f[MN][2][3],pw[MN],res,len;
char s[MN]; 
int main()
{
	scanf("%s",s);len=strlen(s);pw[len+1]=f[0][0][0]=1;
	for (int i=len;i;--i){
		pw[i]=pw[i+1];
		if (s[i-1]=='?') pw[i]=(pw[i]<<1)%mod;
	}
	for (int i=1;i<=len;++i)
	for (int j=0;j<2;++j)
	for (int k=0;k<3;++k)if (f[i-1][j][k]){
		if (s[i-1]!='0'){
			if (k) f[i][j][k-1]=(f[i][j][k-1]+f[i-1][j][k])%mod;
			else if (!j) f[i][1][0]=(f[i][1][0]+f[i-1][j][k])%mod;
			else res=(1ll*res+1ll*f[i-1][j][k]*pw[i+1])%mod;
		}
		if (s[i-1]!='1'){
			if (k<2) f[i][j][k+1]=(f[i][j][k+1]+f[i-1][j][k])%mod;
			else f[i][j][1]=(f[i][j][1]+f[i-1][j][k])%mod;
		}
	}printf("%lld",(1ll*res+f[len][2][1]+f[len][1][0])%mod);return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    ll m=10000000000, ans=0;
    int cnt=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0){
            cnt++;
            a[i]=-a[i];
        }
        m=min(m,a[i]);
        ans+=a[i];
    }
    if(cnt%2==0){
        cout<<ans<<endl;
    }
    else{
        m*=2;
        ans-=m;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include<memory>

using namespace std;

int main() {
	long long row;
	long long column;
	cin >> row;
	cin >> column;

	unsigned long long num = 0;

	if (row == 1 && column == 1) {
		num = 1;
	}
	else if (row == 1) {
		num = column - 2;
	}
	else if (column == 1) {
		num = row - 2;
	}
	else {
		num = (row - 2) * (column - 2);
	}

	cout << num;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,K = map(int,input().split())
a = list(map(int,input().split()))

for k in range(K):
    light = [0]*n
    st = [0]*n
    skip = True
    for i in range(n):
        if i - a[i] >= 0:
            light[i-a[i]] += 1
        else:
            light[0] += 1
        
        if i + a[i] + 1 <= n-1:
            light[i + a[i] + 1] -= 1

    st[0] = light[0]
    if st[0] < n-1:
        skip = False
    for i in range(1,n):
        st[i] = st[i-1] + light[i]
        if st[i] < min(n-1-i,i):
            skip = False
    
    if skip:
        if k < K-1:
            for _ in range(n):
                print(n,end =" ")
            exit()
        else:
            for ans in st:
                print(ans, end = " ")
            exit()
    a = st[::]
for ans in a:
    print(ans, end = " ")
        


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

using namespace std;
using ll = long long int;

int main() {
    int H, W;
    cin >> H >> W;
    string field[H];
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }

    int N = H * W;
    int dest[N][N];
    for (int hf = 0; hf < H; hf++) {
        for (int wf = 0; wf < W; wf++) {
            for (int ht = 0; ht < H; ht++) {
                for (int wt = 0; wt < W; wt++) {
                    int d = abs(hf - ht) + abs(wf - wt);
                    int nt = ht * W + wt;
                    int nf = hf * W + wf;

                    if (field[ht][wt] == '#' or field[hf][wf] == '#') {
                        dest[nf][nt] = N * N;
                        dest[nt][nf] = N * N;
                    } else if (d == 1) {
                        dest[nf][nt] = 1;
                        dest[nt][nf] = 1;
                    } else if (d == 0) {
                        dest[nf][nt] = 0;
                    } else {
                        dest[nf][nt] = N * N;
                        dest[nt][nf] = N * N;
                    }
                }
            }
        }
    }

    for (int n = 0; n < N; n++) {
        for (int nf = 0; nf < N; nf++) {
            for (int nt = 0; nt < N; nt++) {
                if (dest[nf][n] >= 0 and dest[n][nt] >= 0) {
                    dest[nf][nt] = min(dest[nf][nt],
                                       dest[nf][n] + dest[n][nt]);
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (dest[i][j] != N * N) {
                ans = max(dest[i][j], ans);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


#入力
s=input()
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))

#2次元配列
#2dimls=[[0 for i in range(2)] for j in range(n)]

ans="Yes"
if s=="AAA" or s=="BBB":
    ans="No"
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  map<int,ll> M;
  
  REP(i,N) {
    cin >> A[i];
    M[ A[i] ]++;
  }
  int mn = 0;
  ll ans = 0;
  for ( auto m: M ) {
    if (m.second > 1 ) 
      ans += (m.second * (m.second-1)/ 2);
  }

  REP(i,N) {
    int mn = M[A[i]];
    ll ans1 = ans - (mn-1);
    cout << ans1 << endl;
  }
}


Measured memory_bytes: 10240
import sys
l,r=map(int,input().split())
if l+2019<=r:
  print(0)
  sys.exit()
mn=2018*2018
for i in range(l,r+1):
  for j in range(i+1,r+1):
    mn=min(mn,i*j%2019)
print(mn)

Measured memory_bytes: 40812
import bisect

h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(n):
    b.append(b[-1] + a[i])
count = 0
for i in range(h):
    temp = []
    for j in range(w):
        temp.append(str(bisect.bisect(b, count)))
        count += 1
    if i % 2 == 1:
        temp.reverse()
    print(" ".join(temp))

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

using namespace std;

using ll = long long;
using ld = long double;

void solve() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(1e5 + 5, 1e18));
    dp[0][0] = 0;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < dp[i].size(); j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i - 1] >= 0 && dp[i - 1][j - v[i - 1]] < 1e18) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
            }
            if (j > ans && dp[i][j] <= W) {
                ans = j;
            }
        }
    }
    cout << ans;
}

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

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, A, B;
    cin >> N >> A >> B;
    vector<vector<int>> dp(420, vector<int>(420, inf));
    dp[0][0] = 0;
    rep(i, N){
        int a, b, c;
        cin >> a >> b >> c;
        auto tmp = dp;
        rep(j, 420) rep(k, 420) {
            if(j + a < 420 && k + b < 420) tmp[j + a][k + b] = min(tmp[j + a][k + b], dp[j][k] + c);
        }
        dp = tmp;
    }
    
    int ret = inf;
    
    rep(i, 1, 420) rep(j, 1, 420){
        if(i * B == j * A){
            ret = min(ret, dp[i][j]);
        }
    }
    if(ret == inf) output(-1);
    else output(ret);
    
    
    return 0;
}

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

#define   ll      long long
#define   pb      push_back

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

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

    ll t;
    t = 1;
    // cin>>t;

    while (t--)
    {

        string a, b;
        cin >> a >> b;

        int m = a.size();
        int n = b.size();

        int dp[m + 1][n + 1];

        for (int i = 0; i <= m; i++)
            for (int j = 0; j <= n; j++)
                dp[i][j] = 0;

        for (int i = 0; i < m; i++)
        {


            for (int j = 0; j < n; j++)
            {
                if (a[i] == b[j])
                    dp[i + 1][j + 1] = 1 + dp[i][j];
                else
                    dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);

            }
        }


        int max = dp[m][n];

        char ans[max + 1];

        ans[max] = '\0';

        int i = m;
        int j = n;

        while (i > 0 && j > 0)
        {
            if (a[i - 1] == b[j - 1])
            {
                ans[max - 1] = a[i - 1];
                i--;
                j--;
                max--;
            }
            else {

                if (dp[i - 1][j] > dp[i][j - 1])
                    i--;
                else
                    j--;
            }
        }

        cout << ans << endl;

    }

    return 0;
}




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

int main() {
    int n;
    int h[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];

    int ans = 0;
    while (true) {
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] > 0) {
                tmp++;
                while (i < n && h[i] > 0) {
                    h[i]--;
                    i++;
                }
            }
        }
        if (tmp == 0) break;
        ans += tmp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], p = tmp[1];

    long[long] lists;
    lists[2] = 0;
    while (p % 2 == 0)
    {
        ++lists[2];
        p /= 2;
    }
    for (long i = 3; i * i <= p; i += 2)
    {
        if (p % i == 0)
        {
            lists[i] = 0;
            while(p % i == 0)
            {
                ++lists[i];
                p /= i;
            }
        }
    }
    if (p > 1) lists[p] = 1;

    long g = 1;
    foreach (key, val; lists)
    {
        if (val >= n) g *= key ^^ (val / n);
    }

    g.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int N;
    cin >> N;
    if(N == 3) {
        cout << 2 << ' ' << 3 << ' ' << 25 << endl;
    } else {
        vector<int> Ans;
        Ans.push_back(2);
        Ans.push_back(4);
        Ans.push_back(3);
        Ans.push_back(9);
        N -= 4;
        int n = min((int)2499, N / 2);
        N -= n * 2;
        int m = min((int)4999, N / 2);
        N -= m * 2;
        int k = N;
        //cout << n << ':' << m << ':' << k << endl;
        rep(i, 2 * n) {
            Ans.push_back(15 + i * 6);
        }
        rep(i, m) {
            Ans.push_back(8 + i * 6);
            Ans.push_back(10 + i * 6);
        }
        rep(i, k) {
            Ans.push_back(6 * (i + 1));
        }
        sort(all(Ans));
        for(auto x : Ans) cout << x << ' ';
        cout << endl;
    }
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {

	static Main obj = new Main();
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int vertex;
	static int edges;
	static int start;
	static int[] cost;
	static int[] parent;
	static boolean[] visited;
	static ArrayList<Edge>[] graph;

	private class Edge implements Comparable<Edge> {
		int from;
		int to;
		int weight;

		public Edge(int from, int to, int weight) {
			this.from = from;
			this.to = to;
			this.weight = weight;
		}

		@Override
		public int compareTo(Edge other) {
			return this.weight - other.weight;

		}
	}

	public static void main(String[] args) throws IOException {
		input();
		dijk(start);
	}

	public static void dijk(int index) {
		// int added = 1;
		cost[index] = 0;
		visited[index] = true;
		parent[index] = index;
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		for (Edge temp : graph[index]) {
			pq.offer(temp);
			cost[temp.to] = temp.weight;
		}
		while (!pq.isEmpty()) {
			Edge e = pq.poll();
			if (visited[e.to]) {
				continue;
			}
			visited[e.to] = true;
			// added++;
			for (Edge f : graph[e.to]) {
				if (!visited[f.to]&&cost[f.to]>e.weight+f.weight) {
					cost[f.to] = f.weight + e.weight;
					parent[f.to] = f.from;
					pq.offer(obj.new Edge(f.from, f.to, f.weight + e.weight));
				}
			}
		}
		for (int i : cost) {
			if (i == Integer.MAX_VALUE) {
				System.out.println("INF");
			} else {
				System.out.println(i);
			}
		}
	}

	@SuppressWarnings("unchecked")
	public static void input() throws IOException {
		StringTokenizer st = new StringTokenizer(br.readLine());
		vertex = Integer.parseInt(st.nextToken());
		edges = Integer.parseInt(st.nextToken());
		start = Integer.parseInt(st.nextToken());
		cost = new int[vertex];
		parent = new int[vertex];
		visited = new boolean[vertex];
		graph = new ArrayList[vertex];
		for (int i = 0; i < vertex; i++) {
			graph[i] = new ArrayList<Edge>();
			cost[i] = Integer.MAX_VALUE;
		}
		for (int i = 0; i < edges; i++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			graph[a].add(obj.new Edge(a, b, c));
		}

	}
}



Measured memory_bytes: 125008
#include <stdio.h>
int main(void) {
    int n, i, j, wa;
    int d[51];
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &d[i]);
    }
    wa=0;
    for (i=0; i<n-1; i++) {
        for (j=i+1; j<n; j++) {
            wa += d[i] * d[j];
        }
    }

    printf("%d", wa);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
h = list(map(int, input().split()))

ans = 0
while sum(h) != 0:
    for i in range(N):
        if h[i] > 0:
            st = i
            break
    en = N
    for i in range(st+1, N):
        if h[i] <= 0:
            en = i
            break
    for i in range(st, en):
        h[i] -= 1
    ans += 1

print(ans)

Measured memory_bytes: 3064
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
cnt = 0
for i in range(N):
  if sum(A)*(1/(4*M))<=A[i]:
    cnt+=1
if M <= cnt:
  print('Yes')
else:
  print('No')



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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; ///4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};///8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; ///Hexagonal Direction

inline int in() { int x; scanf("%d", &x); return x; }
inline ll inl() { ll x;scanf("%I64d",&x); return x;}
inline double ind() { double x;scanf("%lf",&x);return x;}

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

int gcd(int a,int b) { return b==0 ? a:gcd(b,a%b);}
int power( int x, int n)
{
    if(n==0)return 1;
    else if(n%2==0)
    {
        int y=power(x,n/2);
        return y*y;
    }
    else
        return x*power(x,n-1);
}
//abcdefghijklmnopqrstuvwxyz//
string s;

main()
{
    #ifdef CP
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif // CP
    cin>>s;
    if(s[s.size()-1]=='s')
        cout<<s+"es"<<endl;
    else
        cout<<s+"s"<<endl;
}



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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;


bool valid[10];
inline bool solve(int n)
{
  while (n)
    {
      if (!valid[n%10])
    return false;
      n /= 10;
    }
  return true;
}
int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  memset(valid, 1, sizeof(valid));
  for (int i = 0; i < k; ++i)
    {
      int x;
      scanf("%d", &x);
      valid[x] = false;
    }
  while (!solve(n))
    ++n;
  printf("%d\n", n);
}

Measured memory_bytes: 256