akhauriyash/Code-Regression huggingface dataset:
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

//
// solution 
//
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        K: usize,
        x: [i64; N],
    }

    let mut distance = x[0].abs() + (x[K-1] - x[0]);
    for start in 0..N-K+1 { 
        distance = cmp::min(distance, 
                            cmp::min(x[start].abs(), x[start+K-1].abs()) + (x[start+K-1] - x[start]));
    }
    println!("{}", distance);
}


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

struct Dinic{
    struct edge {
        int64_t to, cap, rev;
        edge(int64_t to, int64_t cap, int64_t rev):to(to), cap(cap), rev(rev){}
    };

    int N, S, T;
    int64_t flow = 0;
    const int64_t INF = 1e18;
    vector<int> level, iter;
    vector<vector<edge>> G;

    Dinic(int N, int S, int T):N(N), S(S), T(T){
        flow = 0;
        level.resize(N);
        iter.resize(N);
        G.resize(N);
    }

    void add_edge(int from, int to, int64_t cap){
        G[from].emplace_back(to, cap, G[to].size());
        G[to].emplace_back(from, 0, G[from].size()-1);
    }

    void bfs(int s){
        fill(level.begin(), level.end(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(que.size()){
            int v = que.front(); que.pop();
            for(auto& e : G[v]){
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int64_t dfs(int v, int t, int64_t f){
        if(v == t) return f;
        for(int& i=iter[v]; i<(int)G[v].size(); i++){
            auto& e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                int64_t d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int64_t max_flow(){
        while(true){
            bfs(S);
            if(level[T] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            while(true){
                int64_t f = dfs(S, T, INF);
                if(f == 0) break;
                flow += f;
            }
        }
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int S = N, T = N+1;
    int64_t ans = 0;
    Dinic solver(T+1, S, T);
    for(int i=0; i<N; i++){
        if(A[i] > 0){
            ans += A[i];
            solver.add_edge(S, i, A[i]);
        }else{
            solver.add_edge(i, T, -A[i]);
        }
    }
    for(int i=1; i<=N; i++) for(int j=2*i; j<=N; j+=i) solver.add_edge(j-1, i-1, solver.INF);
    ans -= solver.max_flow();
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
    int x, y; cin >> x >> y;
    int a = 2 * x - y;
    int b = 2 * y - x;
    if (a < 0 || b < 0 || a % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    a /= 3;
    b /= 3;
    mint ans = choose(a+b,min(a,b));
    cout << ans.x << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string s;
bool flag=false;
int main()
{
	cin>>s;
	int len=s.length();
	for(int i=0;i<s.length()-1;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C')
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b;
    string s;
    vector<string>v;
    cin>>a>>b;
    for(ll i=0;i<a;i++) {cin>>s; v.push_back(s);}
    for(ll i=0;i<b+2;i++) {cout<<"#";}
    cout<<endl;
    for(ll i=0;i<a;i++)
    {cout<<"#";cout<<v[i];cout<<"#"<<endl;}
    for(ll i=0;i<b+2;i++) {cout<<"#";}
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);//freopen("out", "w", stdout);
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	// x / d => number of steps till 0
	ll steps = min(x/d, k);
	k -= steps, x -= steps * d;
	k &= 1;
	if(k == 1)
		x -= d;
	cout << abs(x) << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int ans=0;
	for(int i=0;i<=2;i++)
	{
		if(s1[i]==s2[i])
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * n

dp[0] = 0
for i in range(1, n):
  dp[i] = min(dp[j]+abs(h[i]-h[j]) for j in range(max(0, i-k), i))

    
print(dp[n-1])

Measured memory_bytes: 20528
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e7+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
void solve()
{
    string n;ll m;
    cin>>n>>m;
    int i=0;
    while(i<n.size()&&n[i]=='1')
        i++;
    if(i<n.size()&&m>i)
        cout<<n[i];
    else
        cout<<1;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;for(int te=1;te<=t;te++)
    {
        solve();
    }
    return 0;
}

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

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


int main()
{
	int n; cin >> n;
	vector<int> o(1e5 + 1, 0), e(1e5 + 1, 0);
	rep(i, 1, n)
	{
		int x; cin >> x;
		if (i % 2 == 1) ++o[x];
		else ++e[x];
	}
	int mxO, mxOId, secO, mxE, mxEId, secE;
	mxO = secO = mxE = secE = mxOId = mxEId = 0;
	rep(i, 0, 100000)
	{
		if (mxO <= o[i])
		{
			secO = mxO;
			mxO = o[i];
			mxOId = i;
		}
		else if (secO < o[i])
		{
			secO = o[i];
		}
		if (mxE <= e[i])
		{
			secE = mxE;
			mxE = e[i];
			mxEId = i;
		}
		else if (secE < e[i])
		{
			secE = e[i];
		}
	}
	if (mxOId != mxEId) cout << n - mxO - mxE << endl;
	else
	{
		int res = max(mxO + secE, secO + mxE);
		cout << n - res << endl;
	}
}


Measured memory_bytes: 1024
n, x = map(int, input().split())
a = [1]
b = [1]
for i in range(0,n) :
    a.append(a[i]*2+3)
    b.append(b[i]*2+1)

def task(n,x):
    if n==0 :
        if x <= 0 :
            return 0
        else :
            return 1
    elif x <= (1+a[n-1]) :
        return task(n-1,x-1)
    else :
        return b[n-1]+1+task(n-1,x-2-a[n-1])

print(task(n,x))


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

type luggage struct {
	weight int
	value int
}

func main(){

	var st1,st2 string
	var DP [][]int
	fmt.Scan(&st1)
	fmt.Scan(&st2)
	for i:=0;i<len(st1)+1;i++{
		DP = append(DP,make([]int,len(st2)+1)[:])
	}

	for i:=1;i<len(st1)+1;i++{
		for j:=1;j<len(st2)+1;j++{
			if st1[i-1] == st2[j-1]{
				DP[i][j] = DP[i-1][j-1]+1
			}else{
				DP[i][j] = max(DP[i][j-1],DP[i-1][j])
			}
		}
	}

	key_number := DP[len(st1)][len(st2)]

	for i:=len(st1);i>0;i--{
		for j:=len(st2);j>0;j--{
			if DP[i][j] == key_number && st1[i-1]==st2[j-1]{
				defer fmt.Print(string(st1[i-1]))
				key_number--
				break
			}
		}
	}

}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N>>S;


    ll count = 1;

    REP(i,N-1){
        if(!(S.at(i)==S.at(i+1))){
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >> k;
  int a=0,b=0;
  for(int i=1;i<=k;++i){
    if(i%2) b++;
    else a++;
  }
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        Card[] c1 = new Card[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            c1[i] = new Card(s.substring(0, 1), Integer.parseInt(s.substring(1, 2)));
        }
        Card[] c2 = c1.clone();
        
        bubbleSort(c1, n);
        selectionSort(c2, n);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(c1[i].suit).append(c1[i].value);
            if(i < n-1){
                sb.append(" ");
            }else{
                sb.append(System.lineSeparator());
                sb.append("Stable").append(System.lineSeparator());
            }
        }
        
        for(int i = 0; i < n; i++){
            sb.append(c2[i].suit).append(c2[i].value);
            if(i < n-1){
                sb.append(" ");
            }else{
                sb.append(System.lineSeparator());
            }
        }
        boolean stable = true;
        for(int i = 0; i < n; i++){
            if(!c1[i].suit.equals(c2[i].suit)){
                stable = false;
                break;
            }
        }
        if(stable){
            sb.append("Stable").append(System.lineSeparator());
        }else{
            sb.append("Not stable").append(System.lineSeparator());
        }
        
        System.out.print(sb);
    }
    
    static class Card {
        String suit;
        int value;

        public Card(String suit, int value) {
            this.suit = suit;
            this.value = value;
        }
    }
    
    static void bubbleSort(Card[] c, int n){
        
        for(int i = 0; i < n; i++){
            for(int j = n-1; j >= i+1; j--){
                if(c[j].value < c[j-1].value){
                    Card a = c[j];
                    c[j] = c[j-1];
                    c[j-1] = a;
                }
            }
        }
    }
    
    static void selectionSort(Card[] c, int n){
        
        for(int i = 0; i < n; i++){
            int minj = i;
            for(int j = i; j < n; j++){
                if(c[j].value < c[minj].value){
                    minj = j;
                }
            }
            Card a = c[minj];
            c[minj] = c[i];
            c[i] = a;
        }
    }
}


Measured memory_bytes: 26160
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);

    int result;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            result = i*j;
            if (result == n) {
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	bool up=true;
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		if(a%2==1) up=false;
	}
	if(up) puts("second");
	else puts("first");
	return 0;
}


Measured memory_bytes: 256
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n;
	cin>>n;
	vi a(n);
	for(ll i=0;i<n;++i)
	{
		cin>>a[i];
	}
	vvi cost(n,vi(n,INF)),val(n,vi(n));
	for(ll i=0;i<n;++i)
	{
		val[i][i]=a[i];
		cost[i][i]=0;
	}
	for(ll l=2;l<=n;++l)
	{
		for(ll i=0;i<=n-l;++i)
		{
			ll j=i+l-1;
			for(ll k=i;k<j;++k)
			{
				ll temp=cost[i][k]+cost[k+1][j]+val[i][k]+val[k+1][j];
				if(temp<cost[i][j])
				{
					cost[i][j]=temp;
					val[i][j]=val[i][k]+val[k+1][j];
				}
			}
		}
	}
	cout<<cost[0][n-1]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


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

signed main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, C;
	cin >> N >> C;

	vector<vector<Int>> D(C, vector<Int>(C));
	for (Int i = 0; i < C; i++) {
		for (Int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}

	vector<vector<Int>> color(3, vector<Int>(C));
	Int c;
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			cin >> c;
			c--;//0-indexed
			color[(i + j + 2) % 3][c]++;
		}
	}

	//色を決め打ちして全探索
	Int ans = INF;
	Int sum;
	for (Int i = 0; i < C; i++) {//あまり1のマスの色
		for (Int j = 0; j < C; j++) {//あまり2
			if (i == j)continue;
			for (Int k = 0; k < C; k++) {//あまり0
				if (k == i || k == j)continue;

				sum = 0;
////グリッドの探索
//				for (Int m = 0; m < N; m++) {
//					for (Int n = 0; n < N; n++) {
//						if((m+n+2)%3==1){
//							sum += D[c[m][n]][i];
//						}
//						else if ((m + n + 2) % 3 == 2) {
//							sum += D[c[m][n]][j];
//						}
//						else {
//							sum += D[c[m][n]][k];
//						}
//					}
//				}

				for (Int p = 0; p < C; p++) {//あまり1
					sum += color[1][p] * D[p][i];
				}

				for (Int q = 0; q < C; q++) {//あまり2
					sum += color[2][q] * D[q][j];
				}

				for (Int r = 0; r < C; r++) {//あまり0
					sum += color[0][r] * D[r][k];
				}
				ans = min(ans, sum);
			}
		}
	}

	cout << ans << "\n";

}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
int num[26];

int main(int argc, char const* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<string> s;
  rep(i, h){
    string in;
    cin >> in;
    s.pb(in);
  }
  rep(i, h){
    rep(j, w){
      num[s[i][j] - 'a']++;
    }
  }
  int two = 0, four = 0, odd = 0;
  rep(i, 26){
    if(num[i] % 4 == 0)four++;
    else if(num[i] % 2 == 0)two++;
    else odd++;
  }
  if(odd > 0 && h * w % 2 == 0){
    cout << "No" << endl;
    return 0;
  }
  if(h % 2 == 0 && w % 2 == 0){
    if(two == 0 && odd == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(h % 2 == 0){
    int two_e = h / 2;
    if(two_e < two)cout << "No" << endl;
    else{
      if((two_e - two) % 2 == 0)cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }else if(w % 2 == 0){
    int two_e = w / 2;
    if(two_e < two)cout << "No" << endl;
    else{
      if((two_e - two) % 2 == 0)cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }else{
    if(odd != 1)cout << "No" << endl;
    else{
      int two_e = (h - 1) / 2 + (w - 1) / 2;
      if(two_e < two)cout << "No" << endl;
      else{
        if((two_e - two) % 2 == 0)cout << "Yes" << endl;
        else cout << "No" << endl;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256
import org.w3c.dom.ranges.RangeException
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun bitFS(N: Int, X: Int, Y: Int): Int {
    var res = INF

    for (p in 0 until (0b01 shl N)) {
        var ptn = p
        var cnt = 0
        var x = X
        var y = Y

        for (i in 0 until N) {
            if ((ptn and 0b01) == 1) {
                when (i) {
                    0 -> x *= -1
                    1 -> y *= -1
                    else -> tAssert(false){"i < N"}
                }
                cnt++
            }

            ptn = ptn shr 1
        }

        if (x <= y) {
            cnt += (y - x)
            res = min(res, cnt)
        }
    }

    return res
}

fun solve() {
    val (X, Y) = rd.readIntArray()

    val ans = bitFS(2, X, Y)

    println(ans)
}


//val rd = debug.Reader("agc", "008", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


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

int main()
{
  int i,jud=0;
  string s,p;

  cin>>s>>p;
  for(i=0;i<s.length();i++){
    if(s.find(p)>=0&&s.find(p)<s.length()){
      cout<<"Yes"<<endl; jud=1; break;
    }
    rotate(s.begin(),s.begin()+1,s.end());
  }
  if(!jud) cout<<"No"<<endl;
}
  


Measured memory_bytes: 1204
#include<stdio.h>

int main()


{

int  a,b,c,i;

scanf("%d %d %d",&a,&b,&c);


if(a > b){


i=a;


a=b;


b=i;


}


if(b > c){


i=b;


b=c;


c=i;


}


if(a > b){


i=a;


a=b;


b=i;


}

printf("%d %d %d\n",a,b,c);

return 0;


}

Measured memory_bytes: 596
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int x=scan.nextInt();
    double Ans=0;
    for(int a=0; a<x; a++){
      Ans+=1.0/scan.nextInt();
    }
    Ans=1/Ans;
    System.out.println(Ans);
  }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double PI=3.141592653589793238462643383279;

bool inC(P p, P c, double r){return abs(p-c)<r+1e-9;}

P getE(P p){return p/abs(p);}

double sq(double x){ return  x*x;}

int main(){
    int n,i,j,k,ans,cnt;
    double x, y;
    while(scanf("%d",&n)){
        if(n==0) break;
        ans=0;
        vector<P> ps(n);
        for(i=0; i<n; i++){
            scanf("%lf%lf",&x,&y);
            ps[i] = P(x,y);
        }
        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)if(abs(ps[i]-ps[j])<2){
                double d=sqrt(1-sq(abs(ps[j]-ps[i])*0.5));
                P c1=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,PI/2);
                P c2=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,-PI/2);
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c1,1.0))cnt++;
                if(cnt>ans)ans=cnt;
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c2,1.0))cnt++;
                if(cnt>ans)ans=cnt;
            }
        if(ans==0) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 2672
a, b, c, k = list(map(int, input().split()))

left = k
sum = 0
cards = (a, b, c)

for i, card in enumerate(cards):
  if card <= left:
    sum += card * (1-i)
    left -= card
  elif left > 0:
    sum += left * (1-i)
    left = 0

print(sum)

Measured memory_bytes: 61876
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	boost; IO();

	int N; cin>>N;
	int a=1,b=-1,c=-1,d=1; 
	FOR(i,0,N){
		a*=10; a%=MOD;
		d*=8; d%=MOD;
		b*=9; b%=MOD; b+=MOD; b%=MOD;
		c*=9; c%=MOD; c+=MOD; c%=MOD;
	}
	a+=b; a%=MOD; a+=MOD; a%=MOD;
	a+=c; a%=MOD; a+=MOD; a%=MOD;
	a+=d; a%=MOD;
	cout << a << endl;





	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


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

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int ans=0;
  int count=0;
  for(int i=1;i<N;i++){
    if(a[i]==a[i-1]){
      count++;
    }
    else{
      count=0;
    }
    if(count==1){
      count=-1;
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

bool rec(int i, int result, vector<int> &nums, vector<char> &ops) {
    if (i == 0) {
        result = result - nums[i];
        if (result == 0) {
            return true;
        }
        return false;
    }

    if (rec(i-1, result + nums[i], nums, ops)) {
        ops.push_back('-');
        return true;
    }
    if (rec(i-1, result - nums[i], nums, ops)) {
        ops.push_back('+');
        return true;
    }

    return false;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string line;
    cin >> line;

    vector<int> nums;
    for (auto i: line) {
        nums.push_back(i - '0');
    }

    vector<char> ops;

    rec(3, 7, nums, ops);

    string result = "";

    result += line[0];

    for (int i=1; i<4;i++) {
        result += ops[i-1];
        result += line[i];
    }

    result += "=7";

    cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=0,n=0,d=0,ans=0;
    cin>>t;
    while(t--)
    {
        cin>>n>>d;
        ans=(n-1)*127;
        if(n%2==0)
            ans+=127-d;
        else
            ans+=d;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,_min,_max;
    cin>>a;cin>>b;cin>>c;
    _min=_max=a;
    if(_min>b)
        _min=b;
    if(_min>c)
        _min=c;
    if(_max<b)
        _max=b;
    if(_max<c)
        _max=c;
    cout<<_min<<" "<<_max<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#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 rvc(i,S) for(int i=0;i<S.size();++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
inline int read()
{
	char c=getchar(); int ret=0;
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}int a,b,c;
int main()
{
	a=read(); b=read(); c=(a+b)/2;
	if(abs(a-c)!=abs(b-c))puts("IMPOSSIBLE");
	else cout<<c;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string> 
using namespace std;
#include <string> 
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);
typedef long long ll;
#define MAX 1000000000
const int maxn=111111;
string ma="";
ll dis[maxn];
ll dp[maxn];
vector<ll> v[maxn];
ll DFS(ll s)
{
    if(dp[s]!=-1)return dp[s];
    ll best=0;
    for(int x:v[s])
    {   
        best=max(best,DFS(x)+1);
    }
    return dp[s]=best;
}
int main()
{
	fast;
    ll n,m,i,x,y;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {    cin>>x>>y;
        v[x].push_back(y);
    }
    memset(dp,-1,sizeof(dp));
    ll z=0;
    for(i=1;i<=n;i++){
        z=max(z,DFS(i));
    }
    cout<<z;
    return 0;
}


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

using namespace std;

int main()
{
    int m, n1, n2;
    while(cin >> m >> n1 >> n2, m || n1 || n2){
	int P[201];
	for(int i = 0; i < m; i++) cin >> P[i];
	int ans = n1;
	for(int i = n1; i <= n2; i++){
	    if(P[ans-1]-P[ans] <= P[i-1]-P[i]) ans = i;
	}
	cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "Yes" : "No")<<endl;
using namespace std;


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	string s;
	cin >> s;
	if(s[2]==s[3] && s[4]==s[5]){
		output(1);
	}
	else{
		output(0);
	}

	return 0;
}  


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

int main(){
    string S,T;
    bool flag=1;
    cin >> S >> T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]) flag=0;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> V(H, vector<char>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> V[i][j];
    }
  }
  set<int> h, w;
  for (int i=0; i<H; i++) {
    h.insert(i);
  }
  for (int i=0; i<W; i++) {
    w.insert(i);
  }
  
  
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (V[i][j]=='#') {
        h.erase(i);
        w.erase(j);
      }
    }
  }
  for (int i=0; i<H; i++) {
    if (h.count(i)) {continue;}
    for (int j=0; j<W; j++) {
      if (w.count(j)) {continue;}
      cout << V[i][j];
    }
    cout << endl;
  }
} 


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
	 
	int h = 0;
	int m = 0;
	int s = 0;

	cin >> s;

	h = s / 3600;
	s = s - (h * 3600);

	m = s / 60;
	s = s - (m * 60);

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


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

int main() {
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));
    
    for(int i = 0; i < M ; i++){
        cin >> B[i];
    }

    for(int i = 0; i < N ; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }

    int ans = 0;

    for(int i = 0; i < N ; i++){
        int sum = 0;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if (sum + C > 0) ++ans;
    }

    cout << ans;
}


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

int main(void)
{
	vector<long long>res;
	long long T;
	cin >> T;
	while (T--)
	{
		int op;
		cin >> op;
		if (op == 0)
		{
			long long num;
			cin >> num;
			res.push_back(num);
		}
		else if(op==1)
		{
			long long rank;
			cin >> rank;
			cout << res[rank] << endl;
		}
		else if (op==2)
			res.pop_back();
	}
	return 0;
}


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

using namespace std;

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

#define ll long long

int main()
{
	int n, k;
	cin >> n >> k;
	if (n % k == 0)
		cout << 0 << endl;
	else
		cout << 1 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3 + 10;
const int MAX = 1e4 + 10;
const int INF = INT_MAX - 5;
int h,n;
int a[N], b[N];
ll dp[N][2 * MAX + 10];
int main() {
	cin>>h>>n;
	for(int i = 1; i <= n; ++i) {
		cin>>a[i]>>b[i];
	}
	for(int i = 0; i <= n; ++i) {
		for(int k = 0; k < 2 * MAX + 10; ++k) dp[i][k] = INF;
	}
	for(int i = 0; i <= n; ++i) {
		dp[i][0] = 0;
	}
	for(int i = 1; i <= n; ++i) {
		for(int k = 1; k < 2 * MAX + 10; ++k) {
			if(a[i] > k) dp[i][k] = dp[i - 1][k];
			else if(a[i] == k) {
				dp[i][k] = min(
					dp[i - 1][k],
					dp[i - 1][k - a[i]] + b[i]
				);
			} else {
				dp[i][k] = min(
					min(
						dp[i - 1][k],
						dp[i][k - a[i]] + b[i]
					),
					dp[i - 1][k - a[i]] + b[i]
				);
			}
		}
	}
	/*for(int i = 0; i <= n; ++i) {
		for(int k = 0; k <= h + 10; ++k) cout<<dp[i][k]<<" ";
		cout<<endl;
	}*/
	ll ans = INF;
	for(int i = h; i < 2 * MAX + 10; ++i) ans = min(ans, dp[n][i]); 
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 157952
// Aizu Vol-1 0163: Highway Toll
// 2017.8.3

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int d[7][7] = {
	{  0,  6, 13, 18, 23, 43, 58 },
	{  6,  0,  7, 12, 17, 37, 52 },
	{ 13,  7,  0,  5, 10, 30, 45 },
	{ 18, 12,  5,  0,  5, 25, 40 },
	{ 23, 17, 10,  5,  0, 20, 35 },
	{ 43, 37, 30, 25, 20,  0, 15 },
	{ 58, 52, 45, 40, 35, 15,  0 } };

int f[7][7] = {
	{    0,  300,  500,  600,  700, 1350, 1650 },
	{  300,    0,  350,  450,  600, 1150, 1500 },
	{  500,  350,    0,  250,  400, 1000, 1350 },
	{  600,  450,  250,    0,  250,  850, 1300 },
	{  700,  600,  400,  250,    0,  600, 1150 },
	{ 1350, 1150, 1000,  850,  600,    0,  500 },
	{ 1650, 1500, 1350, 1300, 1150,  500,    0 } };

int main()
{
	int in, out, ti, to;;
	int fee;

	while (1) {
		gets(buf);
		if (!(in = atoi(buf))) break;
		gets(p = buf), ti = getInt() * 100 + getInt();
		gets(buf), out = atoi(buf);
		gets(p = buf), to = getInt() * 100 + getInt();
		fee = f[--in][--out];
		if (d[in][out] <= 40 && ((1730 <= ti && ti <= 1930) || (1730 <= to && to <= 1930)))
			fee = ((fee/2 - 1) / 50 + 1) * 50;
		printf("%d\n", fee);
	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdio>
#define N 200000
using namespace std;
int main()
{
	int n;
	cin >> n;
	int A[N];
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	int mini = A[0];
	int p = A[2] - mini;
	for (int i = 1; i < n; i++)
	{
		if (A[i] - mini > p)
		{
			p = A[i] - mini;
		}
		if (A[i] < mini)
		{
			mini = A[i];
		}
	}

	cout << p << endl;
	return 0;

}


Measured memory_bytes: 3888
#include <stdio.h>

int main()
{
  int S,h,m,s;
  scanf("%d",&S);
  if ((S>=0)&&(S<=86400))
     h=S/3600;
     m=S%3600/60;
     s=S%60;
     printf("%d:%d:%d\n",h,m,s);
}

Measured memory_bytes: 1848
#include <stdio.h>
#include <math.h>

void calcCentralCoordinate(double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y) {
  double a1 = 2 * (x2 - x1);
  double b1 = 2 * (y2 - y1);
  double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
  double a2 = 2 * (x3 - x1);
  double b2 = 2 * (y3 - y1);
  double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

  *x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
  *y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
}

void calcCircumscribedCircleRadius(double x, double y, double x1, double y1, double *r) {
  *r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

int main(void) {
  int n;
  double x1, y1, x2, y2, x3, y3;
  double x, y, r;

  scanf("%d", &n);

  while (!!n--) {
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

    calcCentralCoordinate(x1, y1, x2, y2, x3, y3, &x, &y);
    calcCircumscribedCircleRadius(x, y, x1, y1, &r);

    printf("%.3f %.3f %.3f\n", x, y, r);
  }

  return 0;
}

Measured memory_bytes: 656
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
const int maxn = 1e7 + 10;
long long int a[maxn];
void fun(){
	for(int i = 2; i <= 5 * 1e6; ++ i){
		for(int j = 2; j * i <= 1e7; ++ j){
			a[i * j] ++;
		}
	}
}
int n;
long long int ans = 0;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= 1e7; ++ i)
		a[i] = 2;
	a[1] = 1;
	fun();
	for(int i = 1; i <= n; ++ i){
		ans += a[i] * i; 
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
	
	int A , B ;
	
	scanf("%d %d", &A , &B);

	if(A == B ){
	 printf("Draw");
     }
	
	if((A == 1 && B != 1)||(A != 1 && B == 1)){
	  	
		  if(A == 1)
	  	 printf("Alice");
	  	if(B == 1)
	  	 printf("Bob");
		    
	  }else if(A>B)
	   {
		 if(A <= 13){
		 	printf("Alice");
		 }
	   }else if(B>A){
       	 if(B <= 13){
		 	printf("Bob");
		 }
	   }

	return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
char s[210];
int T,n;ll a[210],bs0[64],bs1[64];
void ins(ll*b,ll x){
	for(int k=59;~k;k--)if(x>>k&1)
		if(!b[k]){b[k]=x;return;}
		else x^=b[k];
}
int chk(ll*b,ll x){
	for(int k=59;~k;k--)if((x>>k&1) && b[k])
		x^=b[k];
	return x==0;
}
int main(){
	scanf("%d",&T);
	while(T--){
		memset(bs0,0,sizeof bs0);
		memset(bs1,0,sizeof bs1);
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%lld",a+i);
		scanf(" %s",s+1);
		for(int i=n;i;){
		//	memset(bs1,0,sizeof bs1);
			while(i && s[i]=='0')ins(bs0,a[i--]);
			while(i && s[i]=='1')ins(bs1,a[i--]);
			for(int i=0;i<60;i++)if(bs1[i])
				if(!chk(bs0,bs1[i])){puts("1");goto sc;}
		}
		puts("0");sc:;
	}
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
 public class Main{
    public static void main(String args[])
{
       String s;
        Scanner sc=new Scanner(System.in);
        s=sc.nextLine();
        if(s.equals("SUN"))
        {
            System.out.println("7");
        }
        if(s.equals("MON"))
        {
            System.out.println("6");
        }
        if(s.equals("TUE"))
        {
            System.out.println("5");
        }
        if(s.equals("WED"))
        {
            System.out.println("4");
        }
        if(s.equals("THU"))
        {
            System.out.println("3");
        }
        if(s.equals("FRI"))
        {
            System.out.println("2");
        }
        if(s.equals("SAT"))
        {
            System.out.println("1");
        }

    
}
}

Measured memory_bytes: 21588
N = [i for i in range(1, 1001)]

while True :
    n = int(input())
    
    if n == 0 :
        break
    
    else :
        cnt = 0
        
        for i in range(1, (n // 2) + 2) :
            s = N[i - 1]
            l = 1
            
            for j in range(i + 1, (n // 2) + 3) :
                if s < n :
                    s += N[j - 1]
                    l += 1
                    
                elif s == n and l > 1:
                    cnt += 1
                    break
                else :
                    break
                
        print(cnt)


Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getindi(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

       ll n;
       cin>>n;
       ll sum=0;
       sum+=1LL* (1000*(n/500));
       n%=500;
       sum+= 5*(n/5);
       cout<<sum<<endl;



return 0;
}


Measured memory_bytes: 256
tmp1 = input()
tmp2 = input()

tmp3 = tmp1.split(" ")
tmp4 = tmp2.split(" ")

N = int(tmp3[0])
K = int(tmp3[1])

for i in range(N):
    tmp4[i] = int(tmp4[i])

tmp4.sort()
out = 0

for i in range(K):
    out = out + tmp4[i]

print(out)


Measured memory_bytes: 9212
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
t = [[] for i in range(n)]
c = [-1 for i in range(n)]
for line in sys.stdin:
    x, y ,z = map(int, line.split())
    x -= 1
    y -= 1
    t[x].append(y)
    t[y].append(x)


def dfs(num, depth):
    if c[num] != -1:
        return
    else:
        c[num] = depth
    for i in t[num]:
        dfs(i, depth)


cnt = 0
for i in range(n):
    if c[i] == -1:
        cnt += 1
        dfs(i, cnt)

print(cnt)


Measured memory_bytes: 110212
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void)

{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a > 9 || b > 9){
        cout<<"-1"<<endl;
    }
    else{
        cout<<(a*b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int dp[31];

int main()
{
  int n;

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

    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    if (n >= 3) {
      for (int i = 3; i <= n; i++) {
        dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
      }
    }

    int day = (dp[n] + 9) / 10;
    int year = (day + 364) / 365;

    cout << year << endl;
  }
}



Measured memory_bytes: 3072