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

class Main {
	private final static int NUM_QUEENS = 8;
	private static boolean[] row = new boolean[NUM_QUEENS];
	private static boolean[] col = new boolean[NUM_QUEENS];
	private static boolean[] dpos = new boolean[NUM_QUEENS*2-1];
	private static boolean[] dneg = new boolean[NUM_QUEENS*2-1];
	private static boolean[][] fixed = new boolean[NUM_QUEENS][NUM_QUEENS];
	private static boolean[][] board = new boolean[NUM_QUEENS][NUM_QUEENS];
	private static boolean done;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int r, c;

		for (int i = 0; i < k; i++)	{
			r = scanner.nextInt();
			c = scanner.nextInt();

			fixedQueen(r, c);
		}

		if(solve(0)) {
			printBoard();
		} else {
			System.out.println("No solution!");
		}
	}

	private static boolean isQueen(int r, int c) {
		return board[r][c];
	}

	private static boolean isFixed(int r, int c) {
		return fixed[r][c];
	}

	private static boolean putQueen(int r, int c) {
		if(isQueen(r, c))
			return false;

		if(row[r] || col[c] || dpos[r+c] || dneg[r-c+NUM_QUEENS-1])
			return false;

		board[r][c] = true;
		row[r] = col[c] = dpos[r+c] = dneg[r-c+NUM_QUEENS-1] = true;

		return true;
	}

	private static void fixedQueen(int r, int c) {
		putQueen(r, c);
		fixed[r][c] = true;
	}

	private static boolean solve(int i) {
		if(i == NUM_QUEENS)
			return done = true;

		for(int j = 0; j < NUM_QUEENS; j++) {
			if(col[j] || dpos[i+j] || dneg[i-j+NUM_QUEENS-1])
				if(!isQueen(i,j))
					continue;

			if(!isFixed(i,j))
				putQueen(i, j);

			if(solve(i+1))
				return done;

			if(!isFixed(i,j))
				takeQueen(i,j);
		}

		return false;
	}

	private static void takeQueen(int r, int c) {
		if(isQueen(r,c)) {
			board[r][c] = false;
			row[r] = col[c] = dpos[r+c] = dneg[r-c+NUM_QUEENS-1] = false;
		}
	}

	private static void printBoard() {
		StringBuilder s = new StringBuilder();

		for(int i = 0; i < NUM_QUEENS; i++) {
			for(int j = 0; j < NUM_QUEENS; j++) {
				s.append(isQueen(i,j) ? "Q" : ".");
			}
			s.append("\n");
		}

		System.out.print(s);
	}
}


Measured memory_bytes: 26456
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]

    #if isinstance(a, int) == False or isinstance(b, int) == False or a < 0 or 100 < a or b < 2 or 1000 < b or b % 2 != 0:
    #    return

    if 13 <= a and a <= 100:
        print(b)
    elif 6 <= a and a <= 12:
        print(b//2)
    elif 0 <= a and a <= 5:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
from collections import deque

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,m,l):
    g = creategraph(n,l)
    for i in range(1,len(g)):
        if len(g[i]) == 0:
            print("No")
            return
    navi = bfs(n,g)
    if min(navi[2:]) == 0:
        print("No")
    else:
        print("Yes")
        for i in navi[2:]:
            print(i)
    
def bfs(n,g):
    navi = [0]*(n+1)
    navi[1] = -1
    q = deque()
    q.append(1)
    while len(q) > 0:
        cp = q.popleft()
        np = g[cp]
        for i in np:
            if navi[i] == 0:
                navi[i] = cp
                q.append(i)
    return navi
    
def creategraph(n,l):
    g = {i:[] for i in range(n+1)}
    for a,b in l:
        g[a].append(b)
        g[b].append(a)
    return g

def resolve():
    n,m = mi()
    l = mix(m)
    main(n,m,l)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 66196
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
//kadai3
    int count[4][3][10]={0};
    int n, b, f, r, v, i, j, k;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1]+=v;
    }
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i<3){
            printf("####################\n");
        }
    }
     
     
     
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int h,w;
int ba[20][20];

// horizontal -> 1:2
// vartically -> 3
//               4
int solve(int x, int y) {
//  cout << x << " "<< y << endl;
//  REP(i,h) {REP(j,w)cout<<ba[i][j];cout<<endl;}
  if (y==h) return 1;
  if (x==w) return solve(0,y+1);
  if (ba[y][x]) return solve(x+1,y);
  // 横置き
  int res = 0;
  if (x<w-1&&ba[y][x+1]==0) {
    if (x&&y &&
        (ba[y-1][x-1]==2 || ba[y-1][x-1]==4) &&
        (ba[y-1][x] == 1 || ba[y-1][x] == 4) &&
        (ba[y][x-1] == 2 || ba[y][x-1] == 3)); // cross
    else {
      ba[y][x] = 1;
      ba[y][x+1] = 2;
      res += solve(x+1,y);
      ba[y][x] = ba[y][x+1] = 0;
    }
  }
  if (y<h-1&&ba[y+1][x]==0) {
    if (x&&y &&
        (ba[y-1][x-1]==2 || ba[y-1][x-1]==4) &&
        (ba[y-1][x] == 1 || ba[y-1][x] == 4) &&
        (ba[y][x-1] == 2 || ba[y][x-1] == 3)); // cross
    else {
      ba[y][x] = 3;
      ba[y+1][x] = 4;
      res += solve(x+1,y);
      ba[y][x] = ba[y+1][x] = 0;
    }
  }
  return res;
}
int main() {                    
  
  while(cin >> h >> w,h||w) {
    cout << solve(0,0) << endl;
  }
}

Measured memory_bytes: 872
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long x = sc.nextLong();
      long y = sc.nextLong();
      long n = 0;
      while(x <= y){
      	x *= 2;
        n++;
      }
      System.out.println(n);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	int x;cin>>x;
	if(x==0) cout<<1<<'\n';
	else cout<<0<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3588
h, w, k = map(int, input().split())
c = []
ans = 0
for i in range(h):
    c_i = list(input())
    c.append(c_i)

for i in range(1 << h):
    for j in range(1 << w):
        cnt = 0
        for ii in range(h):
            for jj in range(w):
                if (i >> ii & 1):
                    continue
                if (j >> jj & 1):
                    continue
                if c[ii][jj] == "#":
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Measured memory_bytes: 9212
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();

        if(k < 10){
            System.out.println(k);
            return;
        }
        Queue<Long> que = new ArrayDeque<>();
        for(long i = 1; i <= 9; i++){
            que.add(i);
        }

        int cnt = 9;
        while(cnt < k){
            long num = que.poll();
            long ldig = num % 10;
            if(ldig == 0){
                que.add(num * 10);
                que.add(num * 10 + 1);
                cnt += 2;
            }else if(ldig == 9){
                que.add(num * 10 + 8);
                que.add(num * 10 + 9);
                cnt += 2;
            }else{
                que.add(num * 10 + ldig - 1);
                que.add(num * 10 + ldig);
                que.add(num * 10 + ldig + 1);
                cnt += 3;
            }
        }

        long out = 0;
        for(int i = que.size(); i > cnt - k; i--){
            out = que.poll();
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 24784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    string s[200000];
    map<string, int> ana;
    long long counter = 0;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        ana[s[i]] += 1;
    }
    for (const auto& [key, value] : ana){
        if(value > 1){
            counter += (long long)value * (value - 1)/2;
        }
    }
    cout << counter << endl;


    return 0;
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int a[50], b[50], c[50], d[50];
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++)
		cin >> c[i] >> d[i];
	for (int i = 0; i < n; i++)
	{
		int ans = 0, far = 1000000000;
		for (int j = 0; j < m; j++)
			if (far > abs(a[i] - c[j]) + abs(b[i] - d[j]))
			{
				far = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j;
			}
		cout << ans + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {

    //int n;
    //scanf("%d",&n);

    char s[6];
    scanf("%s", s);

    if (strcmp(s, "Sunny")==0) {
        printf("Cloudy");
    } else if (strcmp(s, "Cloudy")==0) {
        printf("Rainy");
    } else {
        printf("Sunny");
    }


    return 0;

}


Measured memory_bytes: 128
import numpy as np
from scipy.spatial import distance

N, D = map(int, input().split())

l = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    l.append(tmp)

vector = np.array(l)

distMatrix = distance.cdist(vector, vector, metric="euclidean")

#print(distMatrix)

ans = 0
for i in range(N-1):
    #print(*distMatrix[i][i+1:])
    #print([x.is_integer() for x in distMatrix[i][i+1:]])
    ans += [x.is_integer() for x in distMatrix[i][i+1:]].count(True)
    #float.is_integer()
    
print(ans)


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

using namespace std;

int main()
{
  string s,ss;
  int ans=0;
  cin>>s>>ss;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=ss[i])
      ans++;
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 3912
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n, k);
    makev(a, n);
    VI dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        for(int j = max(0LL, i - k); j < i; ++j){
            dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
        }
    }
    cout << dp.back();


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

struct union_find {
    vector<int> par;

    union_find(int n) : par(n,-1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x]=root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x); int ry = root(y);
        if (rx == ry) return false;
        if (par[rx]>par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<set<int>> dame(n);
    union_find uf(n);

    for(int i=0; i<m; ++i){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        dame[a].insert(b);
        dame[b].insert(a);
        uf.unite(a,b);
    }

    for(int i=0; i<k; ++i){        
        int c,d;
        cin>>c>>d;
        --c;
        --d;
        if(!uf.same(c,d)) continue;
        dame[c].insert(d);
        dame[d].insert(c);
    }

    for(int i=0; i<n; ++i){
        int mem=uf.size(i) -1;
        mem-=dame[i].size();
        cout<<mem<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 24704
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
int main(){
  int n;
  int kusi[220]={};
  cin >> n;
  for(int i=0;i<2*n;i++){
    cin >>kusi[i];
  }
  sort(kusi,kusi+2*n);
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=kusi[i*2];
  }
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
    int n; cin >> n;
    ll s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    rep(i,n-1){
        ll h; cin >> h;
        if(s>=h){
            cnt++;
        }else{
             cnt = 0;
        }
         ans = max(ans,cnt);
        s = h;
    }
    cout << ans <<endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,n;
  char a[3],b[3],c[3];
  //printf("nyuuryoku\n");

  scanf("%s",a);

  scanf("%s",b);

  scanf("%s",c);

  printf("%c%c%c\n",a[0],b[1],c[2]);

  //printf("%c%c%c",a[0][0],a[1][1],a[2][2]);


  return 0;
}

Measured memory_bytes: 128
//#define _USE_MATH_DEFINES

#include <iostream>
//#include <vector>
#include <algorithm>
//#include <numeric>
//#include <string>
//#include <array>
//#include <set>
//#include <sstream>
//#include <cstdio>
//#include <cmath>

using namespace std;
//typedef long long int LL;

int main() {
	int K, S, cnt = 0, z_init = 0;
	cin >> K >> S;

	if (S > 2 * K) z_init = S - 2 * K;

	for (int z = z_init; z <= K; ++z) {
		if (S - z < 0) break;
		if (S - z > K) {
			if (S - z > 2 * K) continue;
			cnt += (2 * K - S + z + 1);
		}
		else cnt += (S - z + 1);
	}
	printf("%d\n", cnt);

	//for (int x = 0; x <= K; ++x) {
	//	if (x > S) break;
	//	for (int y = 0; y <= K; ++y) {
	//		if (x + y > S) break;
	//		for (int z = 0; z <= K; ++z) {
	//			if (x + y + z == S) cnt++;
	//			if (x + y + z > S) break;
	//		}
	//	}
	//}
	//printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

string N;
int main (){
    cin >> N;
    if ( N[1] == N[2] ){
        if(N[0] == N[1] || N[2] == N[3] ) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        cout << "No" << endl;
    }
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll b=0,ans=0;
    string s;
    cin>>s;
    rep(i,s.length()){
        if(s[i]=='B')b++;
        if(s[i]=='W')ans+=b;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
N, K = tuple(map(int, input().split()))
tmp = list(map(int, input().split()))
h = [10**10 for _ in range(K)]
h.extend(tmp)

dp = [10**9 for _ in range(N+K)]
dp[K] = 0
for i in range(K+1, N+K):
    for j in range(1, K+1):
        dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]))
print(dp[-1])

Measured memory_bytes: 57312
N=int(input())
H=[int(item) for item in input().split(" ")]
C=[]
C.append(0)
C.append(abs(H[1]-H[0]))
for i in range(2,len(H)):
  C.append(min(C[i-2]+abs(H[i]-H[i-2]),C[i-1]+abs(H[i]-H[i-1])))
  
  
print(C[len(H)-1]) 
 


Measured memory_bytes: 20420
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>


int ASC(const void *a,const void *b) {
	return *(int *)b - *(int *)a;//降順
}
int main(void)
{
	char s[7];
	scanf("%s",s);
	if (s[2] == s[3] && s[4] == s[5]) {
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
"""dfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())

to = [[] for _ in range(n)]
eid = [[] for _ in range(n)]
ans = [0]*(n-1)

def dfs(v, c=-1, p=-1): # v:これから見るnode、c:pとvを繋ぐedgeの色、p:親node
    k = 1
    for i in range(len(to[v])):
        u = to[v][i]
        ei = eid[v][i]
        if u == p: continue # 親nodeは確認済みなので見ない
        if k == c: k += 1 # 親nodeとの間のedgeの色と同じではいけないのでインクリメントする
        ans[ei] = k
        k += 1
        dfs(u,ans[ei],v)

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); eid[a].append(i) # to:nodeの繋がり、eid:edgeの色
    to[b].append(a); eid[b].append(i)

dfs(0)

mx = 0
for i in range(n):
    mx = max(mx, len(to[i]))
print(mx)
for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 84632
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  static int H[301];
  static int dp[301][301][301];
  rep(i, 0, 301) rep(j, 0, 301) rep(k, 0, 301) dp[i][j][k] = INF;
  int N, K;
  cin >> N >> K;
  rep(i, 0, N) cin >> H[i];

  H[N] = 0;
  dp[0][0][N] = 0;
  rep(i, 0, N) {
    rep(j, 0, K + 1) {
      rep(k, 0, N + 1) {
        if (dp[i][j][k] == INF) continue;
        int prev_h = H[k];
        int cost = 0;
        if (prev_h < H[i]) {
          cost = H[i] - prev_h;
        }
        chmin(dp[i + 1][j][i], dp[i][j][k] + cost);  // without consume
        chmin(dp[i + 1][j + 1][k], dp[i][j][k]);     // consume
      }
    }
  }
  int ans = INF;
  rep(i, 0, K + 1) {
    rep(j, 0, N + 1) { chmin(ans, dp[N][i][j]); }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 213376
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 int main()
 {
    //cout<<(-1%3)<<endl;

    ll int n,i,j;
    cin>>n;
    ll int ar[n][3];
    ll int dp[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>ar[i][j];
        }
    }
  
for(j=0;j<3;j++)
{
    dp[0][j]=ar[0][j];
}
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=ar[i][j]+max(dp[i-1][1],dp[i-1][2]);
            }
            else
            dp[i][j]=ar[i][j]+max(dp[i-1][(j-1)%3],dp[i-1][(j+1)%3]);
            //cout<<dp[i][j]<<endl;
        }
        
    }
    ll int maxx=INT_MIN;
    for(i=0;i<3;i++)
    {
       if(dp[n-1][i]>maxx)
        maxx=dp[n-1][i];
    }
    cout<<maxx;
 }

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int tmp = 0;
    priority_queue<int,vector<int>,greater<int> > pq;
    int ans = 0,top,size;
    int l,r;

    rep(i,100){
        rep(j,100){
            if(i+j > min(n,k))break;

            tmp = 0;
            pq =  priority_queue<int,vector<int>,greater<int> >();
            l = i,r = j;

            rep(a,min(i,n)){
                pq.push(v[a]);
            }

            rep(b,min(j,n-i)){
                pq.push(v[n-1-b]);
            }

            rep(l,k-min(i,n)-min(j,n-i) ){
                if(pq.empty()) break;
                top = pq.top();
                if(top < 0) pq.pop();
                else break;
            }
            
            size = pq.size();
            rep(l,size){
                tmp += pq.top();
                pq.pop();
            }
            ans = max(ans,tmp);
        }
    }

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

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    char ch[] = String.valueOf(N).toCharArray();
    char x = ch[0];
    char ans[] = {x,x,x};
    int di = Integer.parseInt(String.valueOf(ans));
    if(di>=N){
      System.out.println(di);
    }else{
      di+=111;
      System.out.println(di);
    }
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

using namespace std;
//using Graph = vector<vector<int>>;


int x;
int i=0,a = 2;
bool flag = true;
int main() {
	cin >> x;
	i = x-1;
	if (x == 2) {
		cout << 2;
		return 0;
	}
	while (flag) {
		i++;
		for (int a = 2; a < i; a++) {
			if (i % a == 0) break;
			if (a == i - 1) {
				flag = false;
			}
		}
	}
	cout << i << endl;
	return 0;
}

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

using namespace std;

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &a) { return is >> a.first >> a.second; }

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, pair< T1, T2 > &a) { return os << a.first << " " << a.second; }

template< typename T >
istream &operator>>(istream &is, vector< T > &vc) {
  for(int i = 0; i < vc.size(); i++) is >> vc[i];
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, vector< T > &vc) {
  for(int i = 0; i < vc.size(); i++) os << vc[i] << endl;
  return os;
}

#define reps(i, j, n) for(int i = j; i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase(unique( ALL(s)), (s).end());}

typedef long long int64;
const int64 INF = 1LL << 55;
typedef pair< int, int > Pi;
typedef pair< int, Pi > Pii;


int64 S[200], V[200], N, U;

pair< int64, int64 > ps[1 << (30 / 2)];

int64 type1() {
  int n1 = N / 2;
  int n2 = N - n1;
  for(int i = 0; i < 1 << n1; i++) {
    int64 w2 = 0, v2 = 0;
    for(int j = 0; j < n1; j++) {
      if(i >> j & 1) {
        w2 += S[j];
        v2 += V[j];
      }
    }
    ps[i] = make_pair(w2, v2);
  }
  sort(ps, ps + (1 << n1));
  int m = 1;
  for(int i = 0; i < 1 << n1; i++) {
    if(ps[m - 1].second < ps[i].second) {
      ps[m++] = ps[i];
    }
  }
  int64 res = 0;
  for(int i = 0; i < 1 << n2; i++) {
    int64 w2 = 0, v2 = 0;
    for(int j = 0; j < n2; j++) {
      if(i >> j & 1) {
        w2 += S[n1 + j];
        v2 += V[n1 + j];
      }
    }
    if(w2 <= U) {
      int64 v = (upper_bound(ps, ps + m, make_pair(U - w2, INF)) - 1)->second;
      res = max(res, v2 + v);
    }
  }
  return (res);
}

int64 type2() {
  int64 dp[1004 * 200];
  fill_n(dp, 1004 * 200, -1);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = U; j >= S[i]; j--) {
      dp[j] = max(dp[j], dp[j - S[i]] + V[i]);
    }
  }
  return (*max_element(dp, dp + U + 1));
}

int64 type3() {
  int64 dp[1004 * 200];
  fill_n(dp, 1004 * 200, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 1003 * 200 - V[i]; j >= 0; j--) {
      dp[j + V[i]] = min(dp[j + V[i]], dp[j] + S[i]);
    }
  }
  int ret = 0;
  for(int i = 0; i < 1003 * 200; i++) {
    if(dp[i] <= U) ret = max(ret, i);
  }
  return (ret);
}


int main() {
  cin >> N >> U;
  for(int i = 0; i < N; i++) {
    cin >> S[i] >> V[i];
  }
  if(N <= 30) cout << type1() << endl;
  else if(*max_element(S, S + N) <= 1000) cout << type2() << endl;
  else cout << type3() << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;

const int N=200005;

struct E{
	int to,next;
}mem[N];
int n,num,cnt,sig,t,tot,flag;
int head[N],p[N],vis[N],d[N],dp[N],a[N],f[N],b[N];
queue<int> q;

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void topsort(){
	int i,k,u,j;
	memset(dp,-1,sizeof(dp));
	for (i=1;i<=n;i++)
		if (!d[i]){
			q.push(i);
			vis[i]=1;
		}
	while (!q.empty()){
		k=q.front(); q.pop(); vis[k]=1;
		cnt=0; sig=0;
		for (j=head[k];j;j=mem[j].next){
			u=mem[j].to;
			a[++cnt]=dp[u];
		}
		sort(a+1,a+1+cnt); cnt=unique(a+1,a+1+cnt)-a-1;
		for (j=1;j<=cnt;j++)
			if (sig!=a[j]) break;
		else sig++;
		dp[k]=sig;
		u=p[k]; d[u]--;
		if (!d[u]){
			vis[u]=1; q.push(u);
		}
	}
}

void solve(){
	int k,u,j,st;
	st=b[1]; k=p[b[1]];
	while (k!=st){
		cnt=0; sig=0;
		for (j=head[k];j;j=mem[j].next){
			u=mem[j].to;
			a[++cnt]=f[u];
		}
		sort(a+1,a+1+cnt); cnt=unique(a+1,a+1+cnt)-a-1;
		for (j=1;j<=cnt;j++)
			if (sig!=a[j]) break;
		else sig++;
		f[k]=sig;
		if (p[k]!=st) k=p[k];
		else break;
	}
	cnt=0; sig=0;
	for (j=head[st];j;j=mem[j].next){
		u=mem[j].to;
		a[++cnt]=f[u];
	}
	sort(a+1,a+1+cnt); cnt=unique(a+1,a+1+cnt)-a-1;
	for (j=1;j<=cnt;j++)
		if (sig!=a[j]) break;
	else sig++;
	if (sig==f[st]) flag=1;
}

void init(){
	int i,j,k,u; cnt=tot=0;
	for (i=1;i<=n;i++)
		if (!vis[i]) b[++tot]=i;
	k=b[1];
	for (i=1;i<=n;i++) f[i]=dp[i];
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (vis[u]) a[++cnt]=f[u];
	}
	sort(a+1,a+1+cnt); sig=0; cnt=unique(a+1,a+1+cnt)-a-1;
	for (i=1;i<=cnt;i++)
		if (sig!=a[i]) break;
	else sig++;
	f[k]=sig;
	//for (i=1;i<=n;i++) cout<<i<<" "<<dp[i]<<endl;
	solve();
	cnt=0; a[++cnt]=f[k];
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (vis[u]) a[++cnt]=f[u];
	}
	sort(a+1,a+1+cnt); sig=0; cnt=unique(a+1,a+1+cnt)-a-1;
	for (i=1;i<=cnt;i++)
		if (sig!=a[i]) break;
	else sig++;
	f[k]=sig;
	solve();
}

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i;
	scanf("%d",&n); flag=0;
	for (i=1;i<=n;i++){
		scanf("%d",&p[i]);
		add(p[i],i); d[p[i]]++;
	}
	topsort();
	init();
	if (flag) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 7552
macro_rules! read {
    () => {{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf
    }};
    ( Vec<$t:ty> ) => {
        read!()
            .trim()
            .split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect::<Vec<_>>()
    };
    ( $( $t:ty ),* ) => {{
        let buf = read!();
        let mut iter = buf.split_whitespace().collect::<Vec<_>>().into_iter();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

fn main() {
    let (r_a, r_b, h, m) = read!(f64, f64, f64, f64);
    let (theta_a, theta_b) = (
        (360.0 * (60.0 * h + m) / 12.0 / 60.0).to_radians(),
        (360.0 * m / 60.0).to_radians(),
    );
    println!(
        "{}",
        (r_a * r_a + r_b * r_b - 2.0 * r_a * r_b * (theta_b - theta_a).cos()).sqrt()
    )
}


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int A[3];
    FOR(i,0,3)
        cin >> A[i];
    sort(A,A+3);
    int k;
    cin >> k;
    cout << A[0]+A[1]+A[2]*(1<<k) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,Y;
    int ans[3]={-1,-1,-1};
    cin >> N >> Y;
    for(int i=0;i<=N;i++){
        for(int k=0;k<=N-i;k++){
            if(i*10000+k*5000+(N-i-k)*1000==Y){
                ans[0]=i;
                ans[1]=k;
                ans[2]=N-i-k;
                break;
            }
        }
    }
    cout << ans[0] << " "<< ans[1] << " "<< ans[2];
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tolower(c) char(c+0x20)
#define toupper(c) char(c-0x20)
#define chartoll(c) ll(c) - ll('a')

const ll MAX_N = 100000;

int main(void){
    ll N;
    string s[MAX_N];
    ll si[MAX_N];
    ll tens[10];
    ll answer = 0;
    tens[0] = 1;
    rep(i, 9) tens[i + 1] = 26 * tens[i]; 

    cin >> N;
    rep(i, N) cin >> s[i];
    rep(i, N){
        ll v[10];
        si[i] = 0;
        rep(j, 10){
            v[j] = chartoll(s[i][j]);
        }
        sort(v, v+10);
        rep(j, 10){
            si[i] += tens[j] * v[j];
        }
    }

    sort(si, si+N);

    map<ll, ll> cnt;
    rep(i, N) cnt[si[i]] = 0;
    rep(i, N) cnt[si[i]]++;

    for(auto& kv: cnt){
        answer += (kv.second * (kv.second - 1)) / 2;
    }
    

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] line = scanner.nextLine().split(" ");
		int a1 = Integer.parseInt(line[0]);
		int a2 = Integer.parseInt(line[1]);
		int a3 = Integer.parseInt(line[2]);
		int a4 = Integer.parseInt(line[3]);
		int a5 = Integer.parseInt(line[4]);
		int a6 = Integer.parseInt(line[5]);

		int b = Integer.parseInt(scanner.nextLine());
		for (int i = 0; i < b; i++) {
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			int result = 0;
			if (c == a1 || c == a6)
				if (d == a2)
					result = 3;
				else if (d == a3)
					result = 5;
				else if (d == a4)
					result = 2;
				else
					result = 4;
			else if (c == a2 || c == a5)
				if (d == a1)
					result = 4;
				else if (d == a3)
					result = 1;
				else if (d == a4)
					result = 6;
				else
					result = 3;
			else {
				if (d == a1)
					result = 2;
				else if (d == a2)
					result = 6;
				else if (d == a5)
					result = 1;
				else
					result = 5;
			}
			if (c == a4 || c == a5 || c == a6)
				result = 7 - result;
			System.out.println(line[result - 1]);
		}
	}
}

Measured memory_bytes: 17204
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define LL long long

int n;
LL ans;
LL a[N];
LL b[N];

int main()
{
	
	cin>>n;
	for(int i=0;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
		if(b[i]<a[i]) ans+=b[i];
		else if(b[i]<a[i]+a[i+1])
		{
			a[i+1]-=(b[i]-a[i]);
			ans+=b[i];
		}
		else
		{
			ans+=a[i]+a[i+1];
			a[i+1]=0;
		}
	cout<<ans<<'\n';
	
	return 0;
}

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

int main() {
  int N;  //判定する整数
  cin >> N;  //入力
  int M = N;  //最終計算用
  
  int H = 0;  //各桁を足した数
  
  bool flag = false;  //ハージャッド数かどうか（false:ハージャッド数でない、true:ハージャッド数である）
  
  int X[9];  //, N4, N5, N6, N7, N8, N9;  //Nの1～9桁目の数字
  
  for (int i = 0; i < 9 ; i++){
  	X[i] = N % 10;
    N = (N - X[i]) / 10;
    H += X[i];
  }

  if (M % H == 0){
  	flag = true;
  } else {
  	flag = false;
  }
  //出力
  if (flag){
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
	string s;
	cin >> s;
	VI ans(s.length(), 0);
	int rn = 0, ln = 0;
	for (int i = 0; i < s.length();i++) {
		if (s[i] == 'R') {
			if (rn == 0)
				rn = 1;
			else
				rn++;
		}
		else if (rn > 0) {
			ans[i - 1] += (rn + 1) / 2;
			ans[i] += rn / 2;
			rn = 0;
		}
		if (s[i] == 'L') {
			if (ln == 0)
				ln = 1;
			else
				ln++;
		}
		else if (ln > 0) {
			ans[i - ln] += (ln + 1) / 2;
			ans[i - ln - 1] += ln / 2;
			ln = 0;
		}
	}
	ans[s.length() - ln] += (ln + 1) / 2;
	ans[s.length() - ln - 1] += ln / 2;
	REP(i, s.length())
		cout << ans[i] << ' ';
}

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

int main()
{
   int n;
   cin >>n;
  double total = (n+1)/2;
  double ans = (double)total /n;

  printf("%.10f\n",ans);
  

}


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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
int st[6];

int main(int argc, char const* argv[])
{
  ll n;
  int k;
  cin >> n >> k;
  for(int i = 1; i < 6; i++){
    for(int j = 1; j <= 11; j++){
      ll tmp = 8 * j + 9 * i + 9;
      if(tmp % 11 == k){
        st[i] = j;
        break;
      }
      if(j == n - 2){
        st[i] = n + 9;
        break;
      }
    }
  }
  ll res = 0;
  for(int i = 1; i < 6; i++){
    res += (n - 2 - st[i]) / 11 + 1;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;

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

    for (int i = 1; i <= 1000; ++i){
        int aa = (int)(i * 0.08);
        int bb = (int)(i * 0.10);
        if (a == aa && b == bb){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0, n, k;
string s, t;
//cout<<<<endl;


int main()
{
	cin >> n;
	int t = 1;
  if(n==1||n==2)
    cout<<4<<endl;
  else 
{for (int i = 0; t<1000000; i++)
	{
		if (n == 4)
			break;
		else if (n % 2 == 0)
		{
			n = n / 2; t++;
		}
		else
		{
			n = n * 3 + 1; t++;
		}
	}
  
	cout << t + 3 << endl;
}
	return 0;
}


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

using ll=long long;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int div1(ll x){
  return x%1000000007;
}

int xy(int x,int y){
    if (x ==1 && y== 1) return 400000;
    return 0;
}

main(){
    int x=in(),y=in(),ans=0;
    if (x<4) ans+=(4-x)*100000;
    if (y<4) ans+=(4-y)*100000;
    cout << ans+xy(x,y) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	ULL f(ULL a,ULL b,ULL c,ULL d){
		return max(max(a, b), max(c, d)) -
			min(min(a, b), min(c, d));
	}

	void Solve() {
		UL N; cin >> N;
		vector<ULL> A(N); rep(i, N) cin >> A[i];
		rep(i, N - 1) A[i + 1] += A[i];
		ULL ans = 1e18;
		for (UL d = 1; d < N - 2; d++) {
			ULL M1 = A[d], M2 = A[d] + A[N - 1];
			UL l1 = 0, r1 = d;
			while (l1 < r1 - 1) {
				UL m = (l1 + r1) / 2;
				if (A[m] * 2 <= M1) l1 = m; else r1 = m;
			}
			UL l2 = d + 1, r2 = N - 1;
			while (l2 < r2 - 1) {
				UL m = (l2 + r2) / 2;
				if (A[m] * 2 <= M2) l2 = m; else r2 = m;
			}
			ans = min(ans, f(A[l1], A[d] - A[l1], A[l2] - A[d], A[N - 1] - A[l2]));
			if (r1 != d) ans = min(ans, f(A[r1], A[d] - A[r1], A[l2] - A[d], A[N - 1] - A[l2]));
			if (r2 != N - 1) ans = min(ans, f(A[l1], A[d] - A[l1], A[r2] - A[d], A[N - 1] - A[r2]));
			if (r1 != d && r2 != N - 1) ans = min(ans, f(A[r1], A[d] - A[r1], A[r2] - A[d], A[N - 1] - A[r2]));
			//cout << d << " : " << l1 << " " << l2 << endl;
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1792
def smaller(x, y):
	if x < y: return x
	return y

L, R = map(int, input().split())
ans = 2020
if R-L >= 2019:
	ans = 0
else:
	for i in range(L, R):
		for j in range(i+1, R+1):
			m = (i*j) % 2019
			ans = smaller(ans, m)
print(ans)

Measured memory_bytes: 41196
from collections import deque

N, M = map(int, input().split())

to = [[] for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

q = deque([])
q.append(0)

is_visited = [False] * N
pre_room = [-1] * N

while(len(q) != 0):
    tmp = q.popleft()
    is_visited[tmp] = True

    for i in to[tmp]:
        if is_visited[i]:
            continue
        q.append(i)
        is_visited[i] = True
        pre_room[i] = tmp

for i in range(1, N):
    if i == -1:
        print("No")
        exit()

print("Yes")
for i in range(1, N):
    print(pre_room[i] + 1)



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

int main() {
  long N,K,ans=0;
  cin >> N >> K;
  vector<long> H(N);
  for(int i=0;i<N;++i) cin >> H[i];
  sort(H.begin(),H.end(),greater<long>());
  for(int i=K;i<N;++i) ans += H[i];
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;cout<<24+(24-n)<<endl;
    

}

/*

*/


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int dfs(vector<int> v, int joint) {
  if ((int) v.size() < 3) return 1 << 30;
  int res = 1 << 30;
  for (int i = 0; i < (int) v.size(); i++) {
    for (int j = 0; j < (int) v.size(); j++) {
      for (int k = 0; k < (int) v.size(); k++) {
        if (i == j || j == k || k == i) continue;
        res = min(res, abs(v[i] - a) + abs(v[j] - b) + abs(v[k] - c) + joint);
      }
    }
  }
  for (int i = 0; i < (int) v.size(); i++) {
    for (int j = i + 1; j < (int) v.size(); j++) {
      vector<int> tmp = v;
      tmp[i] += tmp[j];
      tmp.erase(tmp.begin() + j);
      res = min(res, dfs(tmp, joint + 10));
    }
  }
  return res;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n >> a >> b >> c;
  vector<int> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  cout << dfs(in, 0) << endl;
  return 0;	 
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (k <= a)
    {
        cout << a - k << ' ' << b << endl;
    }
    else if (k <= a + b)
    {
        cout << 0 << ' ' << b - (k - a) << endl;
    }
    else
        cout << 0 << ' ' << 0 << endl;
}

Measured memory_bytes: 256
n,k,q=map(int,input().split())
A=list(int(input()) for i in range(q))
p_l=list(k-q for i in range(n))

for i in range(q):

  p_l[A[i]-1]+=1

for i in range(n):
  if(p_l[i]>0):
    print("Yes")
  else:
    print("No")
  


Measured memory_bytes: 11788