akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 

int main(void){
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;
	
	int max=0;
	if(A%10!=0&&10-A%10>max) max=10-A%10;
	if(B%10!=0&&10-B%10>max) max=10-B%10;
	if(C%10!=0&&10-C%10>max) max=10-C%10;
	if(D%10!=0&&10-D%10>max) max=10-D%10;
	if(E%10!=0&&10-E%10>max) max=10-E%10;
	
	int sum=0;
	if(A%10==0) sum+=A; else sum+=(A/10+1)*10;
	if(B%10==0) sum+=B; else sum+=(B/10+1)*10;
	if(C%10==0) sum+=C; else sum+=(C/10+1)*10;
	if(D%10==0) sum+=D; else sum+=(D/10+1)*10;
	if(E%10==0) sum+=E; else sum+=(E/10+1)*10;
	
	cout << sum-max;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
int q;
int A[2000];
int m[2000];

int solve(int, int);

int main() {
  int i = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &m[i]);
  }

  for (i = 0; i < q; i++) {
    if (solve(0, m[i])) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

int solve(int i, int m) {
  if (m == 0) return 1;
  if (i >= n) return 0;

  int result = solve(i+1, m) || solve(i+1, m - A[i]);
  return result;
}

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

int main(){
  long N,M,i;
  double pn,ac,ep,ex=0;
  cin>>N>>M;
  i=1;
  ac=pow(0.5,M);
  do{
    pn=pow(1-ac,i-1)*ac;
    ep+=pn*i*(M*1900+(N-M)*100);
	ex+=ep;
    i++;
  }while(pn*i*(M*1900+(N-M)*100)>0.00000001);
  cout<<ex<<endl;
}

Measured memory_bytes: 512
a = []
a = gets.split.map(&:to_i)
 for i in 0..a[2]-a[0]-1
   print "R"
 end
for i in 0..a[3]-a[1]-1
  print "U"
end
print "UL"
 for i in 0..a[2]-a[0]-1
   print "L"
 end
for i in 0..a[3]-a[1]-1
  print "D"
end
print "DR"
for i in 0..a[3]-a[1]-1
  print "U"
end
 for i in 0..a[2]-a[0]-1
   print "R"
 end
print "RD"
for i in 0..a[3]-a[1]-1
  print "D"
end
 for i in 0..a[2]-a[0]-1
   print "L"
 end
puts "LU"




Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        int count = 0;

        for (int i = 0; i < n; i++) {
            int inn = sc.nextInt();
            if (inn >= max) {
                count++;
                max = inn;
            }
        }
        System.out.println(count);
    }
}

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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>s;
    if((s[6]=='4' &&s[8]=='3' &&s[9]=='0') ||s[5]=='0' && s[6]<='4' && s[8]<='3' )
        cout<<"Heisei";
    else
    {
        cout<<"TBD";
    }
    
	
	return 0;
}
	

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


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>x(n+1010);
  for(int i=0;i<n;i++){
  	int order;
  	cin>>order;
  	x[order-1]=i+1;
  }
  for(int i=0;i<n;i++){
  	cout<<x[i]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 1280
(n, t) = map(int, input().split())
cts = []
for i in range(n):
    ct = list(map(int, input().split()))
    if ct[1] <= t:
        cts.append(ct)
if len(cts) == 0:
    print("TLE")
else:
    cts.sort()
    print(cts[0][0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 1000000007;
struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }
	int root(int x) {
		if (par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	bool issame(int x, int y) { return root(x) == root(y); }
	bool merge(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) { return -par[root(x)]; }
};
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	UnionFind tree(n);
	while (m--) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		x--, y--;
		tree.merge(x, y);
	}
	int ans = 0;
	for (auto p : tree.par) {
		if (p < 0) ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n;
string s;
int main(){
    cin>>n>>s;
    if(n%2){
            cout<<"No"<<endl;
            return 0;
    }
    for(int i=0;i<n/2;i++){
        if(s.at(i)!=s.at(i+n/2)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}




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

string S;
size_t cur;
int N;

int digit(){
	int n;
	n=S[cur]-'0';
	cur++;
	return n;
}

int Number(){
	int n=digit();
	while(isdigit(S[cur])&& cur<S.size())
		n=n*10+digit();
	return n;
}

string element(){
	string s;
	s=S[cur++];
	while(isupper(S[cur]))
		s+=S[cur++];
	return s;
}

string expression(){
	string res,tmp;
	int n=1;
	if(isdigit(S[cur])&&cur<S.size())
		 n=Number();
	if(S[cur]=='('&&S.size()){
		cur++;
		tmp=expression();
		cur++;
	}else if(cur<S.size()&&isupper(S[cur]))
		tmp=element();
	res=tmp;
	for(int i=1;i<n&&res.size()<=N+1;i++)
		res+=tmp;
	if(cur<S.size()&&S[cur]==')')
		return res;
	if(cur<S.size())
		res+=expression();
	return res;
}
int main(void){
	while(cin >> S >> N,S!="0"){
		string result;
		cur=0;
		result=expression();
		if(result.size()<N+1)
			cout << '0' <<endl;
		else
			cout << result[N] << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


map<ll, ll> dp[101];

signed main() {
  ll n, w;
  cin >> n >> w;
  P m[100];
  rep(i, 0, n) cin >> m[i].first >> m[i].second;
  dp[0][0] = 0;
  rep(i, 0, n) {
    for(auto it = dp[i].begin(); it != dp[i].end(); it++) {
      dp[i + 1][it->first + m[i].first] = max(dp[i + 1][it->first + m[i].first], dp[i][it->first] + m[i].second);
      dp[i + 1][it->first] = max(dp[i + 1][it->first], it->second);
    }
  }
  ll ans = 0;
  for(auto it = dp[n].begin(); it != dp[n].end(); it++) {
    if(it->first <= w) ans = max(ans, it->second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 13952
//region Template
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion

int main() {
    FASTIO

    int d,t,s;
    cin>>d>>t>>s;

    cout<<(d <= t*s?"Yes":"No")<<endl;

}

Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

//#define READ_FROM_FILE

int main() {
	ios::sync_with_stdio(false);
	#ifdef READ_FROM_FILE
    freopen("input.in","r",stdin);
 	freopen("output.out","w",stdout);
	#endif

	string s;cin>>s;
	int n = s.size();
	vector<vector<ll>> A(n, vector<ll>(26, 0));

	rep(i, s.size()) A[i][s[i]-'a'] = 1;

	for(int i = n-2;i >= 0;i--) {
		for(int j = 0;j < 26;j++) A[i][j] += A[i+1][j];
	}

	ll answer = 1;
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < 26;j++)
			if(s[i]-'a' != j) answer += A[i][j];
	}

	cout<<answer<<endl;

	return 0;
}


Measured memory_bytes: 48916
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInts(n)
	sort.Sort(sort.IntSlice(d))

	ans := 0
	top := 0
	for i := n - 1; i >= 0; i-- {
		if d[i] != top {
			ans++
			top = d[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
n,q=map(int,input().split())

s=input()
lr=[]
for _ in range(q):
    l,r=map(int,input().split())
    lr.append((l,r))

data=[0]
count=0
for i in range(1,len(s)):
    if s[i-1]=="A" and s[i]=="C":
        count+=1
    data.append(count)

for l,r in lr:
    print(data[r-1]-data[l-1])

Measured memory_bytes: 19780
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define max2(a,b) ((a)>(b)?(a):(b))   
#define min2(a,b) ((a)<(b)?(a):(b)) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef pair<ll,ll>     pll;
typedef pair<int,int>   pii;
typedef vector<ll>      vll;
typedef vector<int>      vi;
typedef vector< pll >  vpll;
typedef vector< pii >  vpii;
typedef set<ll>         sll;
typedef set<int>         si;
typedef set< pll >     spll;
typedef set< pii >     spii;
clock_t clk=clock();       

ll i,j,k;
void solve(void);

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

  return 0;
}
// #define cerr if(0)cerr

void solve()
{
	int a; string s ; cin>>a>>s;
	if(a>=3200) cout<<s<<'\n';
	else cout<<"red\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> //std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> // std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N, Q; std::cin >> N >> Q;
  std::vector<std::vector<int>> T(N);
  for(int i=0; i<N-1; i++) {
    int a,b; std::cin >> a >> b;
    T[a-1].push_back(b-1);
    T[b-1].push_back(a-1);
  }

  std::vector<int> value(N);
  std::vector<bool> update(N);
  for(int i=0; i<Q; i++){
    int p,x; std::cin >> p >> x;
    value[p-1] += x;
  } 

  std::queue<int> q; q.push(0);
  while(!q.empty()){
    int now = q.front(); q.pop();
    if ( now != 0 ) {
      for(auto&& v : T[now]){
        if ( update[v] == false ) q.push(v);
        else {
          value[now] += value[v];
          update[now] = true;
        }
      }
    }
    else {
      update[now] = true;
      for(auto&& v : T[now]) q.push(v);
    }
  }

  for(int i=0; i<N; i++) std::cout << value[i] << " ";
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 15604
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

l=make_divisors(n)

ans1=[]
ans2=[]

for value in l:
    ans1.append(value)
    ans2.append(n//value)


ans=10**13
for i in range(len(ans1)):
    ans=min(ans1[i]+ans2[i],ans)

print(ans-2)


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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int cnt = 1;
  rep(i, n) {
    if (a[i] == cnt) {
      cnt++;
    }
  }
  cnt--;
  if (cnt == 0) {
    cout << -1 << endl;
  } else {
    cout << n-cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTetrominoTiling solver = new CTetrominoTiling();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTetrominoTiling {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            long res = 0;
            long i = in.nextInt();
            int o = in.nextInt();
            int t = in.nextInt();
            long j = in.nextInt();
            long l = in.nextInt();
            int s = in.nextInt();
            int z = in.nextInt();
            res += (long) o * 2;
            long cmp = i / 2 * 4 + j / 2 * 4 + l / 2 * 4;
            if (i > 0 && j > 0 && l > 0) cmp = Math.max(cmp, (i - 1) / 2 * 4 + (j - 1) / 2 * 4 + (l - 1) / 2 * 4 + 6);

            out.println(res / 2 + cmp / 2);
        }

    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
bool check(int x){
	int t=x%10;
	while (x){
		if (x%10!=t) return 0;
		x/=10;
	}
	return 1;
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i=n;i<=999;i++) if (check(i)) {printf("%d\n",i); return 0;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi a,b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,k,m,y,z;
    cin>>n>>m>>k;
    in(a,n);
    in(b,m);
    for(int i=1;i<n;i++){
        a[i]+=a[i-1];
    }
    for(int i=1;i<m;i++){
        b[i]+=b[i-1];
    }
    z = 0;
    for(int i=0;i<=n;i++){
        y = 0;
        if(i>0)y=a[i-1];
        if(k-y<0)break;
        auto it = upper_bound(all(b),k-y);
        z = max(z, i + (ll)(it-b.begin()));
    }
    cout<<z;
    
    

    return 0;
}

Measured memory_bytes: 7944
s = int(input())
suretu = [s]
a = s
m = 1
while(True):
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3*a + 1
    m += 1
    if a in suretu:
        break
    suretu.append(a)
    #print(suretu)
print(m)

Measured memory_bytes: 2940
from sys import stdin
x,k,d = map(int, input().split())
x=abs(x)
b=x//d
c=x%d
if d>=x:
    if k%2==0:
        print(x)
    else:
        print(d-x)
else:
    if k<=b:
        print(x-k*d)
    else:
        if (k-b)%2==0:
            print(c)
        else:
            print(d-c)


Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++)
    {
        cin >> d[i];
    }
    
    bool check = true;
    int count = 0;
    
    for(int i=0;i<N;i++)
    {
        check = true;
        for(int j=i+1;j<N;j++)
        {
            if(d[i] == d[j])
            {
                check = false;
                break;
            }
        }
        
        if(check)
        {
            count ++;
        }
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
grid = []
ans = []
grid.append(['.'] * (W + 2))
for i in range(H):
    si = input()
    s = '.' + si + '.'
    grid.append(list(s))
    ans.append([0] * W)
grid.append(['.'] * (W + 2))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if grid[i][j] == '#':
            ans[i - 1][j - 1] = '#'
        if grid[i + 1][j] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i - 1][j] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i][j + 1] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i][j - 1] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i + 1][j + 1] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i + 1][j - 1] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i - 1][j + 1] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1
        if grid[i - 1][j - 1] == '#':
            if ans[i - 1][j - 1] != '#':
                ans[i - 1][j - 1] += 1

for i in range(H):
    print(''.join(map(str, ans[i])))

Measured memory_bytes: 3192
<?php
  fscanf(STDIN,"%d%d%d", $a,$b,$x);
  if($a > 0){
      $under = intdiv(($a-1),$x);
      $over = intdiv($b,$x);
      echo $over-$under;
  }else{
      echo intdiv($b,$x)+1;
  }

Measured memory_bytes: 16244
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int C, D, W, X;
int E[15][30];
int F[15][30];
int memo[31][51][6];

int solve(int day, int w, int x) {
  if (day == D) return 0;
  if (memo[day][w][x] >= 0) return memo[day][w][x];
  int res = 0;
  // 0テつ嘉δ禿つ湘つ甘つづδつεつ嘉つイテつブ
  res = max(res, solve(day+1, w, x));
  // 1テつ嘉δ禿つ湘つ甘つづδつεつ嘉つイテつブ
  REP(i, C) {
    if (E[i][day] == 0) continue;
    if (w + F[i][day] > W) continue;
    res = max(res, E[i][day] + solve(day+1, w+F[i][day], x));
  }
  // テつ陛つ。テつ静つ氾つ嘉δ禿つ湘つ甘つづδつεつ嘉つイテつブ
  if (x < X) {
    REP(i, C) {
      REP(j, i) {
        // テつ地テつ暗δヲjテつづつゥテつづδァiテつづδつεつ嘉つイテつブ
        bool dame = 0;
        int sumv = 0;
        int sumw = 0;
        for (int k=j; k<=i; ++k) {
          if (E[k][day] == 0) {
            dame = 1; break;
          }
          sumv += E[k][day];
          sumw += F[k][day];
        }
        if (!dame && w+sumw<=W) {
          res = max(res, sumv + solve(day+1, w+sumw, x+1));
        }
      }
    }
  }
  return memo[day][w][x] = res;
}

int main() {
  while(cin>>C>>D>>W>>X,C||D||W||X) {
    REP(i, C) REP(j,D) cin >> E[i][j];
    REP(i, C) REP(j,D) cin >> F[i][j];
    memset(memo,-1,sizeof(memo));
    cout << solve(0,0,0) << endl;
  }
}

Measured memory_bytes: 908
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        long a,b,i,total=0,max=0,min=0;

        a = sc.nextInt();
        for(i=0;i<a;i++){
        b = sc.nextInt();
        if(i==0){
            max=b;
            min=b;
        }
            if(max<b)max=b;
            if(min>b)min=b;
            total+=b;
        }
        System.out.println(min+" "+max+" "+total);
   }
}


Measured memory_bytes: 41024
#include<iostream>

using namespace std;

int main(){
  while(1){
    int n;cin>>n;
    if(n==0) break;
    int sumA=0,sumB=0;
    for(int i=0;i<n;i++){
      int a,b;cin>>a>>b;
      if(a>b){
        sumA+=a+b;
      }else if(a<b){
        sumB+=a+b;
      }else{
        sumA+=a;
        sumB+=b;
      }
    }
    cout<<sumA<<" "<<sumB<<endl;
  }
}


Measured memory_bytes: 2996
#include <iostream>

void call( int n ) {
    int i=1;

    while ( i <= n ) {
        int x = i;
        if ( x%3 == 0 ) {
            std::cout << ' ' << i;
        } else {
            while ( x ) {
                if ( x%10 == 3 ) {
                    std::cout << ' ' << i;
                    break;
                }
                x /= 10;
            }
        }
        ++i;
    }
    std::cout << std::endl;
}

int main() {
    int n;
    std::cin >> n;
    call( n );
    return 0;
}



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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n, k;
	cin >> n >> k;
	ll v[n];
	REP(i, n) cin >> v[i];
	ll ans = 0;
	REP(i, n+1){
		REP(j, n+1){
			if(i+j == 0 || i+j > k || i+j > n) continue;
			vector<ll> pos;
			REP(x, i) pos.pb(v[x]);
			REP(x, j) pos.pb(v[n-1-x]);
			sort(ALL(pos), greater<ll>());
			cout << endl;
			ll cur = 0;
			REP(x, pos.size()){
				if(x < (2*i+2*j-k) || pos[x] > 0) cur += pos[x];
			}
			ans = max(ans, cur);
		}
	}
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,k=10000,i,m;
    scanf("%d%d",&n,&x);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&m);
        if(m<k)
            k=m;
        x=x-m;
    }
    printf("%d",n+x/k);
    return 0;
}

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

int main() {
  while(1) {
    int w;
    cin >> w;
    int cost = 0;
    if(w == -1) break;
    cost += 1150;
    int temp;
    if(w > 30) {
      temp = w - 30;
      cost += temp * 160;
      w -= temp;
    }
    if(w > 20) {
      temp = w - 20;
      cost += temp * 140;
      w -= temp;
    }
    if(w > 10) {
      temp = w - 10;
      cost += temp * 125;
      w -= temp;
    }

    cout << 4280 - cost << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <deque>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  deque<char> buff;
  string init; cin >> init;
  for (auto c : init) buff.push_back(c);
  char ch;
  ll N, op, lr; cin >> N;
  bool cur = true;
  REP(i, N) {
    cin >> op;
    if (op == 1) {
      cur = !cur;
    } else {
      cin >> lr >> ch;
      if ((cur && lr == 1) || (!cur && lr == 2)) {
        buff.push_front(ch);
      } else {
        buff.push_back(ch);
      }
    }
  }
  if (cur) {
    for (auto oc : buff) {
      cout << oc;
    }
  } else {
    for_each(buff.rbegin(), buff.rend(), [](auto oc) {
      cout << oc;
    });
  }
  cout << endl;
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    while (cin >> n, n)
    {
        vector<int> s(n), v(n);
        rep(i, n) cin >> s[i];
        int cnt = 0;
        bool flag = 0;
        while (flag != 1)
        {
            copy(ALL(s), v.begin());
            rep(i, n) s[i] = count(ALL(v), v[i]);
            rep(i, n)
            {
                if (s[i] != v[i])
                    break;
                if (i == n - 1)
                    flag = 1;
            }
            cnt++;
        }
        OP(cnt - 1);
        rep(i, n) i != n - 1 ? cout << s[i] << " " : OP(s[i]);
    }
    return 0;
}


Measured memory_bytes: 3060
a=input()
len_a=len(a)
b=input()
len_b=len(b)
c=input()
len_c=len(c)
flag_ab=[True]*20000
for i in range(len_a):
  for j in range(len_b):
    if a[i]!=b[j] and a[i]!='?' and b[j]!='?':
      flag_ab[i-j+10000]=False
flag_ac=[True]*20000
for i in range(len_a):
  for j in range(len_c):
    if a[i]!=c[j] and a[i]!='?' and c[j]!='?':
      flag_ac[i-j+10000]=False
flag_bc=[True]*20000
for i in range(len_b):
  for j in range(len_c):
    if b[i]!=c[j] and b[i]!='?' and c[j]!='?':
      flag_bc[i-j+10000]=False
ans=len_a+len_b+len_c
left_a=0
for left_b in range(-(len_b+len_c),len_b+len_c+1):
  for left_c in range(-(len_b+len_c),len_b+len_c+1):
    if flag_ab[left_b-left_a+10000] and flag_ac[left_c-left_a+10000] and flag_bc[left_c-left_b+10000]:
      right_a=left_a+len_a
      right_b=left_b+len_b
      right_c=left_c+len_c
      left=min(left_a,left_b,left_c)
      right=max(right_a,right_b,right_c)
      ans=min(ans,right-left)
print(ans)

Measured memory_bytes: 51044
import sys;

for line in sys.stdin:
	if (line.find('the') != -1) | (line.find('this') != -1) | (line.find('that') != -1):
		print(line[0:len(line) - 1]);
		continue;
		
	alpha = 'abcdefghijklmnopqrstuvwxyz';
	for i in range(1, 26):
		str = '';
		for j in range(len(line) - 1):
			if ((line[j] == ' ') | (line[j] == '.')):
				str += line[j];
				continue;
			
			index = alpha.find(line[j]);
			str += alpha[(index + i) % 26];
		
		if (str.find('the') != -1) | (str.find('this') != -1) | (str.find('that') != -1):
			print(str);
			break;

Measured memory_bytes: 7388
A, B, K = map(int, input().split())
printed = list()
for i in range(A, min(B + 1, A + K)):
    if not i in printed:
        print(i)
        printed.append(i)
for i in range(max(A, B - K + 1), B + 1):
    if not i in printed:
        print(i)
        printed.append(i)


Measured memory_bytes: 3060
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
int binomialCoeff(int n,int k)
{
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=min(i,k);j>0;j--)
        dp[j]=(dp[j]+dp[j-1])%mod;
    }
    return dp[k]%mod;
    
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int n,d;
    cin>>n>>d;
    int c=0;
    int x,y;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        if((x*x+y*y)<=(d*d))
        c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  vector<ll> a(3);
  cin >> a;
  reverse(all(a));

  ll k;
  cin >> k;
  ll ma = 0;

  ll k2 = k;
  for (int i = 2; i >= 0; --i) {
    ll tmp = min(k2, a[i]);
    ma += tmp * (i - 1);
    k2 -= tmp;
  }
  cout << ma << endl;
}


Measured memory_bytes: 3656
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B????§£????????????
*/

#include <iostream>
using namespace std;
int main() {
    int n,x;
    int ans;
    while(cin >> n >> x,(n!=0)||(x!=0)){
        ans = 0;
        for(int a = 1;a <= n;a++){
            for(int b = a+1;b <= n;b++){
                for(int c = b+1;c<= n;c++){
                    if( a+b+c == x){
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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 (b<a) { a=b; return 1; } return 0; }

const lli N = 10;
bool islunlun(string x){
    rep(i, x.size()-1){
        if(abs(x[i]-x[i+1]) > 1) return false;
    }
    return true;
}

lli k;

int main(void){
    cin >> k;
    queue<lli> q;
    rep(i, 9) q.push(i+1);
    lli ans;
    rep(i, k){
        lli x = q.front();
        if(i == k-1) ans = x;
        q.pop();
        if(x%10 != 0) q.push(10*x+x%10-1);
        q.push(10*x+x%10);
        if(x%10 != 9) q.push(10*x+x%10+1);
    }
    cout << ans << endl;
    return 0;
}


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


int main(void){
  int N;
  cin >> N ;
  int ans = 0;
  int cnt = 0;
  for(int i = 1;i < N+1;i+=2){
    for(int k = 1;k <= i;k++){
      if(i%k == 0){
        cnt++;
      }
    }
    if(cnt == 8){
      ans++;
    }
    cnt = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;


namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            String s = Console.ReadLine();
            string[] ss = s.Split(' ');
            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            int c = int.Parse(ss[2]);
            int x;
            for (x = a; x <= b; x++)
            {
                
                int y = c % x;
                if (y == 0)
                {
                    i = i + 1;
                }
            }

            Console.WriteLine(i);



        }
    }
}

Measured memory_bytes: 9084
a = []
a = input().split()
N = int(a[0])
K = int(a[1])

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

count = 0

for i in range(N) :
  if h[i] >= K :
    count = count + 1

#print('(N, K) = (', N,', ', K, ')')
#print('h = ', h)

print(count)

Measured memory_bytes: 11912
#include<stdio.h>
int longth[110][110];
int main()
{
    int a,b,c,n,m,cou;
    while(scanf("%d%d",&n,&m),n + m)
    {
        for(int i = 0; i < n + 1; i++)
        {
            for(int j = 0; j < n + 1; j++)
            {
                longth[j][i] = -1;
            }
        }
        for(int i = 0; i < m; i++)
        {
            scanf("%d%d%d",&a,&b,&c);
            if(a == 0)printf("%d\n",longth[b][c]);
            else
            {
                scanf("%d",&a);
                if(longth[b][c] > a || longth[b][c] == -1)
                {
                    longth[b][c] = a;longth[c][b] = a;
                    cou = 1;
                    while(cou != 0)
                    {
                        cou = 0;
                        for(int j = 0; j < n; j++)
                        {
                            if(longth[j][b] != -1)
                            {
                                for(int k = j + 1; k < n + 1; k++)
                                {
                                    if(longth[k][b] != -1 && (longth[j][k] == -1 || longth[j][b] + longth[k][b] < longth[j][k]))
                                    {
                                        longth[j][k] = longth[j][b] + longth[k][b];
                                        longth[k][j] = longth[j][k];
                                        cou = 1;
                                    }
                                }
                            }
                        }
                        for(int j = 0; j < n; j++)
                        {
                            if(longth[j][c] != -1)
                            {
                                for(int k = j + 1; k < n + 1; k++)
                                {
                                    if(longth[k][c] != -1 && (longth[j][k] == -1 || longth[j][c] + longth[k][c] < longth[j][k]))
                                    {
                                        longth[j][k] = longth[j][c] + longth[k][c];
                                        longth[k][j] = longth[j][k];
                                        cou = 1;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2616
#include<bits/stdc++.h>
#define N 500005
#define M 500005
using namespace std;
inline int read(){
    int ans=0;
    char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
    return ans;
}
int n,m,first[N],cnt=0,d[N];
bool vis[N];
struct edge{int v,next,c;}e[M<<1];
inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;}
struct heap{int u,v;};
inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;}
priority_queue<heap>q;
set<int>col[N*10];
inline void dijkstra(){
    for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false;
    q.push((heap){1,d[1]});
    while(!q.empty()){
        heap x=q.top();
        q.pop();
        if(vis[x.u])continue;
        vis[x.u]=1;
        for(int i=first[x.u];i;i=e[i].next){
            int v=e[i].v,w=col[x.u].count(e[i].c)?0:1;
            if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c);
            else if(d[v]==d[x.u]+w)col[v].insert(e[i].c);
        }
    }
}
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;++i){
        int u=read(),v=read(),c=read();
        add(u,v,c),add(v,u,c);
    }
    dijkstra();
    printf("%d",d[n]==0x3f3f3f3f?-1:d[n]);
    return 0;
}

Measured memory_bytes: 253688
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N,M;
    cin>>N;
    vector<long long int> m(5);
    for(int i=0;i<5;++i){
        cin>>m.at(i);
    }
sort(m.begin(),m.end());
if(N>m.at(0)&& N%m.at(0)==0){
    M=N/m.at(0)+4;
}
else{
    M=N/m.at(0)+5;
}
cout<<M<<endl;
}

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

using namespace std;

#define inf 210000000
#define int long long

bool cmp(int a,int b){
		return a > b;
}

signed main() {
		string s;
		cin >> s;
		set<char> a;
		string alhu = "abcdefghijklmnopqrstuvwxyz";
		for(auto& A : s) a.insert(A);
		string ans = "None";
		for(auto& A : alhu){
				if(!a.count(A)){
						ans = A;
						break;
				}
		}
		cout << ans << endl;
}


Measured memory_bytes: 512
// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ar[1001];
    int n,m,i,sum=0,x,c=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        sum+=ar[i];
    }

 // x=sum/(4*m);
  for(i=0;i<n;i++)
    {
        if((4*m)*ar[i]>=sum)c++;
    }

  if(c>=m)cout<<"Yes\n";
  else cout<<"No\n";


}







Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            b.add(sc.nextInt());
        }
        List<Integer> a = new ArrayList<>();
        a.add(b.get(0));
        for (int i = 1; i < n -1; i++) {
            a.add(Math.min(b.get(i), b.get(i - 1)));
        }
        a.add(b.get(b.size() - 1));
        System.out.println(a.stream().mapToInt(m -> m).sum());
    }
}


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

int main(){
	long long N, K; cin >> N >> K;

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

	long long ans = 0, XOR = 0, keta = 1;
	while(keta < K) keta <<= 1;
	if(keta > K) keta >>= 1;

	for(long long i = keta; i>0; i>>=1){
		int cnt = 0;

		for(auto x : A)
			cnt += ((i & x) != 0);
			
		if(2*cnt <= N && (XOR | i) <= K) XOR |= i;
	}

	for(auto x : A)
		ans += (x ^ XOR);

	cout << ans << endl;
}


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

using namespace std;

const int maxi = 1e6+10;
int n;
int st[maxi];
map<int,int> mp;
int a[maxi];

int main()
{
    cin>>n;

    st[0]=1;
    for (int i=1;i<=30;i++)
        st[i] = st[i-1]*2;

    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
    }

    sort(a+1,a+n+1);

    int ans = 0;
    for (int i=n;i>0;i--)
    {
        if (mp[a[i]])
        {
            for (int j=30;j>0;j--)
                if (mp[st[j]-a[i]] && (st[j]/2 != a[i] || mp[a[i]]>=2))
            {
                if (st[j]<=a[i]) break;
                ans++;
                mp[st[j]-a[i]]--;
                break;
            }

            mp[a[i]]--;
        }
    }

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


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

# 0 <= A_i <= 9
# 「あるi, jがあって A_i=0 かつ A_j=9」
# 排反事象を取ると：
# 全体 - 「全てのiで A_i != 0 または A_i != 9」
# 「全てのiで A_i != 0 または A_i != 9」はベン図で考えると：
# 「全てのiで A_i = {0,1,2,3,4,5,6,7,8}」+「全てのiで A_i = {1,2,3,4,5,6,7,8,9}」-「全てのiで A_i = {1,2,3,4,5,6,7,8}」
# 以上から、求める値は：10^N - 2*9^N + 8^N
ans = 10**N - 2*9**N + 8**N
ans %= 10**9+7

print(ans)

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

int main( void ){
	
	lint a, b;
	
	cin >> a >> b;
	
	if( ( a * b ) % 2 == 0 ){
		cout << "Even" << endl;
	}else{
		cout << "Odd" << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];

int main() {
  int mx = 0, m = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    if (a[i] <= a[i - 1]) m++;
    else mx = max(m, mx), m = 0;
  }
  cout << max(m, mx) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long r,d,a;
vector<long long> v;
int main()
{
	cin>>r>>d>>a;
	long long x=a;
	for(long long i=0;i<10;i++)
	{
		long long tmp=(long long)r*x-d;
		v.push_back(tmp);
		x=tmp;
	}
	for(long long i=0;i<10;i++)
		cout<<v[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let k = v[2];
	let mut cnt = 0;
	for i in (1..(a+1)).rev() {
		if a%i == 0 && b%i == 0 {
			cnt += 1;
		}
		if cnt == k {
			println!("{}", i);
			break;
		}
	}
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}


int main(){
    ll n,ans=0;
    cin >> n;
    for (ll i=1;i<=n;i++){
        for (ll j=1;j<=n;j++){
            for (ll k=1;k<=n;k++){
                ans+=gcd(gcd(i,j),gcd(j,k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640