akhauriyash/Code-Regression huggingface dataset:
def main():
    A, B = (int(i) for i in input().split())
    grid = [["#" if i < 50 else "."]*100 for i in range(100)]

    for h in range(49):
        if h % 2 == 1:
            continue
        for w in range(0, 100, 2):
            if A > 1:
                grid[h][w] = "."
                A -= 1
            else:
                break
    for h in range(51, 100):
        if h % 2 == 0:
            continue
        for w in range(0, 100, 2):
            if B > 1:
                grid[h][w] = "#"
                B -= 1
            else:
                break
    print(100, 100)
    for r in grid:
        print("".join(r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#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 rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

ll x[55];
ll y[55];
ll dp[55][5050];

int main () {
  ll n, a;
  cin >> n >> a;
  rep(i,n) cin >> x[i];
  ll X = *max_element(x,x+n);
  rep(i,n) y[i] = x[i] - a;
  
  dp[0][n*X] = 1;
  rep(i,n+1) {
    rep(j,2*n*X+1) {
      if (dp[i][j] == 0) continue;
      dp[i+1][j] += dp[i][j];
      dp[i+1][j+y[i]] += dp[i][j];
    }
  }

  ll ans = dp[n][n*X] - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
//	Mohib Manva
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long
 
ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}
 
int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n,m;
		scanf("%d %d",&n,&m);
		static char mat[105][105];
		for(int i=0;i<n;i++){
			scanf("%s",mat[i]);
		}		
		static int cnt[26];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cnt[mat[i][j] - 'a']++;
			}
		}
		static int dp[4];
		for(int i=0;i<26;i++){
			if(cnt[i] % 4 == 0){
				continue;
			}
			dp[cnt[i]%4]++;
		}
		dp[1] += dp[3];
		dp[2] += dp[3];
        int u  = 0;
		if(dp[1] > 0){
			if(dp[1] == 1 && n % 2 && m % 2){
                u++;
			} else {
				puts("No");
				return 0;
			}
		}
		if(dp[2] > 0){
			int atmax = 0;
			if(n%2){
				atmax += m;
			}
			if(m%2){
				atmax += n;
			}
			if(n%2 && m%2)
				atmax -= 1;
			atmax -= u;
			//printf("Mohib:%d\n",atmax);
			if(dp[2] <= atmax/2){
			} else {
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char S[4];
  char temp;
  int flag=0;
  scanf("%s",S);
  temp=S[0];
  for(int i=1;i<=3;i++){
  	if(temp==S[i])
      flag=1;
    temp=S[i];
  }
  if(flag)printf("Bad\n");
   else printf("Good\n");
    
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
#include <cmath>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    long n, k, res, tmp;
    
    cin >> n >> k;
    
    res = n % k;
    tmp = k - res;
    
    if(tmp < 0)
        tmp *= -1;
    
    if(res < tmp)
        cout << res << endl;
    else
        cout << tmp << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans += sqrt(((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
        }
    }
    printf("%.7lf",ans/n*2);
}

Measured memory_bytes: 256
from collections import defaultdict
N, M, *L = map(int, open(0).read().split())
dic = defaultdict(list)
rdic = defaultdict(list)
nin = [0]*N
Els = []
for a,b,c in zip(*[iter(L)]*3):
  dic[a-1] += [b-1]
  rdic[b-1] += [a-1]
  nin[b-1] += 1
  Els += [(a-1,b-1,-c)]

To = [False]*N
From = [False]*N
q = [0]
To[0] = True
while q:
  p = q.pop()
  for e in dic[p]:
    if To[e]==False:
      To[e] = True
      q += [e]
q = [N-1]
From[N-1] = True
while q:
  p = q.pop()
  for e in rdic[p]:
    if From[e]==False:
      From[e] = True
      q += [e]

ok = [False]*N
for i  in range(N):
  ok[i] = To[i]&From[i]

cnt = 0
dist = [float('inf')]*N
dist[0] = 0
cnt = 0
flag = False
while True:
  update = True
  for a,b,c in Els:
    if not(ok[a] and ok[b]):
      continue
    if dist[a]!=float('inf') and dist[b]>dist[a]+c:
      dist[b] = dist[a]+c
      update = False
  if update:
    break
  cnt += 1
  if cnt>2*N:
    flag = True
    break

if flag:
  print('inf')
elif dist[N-1]==float('inf'):
  print('inf')
else:
  print(-dist[N-1])

Measured memory_bytes: 44892
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

#define rep(n) for(int i = 0; i < n; i++)

string s = "";
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> n;
	cout << n / 3 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    string S;
    cin >> S;
    
    int min = 999;
    for (int i = 0; i < S.length() - 2; i++) {
        string sum = S.substr(i, 3);
        int num = stoi(sum);
        if (abs(num - 753) < min) {
            min = abs(num - 753);
        }
    }
    cout << min << endl;
    
    return 0;
}

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

template <typename T> void read_stdin(const size_t size, T& array)
{
   for (size_t i(0); i < size; ++i) {
      cin >> array[i];
   }
}

template <typename T> void output_stdout(const size_t size, const T& array)
{
   for (size_t i(0); i < size; ++i) {
      cout << array[i] << endl;
   }
}

size_t inputA_size;
long long inputA[100];

size_t outputA_size;
string outputA[1];

int main() {
   // read
   {
      cin >> inputA_size;
      read_stdin(inputA_size, inputA);
   }

   // process
   {
      bool is_all(true);
      for (size_t i(0); i < inputA_size; ++i) {
         if (0 == (inputA[i] % 2)) {
            if ((0 != (inputA[i] % 3)) && (0 != (inputA[i] % 5))) {
               is_all = false;
               break;
            }
         }
      }
      if (is_all) {
         outputA[0] = "APPROVED";
      } else {
         outputA[0] = "DENIED";
      }
   }

   // output
   {
      outputA_size = 1;
      output_stdout(outputA_size, outputA);
   }
   
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    char ch[19];
    cin>>ch;
    if(ch[5]==',')
        ch[5]=' ';
    if (ch[13]==',')
        ch[13]=' ';
    cout<<ch<<endl;

    return 0;
}


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

int main() {
  int K,S;
  cin >> K >> S;
  
  int cnt=0,z=0;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      z = S-x-y;  
        if(0<=z && z<=K){
          cnt ++;
      }
    }
  }
  
  cout << cnt << endl;
  return 0;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

vector<int>par; // ツリーの種類
vector<int>fac; // ツリーの大きさ
vector<int>ran; // どちらのツリーを優先させるか？

int find(int x) { // xが含まれているツリー
	if (par[x] == x) {
		return x;
	}
	return find(par[x]);
}

void unit (int x, int y) { // ツリーの所属を決めるメソッド
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
		fac[y] += fac[x]; // ツリーの大きさを更新
	}
	else {
		par[y] = x; // xとyが一致してなければ
		fac[x] += fac[y]; // ツリーの大きさを更新
	}
	if (ran[x] == ran[y])ran[x]++;
}

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

	rep(i, n) {
		par.push_back(i);
		fac.push_back(1);
		ran.push_back(1);
	}

	// 友達関係
	vector<vector<int>>dt(n); //直接の友達の数
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		unit(a, b);
		dt[a].push_back(b);
		dt[b].push_back(a);
	}

	// ブロック関係
	vector<int>ans(n,0);
	rep(i, k) {
		int c, d;
		cin >> c >> d;
		--c;
		--d;
		if (find(c) == find(d)) { // 同じツリーに含まれているなら答えを減らす
			ans[c]--;
			ans[d]--;
		}
	}

  // pr("dt");
  // rep(i,n) {
  //   cout << i << " ";
  //   for(int d:dt[i]) {
  //     cout << d << " ";
  //   }
  //   cout << endl;
  // }

  // pr("par","fac","ran");
  // rep(i,n) {
  //   pr(par[i],fac[i],ran[i]);
  // }

  // pr("===");

	rep(i, n) {
		int tmp = find(i);
		ans[i] += fac[tmp] - dt[i].size()-1;
		cout << ans[i] << " ";
    // pr(ans[i],tmp,fac[tmp],dt[i].size());
	}
  cout << endl;
	return 0;
}


Measured memory_bytes: 8300
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

ll gcd(ll a, ll b) {
    if(a % b == 0) return b;
    else return(gcd(b, a % b));
}

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    rep(i, n) {
        ll t;
        cin >> t;
        ll x = gcd(t, ans);
        ans = ans / x * t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    960 Hours of Solitude
    Quarantine_Day : 40
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

bool pal(ll n){
    ll temp = n, k = 0;
    while(temp){
        k = k * 10 + temp % 10;
        temp /= 10;
    }
    return k == n;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll a, b;
    cin>>a>>b;
    ll res(0);
    for(ll i = a; i <= b; i++){
        if(pal(i)) res++;
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
int d[305][305];
int d2[305][305];
vector<vector<int>>adj;
 main() {
	int n, m, l;
	cin>>n>>m>>l;
	adj.resize(n+1);
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			d[i][j]=1e18;
			if(i==j){
				d[i][j]=0;
			}
		}
	}
	for(int i=0; i<m; i++){
		int u, v, w;
		cin>>u>>v>>w;
		d[u][v]=w;
		d[v][u]=w;
	}
	for(int k=1; k<=n; k++){
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			if(i==j){
				continue;
			}
			if(d[i][j]<=l){
				adj[i].pb(j);
			}
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=0; j<=n; j++){
			d2[i][j]=1000;
			if(i==j){
				d2[i][j]=0;
			}
		}
	}
	for(int i=1; i<=n; i++){
		for(auto u:adj[i]){
			d2[i][u]=1;
		}
	}
	for(int k=1; k<=n; k++){
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				d2[i][j]=min(d2[i][j], d2[i][k]+d2[k][j]);
			}
		}
	}
	int q;
	cin>>q;
	while(q--){
		int u, v;
		cin>>u>>v;
		if(d2[u][v]==1000){
			cout<<-1<<endl;
			continue;
		}
		else{
			cout<<d2[u][v]-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6156
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int w,a,b;
    cin>>w>>a>>b;
    int x=min(a,b);
    int y=max(a,b);
    if(x+w<y)cout<<y-(x+w)<<endl;
    else cout<<0<<endl;
}

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

int main () {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int solve(){
	int n, q, cnt = 0;
	cin >> n;
	vector<int> S(n);
	for (int i = 0; i < n; i++) cin >> S[i];
	cin >> q;
	vector<int> T(q);
	for (int i = 0; i < q; i++) cin >> T[i];
	sort(S.begin(), S.end());
	for (int i = 0; i < q; i++) {
		if (binary_search(S.begin(), S.end(), T[i])) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

signed main(){
	solve();
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, 0, n){
        cin >> h[i];
    }
    int ans = 0;
    while(1){
        bool f = false;
        rep(i, 0, n) if(h[i] != 0) f = true;
        if(!f) break;
        int MAX = *max_element(h.begin(), h.end());
        rep(i, 0, n){
            if(h[i] == MAX){
                h[i]--;
                rep(j, i + 1, n){
                    if(h[j] == MAX){
                        h[j]--;
                    }else{
                        break;
                    }
                }
                break;
            }
        }
        ans++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
#define MOD 1000000007
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

struct ll2 {
  ll a,b;
};

ll N;
vector<ll> hi;
vector<ll> ai;
vector<ll2> li;
vector<ll> dp;

int input(){
  cin >> N;
  REP(i,N) hi.push_back( inp<ll>() );
  REP(i,N) ai.push_back( inp<ll>() );
}

template<class T> class bit {
  public:
    vector<T> dat;
    int N;
    bit(){}
    bit(int N) : N(N) { dat.assign(N,0); }
    // sum [0,i)
    T sum(int i){
        T ret = 0;
        for(--i; i>=0; i=(i&(i+1))-1) ret += dat[i];
        return ret;
    }
    // add x to i
    void add(int i, T x) { for(; i < N; i|=i+1) dat[i] += x; }
};

template<class T> class segtree {
 public:
    int N;
    vector<T> dat;
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2; 
        for(int i = 0; i < 2*N-1; i++) dat.push_back(0);
    }
    // update k th element
    void update(int k, T a) {
        k += N-1; // leaf
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    T query(int a, int b) { return query(a, b, 0, 0, N); }
    T query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return max(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

int main()
{
  input();
  REP(i,N) li.push_back( (struct ll2){i,hi[i]} ); 
  sort(ALL(li),[](const ll2 &l, const ll2 &r) {return l.b < r.b;});
  auto seg = segtree<ll>(N);
  REP(i,N) dp.push_back(0);
  REP(i,N) {
    ll ind = li[i].a; 
    //seg.update(ind,ai[ind]);
    //cout << "*" << seg.query(0,ind) << "," << ai[ind] << endl;
    dp[ind] = seg.query(0,ind)+ai[ind];
    //REP(j,N+1) cout << seg.query(0,j) << "," ;
    //cout << endl;
    seg.update(ind,dp[ind]);
    //cout << ind << "," << dp[ind] << endl;
  }
  ll ma = 0l;
  REP(i,N) ma = max(ma,dp[i]);
  cout << ma << endl;
  
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 211111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[N] ;

int main() {
  int n ;
  ll sum = 0LL ;
  cin >> n ;
  for(int i = 0 ;i<n ;i++){
    cin >> a[i] ;
    a[i]-=(i+1) ;
  }

  sort(a,a+n) ;
  if(n&1){
    int median = a[n>>1] ;
    ll sum = 0LL ;
    for(int i = 0 ;i<n ;i++)
      sum+=abs(a[i]-median) ;
    cout << sum <<endl ;
  }
  else{
    int median_first = a[n/2 -1] ;
    int median_second = a[n/2] ;
    ll sum_first = 0LL, sum_second = 0LL ;
    for(int i = 0 ;i<n ;i++){
      sum_first+=abs(a[i]-median_first) ;
      sum_second+=abs(a[i] - median_second) ;
    }
    cout << min(sum_second, sum_first) << endl ;
  }
    
  return 0 ;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()

{

int n,max=-1,sum=0,p,i,j;
int m[1000];

scanf("%d ",&n);

for(i=0;i<n;i++)
{
scanf("%d",&m[i]);
}
for(i=0;i<n;i++)
{
if(m[i]>max)
{
max=m[i];
}
}


for(j=0;j<n;j++)

{
sum=sum+m[j];

}


 p=sum-max;

if(p>max)
{
printf("Yes\n") ;
}
else
printf("No\n");


return 0;
}   

Measured memory_bytes: 1660
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream ps = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        ps.println(f(n-1, k-1));
    }
    
    static int f(int a, int b) {
        return (a + b - 1) / b;
    }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
  if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

map<vector<int>, int> mp;

void bfs(vector<int> v) {
  queue<vector<int>> que;
  que.push(v);
  mp[v] = 0;

  while (que.size()) {
    vector<int> t = que.front(); que.pop();

    // 0の位置を求める
    int zeroPos = 0;
    for (int i = 0; i < t.size(); i++) {
      if (t[i] == 0) zeroPos = i;
    }

    int y = zeroPos / 4, x = zeroPos % 4;
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;
      vector<int> tt = t;
      int pos = y * 4 + x, npos = ny * 4 + nx;
      swap(tt[pos], tt[npos]);
      if (mp.count(tt)) continue;
      mp[tt] = mp[t] + 1;
      que.push(tt);
    }
  }
}

signed main() {
  vector<int> first(8);
  iota(all(first), 0);
  bfs(first);

  string s;
  while (getline(cin, s)) {
    vector<int> v;
    for (int i = 0; i < s.size(); i+=2) {
      v.push_back(s[i] - '0');
    }
    cout << mp[v] << endl;
  }

  return 0;
}


Measured memory_bytes: 6172
import java.util.*;
import java.io.*;
public class Main  {
    public static void main(String args[]) {
      FastScanner fs=new FastScanner();    
      PrintWriter out=new PrintWriter(System.out);
      
      double d=fs.nextDouble();
      double t=fs.nextDouble();
      double s=fs.nextDouble();
      double tt=d/s;
      if(tt<=t)
      out.println("Yes");
      else
      out.println("No");
        
        out.flush();
        out.close();
    }
	static void ruffleSort(int[] a) {
 		Random random=new Random();
		int n=a.length;
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
}
        class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
				st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		String nextLine(){
		    String str="";
		    try{
		        str=br.readLine();
		    }catch(IOException e){
		        e.printStackTrace(); }
		    return str;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		double nextDouble(){
		    return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

Measured memory_bytes: 32936
#include <stdio.h>
#include <algorithm>
#define N 100001
using namespace std;

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

int a[N];

int main()
{		
	int n, i, l[2] = {0}, j = 0, t = 0;
	
	n = read();
	for(i = 0; i < n; i++) a[i] = read();
	make_heap(a, a + n);
	for(i = n - 1; i >= 0; i--){
		pop_heap(a, a + i + 1);
		if(!t) t = a[i];
		else{
			if(a[i] == t){
				l[j++] = t;
				t = 0;
				if(j == 2) break;
			}
			else t = a[i];
		}
	}
	printf("%lld\n", (long long)l[0] * (long long)l[1]);	
			
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;




int main(){

    uint64_t X;
    uint64_t temp =100;

    int count;

    cin>> X;

    for(count=0;temp <X;count++){
        temp += 0.01 * temp;
    }

    cout<<count<<std::endl;

}



Measured memory_bytes: 3596
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

ll mod_pow(ll a,ll x){
    ll ans=1;
    for(int i=0;i<63;i++){
        if(x>>i&1){ans*=a; ans%=MOD;}
        a*=a;
        a%=MOD;
    }
    return ans;
}

ll R(ll a){
    return mod_pow(a,MOD-2);
}

ll factorial(ll n){
    ll ret=1;
    for(int i=2;i<=n;i++){
        ret*=i%MOD;
        ret%=MOD;
    }
    return ret;
}

ll c(ll n,ll k){
    return factorial(n)*R(factorial(n-k))%MOD*R(factorial(k))%MOD;
}

ll gcd(ll a,ll b){
    if(a%b==0){return b;}
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

bool prime(ll p){
    for(int i=2;i*i<=p;i++){
        if(p%i==0){return false;}
    }
    return true;
}

vector<ll> mk_prime(ll mx){
    vector<ll> p={2};
    for(int i=3;i<=mx;i++){
        bool j=true;
        for(int t=0;p[t]*p[t]<=i;t++){
            if(i%p[t]==0){j=false; break;}
        }
        if(j){p.push_back(i);}
    }
    return p;
}

vector<vector<ll>> C;

vector<vector<ll>> mk_c(){
    ll mx=1000;
    vector<vector<ll>> c(mx+1,vector<ll>(mx+1,0));
    for(ll i=0;i<=mx;i++){
        c[i][i]=1;
        c[i][0]=1;
        for(ll t=1;t<i;t++){
            c[i][t]=c[i-1][t-1]+c[i-1][t];
            c[i][t]%=MOD;
        }
    }
    return c;
}

vector<ll> F={0};

ll Stirling(ll n,ll k){
    ll ret=0;
    for(ll i=1;i<=k;i++){
        if((k-i)%2){ret-=C[k][i]*mod_pow(i,n)%MOD;}
        else{ret+=C[k][i]*mod_pow(i,n)%MOD;}
        ret%=MOD;
    }
    ret*=R(F[k]);
    ret%=MOD;
    if(ret<0){ret+=MOD;}
    return ret;
}

ll Bell(ll n,ll k){
    ll ret=0;
    for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=MOD;}
    return ret;
}



int main(){
    ll n,k;
    cin>>n>>k;
    C=mk_c();
    ll p=1;
    for(ll i=1;i<1500;i++){
        p*=i; p%=MOD;
        F.push_back(p);
    }
    cout<<Bell(n,k)<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 10824
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	FOR(i,1,n+1){
		bool x = false;
		for(auto c:to_string(i)){
			x |= (c=='3');
		}
		if(i%3==0 || x){
			cout << ' ' << i;
		}
	}
	cout << endl;
}



Measured memory_bytes: 3304
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		int a = 0;
		int b = 0;
		int ab = 0;
		int contain = 0;
		for (int i = 0; i < n; i++) {
			if (s[i].charAt(0) == 'B' && s[i].charAt(s[i].length() - 1) == 'A') {
				ab++;
			}
			if (s[i].charAt(0) == 'B') {
				b++;
			}
			if (s[i].charAt(s[i].length() - 1) == 'A') {
				a++;
			}
			while (s[i].indexOf("AB") != -1) {
				contain++;
				s[i] = s[i].substring(s[i].indexOf("AB") + 2);
			}
		}
		if (a == b && ab == a && ab != 0) {
			System.out.println(contain + ab - 1);
		} else {
			System.out.println(contain + Math.min(a, b));
		}
	}
}

Measured memory_bytes: 31220
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int inf=1e8;
	typedef pair<int,int> P;
	int sum[11][1009],n,m,K;
	P st[11];int top;
	inline int get(int x1,int x2,int y1,int y2){
		return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
	}
	int main(){
		n=read<int>(),m=read<int>(),K=read<int>();
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++){
				char c;cin>>c;
				sum[i][j]=c-'0';
			}
		int ret=inf;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++) 
				sum[i][j]+=sum[i][j-1];
		for(int j=1;j<=m;j++)
			for(int i=1;i<=n;i++)
				sum[i][j]+=sum[i-1][j];

		for(int i=0;i<(1<<(n-1));i++){
			int las=1,now=1;top=0;
			for(int j=0;j<n-1;j++)
				if(i>>j&1) st[++top]=P(las,now),now=las=now+1;
				else now++;
			if(now<=n) st[++top]=P(las,now);

			las=0;int ans=top-1;
			for(int j=1;j<=m;j++){
				for(int k=1;k<=top;k++){
				//	cout<<st[k].first<<" "<<st[k].second<<" "<<las+1<<" "<<j<<endl;
				//	cout<<get(st[k].first,st[k].second,las+1,j)<<endl;
					if(get(st[k].first,st[k].second,las+1,j)>K){
						if(las+1==j) ans=inf;
						else las=j-1,ans++,j--;
						break;
					}
				}
			}

			ret=min(ret,ans);

		//	cout<<i<<" "<<top<<endl;
		//	for(int j=1;j<=top;j++)
		//		cout<<st[j].first<<" "<<st[j].second<<endl;
		//	cout<<ans<<endl;
		}
		printf("%d\n",ret);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int ans = 1001001001;
  for(int i = 1; i <= 100; ++i){
    int tmp = 0;
    for(auto e:v) tmp += pow(e - i , 2);
    ChangeMin(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> B[i];

    vector<bool> selected(N, false);
    vector<int> ans;

    while (ans.size() < N) {
        bool found = false;

        for (int i = N - 1; i >= 0; i--) {
            if (selected[i]) continue;

            int val = B[i];

            int less_num = 0;
            for (int j = i - 1; j >= 0; j--) if (selected[j] && B[j] < val) less_num++;

            if (val - 1 == less_num) {
                selected[i] = true;
                ans.push_back(B[i]);
                found = true;
                break;
            } else {
                continue;
            }
        }

        if (!found) {
            cout << -1 << endl;
            return 0;
        }
    }

    for (int a : ans) {
        cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m,x = list(map(int,input().split()))

cList = []

for i in range(n):
    cList.append(list(map(int,input().split())))

priceList = []
for i in range(1,2**n):
    price = 0
    check = 1
    skilList = [0 for  i in range(m)]
    bit = i
    for j in range(1,n+1):
        if bit % 2 == 1:
            price += cList[j-1][0]
            for k in range(m):
                skilList[k] = skilList[k] + cList[j-1][k+1]
        bit = bit // 2
    for j in skilList:
        if j < x:
            check = 0
            break
    if check == 1:
        priceList.append(price)

if len(priceList) > 0:
    print(min(priceList))
else:
    print(-1)

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

using namespace std;

#define reps(i, j, n) for(int i = j; i < (int)n; i++)
#define rep(i, n) reps(i, 0, n)


bool used[50];
int ord[50], low[50];
vector< int > g[50];

int dfs(int idx, int &k, int par = -1)
{
  used[idx] = true;
  ord[idx] = k++;
  low[idx] = ord[idx];

  int ret = 0;
  for(auto &to : g[idx]) {
    if(!used[to]) {
      ret += dfs(to, k, idx);
      low[idx] = min(low[idx], low[to]);
    } else if(to != par) {
      low[idx] = min(low[idx], ord[to]);
    }
    if(ord[idx] < low[to]) ++ret;
  }
  return (ret);
}


int main()
{
  int N, M;
  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int k = 0;
  cout << dfs(0, k) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int x[5];
 
int main(){
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  if(x[0] == 0) cout << "1";
  if(x[1] == 0) cout << "2";
  if(x[2] == 0) cout << "3";
  if(x[3] == 0) cout << "4";
  if(x[4] == 0) cout << "5";
}

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

int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    ll n=0;
    for(int i=0;i<=1e6;i++)
    {
      n=(n*10+7)%k;
      if(n==0)
      {cout<<i+1<<endl;return 0;
      } 	
    }
    
    cout<<"-1"<<endl;
    return 0;
    }	

Measured memory_bytes: 3632
H, W, K = map(int, input().split())
mod = 10 ** 9 + 7
dp = [[0 for _ in range(W + 2)] for _ in range(H + 2)]
dp[0][1] = 1

fib = [0] * (W + 1)
fib[1] = 1
for i in range(2, W + 1):
    fib[i] = fib[i - 1] + fib[i - 2]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        dp[i][j] = (dp[i - 1][j - 1] * fib[j - 1] * fib[W - j + 1] +
                    dp[i - 1][j] * fib[j] * fib[W - j + 1] +
                    dp[i - 1][j + 1] * fib[j] * fib[W - j]) % mod
print(dp[H][K])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int, int>
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a * c;

  ll not_zero_flag = (b < 0 && d < 0) || (0 < a && 0 < c) || (b < 0 && 0 < c) ||
                     (0 < a && d < 0);
  chmax(ans, a * c);
  chmax(ans, a * d);
  chmax(ans, b * c);
  chmax(ans, b * d);
  if (!not_zero_flag) chmax(ans, (ll)0);

  cout << ans << endl;
}

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

const int INF = INT_MAX;

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

    int d[n];
    for(int i = 0; i < n; i++)  cin >> d[i];

    int dp[n+1];
    for(int i = 1; i <= n; i++)  dp[i] = INF;
    dp[0] = 0;

    int c;
    for(int i = 0; i < m; i++){
        cin >> c;
        for(int j = n-1; j >= 0; j--){
            if(dp[j] == INF)    continue;
            dp[j+1] = min(dp[j+1], dp[j] + d[j]*c);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


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

int main(void) {
    int n;
    cin >> n;
    vector<int> vec;
    for (int i = 0; i < n; i++) {
        int64_t a;
        cin >> a;
        auto itr = find(vec.begin(), vec.end(), a);
        if (itr == vec.end()) {
            vec.emplace_back(a);
        } else {
            vec.erase(itr);
        }
    }
    cout << vec.size() << "\n";
}


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

#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define take(x,n)           for(int i=0;i<n;i++)  cin>>x[i];

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll, ll> pll;
typedef map< ll, ll> mll;

ll dp[2007];

ll f(ll s) {
	if (s == 0)
		return 1;
	else if (s == 1 || s == 2)
		return 0;
	else if (s >= 3 && s <= 5)
		return 1;

	if (dp[s] != -1)
		return dp[s];

	ll ans = 0;
	for (ll i = 3; i <= s; i++) {
		if (s - i >= 0)
			ans = (ans + f(s - i)) % mod;
	}

	return dp[s] = ans % mod;
}


int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	ll s;
	cin >> s;

	memset(dp, -1, sizeof(dp));

	dp[0] = 1;
	cout << f(s) << nl;


	return 0;
}


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

int main() {
  int K;
  cin >> K;
  int sum =0;
  for(int i;i<K;i+=2) {
    for(int j=1;j<K;j+=2) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int c[4][4];
	int i,j;
	int x,y,z;

	for(i=1;i<4;i++)
		for(j=1;j<4;j++)
			cin >> c[i][j];
	x=c[1][1]+c[2][2]+c[3][3];
	y=c[1][2]+c[2][3]+c[3][1];
	z=c[1][3]+c[2][1]+c[3][2];
	if(x==y && x==z && y==z)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

vector<pair<int,int>> dish(5);

int main() {
    for (int i = 0; i < 5; i++) {
        int temp; cin >> temp;
        dish[i] = make_pair(temp%10, temp);
    }
    sort(dish.begin(), dish.end());
    int ind = upper_bound(dish.begin(), dish.end(), pair<int,int>(0,1e8)) - dish.begin();
    int sum = dish[ind].second;
    for (int i = 0; i < 5; i++) {
        if (i == ind) continue;
        sum += dish[i].second/10*10 + 10*!!(dish[i].first);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	

    string S;
    cin >> S;
    int length = S.length();

    LL pow3mod[length+1];
    pow3mod[0] = 1;
    FOR(i,1,length+1)
    {
        pow3mod[i] = (pow3mod[i-1] * 3) % MOD;
    }
    LL ABC=0,BC=0,C=0;
    int hatena_count = 0;
    for(int i = length - 1; i >= 0; i--)
    {
        if(S[i] == 'A')
        {
            ABC = (ABC + BC) % MOD;
        }
        if(S[i] == 'B')
        {
            BC = (BC + C) % MOD;
        }
        if(S[i] == 'C')
        {
            C = (C + pow3mod[hatena_count]) % MOD;
        }
        if(S[i] == '?')
        {
            ABC = (3 * ABC + BC) % MOD;
            BC = (3 * BC + C) % MOD;
            C = (3 * C + pow3mod[hatena_count]) % MOD;
            hatena_count++;
        }
    }
    cout << ABC << endl;

}


Measured memory_bytes: 1232
opcomb :: [[Char]]
opcomb = sub 3
  where
    sub :: Int -> [[Char]]
    sub 0 = [[]]
    sub n = ['+' : x | x <- sub (n - 1)] ++ ['-' : x | x <- sub (n - 1)]

solve :: [Int] -> String
solve ns = fuse ns ops0
  where
    ops0 :: [Char]
    ops0 = head (filter check opcomb)
    n0 : ns0 = ns
    check :: [Char] -> Bool
    check ops = (check1 n0 ns0 ops) == 7
    check1 :: Int -> [Int] -> [Char] -> Int
    check1 acc [] [] = acc
    check1 acc (n : ns) ('+' : ops) = check1 (acc + n) ns ops
    check1 acc (n : ns) ('-' : ops) = check1 (acc - n) ns ops
    fuse :: [Int] -> [Char] -> String
    fuse (n:ns') (op:ops') = (show n) ++ (op : fuse ns' ops')
    fuse [n] [] = show n ++ "=7"

main :: IO ()
main = do
  cont <- getContents
  let [strQ] = words cont
      ns = map (\c -> read [c]) strQ
  putStrLn (solve ns)


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = new List<int>();
            int min = 999;
            for(int i=0; i < 5; i++)
            {
                int x = int.Parse(Console.ReadLine());
                if ((x%10!=0) && (x % 10 <= min % 10)) min = x;
                L.Add(x);
            }
            int ans = 0;
            bool Once = true;
            for(int i = 0; i < 5; i++)
            {
                if (Once && (L[i] == min))
                {
                    Once = false;
                    ans += L[i];
                }
                else ans += Up(L[i]);
            }
            Console.WriteLine(ans);
        }
        static public int Up(int x)
        {
            while (x % 10 != 0)
            {
                x++;
            }
            return x;
        }
    }
}


Measured memory_bytes: 27744
import sys
input=sys.stdin.readline

h,w = list(map(int, input().split()))
a = [["#"]*(w+2) for i in range(h+2)]

for i in range(h):
    s = input().strip()
    for j in range(w):
        a[i+1][j+1] = s[j]

for i in a:
    s = ""
    for c in i:
        s += c
    print(s)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;

long long a,b,n,maxn,m;

int main(void)
{
    scanf("%lld%lld%lld",&a,&b,&n);
    if(b-1<=n) maxn=a*(b-1)/b-a*((b-1)/b);
    m=a*n/b-a*(n/b);
    maxn=max(maxn,m);
    
    printf("%lld",maxn);
    return 0;
}

Measured memory_bytes: 1736
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	cout<<max({a*c,a*d,b*c,b*d});

}

Measured memory_bytes: 3600
#include <stdio.h>

int chmin(long long *a, long long b) {
    if (*a > b) {
        *a = b;
        return 1;
    }
    return 0;
}

long long abs(long long a) {
    if (a < 0) {
        return -a;
    }
    return a;
}

const long long INF = 1LL << 60;

long long rec(int i, int jump, long long dp[], long long h[]) {

    if (dp[i] < INF) return dp[i];

    if (i == 0) return 0;

    if (i < jump) jump = i;

    long long res = INF;
    for (int k = 1; k <= jump; k++) {
        chmin(&res, rec(i - k, jump, dp, h) + abs(h[i] - h[i - k]));
    }

    return dp[i] = res;
}

// https://qiita.com/drken/items/dc53c683d6de8aeacf5a#%E7%B6%9A%E3%81%8D
// を参考に実装
int main() {

    int num;
    scanf("%d", &num);

    int jump;
    scanf("%d", &jump);

    long long h[num];
    long long dp[num];

    for (int i = 0; i < num; i++) {
        scanf("%lld", &h[i]);
    }

    for (int i = 0; i < num; i++) {
        dp[i] = INF;
    }

    printf("%lld\n", rec(num - 1, jump, dp, h));

    return 0;
}


Measured memory_bytes: 11136
"""
A - Limited Insertion
"""


def solve():
    N = int(input())
    b = list(map(int, input().split()))
    ans = make_list(b, 0, [])

    if ans == -1:
        print(ans)
    else:
        for a in list(reversed(ans)):
            print(a)
        # ans = list(reversed(ans))
        # ans = [str(i) for i in ans]
        # print(' '.join(ans))


def make_list(b: list, x: int, ans: list):
    re = -1
    # print('try {}'.format(x))
    # print(b)

    if len(b) == 0:
        return ans

    if check_list(b) is False:
        return re

    for i, element in enumerate(b, 1):
        if i == element:
            b_c = b.copy()
            ans_c = ans.copy()
            ans_c.append(b_c[i - 1])
            b_c.remove(element)  # 除去対象は自分より前に同じ要素が存在しない
            # print('match element {}'.format(element))
            # print(ans)
            tmp = make_list(b_c, x + 1, ans_c)
            if tmp != -1:
                re = tmp
                break
    # print('return {} is '.format(x), re)
    return re


def check_list(b):
    re = True
    for i, element in enumerate(b, 1):
        if i < element:
            re = False
            break
    return re


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
n = int(input())
lst1 = list(map(int,input().split()))

"""素因数分解"""
def factrize(n):
    b = 2
    fct = []
    while b*b <= n:
        while n % b == 0:
            n //= b
            #もし素因数を重複させたくないならここを加えてfct.append(b)を消す
            """
            if not b in fct:
                fct.append(b)
            """
            fct.append(b)
        b = b+1
        break
    return len(fct) #リストが帰る

ans = 0

for i in lst1:
    if i == 2:
        ans += 1
    else:
        ans += factrize(i)

print(ans)



Measured memory_bytes: 42220
#include<stdio.h>

int bubblesort(int A[], int N)
{
    int flag, j, temp, cnt, i;
    
    cnt=0;
    i=0;
    flag=1;
    
    while(flag ==1)
    {
        flag = 0;
        
        for(j=N-1; j>=i+1; j--)
        {
            if(A[j]<A[j-1])
            {
                temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                cnt++;
            }
            
            flag=1;
        }
        i++;
        
    }
    
    return cnt;
    
}

int main(void)
{
    int N, cnt, i;
    
    scanf("%d", &N);
    
    int A[N];
    
    for(i=0; i<N; i++)
    {
        scanf("%d", &A[i]);
    }
    
   cnt = bubblesort(A, N);
    
    for(i=0; i<N; i++)
    {
        if(i>0)
        {
            printf(" ");
        }
        printf("%d", A[i]);
    }
    
    printf("\n");
    
    printf("%d\n", cnt);
}


Measured memory_bytes: 2028