akhauriyash/Code-Regression huggingface dataset:
nums = [int(s) for s in input()]
N = 4

ans = [0]*N
for flag in range(1<<N):
    ans = nums[0]
    for i in range(N-1):
        if flag & 1<<i:
            ans += nums[i+1]
        else:
            ans -= nums[i+1]
    if ans == 7:
        ans_str = str(nums[0])
        for i in range(N-1):
            if flag & 1<<i:
                ans_str += "+"
            else:
                ans_str += "-"
            ans_str += str(nums[i+1])
        ans_str += "=7"
        print(ans_str)
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi dp(3,0);
  rep(i,N) {
    vi nextdp(3,0);
    vi s(3);
    rep(i,3) {
      cin >> s[i];
    }
    rep(x,3) {
      rep(y,3) {
        if(x == y) continue;
        nextdp[x] = max(dp[y] + s[x],nextdp[x]);
      }
    }
    dp = nextdp;
  }
  cout << max(dp[0],max(dp[1],dp[2])) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a==c-b)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_X = 100000;
const int MAX_M = 100000;

/* typedef */

/* global variables */

int ds[MAX_X + 1], cs[MAX_M], hcs[MAX_M];

/* subroutines */

/* main */

int main() {
  int n, m;
  cin >> n >> m;

  int maxx = 0;
  for (int i = 0; i < n; i++) {
    int xi;
    cin >> xi;
    ds[xi]++;
    if (maxx < xi) maxx = xi;
  }

  for (int x = 0; x <= maxx; x++) {
    int i = x % m;
    cs[i] += ds[x];
    hcs[i] += ds[x] / 2;
  }
  //for (int i = 0; i < m; i++) printf("%d %d %d\n", i, cs[i], hcs[i]);
  
  int cnt = 0;
  for (int i = 0, j = m; i <= j; i++, j--) {
    if (i == 0 || i == j)
      cnt += cs[i] / 2;
    else {
      if (cs[i] >= cs[j]) {
	cnt += cs[j];
	int d = (cs[i] - cs[j]) / 2;
	cnt += min(hcs[i], d);
      }
      else {
	cnt += cs[i];
	int d = (cs[j] - cs[i]) / 2;
	cnt += min(hcs[j], d);
      }
    }
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 1408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

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

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...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

double dist(pair<int, int> p1, pair<int, int> p2) {
	return sqrt((p1.ff - p2.ff) * (p1.ff - p2.ff) + (p1.ss - p2.ss) * (p1.ss - p2.ss));
}

int fact(int n) {
	return (n == 1) ? 1 : n * fact(n - 1);
}

int main() {

	int n; cin >> n;
	vector<pair<int, int>> v(n); for (int i = 0; i <= n - 1; i++) cin >> v[i].ff >> v[i].ss;

	sort(v.begin(), v.end());
	double tot = 0;
	do {
		double len = 0;
		for (int i = 1; i <= n - 1; i++) len += (dist(v[i], v[i - 1]));

		tot += len;

	} while (next_permutation(v.begin(), v.end()));
	cout << fixed << setprecision(15) ;
	cout << tot / fact(n);

	return 0;
}

Measured memory_bytes: 3660
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};
use std::cmp::min;

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      x: usize,
   }
   let mut c = Vec::new();
   let mut a = Vec::new();
   for _ in 0..n {
      input! {
         _c: usize,
         _a: [usize;m]
      }
      c.push(_c);
      a.push(_a);
   }

   let inf = 100000000;
   let mut ans = inf;
   for k in 1..(1 << n) {
      let mut f = vec![false; n];
      let mut score = vec![0usize; m];
      let mut money:usize = 0;
      {
         let mut k = k;
         let mut i = 0;
         while k > 0 {
            if k & 1 == 1 {
               f[i] = true;
            }
            i+=1;
            k >>= 1;
         }
      }
      for i in 0..n {
         if f[i] {
            for j in 0..m {
               score[j] += a[i][j];
            }
            money += c[i];
         }
      }
      if score.iter().all(|a| *a >= x) {
         ans = min(ans, money);
      }
   }
   if ans == inf {
      println!("-1");
   }else {
      println!("{}", ans);
   }
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, n)cin >> w[i] >> v[i];
    int INF = 1001001001;
    vector<vector<int>> dp(n+1, vector<int>(100001, INF));
    dp[0][0] = 0;
    rep(i, n){
        rep(j, 100001){
            dp[i+1][j] = dp[i][j];
            if(j >= v[i]){
                if(dp[i][j-v[i]] != INF){
                    dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i]);
                }
            }
        }
    }
    int ans = 0;
    rep(i, 100001)if(dp[n][i] <= W)ans = i;
    cout << ans << endl;
}

Measured memory_bytes: 43336
#include <bits/stdc++.h>
using namespace std;
#define int long long
int f(int x, int y, int z) {
  return max({x,y,z})-min({x,y,z});
}
int gs(int x,int y){
  if(x*y%2==0)return x*y/2;
  if(x<y)swap(x,y);
  return x/2*y;
}
int gl(int x,int y){
  if(x*y%2==0)return x*y/2;
  if(x<y)swap(x,y);
  return (x/2+1)*y;
}
main(){
  int h, w;
  cin >> h >> w;
  int res=f(h/3*w,gs(h-h/3,w),gl(h-h/3,w));
  res=min(res,f((h/3+1)*w,gs(h-h/3-1,w),gl(h-h/3-1,w)));
  swap(h,w);
  res=min(res,f(h/3*w,gs(h-h/3,w),gl(h-h/3,w)));
  res=min(res,f((h/3+1)*w,gs(h-h/3-1,w),gl(h-h/3-1,w)));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
            #define ll long long
            #define MOD 1000000007
            #define maxx ((ll)1e6+5)
            #define zuciso ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define test ll t; cin>>t; while(t--)
            #define int long long
            #define INF 1000000000000000005
            #define pb push_back
            #define pi 3.1415926
            #define MAX 300006
            #define MAX_N 1000000
            #define N 15000005
            #define fori(i,a,b) for(int i=a;i<b;i++)
            ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
            ll fact[1000007]={0};
            void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
            ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[r],MOD-2)))%MOD; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll modmul(ll x, ll y){return (x*y)%MOD;}
            ll modadd(ll x, ll y){return (x+y)%MOD;}
            ll modsub(ll x, ll y){return (x-y+MOD)%MOD;}
            ll xx[4]={1,0,-1,0};
            ll yy[4]={0,1,0,-1};
           using namespace std;


            signed main(){
                zuciso;
                int a,v;
                int b,w;
                int t;
                cin>>a>>v>>b>>w>>t;
                if(a>b){
                    int x=a-v*t;
                    int y=b-w*t;
                    if(x<=y){
                        cout<<"YES"<<endl;
                    }
                    else{
                        cout<<"NO"<<endl;
                    }
                }
                else{
                    int x=a+v*t;
                    int y=b+w*t;
                    if(x>=y){
                        cout<<"YES"<<endl;
                    }
                    else{
                        cout<<"NO"<<endl;
                    }
                }

            }


Measured memory_bytes: 3644
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int a,c=0;
      cin>>a;
      while(a)
            {
              if(a%10==7)
              {
                cout<<"Yes\n";
                return 0;
              }
        a/=10;
      }
     cout<<"No\n";
    }

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

struct path{
  ll sx,sy,ex,ey;
  bool operator==(const path& p){
    return sx == p.sx && sy == p.sy && ex == p.ex && ey == p.ey;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,h,w,x,y,x1,y1;
  cin >>n;
  rep(i,n){
    cin >> w >> h;
    vector<vector<ll>> dp(w+3,vector<ll>(h+3,0));
    ll k;
    cin >> k;
    vector<path> p(k);
    rep(j,k){
      cin >> x >> y >> x1 >> y1;
      if(x > x1){
        swap(x,x1);
      }
      if(y > y1){
        swap(y,y1);
      }
      p[j] = path{x,y,x1,y1};
    }
    dp[0][0] = 1;
    rep(l,h+1){
      rep(j,w+1){
        if(find(all(p),path{j,l,j+1,l}) == p.end()){
          dp[j+1][l] += dp[j][l];
        }
        if(find(all(p),path{j,l,j,l+1}) == p.end()){
          dp[j][l+1] += dp[j][l];
        }
      }
    }
    if(dp[w][h]){
      cout << dp[w][h]<<endl;
    }
    else{
      cout << "Miserable Hokusai!"<<endl;
    }
//     rep(j,h-1){
//       rep(l,w-1){
//         cout << dp[l][j] << " ";
//       }
//       cout << endl;
//     }
  }

  return 0;
}

Measured memory_bytes: 3124
// Vicfred
// https://atcoder.jp/contests/abc126/tasks/abc126_d
// dfs, graph, tree
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

const uint MAXN = 10^^5 + 5;

struct edge {
    long u;
    long w;
}

edge[][MAXN] tree;
long[MAXN] dist;

void dfs(long child, long parent, long distance) {
    dist[child] = dist[parent] + distance;

    foreach(item; tree[child]) {
        if(item.u == parent) continue;
        dfs(item.u, child, item.w);
    }
}

void main() {
    const long n = readln.chomp.to!long;

    foreach(i; 1..n) {
        long u, v, w;
        readf("%d %d %d\n", &u, &v, &w);
        tree[u] ~= edge(v, w);
        tree[v] ~= edge(u, w);
    }

    dfs(1, 0, 0);

    for(int i = 1; i <= n; i++) {
        if(dist[i]%2 == 0)
            1.writeln;
        else
            0.writeln;
    }
}



Measured memory_bytes: 22492
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	int M, D;
	cin >> M >> D;
	
	int cnt = 0;
	for(int i = 1; i <= M; i++) {
		for(int d = 22; d <= D; d++) {
			string s = to_string(d);
			int d1 = s[1] - '0';
			int d2 = s[0] - '0';
			if(d1 < 2 or d2 < 2) continue;
			if(d1 * d2 == i) cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,x,y;
	double s,pi=3.141592653589793;
	cin>>a>>b>>x;
	if(x>=a*a*b/2)
	{
		y=2*(a*a*b-x)/a/a;
		s=atan(y/a)/pi*180;
		cout<<fixed<<setprecision(10)<<s<<endl;
	}
	else 
	{
		y=x/b/a*2;
		s=atan(b/y)/pi*180;
		cout<<fixed<<setprecision(10)<<s<<endl;
	}
}

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

using namespace std;

#define int long long

struct Log {
	int p, r;
};

typedef pair<int, int> Pair;

int P, R, T;
vector< vector<int> > p0;
vector<int> r0;
vector<Log> g;
bool isAlive(int t) {
	vector< vector<int> > p = p0;
	vector<int> r = r0;
	for (int i = 0; i < t; ++i) {
		--p[g[i].p][g[i].r];
		--r[g[i].r];
	}
	vector<bool> isFree(P, false);
	for (int i = 0; i < P; ++i) {
		int cnt = 0;
		for (int j = 0; j < R; ++j) {
			cnt += p[i][j] == 0;
		}
		if (cnt == R) {
			isFree[i] = true;
			for (int j = 0; j < R; ++j) {
				r[j] += p0[i][j];
			}
		}
	}

	vector<int> deadCount(P, 0);
	vector<bool> isDead(P, false);
	vector< set<Pair> > need(R);
	for (int i = 0; i < P; ++i) {
		for (int j = 0; j < R; ++j) {
			if (p[i][j] > r[j]) {
				need[j].insert( Pair(p[i][j], i) );
				++deadCount[i];
				isDead[i] = true;
			}
		}
	}

	queue<Pair> Q;
	for (int i = 0; i < P; ++i) {
		if (!isFree[i] && !isDead[i]) {
			isFree[i] = true;
			for (int j = 0; j < R; ++j) {
				Q.push( Pair(j, p0[i][j]-p[i][j]) );
			}
		}
	}
	while ( !Q.empty() ) {
		Pair q = Q.front(); Q.pop();
		int rid = q.first, amount = q.second;
		r[rid] += amount;
		while (need[rid].size() > 0) {
			set<Pair>::iterator it = need[rid].begin();
			if (it->first <= r[rid]) {
				if (--deadCount[it->second] == 0) {
					isDead[it->second] = false;
					isFree[it->second] = true;
					for (int j = 0; j < R; ++j) {
						Q.push( Pair(j, p0[it->second][j]-p[it->second][j]) );
					}
				}
				need[rid].erase(it);
			}
			else {
				break;
			}
		}
	}
	for (int i = 0; i < P; ++i) {
		if (isDead[i]) return false;
	}

	return true;
}

signed main() {
	cin >> P >> R >> T;
	r0 = vector<int>(R);
	p0 = vector< vector<int> >(P, vector<int>(R));
	g.resize(T);
	for (int i = 0; i < R; ++i) cin >> r0[i];
	for (int i = 0; i < P; ++i) {
		for (int j = 0; j < R; ++j) {
			cin >> p0[i][j];
		}
	}
	for (int t = 0; t < T; ++t) {
		cin >> g[t].p >> g[t].r; --g[t].p, --g[t].r;
	}

	int left = 0, right = T+1;
	while ( right-left > 1 ) {
		int m = (left+right)/2;
		if ( isAlive(m) ) {
			left = m;
		}
		else {
			right = m;
		}
	}
	if (right == T+1) cout << -1 << endl;
	else cout << right << endl;
}

Measured memory_bytes: 7172
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int dp[100005];
int main() {
  int n, k;
  cin >> n >> k;

  int h[n + 3];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
    dp[i] = 0x3f3f3f3f;
  }

  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    for (int j = i - 1; j >= max(i - k, 1); j--) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }

  printf("%d\n", dp[n]);
  return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int n, c;
    cin >> n >> c;

    //map<pii, int> d, color;
    v2_int d(c+1, v_int(c+1)), color(n, v_int(n));

    irep(i, c) {
        irep(j, c) {
            cin >> d[i+1][j+1];
        }
    }   

    irep(i, n) {
        irep(j, n) {
            cin >> color[i][j];
        }
    }
    
    v2_int cost(3, v_int(c, 0)); 

    irep2(k, 1, c) {
        irep(i, n) {
            irep(j, n) {
                int mod3 = (i+1+j+1)%3;
                int org_col = color[i][j];
                if(org_col != k) {
                    cost[mod3][k-1] += d[org_col][k]; 
                }
            }
        }
    }
#if 0
    irep(i, 3) {
        irep(j, c) {
            printf("%d,", cost[i][j]);
        } printf("\n");
    }
#endif
    int ans = INF;
    irep(i, c) {
        irep(j, c) {
            irep(k, c) {
                if(i == j || i == k || j == k) { continue; }
                ans = min(ans, cost[0][i]+cost[1][j]+cost[2][k]); 
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a , b , r ;
    cin >> a >> b ;
    if (a + b < 10 )
        cout << a + b ;
    else
        cout << "error" ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vector<vector<char>> s(n+2,vector<char>(m+2,'.'));
    range(i,1,n+1)range(j,1,m+1)cin>>s[i][j];
    // rep(i,n+2){
    //     rep(j,m+2){
    //         cout<<s[i][j];
    //     }
    //     cout<<endl;
   // }

   
   range(i,1,n+1){
       range(j,1,m+1){
           bool can=false;
           if(s[i][j]=='#'){
               rep(k,4){
                   if(s[i+dy[k]][j+dx[k]]=='#') can=true;
                }
                if(can==false){
                    coutn;
                    return 0;
                }
            }
        }
   }
   couty;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n, m;
    ll max = 1e5;
    int mod = 1e9 + 7;
    bool isbroken[max+1];
    ll cnt[max+1];
    rep0(i,max) isbroken[i] = false;
    rep0(i,max) cnt[i] = 0;
    cin >> n >> m;
    rep1(i,m){
        ll tmp;
        cin >> tmp;
        isbroken[tmp] = true;
    }

    cnt[0] = 1;
    if(!isbroken[1]) cnt[1] = 1;
    for(int i = 2; i <= n;i++){
        if(!isbroken[i]){
            if(isbroken[i-1] && isbroken[i-2]){
                continue;
            }else if(isbroken[i-1]){
                cnt[i] = cnt[i-2] % mod;
            }else if(isbroken[i-2]){
                cnt[i] = cnt[i-1] % mod;
            }else{
                cnt[i] = (cnt[i-1] + cnt[i-2]) % mod;
            }
        }
    }
    cout << cnt[n] << endl;

    return 0;
}

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

int main() {
    string input; cin >>input;
    int a, b, c, d;
    a = input[0] - '0';
    b = input[1] - '0';
    c = input[2] - '0';
    d = input[3] - '0';
         if (a+b+c+d==7) {printf("%d+%d+%d+%d=7\n",a,b,c,d);}
    else if (a+b+c-d==7) {printf("%d+%d+%d-%d=7\n",a,b,c,d);}
    else if (a+b-c+d==7) {printf("%d+%d-%d+%d=7\n",a,b,c,d);}
    else if (a+b-c-d==7) {printf("%d+%d-%d-%d=7\n",a,b,c,d);}
    else if (a-b+c+d==7) {printf("%d-%d+%d+%d=7\n",a,b,c,d);}
    else if (a-b+c-d==7) {printf("%d-%d+%d-%d=7\n",a,b,c,d);}
    else if (a-b-c+d==7) {printf("%d-%d-%d+%d=7\n",a,b,c,d);}
    else if (a-b-c-d==7) {printf("%d-%d-%d-%d=7\n",a,b,c,d);}
    return 0;
}

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

using namespace std;

const int mod = 1000000007;

long long dp[4050][4050];
long long fact[10050],inv[10050];
int n;
int x[200050],y[200050];

long long qpow(long long base,int tms)
{
	long long tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * base % mod;
		base = base * base % mod;
		tms >>= 1;
	}
	return tmp;
}

long long C(int x,int y)
{
	return fact[x] * 1ll * inv[y] % mod * inv[x - y] % mod;
}

int main()
{
	fact[0] = inv[0] = 1;
	for(int i = 1;i <= 10000; ++ i) fact[i] = fact[i - 1] * i % mod,inv[i] = qpow(fact[i],mod - 2);
	scanf("%d",&n);
	for(int i = 1;i <= n; ++ i) scanf("%d%d",&x[i],&y[i]);
	for(int i = 1;i <= n; ++ i)
		dp[2001 - x[i]][2001 - y[i]] ++;
	for(int i = 1;i <= 4001; ++ i)
		for(int j = 1;j <= 4001; ++ j)
			dp[i][j] += dp[i - 1][j] + dp[i][j - 1],dp[i][j] %= mod;
	int ans = 0;
	for(int i = 1;i <= n; ++ i)
		ans = (ans + dp[2001 + x[i]][2001 + y[i]]) % mod,ans = (ans - C(x[i] * 2 + y[i] * 2,x[i] * 2) + mod) % mod;
	printf("%d\n",ans * 1ll * qpow(2,mod - 2) % mod);
	return 0;
}

Measured memory_bytes: 129280
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N; cin>>N;
    vector<ll> A(N);
    REP(i, N) cin>>A[i];
    bool res = true;
    for(int i=0; i<N-1; i++){
        if(A[N-2-i]>A[N-1-i]+1){
            res = false;
            break;
        }
        else if(A[N-2-i]>A[N-1-i]){
            A[N-2-i] -=1;
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1152
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	mx := 100
	for i := range as {
		a := as[i]
		var cnt int
		for a%2 == 0 {
			cnt++
			a /= 2
		}
		mx = min(mx, cnt)
	}
	fmt.Println(mx)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

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


Measured memory_bytes: 1844
#include<iostream>

int main(){
  std::string str;
  std::cin >> str;
  int n;
  std::cin >> n;

  for(int i = 0; i < n; i++){
    std::string op;
    std::cin >> op;

    int a, b;
    std::cin >> a;
    std::cin >> b;
    if(op == "print"){
      std::cout << str.substr(a, b - a + 1) << std::endl;
    }else if(op == "reverse"){
      for(int head = a, tail = b; head < tail; head++, tail--){
	char t = str[head];
	str[head] = str[tail];
	str[tail] = t;
      }
    }else if(op == "replace"){
      std::string p;
      std::cin >> p;
      for(int i = 0; i < b - a + 1; i++){
	str[a + i] = p[i];
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int y,m,d; cin >> y >> m >> d;) {
		if(y < 1868 || (y == 1868 && (m < 9 || (m == 9 && d < 8)))) {
			puts("pre-meiji");
		}
		else if(y < 1912 || (y == 1912 && (m < 7 || (m == 7 && d <= 29)))) {
			printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
		}
		else if(y < 1926 || (y == 1926 && (m < 12 || (m == 12 && d <= 24)))) {
			printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
		}
		else if(y < 1989 || (y == 1989 && (m < 1 || (m == 1 && d <= 7)))) {
			printf("showa %d %d %d\n", y - 1926 + 1, m, d);
		}
		else {
			printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

typedef pair<int,int> P;

vector<P> vec;
int n;
int a[100010];

int main()
{
    cin >> n;
    rep(i,0,n - 1) cin >> a[i];
    rep(i,0,n - 1) vec.push_back(P(a[i],i));

    sort(vec.begin(),vec.end());

    int cou = 0;

    rep(i,0,n - 1)
    {
        if((4 * n + i - vec[i].second) % 2 == 1) cou++;
    }

    cout << (cou / 2) + (cou % 2) << endl;
    return 0;

    
}




Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    int N;
    cin >> N;

    int count=0;

    for(int i=1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            for(int k=1;k<N+1;k++){
                 count=count+gcd(i,gcd(j,k));
            }
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 3624
n, m = map(int, input().split())
A = list(map(int, input().split()))

B = []
C = []
for i in range(m):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

D = zip(C, B)
D = sorted(D)
C, B = zip(*D)
C = reversed(C)
B = reversed(B)
total = 0

for i, j in zip(C, B):
    if total >= n:
        break
    else:
        total += j
        A.extend([i] * j)

A = sorted(A)
print(sum(A[-n:]))

Measured memory_bytes: 103888
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(l,i,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	//output.txt", "w", stdout);
	//#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string str ; cin >> str;
	for(int i=0;i<=3;i++){
		if(str[i] == str[i+1]){
			cout << "Bad" ;
			return 0;
		}
	}
	cout << "Good";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 100005;
//////////////////////////////

int n;
string p;
Int dp[3300][3300];
Int dp_sum[3300][3300];

int main()
{
	cin >> n;
	cin >> p;
	dp[0][0] = 1;

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= i - 1; j++) {
			dp_sum[i - 1][j] = dp[i - 1][j];
			if (j - 1 >= 0) dp_sum[i - 1][j] += dp_sum[i - 1][j - 1];
			dp_sum[i - 1][j] %= MOD;
		}
		for (int j = 0; j <= i; j++) {
			if (p[i - 1] == '<') {
				if (j - 1 >= 0) dp[i][j] = dp_sum[i - 1][j - 1];
			}
			else {
				dp[i][j] = dp_sum[i - 1][i - 1];
				if (j - 1 >= 0) dp[i][j] -= dp_sum[i - 1][j - 1];
				dp[i][j] %= MOD;
			}
		}
	}

	Int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += dp[n - 1][i];
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 156288
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100000
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define vi(a)	  vector<ll>a
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		string s;
		cin >> s;
		string s2 = s;
		ll cnt = 0;
		reverse(s2.begin(),s2.end());
		for (int i=0 ; i<(int)s.length() ; i++)
		{
			if(s[i]!=s2[i])
			cnt++;
			//cerr << imie(cnt);
			//cerr << endl;
		}
		cout << cnt/2 << endl;
		
		return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> P,Q;
  P=Q=vector<int>(N);
  for(int i=0;i<N;i++)cin>>P[i];
  for(int i=0;i<N;i++)cin>>Q[i];
  vector<int> tmp(N);
  for(int i=0;i<N;i++)tmp[i]=i+1;
  int cnt=1;
  int a,b;
  do{
    if(tmp==P)a=cnt;
    if(tmp==Q)b=cnt;
    cnt++;
  }while(next_permutation(tmp.begin(),tmp.end()));
  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, M;
bool m[30][30] = {};

signed main()
{
	cin >> N >> M;

	REP(i, N)
	{
		int k;
		cin >> k;
		REP(j, k)
		{
			int a;
			cin >> a;
			m[i][a - 1] = true;
		}
	}

	int cnt = 0;
	REP(j, M)
	{
		bool is_all = true;
		REP(i, N)
		{
			if (!m[i][j])
			{
				is_all = false;
			}
		}
		if (is_all)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}








Measured memory_bytes: 256
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]


a,b = map(str,input().split())
d = int(b[0]+b[2:])
c = int(a)
print(c*d//100)


Measured memory_bytes: 9428
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

typedef pair<ll,ll> P;

ll n;
P a[200000];
ll ca,cb;
ll mod = 1e9 + 7;
int main(){
    cin >> n;
    REP(i,n){
        ll b;
        cin >> b;
        a[i] = P(b,0);
    }
    REP(i,n) {
        ll b;
        cin >> b;
        a[i + n] = P(b,1);
    }

    sort(a,a+2*n);

    ll ans = 1;
    REP(i,2*n) {
        if(a[i].second) {
            if(cb == 0) {
                ca++;
            }else{
                (ans *= cb) %= mod;
                cb--;
            }
        }else {
            if(ca == 0) {
                cb++;
            }else {
                (ans *= ca) %= mod;
                ca--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    string S;cin>>S;
    vector<int> to(N-1);
    bool kisuu=false;
    for(int i=0;i<N-1;i++){
        int a=S[i]-'0';
        int b=S[i+1]-'0';
        
        to[i]=abs(a-b);
        
        if(to[i]==1) kisuu=true;
    }
    
    N=to.size();
    
    if(N==1){
        cout<<to[0]<<endl;
        return 0;
    }
    
    if(kisuu){
        for(int i=0;i<N;i++) to[i]%=2;
    }else{
        for(int i=0;i<N;i++) to[i]/=2;
    }
    
    while(to.size()>1){
        int N=to.size();
        vector<int> xo(N+1);
        for(int i=1;i<=N;i++) xo[i]=xo[i-1]^to[i-1];
        
        vector<int> ne;
        for(int j=30;j>=0;j--){
            if(N&(1<<j)){
                
                for(int i=(1<<j);i<=N;i++){
                    ne.push_back(xo[i]^xo[i-(1<<j)]);
                }
                
                break;
            }
        }
        
        to=ne;
    }
    
    if(kisuu) cout<<to[0]<<endl;
    else cout<<to[0]*2<<endl;
    
}


Measured memory_bytes: 12188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n, d;
  cin >> n >> d;
  cout << (n+2*d)/(2*d+1) << endl;
  return 0;
}

Measured memory_bytes: 3592
n = int(input())
w = [input() for i in range(n)]
if len(set(w)) == n:
    for i in range(1, n):
        s0 = list(w[i - 1])
        s1 = list(w[i])
        if s1[0] == s0[-1]:
            pass
        else:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int main(){

    int A,B,r,l,K;

    scanf("%d%d",&A,&B);

    K=(A+B)/2;
    r=A-K;
    l=B-K;
    if(r<0){
    r=-1*r;
    }
    if(l<0){
        l=-1*l;
    }
    if(r==l){
        printf("%d",K);
    }
    else{printf("IMPOSSIBLE");}

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

ll INF = 1000000007;
ll fac[10000000];
ll inv[10000000],finv[10000000];

void solve(ll n, ll m){
  fac[0] = fac[1] = 1;
  inv[1] = 1;
  finv[0] = finv[1] = 1;
  for(int i  =2; i <= n+m; i++){
    fac[i] = fac[i-1] * i %INF;
    inv[i] =INF - inv[INF%i]*(INF/i)%INF;
    finv[i] = finv[i-1]*inv[i]%INF;
  }
}

ll COM(ll n, ll k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

int main(void){
  ll X,Y; cin >> X >> Y;
  ll n = (2*X-Y)/3, m = (2*Y-X)/3;
  if((X+Y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }
  if(n < 0 || m < 0){
    cout << 0 << endl;
    return 0;
  }
  solve(n,m);
  cout << COM(n+m,m) << endl;
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 003_agc_b / Link: https://agc003.contest.atcoder.jp/tasks/agc003_b?lang=en ----- */
/* ------問題------

高橋君は 1 から N までの整数のうちのどれかが書かれたカードをたくさん持っています。 高橋君は整数 i が書かれたカードを Ai 枚持っています。

2 枚のカードについて、それらに書かれた整数の差の絶対値が 1 以下のとき、これらをペアにすることができます。

高橋君は、同じカードが複数のペアに使われないように、できるだけ多くのペアを作りたいです。高橋君が作れるペアの個数の最大値を求めてください。

-----問題ここまで----- */
/* -----解説等-----

言われた感じにやっていけば良い

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N);

	FOR(i, 0, N) {
		cin >> a[i];
	}

	FOR(i, 0, N) {
		ans += a[i] / 2;
		a[i] = a[i] % 2;
		if (i != N - 1) {
			LL cnt = min(a[i], a[i + 1]);
			assert(cnt < 2);
			a[i] -= cnt;
			a[i + 1] -= cnt;
			ans += cnt;
		}
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    string s;
    cin >> s;
    int a = s.size();
    int ans = a;
    a /= 2;
    a--;
    for(int i= a;i > 0; i--){
        int t=1;
        REP(j,i){
            if(s[j] != s[j+i]){
                t=0;
                break;
            }
        }
        if(t == 1){
            ans = 2*i;
            break;
        }

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


Measured memory_bytes: 256
package main

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

func main(){
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	N, e := strconv.Atoi(sc.Text())
	var res = N
	if e != nil {
		panic(e)
	}
	for i := 0; i <= N; i++ {
		cc := 0
		t := i
		for t > 0 {
			cc+=t%6
			t/=6
		}
		t=N-i
		for t > 0 {
			cc+=t%9
			t/=9
		}
		if res > cc{
			res = cc
		}
	}
	fmt.Print(res)
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int price[4]={6000,4000,3000,2000};
    int i,num,kazu;
    for(i=0;i<4;i++){
        scanf("%d %d",&num,&kazu);
        printf("%d\n",price[num-1]*kazu);
    }
    return 0;
}

Measured memory_bytes: 600