akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] data = new int[] {0, Integer.MAX_VALUE};
        for (int i  = 0; i < N; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (b < data[1]) {
                data[0] = a;
                data[1] = b;
            }
        }
        int x = data[0] + data[1];
        System.out.println(x);
    }
}

Measured memory_bytes: 63024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll W,H;
ll x,y;
  cin>>W>>H>>x>>y;
 //ll ans;
  
  if(W%2==1&&H%2==1){
  cout<<W*H/2+0.5<<" ";
  }
else{
cout<<W*H/2<<" ";
}
  
  if(2*x==W&&2*y==H){
    cout<<1<<endl;
  }
  else{
  cout<<0<<endl;
  }
  

  
  
  
  
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n ;
int Min;
int a, b;

void check(int x){
	int y = n - x ;
	int now = 0;
	int xx = x , yy = y;
	while(x){
	   now += x % 10;
	   x /= 10;
	}
	while(y){
	   now += y % 10;
	   y /= 10;
	}
	if( now < Min ) Min = now , a = xx , b = yy; 
	return;
}

int main(){
    scanf("%d",&n);
    Min = 100000000;
	for(int i = 1;i < n;++i)
      check(i);
    printf("%d",Min);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
		var n = int.Parse(Console.ReadLine());
      var l2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      var T = l2[0];var A = l2[1];
      double min = 601;
      int idx = -1;
      var arrH = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      for (int i = 0; i < n; i++)
      {
        var tmp = T - (0.006 * arrH[i]);
        var diff = Math.Abs(A - tmp);
        if (diff < min) { min = diff; idx = i+1; }
      }
      Console.WriteLine(idx);
	}
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		 Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
  //      pw=new PrintWriter("C:\\Users\\Hp\\Desktop\\outt.txt");
        int n=sc.nextInt();
        int r=sc.nextInt();
        int ans=r;
        if(n<10){
          ans+=100*(10-n);
        }
        pw.println(ans);
        pw.close();
    }

    public static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException, IOException {
            return br.ready();
        }

    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double s=0;
  for(int i=0;i<n;i++){
    double a;
    cin>>a;
    s+=1/a;
  }
  cout<<fixed<<setprecision(10)<<1/s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,Ma,Mb,K=0,C[45];
ll A,B[100005]={};
ll T,a,b;
ll ans=0;
bool h,o;
//bool D[100005];
string str,str2[55][55];
map<string,int> m;
vector<int> v[10];
ll dp[45][405][405];
int main(){
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>A;
		B[A]++;
	}
	for(int i=0;i<100005;++i){
		if(B[i]>0){
			++ans;
			if(B[i]>1){
				K+=B[i]-1;
			}
		}
	}
	cout<<ans-K%2<<endl;
	return 0;
}


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

using namespace std;

struct DudeWhat { // fenwick
	int n;
	vector<int> arr;
	DudeWhat() {}
	DudeWhat(int n) : n(n), arr(n + 1) {}
	int LSB(int ci) {return (ci & (-ci));}
	void add(int i, int v) {
		for (int ci = i + 1; ci <= n; ci += LSB(ci)) arr[ci] += v;
	}
	int getPrefix(int i) {
		int ans = 0;
		for (int ci = i + 1; ci > 0; ci -= LSB(ci)) ans += arr[ci];
		return ans;
	}
	int getRangeSum(int i, int j) {
		return getPrefix(j) - getPrefix(i-1);
	}
};

int main() {
	int n, q; scanf("%d %d", &n, &q);
	vector<int> colors(n);
	for (int i = 0; i < n; ++i) scanf("%d", &colors[i]);
	vector<int> sagot(q, -1);
	vector<vector<pair<int, int>>> qToAnswer(n);
	for (int i = 0; i < q; ++i) {
		int l, r; scanf("%d %d", &l, &r);
		--l; --r;
		qToAnswer[l].emplace_back(r, i);
	}
	DudeWhat dsjongOrz(n);
	map<int, int> lastOcc;
	for (int i = n - 1; i >= 0; --i) {
		if (lastOcc.count(colors[i]) > 0) {
			dsjongOrz.add(lastOcc[colors[i]], -1);
		}
		dsjongOrz.add(i, 1);
		lastOcc[colors[i]] = i;
		for (auto [qRight, itp] : qToAnswer[i]) {
			sagot[itp] = dsjongOrz.getRangeSum(i, qRight);
		}
	}
	for (int i = 0; i < q; ++i) printf("%d\n", sagot[i]);
	return 0;
}


Measured memory_bytes: 54744
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int L,a,b,m;
int x=0;
int gy[3][3],tmp[3][3],ans[3][3];
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;//res%=MOD;
    n*=n;//n%=MOD;
    k>>=1;
  }
  return res;
}
void toans(){
  memset(tmp,0,sizeof(tmp));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
        tmp[i][j]+=gy[i][k]*ans[k][j];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)ans[i][j]=tmp[i][j]%m;
}
void gygy(){
  memset(tmp,0,sizeof(tmp));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
        tmp[i][j]+=gy[i][k]*gy[k][j];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)gy[i][j]=tmp[i][j]%m;
}
void g(int n){
  int t=n;
  memset(ans,0,sizeof(ans));
  ans[0][0]=ans[1][1]=ans[2][2]=1;
  while(n){
    if(n&1)toans();
    gygy();
    n>>=1;
  }
}
void f(int n){
  int l=(pw(10,n-1)-a)/b;if((pw(10,n-1)-a)%b)l++;if((pw(10,n-1)-a)<0)l=0;
  int r=(pw(10,n)-a)/b;r--;if((pw(10,n)-a)%b)r++;if((pw(10,n)-a)<0)r=-1;
  r=min(r,L-1);l=min(l,L);
  //cout<<l<<" "<<r<<endl;
  memset(gy,0,sizeof(gy));
  gy[0][1]=gy[1][1]=gy[2][2]=1;
  gy[1][2]=b;
  gy[0][0]=pw(10,n)%m;
  g(r-l+1);
  x=(ans[0][0]*x+ans[0][1]*((a%m+b%m*l)%m)+ans[0][2])%m;
  //cout<<x<<endl;
}
//main
signed main(){
  cin>>L>>a>>b>>m;
  for(int i=1;i<=18;i++)f(i);
  cout<<x<<endl;
}


/*
if(t==2&&n==1){
  cout<<gy[0][0]<<" "<<gy[0][1]<<" "<<gy[0][2]<<endl;
  cout<<gy[1][0]<<" "<<gy[1][1]<<" "<<gy[1][2]<<endl;
  cout<<gy[2][0]<<" "<<gy[2][1]<<" "<<gy[2][2]<<endl;
}
*/


Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(N,K);
    Cins(S);
    rep(i,N){
        if(i==K-1) cout << char(S[i] - 'A' + 'a');
        else cout << S[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int year,month,day;
  scanf("%d/%d/%d",&year,&month,&day);
  if(year!=2018){
    year=2018;
  }
  printf("%d/",year);
  if(month<10){
    printf("0");
  }
  printf("%d/",month);
  if(day<10){
    printf("0");
  }
  printf("%d",day);
  return 0;
}

Measured memory_bytes: 128
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache, reduce

import numpy as np
from operator import itemgetter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
AB.sort(key=itemgetter(1))

A, B = zip(*AB)
A = np.array(A).cumsum()
B = np.array(B)

if all(A <= B):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 77592
str_list = ["dream","erase","er","ase","r",]

class stringJudge():
    def __init__(self,string,string_list):
        self.string = string
        self.string_list = string_list
        
    def isNextMatch(self):
        for (i,str_val) in enumerate(str_list):
            if self.string.startswith(str_val):
                self.string = self.string.split(str_val,1)[1]
                if len(self.string) == 0:
                    return True
                if i ==0:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[2]):
                        return True
                elif i == 1:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]) or self.string.startswith(self.string_list[4]):
                        return True
                elif i == 2:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]) or self.string.startswith(self.string_list[3]):
                        return True
                elif i == 3:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1])  or self.string.startswith(self.string_list[4]):
                        return True
                elif i == 4:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):
                        return True
        return False
                    
                    
           
    
instance = stringJudge(input(),str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()

print('YES' if check else 'NO')

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

#define int long long
#define endl '\n'
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define dvec(vct) for(auto i : vct) cout << i << " "; cout << endl;
#define darr(a, n) for(int i=0;i<n;) cout << a[i++] <<' '; cout<< '\n';
#define print_(x) cout << #x << " : " << x << endl;

const int mod = 1e9 + 7;

void solve() {
    int k, x; 
    cin >> k >> x;
    if (k*500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}

int32_t main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
X=[int(input()) for i in range(5)]
ans=0
W=[]
Y=0
for i in range(5):
    if X[i]%10 == 0:
        ans+=X[i]
    else:
        ans+=(X[i]//10)*10+10
        W.append(X[i]%10)
        Y=10-min(W)
ans -= Y
print(ans)

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

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

    int res=0;
    for(int i=1; i<n; ++i) {
        auto x=s.substr(0, i);
        auto y=s.substr(i);
        int a=0; for(auto& c: x) a|=1<<(c-'a');
        int b=0; for(auto& c: y) b|=1<<(c-'a');
        res=max(res, __builtin_popcount(a&b));
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  string s;
  cin>>s;
  if(s=="keyence") {
    std::cout << "YES" << std::endl;
    return 0;
  }
  for(int i=0; i<s.size(); i++) {
    for(int j=1; i+j<s.size(); j++) {
      string t = s;
      t.erase(i,j);
      if(t == "keyence") {
	std::cout << "YES" << std::endl;
	return 0;
      }
    }
  }
  std::cout << "NO" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	int n=s.size();
	int k;
	std::cin >> k;


	if(k==1) {
		print((int)(s[0]-'0')+(n-1)*9);
		return 0;
	} else if(k==2) {
		int ans = 0;
		ans+=(int)(s[0]-'0'-1)*9*(n-1);
		ans+=(n-1)*(n-2)/2*81;
		rep(i,n) {
			if(i==0) continue;
			if(s[i]!='0') {
				ans+=s[i]-'0';
				ans+=(n-i-1)*9;
				break;
			}
		}
		print(ans);
		return 0;
	} else if(k==3) {
		int ans = 0;
		ans+=(int)(s[0]-'0'-1)*9*9*(n-1)*(n-2)/2;
		ans+=(n-1)*(n-2)*(n-3)/6*9*9*9;
		int i=1;
		for(;i<n;i++) {
			if(s[i]!='0') {
				ans+=(s[i]-'0'-1)*(n-i-1)*9;
				ans+=81*(n-i-1)*(n-i-2)/2;
				i++;
				break;
			}
		}
		for(;i<n;i++) {
			if(s[i]!='0') {
				ans+=s[i]-'0';
				ans+=(n-i-1)*9;
				break;
			}
		}
		print(ans);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N;
vpint adj[100003];
int d[2][100003],color[2][100003],p[2][100003];
void dijkstra(int ban,int start){
	priority_queue<pint> PQ;
	rep(i,N){
		d[ban][i]=INF;
		color[ban][i]=0;
	}
	d[ban][start]=0;
	color[ban][start]=1;
	PQ.push(mp(start,start));
	while(!PQ.empty()){
		pint f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[ban][u]=2;
		if(d[ban][u]< -f.first) continue;
		rep(j,adj[u].size()){
			int v=adj[u][j].first;
			if(color[ban][v]==2) continue;
			if(d[ban][v]>d[ban][u]+adj[u][j].second){
				d[ban][v]=d[ban][u]+adj[u][j].second;
				PQ.push(mp(-d[ban][v],v));
				color[ban][v]=1;
			}
		}
	}
}
int main(){
	int a[100000],b[100000];
	int fpoint=0,spoint=0;
	scan(N);
	rep(i,N-1){
		scan(a[i]);scan(b[i]);
		adj[a[i]-1].push_back(mp(b[i]-1,1));
		adj[b[i]-1].push_back(mp(a[i]-1,1));
	}
	dijkstra(0,0);
	dijkstra(1,N-1);
	rep(i,N){
		if(d[0][i]<=d[1][i]) fpoint++;
		else spoint++;
		//printf("node:%d F:%d S:%d\n",i+1,d[0][i],d[1][i]);
	}
	if(fpoint>spoint) prin("Fennec");
	else prin("Snuke");
	return 0;
}


Measured memory_bytes: 8948
#include "bits/stdc++.h"
using namespace std;

class Edge
{
	public:
	int to,cost;
	Edge(int t,int c)
	{
		to=t;cost=c;
	}
};

vector<Edge> g[100];
vector<int> freeze;//冷凍できる街
bool freezef[100];
int root[100][100];//街iから街jへの経路
int dp[100][101];//街iに残り時間jでいる最短時間
int m;
void dfs(int nowp,int nowz,int nowt)
{
	dp[nowp][nowz]=nowt;
	//回復する
	if(freezef[nowp])
	{
		for(int i=0;i<=m;i++)
		{
			if(nowz+i>m)
				break;
			dp[nowp][nowz+i]=min(dp[nowp][nowz+i],dp[nowp][nowz]+i);
		}
	}
	//消費する
	for(int i=0;i<nowz;i++)
		dp[nowp][i]=min(dp[nowp][i],dp[nowp][nowz]+(nowz-i));
	//行き先を調べる
	for(int i=0;i<g[nowp].size();i++)
	{
		Edge e=g[nowp][i];
		if(e.cost>m)
			continue;
		int mini=1e8-1;
		int minin=-1;
		for(int j=e.cost;j<=m;j++)
		{
			if(mini>dp[nowp][j]+e.cost)
			{
				mini=dp[nowp][j]+e.cost;
				minin=j;
			}
		}
		if(minin!=-1 && mini<dp[e.to][minin-e.cost])
			dfs(e.to,minin-e.cost,mini);
	}
	return;
}
int main()
{
	int n,l,k,a,h;
	while(1)
	{
		cin>>n>>m>>l>>k>>a>>h;
		if(n==0)
			break;
		freeze.clear();
		fill(freezef,freezef+100,false);
		for(int i=0;i<l;i++)
		{
			int tmp;
			cin>>tmp;
			freezef[tmp]=true;
			freeze.push_back(tmp);
		}
		fill(root[0],root[100],1e8-1);
		for(int i=0;i<100;i++)
		{
			g[i].clear();
			root[i][i]=0;
		}
		for(int i=0;i<k;i++)
		{
			int f,t,c;
			cin>>f>>t>>c;
			root[f][t]=min(root[f][t],c);
			root[t][f]=min(root[t][f],c);
		}
		//ワーシャルフロイド
		for(int k=0;k<n;k++)
		{
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
					root[i][j]=min(root[i][j],root[i][k]+root[k][j]);
			}
		}
		/*
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
				cerr<<root[i][j]<<" ";
			cerr<<endl;
		}*/
		//辺を貼り直す
		//貼り直す対象はスタートとゴール、冷凍施設
		g[a].push_back(Edge(h,root[a][h]));
		g[h].push_back(Edge(a,root[h][a]));
		for(int i=0;i<freeze.size();i++)
		{
			g[a].push_back(Edge(freeze[i],root[a][freeze[i]]));
			g[h].push_back(Edge(freeze[i],root[h][freeze[i]]));
			g[freeze[i]].push_back(Edge(a,root[freeze[i]][a]));
			g[freeze[i]].push_back(Edge(h,root[freeze[i]][h]));
		}
		for(int i=0;i<freeze.size();i++)
		{
			for(int j=i+1;j<freeze.size();j++)
			{
				g[freeze[i]].push_back(Edge(freeze[j],root[freeze[i]][freeze[j]]));
				g[freeze[j]].push_back(Edge(freeze[i],root[freeze[i]][freeze[j]]));
			}
		}
		fill(dp[0],dp[100],1e8-1);
		dfs(a,m,0);
		int ans=1e8-1;
		for(int i=0;i<=m;i++)
		{
			//cerr<<dp[h][i]<<endl;
			ans=min(ans,dp[h][i]);
		}
		if(ans==1e8-1)
			cout<<"Help!"<<endl;
		else
			cout<<ans<<endl;
	}
	return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int t, x;
    cin >> t >> x;
    cout << (float)(t)/ x << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,M,R,i,j,k;
    cin>>N>>M>>R;
    long long r[R],d[N][N];
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            d[i][j]=100000000;
            if(i==j){
                d[i][j]=0;
            }
        }
    }
    for(i=0;i<R;i++){
        cin>>r[i];
        r[i]--;
    }
    sort(r,r+R);
    for(i=0;i<M;i++){
        long long a,b,c;
        cin>>a>>b>>c;
        if(d[a-1][b-1]>c){
            d[a-1][b-1]=c;d[b-1][a-1]=c;
        }
    }
    long long count=1;
    while(count>0){
        count=0;
        for(i=0;i<N;i++){
            for(j=0;j<N;j++){
                for(k=0;k<N;k++){
                    if(d[i][j]>d[i][k]+d[k][j]){
                        d[i][j]=d[i][k]+d[k][j];
                        d[j][i]=d[i][j];
                        count++;
                    }
                }
            }
        }
    }
    long long ans=100000000,sum;
    do{
        sum=0;
        for(i=0;i<R-1;i++){
            sum+=d[r[i]][r[i+1]];
        }
        if(sum<ans){
            ans=sum;
        }
    }while(next_permutation(r,r+R));
    cout<<ans<<endl;
}

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

int main() {
	int N;
	set<int> a;
	for (int i = 0; i < 4; ++i) {
		cin >> N;
		a.insert(N);
	}
	if (a.count(1) && a.count(4) && a.count(7) && a.count(9)) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
n = int(input())
f10 = 1
f8 = 1
f9 = 2
for _ in range(n):
    f10 = (f10*10) % (1e9+7)
    f8 = (f8*8) % (1e9+7)
    f9 = (f9*9) % (1e9+7)
print(int((f10+f8-f9)%(1e9+7)))

Measured memory_bytes: 9196
def result?( alice, bob )
    if(alice > 13 || bob > 13)
        return ''
    elsif(alice == bob)
        return 'Draw'
    elsif(alice == 1) 
        return 'Alice'
    elsif(bob == 1) 
        return 'Bob'
    elsif(alice > bob)
        return 'Alice'
    else
        return 'Bob'
    end
end
    
hands = STDIN.gets.split(" ")
STDOUT.puts(result?(hands[0].to_i, hands[1].to_i))

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        
        if(S.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
        
    }
}


Measured memory_bytes: 35664
n, k = map(int, input().split())
A = list(map(int, input().split()))
ng = -1
ok = max(A) + 1
def test(x):
    if x == 0:
      return False
    cnt = 0
    for a in A:
        if a > x:
            cnt += -(-a//x) - 1
    return cnt <= k

while ok - ng > 1:
    mid = (ok+ng) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid
        
print(ok)

Measured memory_bytes: 30684
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
const ll inf = 2e18 + 7;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 7;
const ld pi = 3.14159265358979;

void solve() {
    ll n;
    cin>>n;
    vector<ll> facts;
    for(ll i=2;i*i<=n;i++) {
        if(n%i==0) {
            ll cnt=0;
            while(n%i==0) {
                n/=i;
                cnt++;
            }
            facts.pb(cnt);
        }
    }
    if(n!=1) {
        facts.pb(1);
    } 
    ll ans=0;
    for(int i=0;i<facts.size();i++) {
        ll x=0;
        for(ll j=1;j<N;j++) {
            ll val=(j*(j+1))/2;
            if(val<=facts[i]){
                x=j;
            }
        }
        ans+=x;
    }
    cout<<ans;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


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

l2 = 1
l1 = 2

if n == 0:
    l2 = l1
elif n == 1:
    pass
else:
    for i in range(n-1):
        l0 = l1
        l1 = l2
        l2 = l1 + l0

print(l2)

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

int main(){
  ll n,d,ans=0;
  cin>>n>>d;
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
int main(){
ll n;
cin>>n;
ll order[n+1];

for(ll i=1;i<=n;i++){
    ll t;
    cin>>t;
    order[t]=i;



}
for(ll i=1;i<=n;i++){
    cout<<order[i]<<" ";

}















}


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

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

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

template <class M>
struct LazySegmentTree{
    using T = typename M::T;
    using L = typename M::L;
    int sz, height{};
    vector<T> seg; vector<L> lazy;
    explicit LazySegmentTree(int n) {
        sz = 1;
        while(sz < n) sz <<= 1, height++;
        seg.assign(2*sz, M::e());
        lazy.assign(2*sz, M::l());
    }

    void set(int k, const T &x){
        seg[k + sz] = x;
    }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    T reflect(int k){ return lazy[k] == M::l() ? seg[k] : M::g(seg[k], lazy[k]); }

    void eval(int k){
        if(lazy[k] == M::l()) return;
        lazy[(k<<1)|0] = M::h(lazy[(k<<1)|0], lazy[k]);
        lazy[(k<<1)|1] = M::h(lazy[(k<<1)|1], lazy[k]);
        seg[k] = reflect(k);
        lazy[k] = M::l();
    }
    void thrust(int k){ for (int i = height; i; --i) eval(k>>i); }
    void recalc(int k) { while(k >>= 1) seg[k] = M::f(reflect((k<<1)|0), reflect((k<<1)|1));}
    void update(int a, int b, const L &x){
        thrust(a += sz); thrust(b += sz-1);
        for (int l = a, r = b+1;l < r; l >>=1, r >>= 1) {
            if(l&1) lazy[l] = M::h(lazy[l], x), l++;
            if(r&1) --r, lazy[r] = M::h(lazy[r], x);
        }
        recalc(a);
        recalc(b);
    }

    T query(int a, int b){ // [l, r)
        thrust(a += sz);
        thrust(b += sz-1);
        T ll = M::e(), rr = M::e();
        for(int l = a, r = b+1; l < r; l >>=1, r>>=1) {
            if (l & 1) ll = M::f(ll, reflect(l++));
            if (r & 1) rr = M::f(reflect(--r), rr);
        }
        return M::f(ll, rr);
    }

    T operator[](const int &k) const { // 0-indexed
        return seg[k + sz];
    }
};

struct Monoid{
    using T = ll;
    using L = ll;
    static T f(T a, T b) { return max(a, b); }
    static T g(T a, L b) {
        return a+b;
    }
    static L h(L a, L b) {
        return a+b;
    }
    static T e() { return 0; }
    static L l() { return 0; }
};

int main() {
    int n, m;
    cin >> n >> m;
    using P = array<int, 3>;
    vector<P> v(m);
    for (auto &&a : v) {
        scanf("%d %d %d", &a[1], &a[0], &a[2]);
    }
    sort(v.begin(),v.end());
    LazySegmentTree<Monoid> seg(n+1);
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        seg.update(i+1, i+2, seg.query(0, i+1));
        while(cur < m && v[cur][0] == i+1){
            seg.update(v[cur][1], v[cur][0]+1, v[cur][2]);
            cur++;
        }
    }
    cout << seg.query(0, n+1) << "\n";

    return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;

int main(){
  int n,k; cin>>n >>k;
  int h[n];
  for(int i=0;i<n;i++)cin>>h[i];
  
  vector<int> dp(n,INF);
  dp[0]=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+k;j++){
      if(j<n){
        dp[j]=min(dp[i]+abs(h[j]-h[i]),dp[j]);
      }
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 1000000
int A[N];
int Partition(int p, int r){
  int x, i, j, tmp;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
  }
  int main(){
    int n, i, x;
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
      scanf("%d", &A[i]);
    }
    x = Partition(1, n);
    for(i = 1; i <= n; i++){
      if(i == x){
        printf("[%d]",A[i]);
      }
      else
      {
        printf("%d",A[i]);
      }
      if(i < n)
      {
        printf(" ");
      }
    }
    printf("\n");
    return 0;
  }



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

using namespace std;

bool solve(int i, int m, int n,vector<int> &a) {
	if (m == 0) {
		return true;
	}
	if (i >= n) {
		return false;
	}
	int res = solve(i + 1, m,n,a) || solve(i + 1, m - a[i],n,a);
	return res;
}

int main() {

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

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

		cout << (solve(0, m, n, a) ? "yes" : "no")  << endl;

	}

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int oo=1000000000;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin>>n;
	vector<int> bamb(3), m(n), m2; cin>>bamb[2]>>bamb[1]>>bamb[0];
	for(int i=0; i<n; ++i) cin>>m[i];
	int ans=oo, x, y, z, cur;
	set<int> del, del2;
	do{
		m2 = m; z=0;
		for(int k=0; k<3; ++k){
			n = (int)m2.size(); del.clear(); y=oo;
			for (int i=1; i<(1<<n);++i){
				x=0; del2.clear();
				for (int j=0; j<n; ++j) if (i&(1<<j)) {x+=m2[j]; del2.insert(j);}
				cur  = 10*(__builtin_popcount(i)-1) + abs(x - bamb[k]);
				if (cur < y){del = del2; y = cur;}
			}
			for (auto i: del)m2[i] = -oo;
			z+=y;
		}
		ans=min(ans, z);
	}while(next_permutation(bamb.begin(), bamb.end()));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<long long> dp(n + 1, -1e18);
	vector<long long> way(n + 1);
	dp[0] = 0;
	way[0] = 1;
	for (int i = 0; i < n; i++) {
		long long v;
		cin >> v;
		for (int j = n - 1; j >= 0; j--) {
			if (dp[j + 1] < dp[j] + v) {
				dp[j + 1] = dp[j] + v;
				way[j + 1] = way[j];
			} else if (dp[j + 1] == dp[j] + v) {
				way[j + 1] += way[j];
			}
		}
	}
	printf("%.8f\n", 1.0 * dp[a] / a);
	long long ans = 0;
	for (int i = a; i <= b; i++) {
		if (dp[i] * a == dp[a] * i) {
			ans += way[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a;
int b;
int c;
int i;
int m;
 scanf("%d %d %d",&a,&b,&c);
 for(i=a;i<=b;i++)
 {
  if(c%i==0)
  {
   m=m+1;
  }
 }
 printf("%d\n",m);
return 0;
 
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using Graph=vector<vector<ll>>;
int main(){
  int x,y;cin>>x>>y;
  int c=0;
  if(x==3)c+=100000;
  if(x==2)c+=200000;
  if(x==1)c+=300000;
  if(y==3)c+=100000;
  if(y==2)c+=200000;
  if(y==1)c+=300000;
  if(x==1&&y==1)c+=400000;
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 123, K = 1000;
int n, a[N], q, ind[N], dp[N], f[N];
pii query[N], p[N];
vi vec[N];

struct block {
	vector <pii> v, tmp_v;
	vi s, ord, tmp;
	int suf = N, val = -1;
	void add(int x) {
		for (int i = suf; i < (int)v.size(); i++) {
			v[i].F = val;
		}
		suf = N, val = -1;
		int l = p[x].F, r = p[x].S;
		v.pb({r, l});
		s.pb(dp[l - 1] - f[l - 1]);
		for (int i = (int)s.size() - 2; i >= 0; i--) {
			s[i] = min(s[i], s[i + 1]);
		}
	}
	int get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S;
		int pos = lower_bound(all(v), mp(L - 1, 0)) - v.begin();
		if (pos < suf) {
			if (pos == (int)v.size()) {
				return N;
			}
			suf = pos, val = R;
			return s[pos];
		}	else {
			if (val >= L - 1) {
				val = R;
				return s[suf];
			}	else {
				return N;
			}
		}
	}
	int naive_get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S, res = N;
		for (int i = 0; i < (int)v.size(); i++) {
			if (i >= suf) {
				v[i].F = val;
			}
			if (v[i].S <= L && v[i].F >= L - 1) {
				res = min(res, dp[v[i].S - 1] - f[v[i].S - 1]);
				v[i].F = R;
				tmp.pb(i);
			}	else {
				ord.pb(i);
			}
		}
		suf = N, val = -1;
		for (int i = 0; i < (int)ord.size(); i++) {
			tmp_v.pb(v[ord[i]]);
		}
		for (int i = 0; i < (int)tmp.size(); i++) {
			tmp_v.pb(v[tmp[i]]);
		}
		v = tmp_v;
		ord.clear();
		tmp.clear();
		tmp_v.clear();
		for (int i = (int)s.size() - 1; i >= 0; i--) {
			if (i == (int)s.size() - 1) {
				s[i] = dp[v[i].S - 1] - f[v[i].S - 1];
			}	else {
				s[i] = min(s[i + 1], dp[v[i].S - 1] - f[v[i].S - 1]);
			}
		}
		return res;
	}
};

block b[250];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[i] = f[i - 1] + (a[i] == 0) - (a[i] == 1);
		s += a[i];
	}
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int l, r;
		cin >> l >> r;
		p[i] = {l, r};
		vec[r].pb(i);
		query[i - 1] = {l, i};
	}
	sort(query, query + q);
	for (int i = 0; i < q; i++) {
		ind[query[i].S] = i;
	}
	for (int i = 1; i <= n; i++) {
		int res = N;
		for (int j : vec[i]) {
			b[ind[j] / K].add(j);
			for (int k = 0; k < N / K; k++) {
				int last = min(q - 1, K * (k + 1) - 1);
				if (query[last].F <= p[j].F && last < q - 1) {
					res = min(res, b[k].get(j));
				}	else {
					res = min(res, b[k].naive_get(j));
					break;
				}
			}
		}
		dp[i] = min(dp[i - 1], res + f[i]);
	}
	cout << dp[n] + s;
}


Measured memory_bytes: 20864
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

struct st {
  vector<st> *pre;
  vector<st> *next;
  ll max;
};

int main() {
  ll N, K, P;
  std::vector<ll> vec;
  cin >> N >> K;
  vec.reserve(N);
  for (auto i = 0;i < N; i++) {
    cin >> P;
    vec.push_back(P);
  }
  sort(vec.begin(), vec.end());
  ll ret = 0;
  for (auto i = 0;i < K; i ++) {
    ret += vec[i];
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3596
// ALDS1_5_B: Merge Sort

fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn scan_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s: String = scan();
    s.split_whitespace().map(|a| T::from_str(a).ok().unwrap()).collect()
}

fn merge(a: &mut Vec<i64>, left: usize, mid: usize, right: usize) -> usize {
    let mut l: Vec<i64> = Vec::new();
    let mut r: Vec<i64> = Vec::new();
    for i in left..mid {
        l.push(a[i]);
    }
    for i in mid..right {
        r.push(a[i]);
    }
    l.push(std::i64::MAX);
    r.push(std::i64::MAX);
    let mut i: usize = 0;
    let mut j: usize = 0;
    for k in left..right {
        if l[i] <= r[j] {
            a[k] = l[i];
            i += 1;
        } else {
            a[k] = r[j];
            j += 1;
        }
    }
    right - left
}

fn merge_sort(a: &mut Vec<i64>, left: usize, right: usize) -> usize {
    let mut cnt: usize = 0;
    if left + 1 < right {
        let mid = (left + right) / 2;
        cnt += merge_sort(a, left, mid);
        cnt += merge_sort(a, mid, right);
        cnt += merge(a, left, mid, right);
    }
    cnt
}

fn main() {
    let n: usize = scan();
    let mut a: Vec<i64> = scan_vec();
    let cnt = merge_sort(&mut a, 0, n);
    let a = a.iter().map(|a| a.to_string()).collect::<Vec<String>>().join(" ");
    println!("{}", a);
    println!("{}", cnt);
}


Measured memory_bytes: 33684
n, c = gets.split.map(&:to_i)

d = c.times.map {gets.split.map(&:to_i)}
cc = n.times.map {gets.split.map(&:to_i)}

ary = Array.new(3) {Array.new(c, 0)}
n.times do |i|
    n.times do |j|
        ary[(i + j) % 3][cc[i][j] - 1] += 1
    end
end

ans = 1 << 40
(0...c).to_a.permutation(3) do |s,t,u|
    sum = 0
    c.times do |i|
        sum += d[i][s] * ary[0][i] + d[i][t] * ary[1][i] + d[i][u] * ary[2][i]
    end
    ans = sum if ans > sum
end

p ans

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

using namespace std;

int main(){
int a,b,n;
cin >> a >> b >> n;

for(int i=0;i<n;i+=2){
if(a%2==1){
	a-=1;
}
b=b+a/2;
a=a/2;
if(n-1==i)break;
if(b%2==1){
	b-=1;
}
a=a+b/2;
b=b/2;
}
cout << a << " " << b << endl;

return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long const p=1e9+7;
long long a,b,n,res;
long long quickpow(long long a,long long b)
{
	long long r=1;
	while(b)
	{
		if(b&1)
		r=r*a%p;
		a=a*a%p;
		b>>=1;
	}return r%p;
}
long long jiec(long long a,long long b)
{
	long long s=1;
	for(int i=a;i<=b;++i)
	{
	s=s*i%p;	
	}
	return s%p;
}
int main()
{
	cin>>n>>a>>b;
	res=quickpow(2,n)+p-1;res%=p;
	long long xa=jiec(1,a);xa=quickpow(xa,p-2);
	long long xb=jiec(1,b);xb=quickpow(xb,p-2);
	long long na=jiec(n-a+1,n);
	long long nb=jiec(n-b+1,n);
	res+=p+p-na*xa%p-nb*xb%p;
	res=res%p;
	cout<<res;
}

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


public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<String> list=new ArrayList<String>();


	while(sc.hasNext()) {
		list.add(sc.nextLine());
	}
	
	


	int i=0;
	
	if(list.get(0).charAt(0)==list.get(1).charAt(0))i++;
	if(list.get(0).charAt(1)==list.get(1).charAt(1))i++;
	if(list.get(0).charAt(2)==list.get(1).charAt(2))i++;

	

	System.out.print(i);

}
}



Measured memory_bytes: 35672
#include <stdio.h>

int main() {
	int N, Y, i, j, k, w = 1, I = -1, J = -1, K = -1;
	for (scanf("%d %d", &N, &Y), i = 0; w && i <= 2000; i++)
		for (j = 0; w && j <= 2000; j++)
			if ((Y-i*10000-j*5000)%1000 == 0 && (Y-i*10000-j*5000)/1000 >= 0 && i+j+(Y-i*10000-j*5000)/1000 == N)
				I = i, J = j, K = (Y-i*10000-j*5000)/1000, w = 0;
	printf("%d %d %d", I, J, K);
}

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

const double EPS = 1e-9;

inline double dis(int ax, int ay, int bx, int by){
  return sqrt( (ax-bx)*(ax-bx) + (ay-by)*(ay-by) );
}

int main(){
  int n;
  cin >> n;
  int f,a,t,x,y;
  cin >> f >> a >> t >> x >> y;

  double la=0,ta=1e9,lb=0,tb=1e9;
  for(int i=1;i<n;i++){
    int F,A,T,X,Y;
    cin >> F >> A >> T >> X >> Y;
    
    if(T==t && A!=a){
      double L = dis(x,y,X,Y);
      if(t==0){
	if(abs(L-la)<EPS) ta = min(ta,(double)(F-f));
	else if(la < L) la = L, ta = F-f;
      }else{
	if(abs(L-lb)<EPS) tb = min(tb,(double)(F-f));
	else if(lb < L) lb = L, tb = F-f;
      }
    }
    f = F; a = A; t = T; x = X; y = Y;
  }

  if(la==0)cout << "-1 -1" << endl;
  else cout << fixed << setprecision(9) << la << " " << ta/60 << endl;
  if(lb==0)cout << "-1 -1" << endl;
  else cout << fixed << setprecision(9) << lb << " " << tb/60 << endl;
}

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

int main(){
  int n,cnt=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n-2;i++){
    if((a[i]<a[i+1]&&a[i+1]<a[i+2])||(a[i]>a[i+1]&&a[i+1]>a[i+2]))
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,p[10001],d1[10001],d2[10001];
	int i,j,s[10001],max=0;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++) s[i]=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p[i],&d1[i],&d2[i]);
			s[i]=d1[i]+d2[i];
		}
		max=0;
		for(i=0;i<n;i++){
			if(max<s[i]){
				max=s[i];
				j=i;
			}
		}	
		printf("%d %d\n",p[j],max);
	}	
	return 0;
}	

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

int main() {
  ll n,m;
  cin>>n>>m;
  ll ans;
  if(m==1){
    cout<<0<<endl;
    return 0;
  }
  if(2*n>m){
    ans=min(n,m/2);
  }else{
    ans=n+(m-2*n)/4;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y;cin>>X>>Y;
  int s=0;
  if(X==1)s+=300000;
  if(X==2)s+=200000;
  if(X==3)s+=100000;
  if(Y==1)s+=300000;
  if(Y==2)s+=200000;
  if(Y==3)s+=100000;
  if(X==Y&&X==1)s+=400000;
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a1,a2,b1,b2;
int main()
{
	cin>>a1>>a2>>b1>>b2;
	if(a1+a2>b1+b2)cout<<"Left"<<endl;else
	if(a1+a2==b1+b2)cout<<"Balanced"<<endl;
	else
	if(a1+a2<b1+b2)cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	set<int> color_set;
	color_set.insert(a);
	color_set.insert(b);
	color_set.insert(c);

	cout << color_set.size();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main(){
    int n;
    int max_s=0;
    int sum_s=0;
    vector<int>vc;
    cin>>n;
    vc=vector<int>(n);
    
    for (int i=0;i<n;++i){
        cin>>vc[i];
        //cout<<vc[i]<<'\n';
    }
    sort(vc.begin(),vc.end());
    max_s=vc.back();
   // cout<<vc.at(1)<<endl;
    
  	for (int j=0 ;j<n-1;++j){
          sum_s+=vc[j];
         // cout<<vc[j];
      }
    //cout<<sum_s<<endl;
	if (max_s<sum_s){
    cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
    }
      
    
    return 0;


}


Measured memory_bytes: 256
def main():
    import sys
    入力 = sys.stdin.readline
    範囲, 出力 = range, print
    真, 偽 = True, False
    何もしない = None
    一行に複数個の入力 = lambda:map(int, 入力().split())
    頂点の数, 操作回数 = 一行に複数個の入力()
    辺 = [[] for _ in 範囲(頂点の数)]
    カウンター = [0] * 頂点の数
    辺の数 = 頂点の数-1
    for _ in 範囲(辺の数):
        頂点1, 頂点2 = 一行に複数個の入力()
        頂点1 -= 1
        頂点2 -= 1
        辺[頂点1] += 頂点2,
        辺[頂点2] += 頂点1,
    for _ in 範囲(操作回数):
        頂点, 足す値 = 一行に複数個の入力()
        頂点 -= 1
        カウンター[頂点] += 足す値
    到達済み = [偽] * 頂点の数
    親 = 0
    到達済み[親] = 真
    スタック = [親]
    while スタック:
        親 = スタック.pop()
        for 子 in 辺[親]:
            if 到達済み[子]:
                何もしない
            else:
                到達済み[子] = 真
                カウンター[子] += カウンター[親]
                スタック += 子,
    出力(*カウンター)
main()

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  ll res = 0;
  rep(i,N) {
    if (i == 0 && a[i] != 0) {
      puts("-1");
      return 0;
    }
    if (i != 0) {
      if (a[i] - a[i-1] > 1) {
        puts("-1");
        return 0;
      } else {
        if(a[i] == a[i-1] + 1) res++;
        else res += a[i];
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5000001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 

int main()
{
   string s;
   cin>>s;
   fo(i,0,sz(s))
   cout<<'x';
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut n = String::new();
    let mut res = "No";

    io::stdin().read_line(&mut n).unwrap();

    let n: usize= n.trim().parse().unwrap();

    if n%4==0 || n%7==0 || !n<4{
        res = "Yes";
    }else {
        let mut i = 4;
        while i<n {
            if (n-i)%7==0 {
                res = "Yes";
                break;
            }
            i = i+4;
        }
    } 
    println!("{}", res);
}

Measured memory_bytes: 4352