akhauriyash/Code-Regression huggingface dataset:
class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0 for i in range(n + 1)]
        self.member = [1 for i in range(n + 1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.member[y] += self.member[x]
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.member[x] += self.member[y]
        else:
            self.par[y] = x
            self.rank[x] += 1
            self.member[x] += self.member[y]

    def size(self, x):
        return self.member[self.find(x)]

n, m = map(int, input().split())
E = [list(map(int, input().split())) for _ in range(m)]
ans = [0 for _ in range(m + 1)]
ans[-1] = n * (n - 1) // 2
tree = UnionFind(n)
for i, e in enumerate(E[::-1]):
    if tree.check(*e):
        ans[-(i + 2)] = ans[-(i + 1)]
    else:
        ans[-(i + 2)] = ans[-(i + 1)] -  tree.size(e[0]) * tree.size(e[1])
        tree.union(*e)
for a in ans[1:]:
    print(a)


Measured memory_bytes: 35780
#define _USE_MATH_DEFINES
#include <iomanip>
#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>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

int x[100];

int fib(int n){
    for (int i = 0; i <= n;i++){
        if(i==0)
            x[0] = 1;
        else if(i==1)
            x[1] = 1;
        else
            x[i] = x[i - 2] + x[i - 1];
    }
    return x[n];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << fib(n) << endl;
}


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

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

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

    cin >> n;

    int res = 0;
    ll lasti;
    for (ll i = 2; i * i <= n; ++i) {
      if (i * i <= n - 1) {
        ll m = n - 1;
        if (m % i == 0) {
          res += (i * i == n - 1 ? 1 : 2);
          continue;
        }
      }
      ll m = n;
      while (m % i == 0) {
        m = m / i;
      }
      if (m > i) {
        m = m % i;
      }
      if (m == 1)
        ++res;
    }

    ++res;
    if (n - 1 >= 2)
      ++res;

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
s = list(input())

# 1種類は確実にいる
ans = 1

s1 = s[0]
for i in range(1, len(s)):
    s2 = s[i]
    if s1 != s2:
        ans += 1
    s1 = s[i]

print(ans)

Measured memory_bytes: 13476
//这道题可以用桶排来解，每输入一个数，其对应的桶加一。
//需要注意的是，如果一个数大于数的总量，就必须删除。
#include<iostream>
using namespace std;
int n,a[100001],x,ans;//数组如果开到10亿，就超空间了
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x>n) ans++;//大于n的x删除，计数器加一
		else a[x]++;//不大于n的x的桶加一，计量x出现的次数
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0) continue;//桶为0，表示i从未出现
		if(a[i]<i) ans+=a[i];//i不超过装它的桶，全部删除
		else if(a[i]>i) ans+=a[i]-i;//i超过装它的桶，删除超过的部分
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  let inputs: any[][] = [];
  for (let i = 0; i < lines.length; i++) {
    inputs.push([Number(lines[i]), false]);
  }

  let nextBtn = 1;
  let count = 0;
  while (true) {
    count++;

    nextBtn = inputs[nextBtn][0];

    if (inputs[nextBtn][1]) {
      console.log(-1);
      break;
    }

    if (nextBtn === 2) {
      console.log(count);
      break;
    }

    inputs[nextBtn][1] = true;
  }
});


Measured memory_bytes: 31800
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

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

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   ll n, m, i, j, k, t, q;

   cin>>k;

   queue<ll> qu;
    

   for(i = 1;i <= 9;i++){
     qu.push(i);
   }

   ll count;

  // cout<<count<<"\n";

   
       count = 1;
       while(count < k){
           ll te = qu.front();
         //  cout<<te<<"\n";
           qu.pop();
           if(te%10 == 9){
                              qu.push(10*te+8);

               qu.push(10*te+9);
           }
           else if(te%10 == 0){
               qu.push(10*te);
               qu.push(10*te+1);
           }
           else{
               ll end = te%10;
                qu.push(10*te+end-1);

               qu.push(10*te+end);
               qu.push(10*te+end+1);
           }
         //  cout<<qu.front()<<"\n";
           count++;
       }
       cout<<qu.front();
   


}




Measured memory_bytes: 1792
# E - Red Scarf

N = int(input())
A = list(int(a) for a in input().split())

B = A[0]
for i in range(1, N):
    B ^= A[i]

C = []
for i in range(N):
    C.append(B^A[i])

print(' '.join(map(str, C)))

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

int main() {
    int n = 3;
    vector<int> V;
    for(int i = 0; i < n; ++i) {
        int ret; scanf("%d", &ret);
        V.emplace_back(ret);
    }
    sort(V.begin(), V.end());
    cout << V[2] - V[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define me(x) memset(x,0,sizeof(x))
#define bi(x) memset(x,0x3f,sizeof(x))
#define graph(x) for(int i=first[x];i;i=e[i].next)
#define ud  using namespace std
ud;
const int maxn=1e5+1000,mod=1e9+7;
int N,M,p[maxn],m,c[maxn],inv[maxn],Ans=1;
inline long long read()
{
	long long s=0,f=1;
	char ch;
	for(;ch<'0' || ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0' && ch<='9';ch=getchar()) s=(s<<1)+(s<<3)+ch-'0';
	return s*f;
}
void div(int n)
{
	m=0;
	for(int i=2;i<=sqrt(n);++i)
	{
		if(n%i==0)
		{
			p[++m]=i,c[m]=0;
			while(n%i==0) n/=i,++c[m];
		}
	}
	if(n>1) p[++m]=n,c[m]=1;
}
int exgcd(int a,int b,int &x,int &y)//扩展欧几里得算法 
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    int ret=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return ret;
}
int Inv(int a,int mod)//求a在mod下的逆元，不存在逆元返回-1 
{
    int x,y;
    int d=exgcd(a,mod,x,y);
    return d==1?(x%mod+mod)%mod:-1;
}
int C(int y,int x)
{
	if(y<0||x<0||y<x) return 0; y%=mod;
	if(x==0||y==0) return 1; int ans=1;
	for(int i=0;i<x;++i) ans=(ll)ans*(y-i)%mod;
	for(int i=1;i<=x;++i) ans=(ll)ans*inv[i]%mod;
	return ans;
} 
int main()
{
	N=read(),M=read(),div(M);
	for(int i=1;i<=maxn;++i) inv[i]=Inv(i,mod);
	for(int i=1;i<=m;++i)
	{
		int res=C(N+c[i]-1,N-1);
		Ans=(ll)Ans*res%mod;
	}
	printf("%d\n",(Ans+mod)%mod);
	return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    if (N == 1) {
        cout << abs(A[0] - W) << endl;
    } else {
        cout << max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1])) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	int H, W, N;
	cin >> H >> W >> N;
	int v = max(H, W);
	cout << (N + v - 1) / v << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a;
multiset<int> st;
vector<int> vec;

signed main() {
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		cin >> a;
		st.insert(a);
	}
	vec.push_back(*st.rbegin());
	st.erase(st.lower_bound(*st.rbegin()));
	for (int i = 0; i < n; i++) {
		vector<int> ve;
		for (int j = 0; j < (int)vec.size(); j++) {
			if (st.lower_bound(vec[j]) == st.begin()) {
				cout << "No" << endl;
				return 0;
			}
			ve.push_back(*--st.lower_bound(vec[j]));
			st.erase(--st.lower_bound(vec[j]));
		}
		for (int j = 0; j < (int)ve.size(); j++)vec.push_back(ve[j]);
	}
	cout << "Yes" << endl;
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

int main(){

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

    vector<vector<ModInt>> dp(c + 1, vector<ModInt>(d + 1));

    dp[a][b] = ModInt(1, MODN2);

    for(int i = a + 1; i <= c; i++){
        dp[i][b] = dp[i - 1][b] * ModInt(b, MODN2);
    }

    for(int j = b + 1; j <= d; j++){
        dp[a][j] = dp[a][j - 1] * ModInt(a, MODN2);
    }

    for(int i = a + 1; i <= c; i++){
        for(int j = b + 1; j <= d; j++){
            dp[i][j] = dp[i - 1][j] * ModInt(j, MODN2) + dp[i][j - 1] * ModInt(i, MODN2) - ModInt((i - 1) * (j - 1), MODN2) * dp[i - 1][j - 1];
        }
    }

    cout << dp[c][d].n << endl;

    return 0;
}


Measured memory_bytes: 144120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForce
{
    class CF
    {

        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            bool answer = word[2] == word[3] && word[4] == word[5];
            if (answer)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int>h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int>dp(n,INT_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i>=j)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cstdio>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

typedef long long ll;

using namespace std;
int main()
{
    ll D, N;
    cin >> D >> N;
    ll num;
    if (N != 100)
    {
        num = N * pow(100, D);
    }
    else
    {
        num = (N + 1) * pow(100, D);
    }
    cout << num;
    return 0;
}

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

int main()
{
   int n,k;
   int res;
   cin>>n>>k;
   if(n%k==0){

res=0;

   }


   else {

    res=1;

   }
   cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,m,a[300001],b[300001],p1,p2;
typedef pair<int,int> pi;
set<pi>st;

int main()
{
	int i,j,x,y;
	cin>>h>>w>>m;
	vector<int>l,r;
	for(i=1;i<=m;++i)
	{
		cin>>x>>y;
		st.insert(make_pair(x,y));
		a[x]++;
		b[y]++;
		if(a[x]>p1)
		{
			l.clear();
			p1=a[x];
		}
		if(a[x]==p1)
			l.push_back(x);
		if(b[y]>p2)
		{
			r.clear();
			p2=b[y];
		}
		if(b[y]==p2)
			r.push_back(y);
	}
	for(i=0;i<l.size();++i)
	{
		for(j=0;j<r.size();++j)
		{
			if(st.find(make_pair\
			(l[i],r[j]))==st.end())
			{
				cout<<p1+p2;
				return 0;
			}
		}
	}
	cout<<p1+p2-1<<endl;
}

Measured memory_bytes: 21924
N,A,B,C,D = map(int,input().split())
S = input()
M = max(C,D)
A -= 1
B -= 1
C -= 1
D -= 1


for i in range(A,max(C,D)):
    if S[i] == S[i+1] and S[i+1] == '#':
        print("No")
        quit()
if  C < D:
    print("Yes")
elif D <= C:
    for i in range(B-1,D):
        if S[i] == S[i+1] and S[i+1]== S[i+2]  and S[i+2] == '.':
            print("Yes")
            quit()
    print("No")



Measured memory_bytes: 40560
n = gets.to_i
xs = gets.chop
xi = xs.to_i(2)
init_count = xs.count('1')
p_init_count = init_count + 1
m_init_count = init_count - 1
pxi = xi % p_init_count
mxi = xi % m_init_count if m_init_count > 0
ans = []
n.times do |i|
  if xi[i].zero?
    t = (pxi + 2.pow(i,p_init_count)) % p_init_count
  else
    next ans.push(0) if m_init_count.zero?
    t = (mxi - 2.pow(i,m_init_count)) % m_init_count
  end
  c = 1
  until t == 0
    t %= t.to_s(2).count('1')
    c += 1
  end
  ans.push(c)
end
ans.reverse_each { puts _1 }

Measured memory_bytes: 16488
//わからん
#include <iostream>
#define int long long
using namespace std;

int n;
int a[10000];
int b[10000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) cin >> b[i];
	
	int sumA = 0, sumB = 0;
	for (i = 0; i < n; i++) sumA += a[i];
	for (i = 0; i < n; i++) sumB += b[i];
	if (sumB - sumA < 0) { cout << "No" << endl; return 0; }
	
	int opeCnt = sumB - sumA;
	int aOpeCnt = 0, bOpeCnt = 0;
	while (true) {
		bool flag = false;
		for (i = 0; i < n; i++) {
			if (a[i] < b[i]) {
				aOpeCnt += (b[i] - a[i] + 1) / 2;
				a[i] += (b[i] - a[i] + 1) / 2 * 2;
				flag = true;
			}
			else if (b[i] < a[i]) {
				bOpeCnt += b[i] - a[i];
				b[i] = a[i];
				flag = true;
			}
		}
		if (!flag) break;
	}
	
	if (aOpeCnt > opeCnt || bOpeCnt > opeCnt) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }
	return 0;
}

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

struct UF{
    int par[200000];
    int rank[200000];
    
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x!=y){
            if(rank[x]<rank[y]){
                par[x]=y;
            }else{
                par[y]=x;
                if(rank[x]==rank[y])rank[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int main(void){
    int h,w;
    long long t=0;
    string s[404];
    UF u;
    map<int,long long> a,b;
    cin>>h>>w;
    u.init(160008);
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j<w-1){
                if(s[i][j]!=s[i][j+1]){
                    u.unite(i*400+j,i*400+j+1);
                }
            }
            if(i<h-1){
                if(s[i][j]!=s[i+1][j]){
                    u.unite(i*400+j,(i+1)*400+j);
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int m=i*400+j,l;
            l=u.find(m);
            if(s[i][j]=='#'){
                a[l]++;
            }else{
                b[l]++;
            }
        }
    }
    
    for(auto x=a.begin();x!=a.end();x++){
        int k=x->first;
        t+=a[k]*b[k];
    }
    
    cout<<t<<endl;
    
    
}


Measured memory_bytes: 19200
#include <iostream>
#include <vector>
using namespace std;
void p(const vector<vector<bool>>& xss) {
  for(const auto& xs:xss) {
    for(const auto& x:xs) cout<<(x?'#':'.');
    cout<<'\n';
  }
}
main() {
  vector<vector<bool>> xss(100); for(auto& xs:xss) xs=vector<bool>(102);
  int N; cin>>N;
  for(int n=1; n<=N; ++n) {
    int h; cin>>h;
    for(int i=1; i<=h; ++i) xss[xss.size()-i][n]=true;
  }
  bool prev=false; int ans=0;
  for(int h=0; h<xss.size(); ++h) {
    const auto& xs=xss[h];
    for(int n=0; n<xs.size(); ++n) {
      const auto& x=xs[n];
      if(prev && !x) ++ans;
      prev=x;
    }
  }
  cout<< ans <<'\n';
}

Measured memory_bytes: 256
M=10**9+7
n,k,*l=map(int,open(0).read().split())
lp,lm=[],[]
for i in l:
  if i<0: lm+=[i]
  else: lp+=[i]
cp,cm=len(lp),len(lm)
ok=0
if cp:
  if n==k: ok=1-cm%2
  else: ok=1
else: ok=1-k%2
a=1
if ok<1:
  l.sort(key=lambda x:abs(x))
  for i in range(k): a=a*l[i]%M
else:
  lp.sort()
  lm.sort(reverse=1)
  if k%2: a=lp.pop()
  p=[]
  while len(lp)>1: p+=[lp.pop()*lp.pop()]
  while len(lm)>1: p+=[lm.pop()*lm.pop()]
  p.sort(reverse=1)
  for i in range(k//2): a=a*p[i]%M
print(a)

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    vector<int> d(N); REP(i, N) cin >> d[i];
    SORT(d);
    int ans = max(d[N / 2] - d[N / 2 - 1], 0);
    cout << ans << "\n";
}


Measured memory_bytes: 3688
#include <stdio.h>
int main()
{
	int temp,i,j,a[10];
	for(i=0;i<10;i++)
		scanf("%d",&a[i]);
	for(j=0;j<3;j++)
		for(i=0;i<9-j;i++)
		{
			if(a[i]>a[i+1])
				{temp=a[i];
				a[i]=a[i+1];
				a[i+1]=temp;}
		}
	for(i=0;i<3;i++)
		printf("%d\n",a[9-i]);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct Edge {
    int to;
    double cost;
};

double solve() {
    double e = 1e-12;
    double xs, ys, xt, yt;
    ll N;
    cin >> xs >> ys >> xt >> yt;
    cin >> N;
    vector<double> X(N+2), Y(N+2), R(N+2), dst(N+2, 1e14);
    for ( int i = 1; i <= N; i++ ) {
        cin >> X[i] >> Y[i] >> R[i];
    }
    X[0] = xs, Y[0] = ys, R[0] = 0;
    X[N+1] = xt, Y[N+1] = yt, R[N+1] = 0;

    auto f_dist = [&](int a, int b) {
        double dx = X[a] - X[b], dy = Y[a] - Y[b];
        return max(0.0, sqrt(dx*dx+dy*dy) - R[a] - R[b]);
    };
    
    vector<vector<Edge>> G(N+2);
    for ( int i = 0; i < N+2; i++ ) {
        for ( int j = i; j < N+2; j++ ) {
            double w = f_dist(i,j);
            G[i].push_back(Edge{j, w});
            if ( i != j ) {
                G[j].push_back(Edge{i, w});
            }
        }
    }

    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> q;
    dst[0] = 0;
    q.push({dst[0], 0});
    while ( !q.empty() ) {
        auto p = q.top();
        q.pop();
        int v = p.second;
        double w = p.first;
        if ( dst[v] < w - e ) continue;
        for ( auto a : G[v]) {
            if ( dst[a.to] > dst[v] + a.cost ) {
                dst[a.to] = dst[v] + a.cost;
                q.push({dst[a.to], a.to});
            }
        }
    }
    return dst[N+1];
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

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

    long long x = 0;
    long long y = 0;
    cin >> x >> y;

    // An = x * 2 ^ (n - 1)より
    // y >= x * 2 ^ (n - 1
    // y / x >= 2 ^ (n - 1)
    // log(y) - log(x) >= n - 1
    // log(y) - log(x) + 1 >= n
    // を満たす最大の整数nを求めれば良さそう
    // だけどなんか計算誤差が出てるのがACできないサンプルが1個だけあるので愚直に解くことにする。。

    // long long n = floor(log2(y) - log2(x) + 1);
    // cout << n << endl;

    long long i = 0;
    while (x <= y)
    {
        x *= 2;
        ++i;
    }

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 764
import Control.Applicative
import Data.List

main = do
 list <- map read . words <$> getLine
 print $ solve list

solve :: [Int] -> Int
solve list = f (a,b,c)
    where [a,b,c] = sort list

f :: (Int,Int,Int) -> Int
f (a,b,c) = g (c-a) (c-b) 

g :: Int -> Int -> Int
g a b = ra + rb + (h' ma mb)
    where (ra,ma) = h a 2
          (rb,mb) = h b 2

h' 0 0 = 0
h' 0 1 = 2
h' 1 0 = 2
h' 1 1 = 1

h x y = (div x y, mod x y)


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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a = 0, b = 0, c = 0, k = 0;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    while(a > 0 && k > 0) {
        k--;
        a--;
        ans++;
    }
    while(b > 0 && k > 0) {
        k--;
        b--;
    }
    while(c > 0 && k > 0) {
        k--;
        c--;
        ans--;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;

#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;




signed main() {
	ll N; cin >> N;
	ll res = 0LL;


	if(N%2 == 0 && N >= 10){
		ll digit = 10;

		while(digit <= N){
			res += (ll) N / digit;
			digit *= 5;
		}
	}



	cout << res << endl;

}

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

using namespace std;

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

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

    rep(i,n)rep(j,m)cin >> a[i][j];
    rep(i,m)cin >> b[i];

    rep(i,n){
        int c_i = 0;
        rep(j,m)c_i += a[i][j]*b[j];
        cout << c_i << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3208
#include<cstdio>
using namespace std;
int main(){
    long long int n, m;
    scanf("%lld%lld",&n, &m);
    if(n > m){
        n ^= m ^= n ^= m;
    }
    if(n == 1){
        if(m == 1){
            printf("1");
            return 0;
        }
        printf("%lld", m*n - 2);
        return 0;
    }
    printf("%lld", n*m - (n*2+2*m - 4));
}

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

const int N = 300054;

int n, a[N];
bool diff[N];

int main() {
	int i, j, lower, upper;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", a + i), diff[i] = a[i] != i;
	for (i = 2; i < n && !(diff[i - 1] && diff[i] && diff[i + 1]); ++i);
	if (i < n) return puts("No"), 0;
	for (j = i = 1; i <= n; i = j) {
		for (; j <= n && (diff[i] ^ diff[j] ^ i ^ j ^ 1) & 1; ++j);
		if ((i += !diff[i]) == j) continue;
		for (lower = upper = i; i < j; i += 2)
			if (a[i] < i) lower = (a[i] >= lower ? a[i] : INT_MAX);
			else upper = (a[i] >= upper ? a[i] : INT_MAX);
		if (lower >= j || upper >= j) return puts("No"), 0;
	}
	return puts("Yes"), 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
#define int long long
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}

signed main()
{
	fastio;
	int n, a, b;
	cin >> n >> a >> b;
	cout << (n / (a + b))*a + min(a, n % (a + b)) << endl;

}



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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];

    int ans = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans += (list[i] * list[j]);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
//MIPT Cryptozoology 17.2
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
    //assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
    //freopen(FILENAME ".in", "r", stdin);
    //freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        //cerr << testNum << endl;
        solve(true);
        //cerr << testNum - 1 << endl;
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

//#define int li
//const int mod = 1000000007;

void solve(bool read) {
    int n, a, b;
    cin >> n >> a >> b;
    int d = b - a;
    if (d % 2 == 0) {
        cout << "Alice\n";
    } else {
        cout << "Borys\n";
    }
}

Measured memory_bytes: 256
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*3]*n
dp[0] = abc[0]
for i in list(range(n))[1:]:
    p_dp = dp[i-1][:]
    dp[i][0] = max(p_dp[1:]) + abc[i][0]
    dp[i][1] = max(p_dp[::2]) + abc[i][1]
    dp[i][2] = max(p_dp[:2]) + abc[i][2]
print(max(dp[n-1]))

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

int main(){
	int N,K;
	cin >> N >> K;
	string S;
	cin >> S;
	
	int happy = 0;
	
	rep(i,N-1){
		if(S[i] == S[i+1]) happy++;
	}
	
	happy = min(happy+2*K, N-1);
	
	cout << happy << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i=0; i<n; ++i) cin >> v[i];
    map<int, int> even, odd; // 0-indexed
    int even_n = 0, odd_n = 0;
    for (int i=0; i<n; ++i) {
        if (i%2 == 0) {
            even_n++;
            even[v[i]]++;
        } else {
            odd_n++;
            odd[v[i]]++;
        }
    }
    pair<int, int> Me, Mo, Se, So; // index, num
    Me = make_pair(-1, 0);
    Mo = Se = So = Me;
    for (auto i: even) {
        if (Me.second < i.second) {
            Se = Me;
            Me = i;
        }
        else if (Se.second < i.second) {
            Se = i;
        }
    }
    for (auto i: odd) {
        if (Mo.second < i.second) {
            So = Mo;
            Mo = i;
        }
        else if (So.second < i.second) {
            So = i;
        }
    }
    int ans = 0;
    if (Me.first == Mo.first) {
        if (even_n - Se.second < odd_n - So.second) {
            ans = (even_n - Se.second) + (odd_n - Mo.second);
        }
        else {
            ans = (even_n - Me.second) + (odd_n - So.second);
        }
    }
    else ans = (even_n - Me.second) + (odd_n - Mo.second);
    cout << ans << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
const int N=200005;
int i,n,dp[200005][55],p[N],k,T,ans,j;
struct str{
	int a,b;
}a[N];
bool cmp(str a,str b)
{
	return 1ll*(a.b+1)*b.a<1ll*(b.b+1)*a.a;
}
int main()
{
	scanf("%d %d",&n,&T);
	for(i=1;i<=n;++i)
	{
		scanf("%d %d",&a[i].a,&a[i].b);
		if(a[i].a==0)
		{
			p[++k]=a[i].b;
			--i,--n;
		}
	}
	sort(a+1,a+1+n,cmp);
	for(j=1;j<=50;++j)
		dp[0][j]=T+1;
	for(i=1;i<=n;++i)
	{
		for(j=1;j<40;++j)
			dp[i][j]=min(1ll*dp[i-1][j],dp[i-1][j-1]+1+1ll*(dp[i-1][j-1]+1)*a[i].a+a[i].b);//printf("%lld ",dp[i][j]);
//		printf("\n");
	}
	sort(p+1,p+1+k);
	for(i=0;i<=30;++i)
	{
//		printf("%lld ",dp[n][i]);
		if(dp[n][i]<=T)
		{
			long long s=0;
			for(j=1;j<=k;++j)
			{
				s+=p[j]+1;
				if(dp[n][i]+s>T)
					break;
			}
			ans=max(ans,j-1+i);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 45056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int h,w,n,a,c[110][110]={},b[10010],s=0;
  cin>>h>>w>>n;
  Fr(j,n){
    cin>>a;
    fr(i,a) b[s+i]=j;
    s+=a;
  }
  fr(i,h){
    if(i%2) fr(j,w) c[i][j]=b[(i+1)*w-j-1];
    else fr(j,w) c[i][j]=b[i*w+j];
  }
  fr(i,h){
    fr(j,w) cout<<c[i][j]<<" ";
    cout<<endl;
  }
}

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

int main() {
int64_t N,A,B;
  cin >> N >> A >> B;
  int64_t warizan, amari;
  if(A == 0){
     cout << 0 << endl;
  }
  else {
  warizan = N/(A+B);
  amari = N%(A+B);
  if(amari >= A){
  	cout << A*warizan + A << endl;
  }
  else cout << A*warizan + amari << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, A, B;
  cin >> N >> M;
  vector<pair<int,int>> list(N);
   for (int i = 0; i < N; i++) {
    cin >> A >> B;
    list[i] = make_pair(A, B);
  }
  
  sort(list.begin(), list.end());
  
  long cost = 0;
  int drink = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < list[i].second; j++) {
      if (drink < M) {
         drink++;
         cost += list[i].first;
      }if (drink >= M) {break;}
    }if (drink >= M) {break;}
  }
  
  cout << cost << endl;
}

Measured memory_bytes: 1024
import re


def actual(a, b, s):
    pattern = r'\d{' + f'{a}' + r'}-\d{' + f'{b}' + '}'
    
    if re.fullmatch(pattern, s):
        return 'Yes'

    return 'No'

a, b = map(int, input().split())
s = input()

print(actual(a, b, s))

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int a[3][3];

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}

	int n; cin >> n;

	vector <int> b(n);

	for(int i = 0; i < n; i++){
		cin >> b[i];
		for(int r = 0; r < 3; r++){
			for(int c = 0; c < 3; c++){
				if(a[r][c] == b[i]){
					a[r][c] = -1;
				}
			}
		}
	}

	bool ans = false;

	for(int i = 0; i < 3; i++){
		bool bin = true;
		for(int j = 0; j < 3; j++){
			if(a[i][j] != -1) bin = false;
		}
		ans |= bin;
	}

	for(int i = 0; i < 3; i++){
		bool bin = true;
		for(int j = 0; j < 3; j++){
			if(a[j][i] != -1) bin = false;
		}
		ans |= bin;
	}

	ans |= (a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1);
	ans |= (a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1);

	cout << (ans ? "Yes" : "No") << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main( ){

  int a,b,d,r;
scanf("%d %d",&a,&b);
 double f;
 d=a/b;
 r=a%b;
 f=1.0*a/b;
 printf("%d %d %.5lf\n",d,r,f);
return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int a, b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int cost[10][10];
int a[210][210];

int main()
{
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < 10; ++i)
  {
    for (int j = 0; j < 10; ++j)
    {
      cin >> cost[i][j];
    }
  }
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      cin >> a[i][j];
    }
  }

  for (int k = 0; k < 10; ++k)
  {
    for (int i = 0; i < 10; ++i)
    {
      for (int j = 0; j < 10; ++j)
      {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  ll sum = 0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      if (a[i][j] >= 0)
        sum += cost[a[i][j]][1];
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 384
// ABC100 B - Ringo's Favorite Numbers.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

lolo myPow(lolo x, lolo n, lolo m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

int main()
{
	lolo D, N;
	cin >> D >> N;
	lolo cnt = 0;
	lolo ans;

	FOR(i, 200) {
		if (i % 100 == 0) continue;
		cnt += 1;
		if (cnt == N) {
			ans = i;
			break;
		}
	}

	cout << ans * myPow(100, D, 1000000000) << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve1(N, K, heights):
    heights += [INF] * K
    costs = [INF] * (N + K)
    costs[0] = 0
    for i in range(N - 1):
        for k in range(1, K + 1):
            newcost = costs[i] + abs(heights[i + k] - heights[i])
            if newcost < costs[i + k]:
                costs[i + k] = newcost
    return costs[N - 1]


def solve2(N, K, heights):
    costs = [0] * N
    costs[0] = 0
    for i in range(1, N):
        costs[i] = min(
            costs[j] + abs(heights[i] - heights[j])
            for j in range(max(i - K, 0), i)
        )

    return costs[-1]


def solve(N, K, heights):
    costs = [None] * N
    costs[0] = 0

    def get_cost(i):
        if costs[i] != None:
            return costs[i]

        c = min(
            get_cost(j) + abs(heights[i] - heights[j])
            for j in range(max(i - K, 0), i)
        )
        costs[i] = c
        return c

    return get_cost(N - 1)


def main():
    N, K = map(int, input().split())
    heights = list(map(int, input().split()))
    print(solve(N, K, heights))


def _test():
    """
    >>> solve(5, 3, [10, 30, 40, 50, 20])
    30
    >>> solve(3, 1, [10, 20, 10])
    20
    >>> solve(2, 100, [10, 10])
    0
    >>> solve(10, 4, [40, 10, 20, 70, 80, 10, 20, 70, 80, 60])
    40
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 344800
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Mon Feb  4 12:11:39 2019
//
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	ans := 0
	for b := 1; b <= N; b++ {
		if b-1 < K {
			continue
		}
		num := (b - 1) - K + 1
		ans += (N / b) * num

		rem := (N % b) - K + 1
		if rem > 0 {
			ans += rem
		}
	}

	if K == 0 {
		ans -= N
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            WriteLine(s.Substring(0, 3));
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 25880
import java.util.*;

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

		int r = sc.nextInt();
		int c = sc.nextInt();
		int tblData[][] = new int[c+1][r+1];
		
		//???????????\???
		for(int i = 0; i < r; i++) {
			for(int j = 0; j < c; j++) {
				tblData[j][i] = sc.nextInt();
			}
		}
		
		//????????????????¨?
		for(int i = 0; i < r; i++) {
			for(int j = 0; j < c; j++) {
				tblData[c][i] = tblData[c][i] + tblData[j][i];
			}
		}
		
		//????????????????¨?
		for(int j = 0; j < c; j++) {
			for(int i = 0; i < r; i++) {
				tblData[j][r] = tblData[j][r] + tblData[j][i];
			}
		}
		
		//???????¨?
		for(int i = 0; i < r; i++) {
			tblData[c][r] = tblData[c][r] + tblData[c][i];
		}
		
		for(int i = 0; i < r + 1; i++) {
			for(int j = 0; j < c + 1; j++) {
				if(j != c) {
					System.out.printf("%d ", tblData[j][i]);
				} else if(j == c) {
					System.out.printf("%d", tblData[j][i]);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 51680
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 200 + 5, INF = 1e9;
int h,w, c[10][10], a[N][N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>h>>w;
    
    for (int i = 0; i <= 9; i++)
        for (int j = 0; j <= 9; j++)
            cin>>c[i][j];
    

    
    
    for(int k = 0; k < 10; k++)
        for(int i = 0; i < 10; i++)
            for(int j = 0; j < 10; j++)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    
    int a;
    long long ans = 0;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++){
            cin>>a;
            if(a!=-1) ans += c[a][1];
        }
    
    cout<<ans<<endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 256
array = STDIN.each_line.map(&:chomp).map(&:to_i)

array.sort!{ |a, b| (a % 10 <=> b % 10) }

newArray = array.reject { |item| item % 10 == 0 }                       
array.each{ |item| if (item % 10 == 0) then
                     newArray.push(item)
                     end
            }

sum = 0
newArray.each_with_index { |i, index|
                        if index == 0 then
                          sum += i
                        else
                          # 下一桁を繰り上げたい
                          sum += ((i % 10) != 0) ? (i / 10) * 10 + 10
                                                 : i
                        end }

puts sum

Measured memory_bytes: 1788