akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool cant[20][20];
int a,b,ans;

int main()
{
	while(cin >> a >> b,a)
	{
		REP(i,20)REP(j,20)cant[i][j] = false;
		ans = 0;
		int n;
		cin >> n;
		
		REP(i,n)
		{
			int x,y;
			cin >> x >> y;
			cant[x-1][y-1] = true;
		}
		
		queue<pair<int,int> > q;
		q.push(MP(0,0));
		
		while(!q.empty())
		{
			pair<int,int> tmp = q.front();q.pop();
			
			if(tmp.FI == a-1 && tmp.SE == b-1)
			{
				ans++;
				continue;
			}
			
			if(cant[tmp.FI][tmp.SE] == true)
			{
				continue;
			}
			
			if(tmp.FI < a-1)
			{
				q.push(MP(tmp.FI+1,tmp.SE));
			}
			
			if(tmp.SE < b-1)
			{
				q.push(MP(tmp.FI,tmp.SE+1));
			}
		}
		
		cout << ans << endl;
	}
		

	
	return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;
const int N = 404;

int n, m, ans;
int a[N], b[N];
int f[N][N][N], g[N][N][N];
int cnt[N];
int dp[N][N][N];
int ok[N][N];

inline void add(int &x, int a) {
	x = (x + a > MOD) ? x + a - MOD : x + a;
}
inline void sub(int &x, int a) {
	x = (x < a) ? x - a + MOD : x - a;
}

int main(void) {
	scanf("%d", &n); m = n / 3;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			ok[i][j] = 1;
			for (int k = 1; k <= i; k++)
				if (a[k] == b[j]) ok[i][j] = 0;
			for (int k = 1; k <= j; k++)
				if (b[k] == a[i]) ok[i][j] = 0;
		}
	
	int size;
	for (int t = 1; t <= m; t++) {
		size = 0;
		for (int i = 1; i <= n; i++) cnt[i] = 0;
		for (int i = 1; i <= n; i++) {
			if (!cnt[a[i]]) ++size;
			++cnt[a[i]];
			for (int j = 1; j <= n; j++) {
				if (!cnt[b[j]]) ++size;
				++cnt[b[j]];
				if (ok[i][j])
					f[t][i][j] = n - 3 * (m - t) - size;
			}
			for (int j = 1; j <= n; j++) {
				--cnt[b[j]];
				if (!cnt[b[j]]) --size;
			}
		}
	}

	g[0][0][0] = 1;
	for (int i = 0; i <= m; i++)
		for (int j = 0; j <= m; j++)
			for (int k = max(i, j); k <= m; k++)
				if (g[i][j][k]) {
					if (i < m) add(g[i + 1][j][k], (ll)(k - i) * g[i][j][k] % MOD);
					if (j < m) add(g[i][j + 1][k], (ll)(k - j) * g[i][j][k] % MOD);
					if (k < m) add(g[i][j][k + 1], g[i][j][k]);
				}

	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			dp[0][i][j] = 1;
	for (int t = 1; t <= m; t++) {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++) {
				dp[t][i][j] = 0;
				if (!ok[i][j]) continue;
				add(dp[t][i][j], (ll)dp[t - 1][i - 1][j - 1] * f[t][i][j] % MOD);
			}
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				add(dp[t][i][j], dp[t][i - 1][j]);
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				add(dp[t][i][j], dp[t][i][j - 1]);
	}
	
	ans = (ll)dp[m][n][n] * g[m][m][m] % MOD;
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 260352
#include<stdio.h>

int sl=0, tl=0;
char s[51], t[51];

void restore(int idx){
        for(int i=0; i<sl; i++){
                if(idx<=i && i<idx+tl) s[i] = t[i-idx];
                else if(s[i]=='?') s[i] = 'a';
        }
}

int main(void){
        while((s[sl]=getchar())!='\n') sl++;
        while((t[tl]=getchar())!='\n') tl++;

        int idx = -1;
        for(int i=0; i<=sl-tl; i++){
                int can = 1;
                for(int j=0; j<tl; j++){
                        if(s[i+j]!=t[j] && s[i+j]!='?') can = 0;
                }
                if(can) idx = i;
        }

        if(idx>=0){
                restore(idx);
                printf("%s", s);
        }else puts("UNRESTORABLE");
        return 0;
}


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

using namespace std;

int solve(int K, vector<int> &xs)
{
    sort(xs.begin(), xs.end());
    xs.back() *= (1 << K);
    return accumulate(xs.begin(), xs.end(), 0);
}

int main()
{
    ios::sync_with_stdio(false);
    vector<int> xs(3);
    for (int i = 0; i < 3; i++)
        cin >> xs[i];

    int K;
    cin >> K;

    auto ans = solve(K, xs);

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string in;
    cin>>in;
    vector<int> dan;
    vector<pair<int,int>> ikes;
    for(size_t i=0;i<in.size();i++){
        if(in[i]=='\\'){
            dan.push_back(i);
        }
        if(in[i]=='/'&&!dan.empty()){
            int l=dan.back();dan.pop_back();
            pair<int,int> ike;
            ike.first=l;
            ike.second=i-l;
            while(!ikes.empty()&&ikes.back().first>l){
                ike.second+=ikes.back().second;
                ikes.pop_back();
            }
            ikes.push_back(ike);
        }
    }
    long ans=0;
    for(auto i:ikes)ans+=i.second;
    cout<<ans<<endl;
    cout<<ikes.size();
    if(ikes.size()==0)cout<<endl;
    else cout<<" ";
    for(size_t j=0;j<ikes.size();j++){
        auto i=ikes[j];
        cout<<i.second;
        if(j==ikes.size()-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
}


Measured memory_bytes: 3264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

			String in = br.readLine();
			String chr[] = in.split(" ");
			double t = Integer.parseInt(chr[0]);
			double x = Integer.parseInt(chr[1]);
			 System.out.println(t/x);
		}
	}
}

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

int main(){
  ll x,y;
  cin >>x >>y;
  if(x%y==0) cout << -1 << endl;
  else cout << x << endl;
  return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = min(A * N, B);
  cout << ans << endl;
}

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

  solve();

  return 0;
}


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

constexpr int INF = 1e9;

int main() {
    int N, M; cin >> N >> M;
    vector<int> num(M);
    vector<vector<int>> sum(N + 1, vector<int>(M));
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        sum[i + 1][a - 1]++;
        num[a - 1]++;
        for(int j = 0; j < M; ++j) {
            sum[i + 1][j] += sum[i][j];
        }
    }

    vector<int> dp(1 << M, INF);
    dp[0] = 0;
    vector<int> len(1 << M);
    for(int S = 0; S < (1 << M); ++S) {
        for(int i = 0; i < M; ++i) {
            if(S & (1 << i)) {
                continue;
            }
            int l = len[S], r = len[S] + num[i];
            dp[S | (1 << i)] = min(dp[S | (1 << i)], dp[S] + (r - l) - (sum[r][i] - sum[l][i]));
            len[S | (1 << i)] = r;
        }
    }

    cout << dp.back() << endl;
}



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

int main() {
	int a,b,c,n,buhin[300],kensa[1000][4];
	while(1){
	for(int i = 0;i < 300;i++) buhin[i] = 2; 
	cin >> a >> b >> c >> n;
	if(a == 0 && b == 0 && c == 0) break;
	for(int i = 0;i < n;i++){
		cin >> kensa[i][0] >> kensa[i][1] >> kensa[i][2] >> kensa[i][3];
		if(kensa[i][3]){
			buhin[kensa[i][0] - 1] = 1;
			buhin[kensa[i][1] - 1] = 1;
			buhin[kensa[i][2] - 1] = 1;
		}
	}
	for(int i = 0;i < n;i++){
		if(!kensa[i][3]){
			if(buhin[kensa[i][0] - 1] == 1 && buhin[kensa[i][1] - 1] == 1) buhin[kensa[i][2] - 1] = 0;
			if(buhin[kensa[i][0] - 1] == 1 && buhin[kensa[i][2] - 1] == 1) buhin[kensa[i][1] - 1] = 0;
			if(buhin[kensa[i][2] - 1] == 1 && buhin[kensa[i][1] - 1] == 1) buhin[kensa[i][0] - 1] = 0;
		}
	}
	for(int i = 0;i < a + b + c;i++) cout << buhin[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


N = int(input())
fact = factorization(N)
ans = 0
for f in fact:
    if f[0] >= 2:
        remain = f[1]
        tmp = 1
        while True:
            remain -= tmp
            if remain >= 0:
                ans += 1
            else:
                break
            tmp += 1
print(ans)


Measured memory_bytes: 9484
#include <iostream>

using namespace std;
#include <algorithm>
#include <iostream>
#include <vector>
bool compare_by_b(pair<string, int> a, pair<string, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}
int main(){
  int N;
  cin>>N;
  vector<string> S;
  string s;
  for(int i=0;i<N;i++){
    cin>>s;
    S.push_back(s);
  }
  vector<pair<string,int> > ans;
  int count=1;
  int max_con=1;
  sort(S.begin(),S.end());

  pair<string,int> p1=make_pair(S[0],count);
  ans.push_back(p1);
  for(int i=1;i<S.size();i++){
    if(S[i]==S[i-1]){
      ans[ans.size()-1].second++;
      count++;

    }else{
      pair<string,int> pn=make_pair(S[i],1);
      ans.push_back(pn);
      if(count>max_con)max_con=count;
      count=1;
    }
  }
  if(count>max_con)max_con=count;
  
  sort(ans.begin(),ans.end(),compare_by_b);
  vector<string> anss;
  for(int i=0;i<ans.size();i++){
    if(ans[i].second>=max_con){
      anss.push_back(ans[i].first);
    }
  }
  sort(anss.begin(),anss.end());
  for(int i=0;i<anss.size();i++)cout<<anss[i]<<endl;

}

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>>data(n,vector<int>(n));
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 2;j++){
      cin >> data.at(i).at(j);
    }
  }
  
  bool flg = false;
  for(int i = 0;i < n-2;i++){
    if(data.at(i).at(0) == data.at(i).at(1)
      &&data.at(i+1).at(0) == data.at(i+1).at(1)
      &&data.at(i+2).at(0) == data.at(i+2).at(1))
      flg = true;
  }
  
  if(flg)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vec(T) vector<T>
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int A, B;
    cin >> A >> B;
    if(A >= 13) cout << B << endl;
    else if(A <= 5) puts("0");
    else cout << B / 2 << endl;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    ans := a+b+c-max32(a,max32(b,c))
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  s=chomp(readline())
  flag=('N' in s)==('S' in s) && ('E' in s)==('W' in s)
  println(flag ? "Yes" : "No")
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 108284
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  vecint h(n);
  for(auto&& e:h) cin>>e;
  vecint top(n);
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    top[a] = max(top[a], h[b]);
    top[b] = max(top[b], h[a]);
  }
  int cnt = 0;
  REP(i,n) if (h[i] > top[i]) ++cnt;
  cout<<cnt<<"\n";
  return 0;
}


Measured memory_bytes: 3964
n=int(input())
a=[]
cnt = [0]*100005
for i in input().split():
	cnt[int(i)]+=1
	a+=[int(i)]
ans = sum(a)
Q=int(input())
for i in range(Q):
	b,c=map(int,input().split())
	ans += cnt[b]*c - cnt[b]*b
	cnt[c]+=cnt[b]
	cnt[b]=0
	print(ans)


Measured memory_bytes: 21212
N = int(input())
A = list(map(int, input().split()))

if A.count(0) > 0:
    print(0)
    exit()

ans = 1
for i in range(N):

    if ans * A[i] > 10**18:
        print(-1)
        exit()

    ans *= A[i]

print(ans)


Measured memory_bytes: 87788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < H; i++) {
            String s = scan.next();
            if (0 <= s.indexOf("#")) {
                list.add(s);
            }
        }
        boolean[] f = new boolean[W];
        for (int i = 0; i < W; i++) {
            boolean feasible = true;
            for(String s : list) {
                char[] d = s.toCharArray();
                if (d[i] == '#') {
                    feasible = false;
                    break;
                }
            }
            f[i] = feasible;
        }
        List<String> answer = new ArrayList<>();
        for(String s : list) {
            char[] d = s.toCharArray();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < W; i++) {
                if (!f[i]) {
                    sb.append(d[i]);
                }
            }
            answer.add(sb.toString());
        }
        for(String s: answer) {
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  A, B ;
  cin >> A >> B; 
     if(B >=0 && A + B >= A * B)
  cout << A + B << endl; 
     else if(B <=0 && A - B >= A * B)
  cout << A - B << endl; 
     else
  cout << A * B << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<int, int>;

int a[100001], b[100001];

// return n! mod p
int fact(int n, int p = INT_MAX){
    static vector<int> memo(1, 1);
    if ((int) memo.size() <= n) {
        int l = memo.size();
        memo.resize(n+1);
        for(int i = l; i <= n; i++) memo[i] = (ll) memo[i-1] * i % p;
    }
    return memo[n];
}

//solve ax+by=gcd(a, b)
//return gcd(a, b)
int gcd(int a, int b, int* px = NULL, int* py = NULL){
    if(py == NULL){
        if(b == 0) return a;
        return gcd(b, a % b);
    }
    int d = a;
    if( b != 0){
        d = gcd(b, a % b, py, px);
        *py -= (a / b) * *px;
    }else{
        *px = 1; *py = 0;
    }
    return d;
}

// return a^(-1) mod m
int modInverse(int a, int m = MOD){
    int x, y;
    gcd(a, m, &x, &y);
    return (m + x % m) % m;
}

// return a mod p (when n!=a*p^e), o(log_p n)
int modFact(int n, int& e, int p = MOD){
    e = 0;
    if(n == 0) return 1;

    int res = modFact(n / p, e, p);
    e += n / p;

    if((n / p % 2 != 0)) return (ll) res * (p - fact(n % p, p)) % p;
    return (ll) res * fact(n % p, p) % p;
}

// return nPk mod p
int perm(int n, int k, int p = MOD){
    if(n < 0 or k < 0 or n < k) return 0;
    int e1, e2;
    int a1 = modFact(n, e1, p), a2 = modFact(n - k, e2, p);
    return (ll) a1 * modInverse(a2, p) % p;
}

// return nCk mod p, o(log_p n)
int comb(int n, int k, int p = MOD){
    if(n < 0 or k < 0 or n < k) return 0;
    int e1, e2, e3;
    int a1 = modFact(n, e1, p), a2 = modFact(k, e2, p), a3 = modFact(n - k, e3, p);
    if(e1 > e2 + e3) return 0;
    return (ll) a1 * modInverse((ll)a2 * a3 % p, p) % p;
}

// return nHk mod p
int hcomb(int n, int k, int p = MOD){
    if(n < 0 or k < 0) return 0;
    if(n == 0 and k == 0) return 1;
    return comb(n + k - 1, k, p);
}

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

    sort(b, b+N+1);
    int num;
    for(int i = 0; i < N; i++){
        if(b[i] == b[i+1]) num = b[i];
    }

    int i, l = 0;
    for(i = 0; i < N+1; i++){
        if(a[i] == num) break;
        l++;
    }
    i++;
    while(a[i] != num) i++;
    for(i++; i < N + 1; i++) {l++;}

    for(int k = 1; k <= N+1; k++){
        cout << ((comb(N+1, k) - comb(l, k-1)) + (ll) MOD) % MOD << '\n';
    }

    return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a,b,c;
		cin >> a >> b >> c;
		if(c < a || c < b){
			int* x = (a > b) ? &a : &b;
			int temp  = c;
			c = *x;
			*x = temp;
		}
		cout << ((a*a + b*b == c*c) ? "YES" : "NO" )<< endl;
	}
}


Measured memory_bytes: 3076
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			String s=sc.next();
			if(s.equals("0")){
				break;
			}
			int r=Integer.parseInt(s.substring(1, 3), 16);
			int g=Integer.parseInt(s.substring(3, 5), 16);
			int b=Integer.parseInt(s.substring(5, 7), 16);
			int k=-1;
			double min=INF;
			for(int i=0; i<8; i++){
				int dr=r-(i/4)*0xff;
				int dg=g-((i/2)%2)*0xff;
				int db=b-(i%2)*0xff;
				double d=Math.sqrt(dr*dr+dg*dg+db*db);
				if(d+EPS<min){
					k=i;
					min=d;
				}
			}
			println(new String[]{"black", "blue", "lime", "aqua", "red",
					"fuchsia", "yellow", "white",}[k]);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin>>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  map<int,ll> mp;
  rep(i,n){
    mp[a[i]]++;
    mp[a[i]-1]++;
    mp[a[i]+1]++;
  }
  ll count=0;
  for(auto x:mp){
    count = max(count,x.second);
  }
  cout <<count<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

inline void Main() {
  // code
  int n, cu=0, co=1;
  cin >> n;
  vector<int> vi(n);
  rep(i, n) cin >> vi.at(i);
  while(co<=n) {
    cu = vi.at(cu) - 1;
    if(cu==1) {
      cout << co << endl;
      return;
    }
    co++;
  }
  cout << -1 << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 640
<?php
while (true) {
    fscanf(STDIN, "%d %s %d", $a, $op, $b);
    switch ($op) {
        case '+':
            echo $a + $b.PHP_EOL;
            break;
        case '-':
            echo $a - $b.PHP_EOL;
            break;
        case '*':
            echo $a * $b.PHP_EOL;
            break;
        case '/':
            echo floor($a / $b).PHP_EOL;
            break;
        case '?':
            exit;
        default:
            break;
    }
}

Measured memory_bytes: 15248
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	int ans[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans[i]=0;
	}
	a[n]=0;
	int dis=abs(a[0]);
	for(int i=1;i<n;i++){
		dis+=abs(a[i]-a[i-1]);
	}
	dis=dis+abs(a[n-1]);
	for(int i=0;i<n;i++){
		if(a[i]<0&&a[i+1]<0&&a[i]>a[i+1]){
			ans[i]=dis;
		}
		else if(a[i]>0&&a[i+1]>0&&a[i]<a[i+1]){
			ans[i]=dis;
		}
		else if(a[i]==a[i+1]){
			ans[i]=dis;
		}
		else if(a[i]==0&&i==n-1){
			ans[i]=dis;
		}
		ans[i]=dis-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]);
	}
	for(int i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 2048
#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>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, vector<pair<int,ll>>> m;
    for(int i=0;i<n-1;++i)
    {
        int src, dst, cost;
        cin >> src >> dst >> cost;
        m[src-1].PB(MP(dst-1, cost));
        m[dst-1].PB(MP(src-1, cost));
    }

    bool visited[n] = {};
    int color[n] = {};
    visited[0] = true;

    deque<int> q;
    q.push_back(0);

    while(!q.empty())
    {
        int start = q.front();
        q.pop_front();
        auto links = m[start];

        for(const auto& link : links)
        {
            int dst = link.first;
            ll cost = link.second;

            if(!visited[dst])
            {
                if ((cost % 2) == 0)
                {
                    color[dst] = color[start];
                }
                else
                {
                    color[dst] = 1 - color[start];
                }

                q.push_back(dst);
                visited[dst] = true;
            }
        }
    }

    for(int i=0;i<n;++i)
    {
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
#define lim 1000000000000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(),v.end()
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
const int N = (int)1e3+5;

vector<pii> v[N][N];
vector<vector<int>> distance_from_source;
vector<string> grid;
int r, c;
void dijksta(int source_x, int source_y) {
  distance_from_source[source_x][source_y] = 0;
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  pq.push({0,{source_x,source_y}});
  while(!pq.empty()) {
    pii curr_node = pq.top();
    pq.pop();
    int x = curr_node.second.first, y = curr_node.second.second;
    if(distance_from_source[x][y] == curr_node.first) {
      REP(k,-2,2) {
        REP(l,-2,2) {
          if(x+k>=0 && x+k<r && y+l>=0 && y+l<c && grid[x+k][y+l]=='.') {
            int _x = x+k, _y = y+l, d = (abs(k)+abs(l))!=1;
            if(distance_from_source[_x][_y] > distance_from_source[x][y] + d) {
              distance_from_source[_x][_y] = distance_from_source[x][y] + d;
              pq.push({distance_from_source[_x][_y], {_x, _y}});
            }
          }
        }
      }
    }
  }
}

void solve() {
  cin >> r >> c;
  distance_from_source = vector<vector<int>>(r,vector<int>(c,1e9));

  int source_x, source_y;
  int destination_x, destination_y;
  cin >> source_x >> source_y;
  cin >> destination_x >> destination_y;
  source_x--, source_y--;
  destination_x--, destination_y--;

  grid = vector<string>(r);
  REP(i,0,r-1) {
    cin>>grid[i];
  }
  dijksta(source_x, source_y);
  if(distance_from_source[destination_x][destination_y] == 1e9) {
    distance_from_source[destination_x][destination_y] = -1;
  }
  cout << distance_from_source[destination_x][destination_y];
}

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

  int T=1;
  //cin>>T;
  REP(TC,1,T) {
      //cout<<"Case #"<<TC<<": ";
      solve();
      cout<<"\n";
  }
}


Measured memory_bytes: 32340
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, *abc = map(int, read().split())
c = abc[2 * (N - 1):]
c.sort()
graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(abc[:2 * (N - 1)])] * 2):
    graph[a].append(b)
    graph[b].append(a)

nodes = [0] * (N + 1)
score = sum(c) - c[-1]
start = 1
nodes[start] = c.pop()
queue = [start]
while queue:
    V = queue.pop()
    for v in graph[V]:
        if nodes[v] == 0:
            nodes[v] = c.pop()
            queue.append(v)

print(score)
print(' '.join(map(str, nodes[1:])))


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

int main(){
  vector<int> t(3);
  rep(i,3) cin >> t[i];
  sort(t.begin(),t.end());
  cout << t[2]-t[1] + t[1]-t[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define endl '\n'
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <=n; i++)
#define rep2(i, n) for (i = 0; i < n-1; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend() //Sort in reverse,Vector.
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.



int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif

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

   int i,k=0;

   for(i=0;s[i]!='\0';i++)
   {
      if(s[i]!=t[i])
        k++;
   }

   cout<<k;


  
   
}  
   




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

int a[200005];
int dp[200005][5];

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

  for(int i = 0; i <= l; i++) {
    for(int j = 0; j < 5; j++) {
      dp[i][j] = 1e9;
    }
  }
  dp[0][0] = 0;

  for(int i = 1; i <= l; i++) {
      int pre = 1e9;
      for(int k = 0; k < 5; k++) {
	pre = min(pre,dp[i-1][k]);
	int tmp;
	if(k == 0 || k == 4) tmp = a[i-1];
	if(k == 1 || k == 3) tmp = (a[i-1] == 0 ? 2 : a[i-1] % 2);
	if(k == 2) tmp = (a[i-1]+1) % 2;
	dp[i][k] = pre + tmp;
      }
    
  }

  int ans = 1e9;

  for(int i = 0; i < 5; i++) ans = min(ans,dp[l][i]);

  cout << ans << endl;
}

  
  


Measured memory_bytes: 4992
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int count = K;
        int sum =0;

        while(count>0){
            if(A>0){
                sum+=1;
                A--;
            }else if(B>0){
                B--;
            }else if(C>0){
                sum-=1;
                C--;
            }

            count--;
        }

        System.out.println(sum);
    }
}

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

int main() {

    int n;

    std::cin >> n;

    int a[100] = { };

    for ( int i = 0; i < n; i++ ) {
        std::cin >> a[i];
    }

    for ( int i = n - 1; i >= 0; --i ) {
        std::cout << a[i];
        if ( i ) std::cout << " ";
    }

    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 3076
using System;

namespace ABC122_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var cnt = 0;
            var ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T')
                {
                    ans = Math.Max(ans, cnt);
                    cnt = 0;
                }
                else
                {
                    cnt++;
                }
            }

            ans = Math.Max(ans, cnt);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        
        int R = 0;
        for (int i = 0; i < N; i++) {
            int A = scanner.nextInt();
            
            if (i % 2 == 0 && A % 2 ==1){
                R++;
            }
        }

        System.out.println(R);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35924
using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            // 下手な鉄砲数うちゃ当たる！！

            // 1行目
            long input1 = 0;
            input1 = long.Parse(Console.ReadLine());
            // 2行目
            //string[] input2 = new string[] { "1", "2", "3", "4", "5", "6" };
            //string[] input2 = new string[] { "10", "-10" };
            string[] input2 = Console.ReadLine().Split(' ');
            //string[] input2 = new string[] { "1", "1", "1", "1", "1", "1" };
            //string[] input2 = new string[] { "6", "5", "4", "3", "2"};
            //string[] input2 = new string[] { "1", "0", "0", "0", "-1" };
            //string[] input2 = new string[] { "100000000000", "-100000000000" };

            List<long> resultList = new List<long>();

            long sum = 0;
            for (long i = 0; i < input2.Length; i++)
            {
                sum += long.Parse(input2[i]);
            }
            long senkou = 0;
            long koukou = 0;

            for (long i = 0; i < input2.Length -1; i++)
            {
                senkou += long.Parse(input2[i]);
                koukou = sum - senkou;
                long calcResult = senkou - koukou;
                if (calcResult < 0)
                {
                    calcResult = calcResult * -1;
                }
                resultList.Add(calcResult);
            }

            resultList.Sort();
            string ret = resultList[0].ToString();
            //出力
            Console.WriteLine(ret);

        }

    }
}


Measured memory_bytes: 35012
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int[] d = new int[n];
	  int sum = 0;
	  for(int i=0;i<n;i++)d[i]=sc.nextInt();
	  for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++){
	  	sum+=d[j]*d[i];
	  }
	  System.out.println(sum);
	}
}

Measured memory_bytes: 23124
def umeru(x):#x Z
    s = str(x)
    return  '0'*(3-len(s))+s

def search(s,S):
    ok = 0
    for i in range(len(S)):
        point = s[ok]
        if S[i]==point:
            ok +=1
        if ok==3:
            return True
    return False
n = input()
S = input()
count = 0
for i in range(1000):
    s = umeru(i)
    if search(s,S):
        count +=1
print(count)

Measured memory_bytes: 42096
input_lines = input()
input_num = input_lines.split()
num1 = int(input_num[0])
num2 = int(input_num[1])

mul_num = num1 * num2

if(mul_num % 2 == 1):
  print("Odd")
elif(mul_num % 2 == 0):
  print("Even")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.size() <= k)
		cout << s << endl;
	else
	{
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
}

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

char str[30005];
int nxt[30005][10];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",&str);
	for(int i=0;i<10;i++) nxt[n][i]=n;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=0;j<10;j++) nxt[i][j]=nxt[i+1][j];
		int a=str[i]-'0';
		nxt[i][a]=i;
	}
	int ret=0;
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
		{
			for(int k=0;k<10;k++)
			{
				int now=nxt[0][i];
				now++;
				now=nxt[min(now,n)][j];
				now++;
				now=nxt[min(now,n)][k];
				if(now<n) ret++;
			}
		}
	}
	printf("%d\n",ret);
	return 0;
}

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

map< pi, int > squares;

void solve() {
  int h, w, n;
  int x, y;
  cin >> h >> w >> n;

  rep(l, 1, n) {
    cin >> x >> y;
    rep(i, x - 1, x + 1) {
      rep(j, y - 1, y + 1) {
        if (i <= 1 || j <= 1 || i >= h || j >= w) {
          continue;
        }
        squares[mp(i, j)]++;
      }
    }
  }

  vector<ll> res(10, 0);
  res[0] = (h - 2) * 1ll * (w - 2) - (ll)squares.size();
  for (auto it : squares) {
    res[it.second]++;
  }

  rep(i, 0, 9) {
    cout << res[i] << nl;
  }
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}


Measured memory_bytes: 59740
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int A,N, B;
	cin >> N >> A >> B;
	cout << min(N*A, B);
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

gap = float("inf")

for i in range(N):
    if abs(T - H[i] * 0.006 - A) < gap:
        ans = i + 1
        gap = abs(T - H[i] * 0.006 - A)
print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"strings"
)

func main() {
	var slimes int
	fmt.Scanf("%d", &slimes)
	var color string
	fmt.Scanf("%s", &color)

	strColor := strings.Split(color, "")

	str := ""
	counter := 0
	for i := 0; i < slimes; i++ {
		if str != strColor[i] {
			str = strColor[i]
			continue
		}
		counter++
	}

	fmt.Printf("%d", (slimes - counter))
}


Measured memory_bytes: 2944
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
struct node {
  int l, r;
  bool operator < (const node &a) const {
    return r == a.r? l > a.l :r < a.r;
  }
}a[120000];
bool bkt[120000];
int main() {
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= m; i ++ ) {
    cin >> a[i].l >> a[i].r;
  }
  sort(a+1, a+m+1);
  int now = 0;
  int maxn = 0;
  for(int i = 1; i <= m; i ++ ) {
    // cout<<a[i].l<<" "<<a[i].r<<endl;
    if(maxn > a[i].l) continue;
    else maxn = a[i].r, now ++;
  }
  printf("%d\n", now);
}


Measured memory_bytes: 1024
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        w: usize,
        h: usize,
        x: usize,
        y: usize,
    }
    let min = w * h / 2;
    let odd = w % 2 == 1 && h % 2 == 1;
    let ww = vec![x, w - x];
    let hh = vec![y, h - y];
    // center
    let cnt_result = if ww[0] == ww[1] && hh[0] == hh[1] {
        1
    } else {
        0
    };
    // let rects = vec![
    //     vec![x * y, x * (h - y),],
    //     vec![(w - x) * y, (w - x) * (h - y),],
    // ];
    // // println!("{:?}", rects);
    // let hol = vec![rects[0][0] + rects[0][1], rects[1][1] + rects[1][0],];
    // let hol = hol.iter().min().unwrap();
    // let vert = vec![rects[0][0] + rects[1][0], rects[1][1] + rects[0][1],];
    // let vert = vert.iter().min().unwrap();
    // let sum_rects = vec![
    //     hol,
    //     vert
    // ];
    // // println!("{:?}", sum_rects);
    // let min = sum_rects.iter().max().unwrap();
    // let cnt = sum_rects.iter().filter(|&v| v == min).count();
    // let cnt_result = if cnt > 1 {
    //     1
    // } else {
    //     0
    // };
    println!("{}{} {}", min, if odd { ".5" } else { "" }, cnt_result);
}


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

int main(){
    int a[5], b[5];
    int MIN=10;
    int sum = 0;
    rep(i,5){
        cin >> a[i];
        if(a[i]%10==0){
            b[i] = 10;
        }else{
            b[i] = a[i]%10;
        }
        sum += a[i] -b[i] + 10;
        MIN = min(MIN, b[i]);
    }

    sum += MIN - 10;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=2005,MOD=1e9+7;
int n,m;
int f[N];
void readData(){
    scanf("%d%d",&n,&m);
}
void dp(){
    f[n+1]=1;
    int sum,last;
    for(int i=1;i<m;i++){
        sum=f[n-i+2];
        for(int j=n-i+1;j>=2;j--){
            (sum+=f[j])%=MOD;
                f[j]=sum;
        }
    }
    int ans=0;
    for(int j=2;j<=n-(m-1)+1;j++) (ans+=f[j])%=MOD;
    if(m==1) ans=1;
    for(int i=1;i<=n-m-1;i++) (ans<<=1)%=MOD;
    printf("%d\n",ans);
}
int main(){
    readData();
    dp();
    return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long H, long long A) {
    cout << (H + A - 1) / A << endl;
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long A;
  scanf("%lld", &A);
  solve(H, A);
  return 0;
}


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

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           

                
void solve(){
    int n ;
    cin >> n ;
    int a[4]={0};
    while(n--){
        string s; cin >> s;
        if(s== "AC")a[0]++;
        else if (s=="WA")a[1]++;
        else if(s=="TLE")a[2]++;
        else if(s=="RE")a[3]++;
    }
    cout << "AC x "<< a[0] << endl << "WA x "<< a[1] << endl << "TLE x "<< a[2] << endl << "RE x "<< a[3] << endl;
}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
  //  int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using std::string;
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define FORR(i,l,r) for(int (i)=l;(i)<(r);++(i))
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define EPSILON 1e-9
#define MAX 100002
#define PI 3.1415926535897932384626433832795028841971693993751
typedef long long  ll;
typedef unsigned long long llu;
typedef long double  ldb;
typedef double  db ;
int dp[100002],h[100002],inf=1000000002;
int main()
{
    // freopen("in.txt","r",stdin);
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>h[i];
        dp[i]=inf;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++)
    {
        for(int j=1; j<=k; j++)
            if(i-j>=0)
                dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1
#define KETA 2
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<std::setw(KETA) << std::setfill('0')<<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
//#define MAX 10

    ll N,K,id=9;
    ll A[100010],sum=0,ans=0;


int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>K;
    int temp=(N+11-2)%11;
    if(N-2<0)ans=0;
    else ans+=((N-2)/11)*5;

        REP(i,temp+1){
            ll a=id;
            REP(j,5){
                if(i==0||i==N-1)break;
                    if(j==0){
                        sum=a*9;
                    }else{
                        a++;
                        sum=a*9;
                    }
                    DEB(sum%11)
                    if(sum%11==K){ans++;}
            }
            END;
            if(!(i==0||i==N-1))id+=7;
            //DEB(id) END
        }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int count = 0;
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
			if (a[i] == 5) {
				count++;
			}
		}
		if (count == 1 || count == 3) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}

}


Measured memory_bytes: 9428
X = gets.to_i
P = gets.split.map(&:to_i).sort_by{|_| (X-_).abs }
if X!=P.shift
	p X
else
	(1..).each{|d|
		pp = P.shift 2
		if not pp.include? X-d
			break p(X-d)
		elsif not pp.include? X+d
			break p(X+d)
		end
	}
end


Measured memory_bytes: 14304
#A,B,C,X=map(int,input().split()) #500,100,50, total
#X=500*a+100*b+50*c
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if X==500*a+100*b+50*c:
        count=count+1
print(count)
        



Measured memory_bytes: 2940