akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
int dfs(int m, int n,hei(int) a) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			int ans = a[0];
			rep(i, 0, 3) {
				if (now[i] == '0') {
					ans -= a[i + 1];
				}
				else ans += a[i + 1];
			}
			if(ans==7){
				cout << a[0];
				rep(i, 0, 3) {
					if (now[i] == '0')cout << "-" << a[i + 1];
					else cout << "+" << a[i + 1];
				}
				cout <<"="<<7<< endl;
				return 0;
		     }
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

int main() {
	string s;
	cin >> s;
	hei(int) a(4);
	rep(i, 0, 4) {
		a[i] = s[i] - '0';
	}
	dfs(2, 3,a);
	return 0;
	
}


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

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

	int H, W, D;
	scanf("%d %d %d", &H, &W, &D);

	vector<vector<int>> from_i(D, vector<int>(((H * W) / D) + 1, -1));
	vector<vector<pair<int, int>>> loc(D, vector<pair<int, int>>(((H * W) / D) + 1, make_pair(-1, -1)));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			int tmp;
			scanf("%d", &tmp);
			tmp--; //0~H*W-1
			loc[tmp % D][tmp / D] = make_pair(i, j);
		}
	}

	for (int i = 0; i < D; i++)
	{
		from_i[i][0] = abs(loc[i][0].first - 0) + abs(loc[i][0].second - 0);
		// cout << i << "\n"
		// 	 << from_i[i][0] << " ";
		for (int j = 1; j < ((H * W) / D) + 1; j++)
		{
			if (loc[i][j].first == -1)
			{
				break;
			}
			from_i[i][j] = from_i[i][j - 1] + abs(loc[i][j].first - loc[i][j - 1].first) + abs(loc[i][j].second - loc[i][j - 1].second);
			// cout << from_i[i][j] << " ";
		}
		// cout << "\n";
	}

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

	for(int i=0;i<Q;i++){
		int L,R;
		scanf("%d %d", &L, &R);
		L--;
		R--;
		printf("%d\n",from_i[R%D][R/D]-from_i[L%D][L/D]);
	}
	return 0;
}

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

#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;

#ifdef SMIT
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN


int n, i, j, cnt;
string s;
void solve()
{
// #define TEST
	cin >> n >> s;
	i = 0; j = n - 1; cnt = 0;
	while (i < j)
	{
		while (i < n and s[i] == 'R') i++;
		while (j >= 0 and s[j] == 'W') j--;
		if (i == n or j < 0 or i>j) break;
		cnt++;
		i++; j--;
	}
	cout << cnt << endl;
}

int32_t main()
{
#ifdef SMIT
	// freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

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

int main(void){
	int h, w;

	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0) break;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if((j+i)%2 == 0) cout << "#";
				else cout << ".";
			}
			puts("");
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	ll A,B,N;
	cin >> A >> B >> N;
	ll temp = A*min(B-1,N);
	ll temp2 = temp / B;
	cout << temp2 << endl;

  return 0;
}


Measured memory_bytes: 3596
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

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

def searchIndex(c):
    return alphabet.index(c)
  
s_rot_n = ''
for i in range(len(s)):
    index = (searchIndex(s[i]) + n) % 26
    s_rot_n += alphabet[index]
    
print(s_rot_n)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<cassert>
#include<numeric>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;

using namespace std;

int main(){
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> x(N);
    for(int i=0; i<N; i++)  cin >> x[i];
    ll ans = 0;
    for(int i=1; i<N; i++){
        if((x[i] - x[i-1]) * A < B) ans += (x[i] - x[i-1]) * A;
        else    ans += B;
    }
    print(ans);
}

Measured memory_bytes: 3988
#include <stdio.h>
#define N 10000
#define Q 500
int main()
{
  int n,q,S[N],T[Q],i,j,count=0;

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

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }

  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(S[j]==T[i]){
	count++;
	break;
      }
    }
  }

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

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

#include <string>

int main() {
    int H, W;
    cin >> H >> W;

    std::vector<std::string> h;

    std::string init;
    for (int i = 0; i < W+2; ++i) init += ".";

    h.push_back(init);
    for (int i = 0; i < H; ++i) {
        std::string s;
        cin >> s;
        std::string tmp = "." + s + ".";
        h.push_back(tmp);
    }
    h.push_back(init);

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char here = h.at(i+1)[j+1]; // we are here
            if (here == '#') continue;

            int cnt = 0;
            for (int k=0; k<3; ++k) {
                for (int l=0; l<3; ++l) {
                   char cell = h.at(i+k)[j+l];
                   if (cell == '#') ++cnt;
                }
            }
            h.at(i+1)[j+1] = '0' + cnt;
        }
    }

    for (int i = 1; i < H+1; ++i) {
        for (int j = 1; j < W+1; ++j) {
            cout << h.at(i)[j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define rep(i,N) for(int i=0;i<N;i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1e9+7;

int main() {
  ll a, b;
  cin >> a >> b;
  
  ll answer = (a + b) / 2 + (a + b) % 2;

  cout << answer << endl;
  return 0;
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}
*/
int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}
/*
void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n;
  cin >> n;
  vector<vector<int64_t>> c(10,vector<int64_t>(10));
  rep(k,n){
    string s = to_string(k+1);
    rep(i,10){
      rep(j,10){
        if(s.at(0) == i + '0' && s.at(s.size()-1) == j + '0'){
          c.at(i).at(j)++;
        }
      }
    }
  }
  
  int64_t result = 0;
  
  rep(i,10){
    rep(j,10){
      result += c.at(i).at(j)*c.at(j).at(i);
    }
  }
  
  cout << result;
      
        
        
        
      
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int d;
    int n;
    cin >> d >> n;
    int s = 1;
    for(int i = 0; i < d; i++)
    s *= 100;
    {
        if(n <= 99){
            cout << s * n << endl;
        }
        else{
            cout << s * 101 << endl;
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if (b <= a)
    {
        while (b <= a && k != 0)
        {
            b = b * 2;
            k--;
        }
    }
    if (c <= b)
    {
        while (c <= b && k != 0)
        {
            c = c * 2;
            k--;
        }
    }
    if (b > a && c > b)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 3644
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	a := make([]float64, 10)
	for scanner.Scan() {
		info := strings.Split(scanner.Text(), ",")
		for j := 0; j < 10; j++ {
			a[j], _ = strconv.ParseFloat(info[j], 64)
		}
		v1, _ := strconv.ParseFloat(info[10], 64)
		v2, _ := strconv.ParseFloat(info[11], 64)
		sum := 0.0
		for i := 0; i < 10; i++ {
			sum += a[i]
		}
		match := v1 * ((sum/(v1+v2)))
		if match == 0 {
			fmt.Println(1)
		} else {
			sum = 0
			for k := 0; k < 10; k++ {
				sum += a[k]
				if match <= sum {
					fmt.Println(k+1)
					break
				}
			}
		}
	}
}


Measured memory_bytes: 1072
const byteToDigits = (byte) => {
  let digit = 0
  const digits = {}

  while (byte > 0) {
    if (byte % 2 === 1) {
      digits[digit] = true
    }

    byte = Math.floor(byte / 2)
    digit++
  }
  
  return digits
}

const blackCellCount = (c, redRows, redColumns) => {
  let count = 0
  c.forEach((cells, i) => {
    cells.forEach((cell, j) => {
      if (c[i][j] === '#' && !redRows[i] && !redColumns[j]) {
        count++
      }
    })
  })
  
  return count
}

const main = async () => {
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()
  const rows = input.split('\n')
  const hwk = rows.shift()
  const [h, w, kString] = hwk.split(' ')
  const k = Number(kString)
  
  const c = []
  
  rows.forEach((row, i) => {
    c[i] = []
    const cells = row.split('')
    
    cells.forEach((cell, j) => {
      c[i][j] = cell
    })  
  })
 	
  // 全ての h, w の true/false の組み合わせを作る → ビット
  const hByteMax = Math.pow(2, h)
  const wByteMax = Math.pow(2, w)

  let count = 0

  for (let hByte = 0; hByte < hByteMax; hByte++) {
    const redRows = byteToDigits(hByte)

    for (let wByte = 0; wByte < wByteMax; wByte++) {
      const redColumns = byteToDigits(wByte)
      
      if (blackCellCount(c, redRows, redColumns) === k) {
        count++
      }
    }
  }

  console.log(count)
}

main()

Measured memory_bytes: 33520
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrA = np.array(input().split(),dtype=np.int64)

ans = sum(arrA -1)

print(ans)

Measured memory_bytes: 13176
// finish date: 2018/07/17
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

//dijkstra(開始ノード、ノード数、edge[頂点名][距離、行先の頂点])
vi dijkstra(int s, int V, vector<vector<pii>> edge) {
    vi dist(V, INF); //INFの値がこれでいいか確認するべき
    vb used(V, false);
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push(pii(0, s));
    while (!pq.empty()) {
        int d, t;
        tie(d, t) = pq.top();
        pq.pop();
        if (used[t]) continue;
        used[t] = true;
        dist[t] = d;
        for (pii e:edge[t]) {
            if (dist[e.second] < d + e.first) continue;
            pq.push(pii(d + e.first, e.second));
        }
    }
    return dist;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<pii>> edge(N + M);
    rep(i, N) {
        int K;
        cin >> K;
        rep(j, K) {
            int L;
            cin >> L;
            L--;
            edge[i].push_back(pii(1, N + L));
            edge[N + L].push_back(pii(1, i));
        }
    }
    vi dist = dijkstra(0, N+M, edge);
    rep(i, N) {
        if(dist[i] == INF){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}



Measured memory_bytes: 19828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  bool ans = false;
  rep(i, n){
    cin >> a[i];
  }
  rep(i,m){
    cin >> b[i];
  }
  rep(i, n - m + 1){
    rep(j,n-m+1){
      bool judge = true;
      rep(k, m){
        rep(l,m){
          if(a[k+i][l+j]!=b[k][l]){
            judge = false;
            break;
          }
        }
      }
      if(judge){
        ans = true;
        break;
      }
    }
  }
  if(ans){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
/*
 * kadai3_4
 * kamecha
 */
#include<stdio.h>

int main(void){
    int num;
    scanf("%d", &num);
    /*
     * 1~9のどれかで割り切れたらOK
     */
    int flag = 0;  //どれかで割り切れたらflag = 1
    for(int i = 1; i <= 9; i++){
        if(num%i == 0){
            /*
             * 商が1~9だとOK
             */
            int devided = num/i;
            if(devided >= 1 && devided <= 9){
                puts("Yes");
                flag = 1;
                break;
            }
        }
    }
    /*
     * どれにも当てはまらなかった
     */
    if(!flag)   puts("No");
    return 0;
}


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

int main()
{
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  A.push_back(A[0]+K);
  
  int l = 0;
  for(int i = 0; i < N; ++i)
  {
    l = max(l, A[i+1]-A[i]);
  }
  
  cout << K-l << endl;
}

Measured memory_bytes: 4828
x = int(input())

if (x>=400) and (x<=599):
    print("8")
elif (x>=600) and (x<=799):
    print("7")
elif (x>=800) and (x<=999):
    print("6")
elif (x>=1000) and (x<=1199):
    print("5")
elif (x>=1200) and (x<=1399):
    print("4")
elif (x>=1400) and (x<=1599):
    print("3")
elif (x>=1600) and (x<=1799):
    print("2")
elif (x>=1800) and (x<=1999):
    print("1")


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A, B;
    cin >> A >> B;
    loop(i,1,1e5+1)
    {
        if ((8*i)/100 == A && i/10 == B)
        {
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	int A[N];
	int B[N];
	int C[N];
	int K=0,i;
	for(i=1;i<N+1;i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<N+1;i++){
		scanf("%d",&B[i]);
	}
	for(i=1;i<N;i++){
		scanf("%d",&C[i]);
	}
	
	for(i=1;i<N+1;i++){
		K=K+B[i];
		if(A[i]-A[i-1]==1){
			K=K+C[A[i-1]];
		}
	}
	printf("%d",K);
}


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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n, m, a, b, c, d, e, cnt = 0, ans = 0, wa, ac;
   string s, v, sv[10010];
   vector<int> x, y, z;
   priority_queue<int> pr;
   priority_queue<int, vector<int>, greater<int>> gpr;

   cin >> s;

   rep(i, s.size())
   {
      x.push_back((s[i] - '0'));
   }

   rep(i, (x.size() - 2))
   {
      y.push_back(abs(753 - (x[i] * 100 + x[i + 1] * 10 + x[i + 2])));
   }

   sort(all(y));

   cout << y[0] << '\n';
}

Measured memory_bytes: 384
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> x;
  if (400 <= x && x <= 599)
    Cout(8);
  else if (600 <= x && x <= 799)
    Cout(7);
  else if (800 <= x && x <= 999)
    Cout(6);
  else if (1000 <= x && x <= 1199)
    Cout(5);
  else if (1200 <= x && x <= 1399)
    Cout(4);
  else if (1400 <= x && x <= 1599)
    Cout(3);
  else if (1600 <= x && x <= 1799)
    Cout(2);
  else
    Cout(1);
  return 0;
}

Measured memory_bytes: 3652
N = int(input())
S = input()
k = 1
ans_list = []
for i in range(1000,2000):
    ansyo = str(i)
    for j in range(0,N):
        if ansyo[k] == S[j]:
            k += 1
        if k == 4:
            ans_list.append(ansyo)
            k = 1
        if j == N-1:
            k = 1
ans_list = set(ans_list)
print(len(ans_list))

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

int main(){
	string s1=" ";
	int count[26] = {};
	char out;

	while (cin >> s1){
		for(int i=0;i<s1.length();i++){
			if(s1[i]==' ' | s1[i]=='.') continue;
			count[tolower(s1[i])-'a'] += 1;
		}
	}

	for(int i=0;i<26;i++){
		out = i + 'a';
		cout << out << " : " << count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3196
#include <atcoder/dsu.hpp>
#include <iostream>
#include <set>

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n)                       _range(i, 0, n)
#define _range(i, a, b)                  for (int i = int(a); i < int(b); ++i)
#define rep(...)                         _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)

#define _rrep(i, n)      _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)
#define rrep(...)        _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)

using ll = long long;
using namespace std;
using namespace atcoder;

int main(void) {
    int n;
    cin >> n;
    vector<int> x(n), y(n);

    rep(i, n) {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
    }

    vector<int> ans(n);
    dsu uf(n);

    vector<int> x2idx(n), y2idx(n);

    rep(i, n) {
        x2idx[x[i]] = i;
        y2idx[y[i]] = i;
    }

    set<int> s;

    rep(xi, n) {
        const int idx = x2idx[xi];
        const int yi  = y[idx];
        s.insert(yi);

        const int yimin = *begin(s);

        while (s.size()) {
            auto it = begin(s);
            if (*it > yi) { break; }
            uf.merge(y2idx[yi], y2idx[*it]);
            s.erase(it);
        }

        s.insert(yimin);
    }

    rep(i, n) {
        cout << uf.size(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 11720
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		long n = sc.nextLong();
		long p = sc.nextLong();
		long max = (long)Math.pow(p, 1.0 / n) + 1;
		System.out.println(getAns(n, p, max));
	}
	long getAns(long n, long p, long max) {
		for(long i = max; i >= 1; i--) {
			if(p % (long)Math.pow(i, n) == 0)return i;
		}
		return 1;
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <algorithm>
#include <string>

using Int = long long int;
using std::string;

constexpr Int MOD = 1000000007;

Int ipow(Int x, Int n) {
    Int ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= MOD;
        n >>= 1;
        (x *= x) %= MOD;
    }
    return ret;
}

bool ispali(string s) {
    string t = s;
    std::reverse(t.begin(), t.end());
    return s == t;
}

int main() {
    int n;
    string t, u;
    std::cin >> t >> u >> n;

    if (n > u.length()) {
        Int ans = ipow(26LL, (n - u.length() + 1) / 2);

        std::reverse(u.begin(), u.end());
        std::cout << (ispali(t + u) ? ans
                                    : 0)
                  << std::endl;
    } else {
        std::reverse(u.begin(), u.end());
        string s = u.substr(0, n);
        std::reverse(u.begin(), u.end());

        std::cout << (ispali(s + t + s + u) ? 1
                                            : 0)
                  << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int n,res,ans,a[100001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]<=a[i-1])res++,ans=max(ans,res);
		else res=0;
	//	printf("%d ",res);
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            int R = int.Parse(Console.ReadLine());
            int G = int.Parse(Console.ReadLine());

            Console.WriteLine(2 * G - R);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), max = 0;
		if(a + b > a - b){
			max = a + b;
		}else{
			max = a - b;
		}
		if(max > a * b){
			max = max;
		}else{
			max = a * b;
		}
		System.out.print(max);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)


int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n)
    {
        if(n == 0)
            return 0;
        vector<int> nums;
        REP(i, n)
        {
            int tmp;
            cin >> tmp;
            nums.push_back(tmp);
        }
        sort(nums.begin(),nums.end());
        int sum = 0;
        RFOR(i, n-1, 1)
            sum += nums[i];
        cout << sum / (n-2) << '\n';
    }
}

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

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

	if ( a > b)
	{
	x = a;
	y = b;
	}
	else
	{
	x = b;
	y = a;
	}
	
	int z = y;
	while ( x%y != 0 )
	{
		z = x%y;
		x = y;
		y = z;
	}
	cout << z << endl;

	return 0;
}


Measured memory_bytes: 3108
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String args[])
{
	int j;
	//Scanner a = new Scanner(System.in);
	Scanner in = new Scanner(System.in);
	//System.out.println("ENter the list");
	int height[]=new int[10];
	int i;
	//int j;
	int x;
	for(i=0;i<10;i++)
	{
		height[i]=in.nextInt();
		
	}
	/*for(i=0;i<10;i++)
	{
		System.out.print(height[i]+ " ");
	}
	*/
for(i=0;i<10;i++)
{
	for(j=i+1;j<10;j++)
		if(height[i]>height[j])
		{
			int temp=height[i];
			height[i]=height[j];
			height[j]=temp;
		}
}
//System.out.println("Sorted");
for(i=9;i>6;i--)
{
	System.out.println(height[i]);
}
	

}
}

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

#define ll   long long int
#define PI 3.14159265358979

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, candies;
    cin>>n;
    candies=(n+1)*n/2;
    cout<<candies;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,j,a[26],b[26],mx,cnt,x;
	char s[101];
	scanf("%d",&n);
	scanf("%s",s);
	mx=0;
	for(i=1;i<n-1;i++)	{
		for(j=0;j<26;j++)	{
			a[j]=0;	b[j]=0;
		}
		for(j=0;j<i;j++)	{
			x=s[j]-'a';
			a[x]=1;
		}
		for(j=i;j<n;j++)	{
			x=s[j]-'a';
			b[x]=1;
		}
		cnt=0;
		for(j=0;j<26;j++)	{
			if(a[j]==1 && b[j]==1)	cnt++;
		}
		mx=max(mx,cnt);
	}
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <utility>
#include <string>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
bool scan(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	bool t['z' + 1] = {};
	for (int c: "yuiophjklnm")
		t[c] = true;
	for (string s; scan(s) && s != "#";) {
		int n = -1, h = -1;
		for (int c: s) {
			if (t[c] != h)
				n++;
			h = t[c];
		}
		out(n, '\n');
	}
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, x, y; cin >> n >> x >> y;
    map<ll, ll> mp;
    for (int i = 1; i < n; i++) mp[i] = 0;

    for (ll i = 1; i < n; i++) {
        for (ll j = i + 1; j <= n; j++) {
            mp[min(min(j - i, abs(x - i) + 1 + abs(j - y)), abs(y - i) + 1 + abs(j - x))]++;
        }
    }

    for (int i = 1; i < n; i++) cout << mp[i] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll ans = 0;
    rep(i,N){
        auto itrc = upper_bound(all(C),B[i]);
        auto itra = lower_bound(all(A),B[i]);
        ll cnow = *itrc;
        ll anow = *itra;
        ll ccnt,acnt;
        ccnt = C.end() - itrc;
        acnt = itra - A.begin();
        ans += ccnt*acnt;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int dup = n;
    int sum = 0;
    while (true) {
        if (dup == 0) {
            break;
        }
        sum += (dup % 10);
        dup /= 10;
    }
    cout << (n % sum == 0 ? "Yes" : "No") << '\n';
    return 0;
}


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

int main()
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);

    if (a - b >= 0) {
        printf("%s\n", "delicious");
    } else if (b - a <= x) {
        printf("%s\n", "safe");
    } else {
        printf("%s\n", "dangerous");
    }
}


Measured memory_bytes: 128
//https://atcoder.jp/contests/abc047/tasks/arc063_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,T; cin>>N>>T;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    ll minv=INT32_MAX;
    ll maxv=0;
    vector<ll> profit(N,0);
    for(ll i=N-1;i>=0;--i){
        ll a=an.at(i);
        minv = min(minv, a);
        maxv = max(maxv, a);
        profit.at(i)=maxv-a;
    }
    sort(profit.begin(),profit.end(),greater<ll>());
    ll ans=0;
    ll p0 = profit.at(0);
    for(const auto& p:profit){
        if (p==p0) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int a,b;
 cin >> a >> b;
 string A=to_string(a);
 string B=to_string(b);
 string N,M;
 for (int i = 0; i < b; i++)
 {
    N+=A;
 }
  for (int i = 0; i < a; i++)
 {
    M+=B;
 }
 if(N<=M){
     cout << N << endl;
 }
 else{
     cout << M << endl;
 }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        int answer = n * (n + 1) / 2;

        Console.WriteLine(answer);
    }

    // 最大公約数
    private static int Gcd(int a, int b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            int r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    private static int Lcm(int a, int b)
    {
        return a / Gcd(a, b) * b;
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector<int> k(M), p(M), sw[M];
    for(int i = 0; i < M; i++){
        std::cin >> k[i];
        std::vector<int> s(k[i]);
        for(int j = 0; j < k[i]; j++) std::cin >> s[j];
        sw[i] = s;
    }
    for(int i = 0; i < M; i++) std::cin >> p[i];
    long long ans = 0;
    for(int bit = 0; bit < (1 << N); bit++){
        std::vector<int> son(N, 0);
        int flag = 1;
        for(int i = 0; i < N; i++){
            if(bit & (1 << i)) son[i] = 1;
        }
        for(int i = 0; i < M; i++){
            int count = 0;
            for(int j: sw[i]){
                if(son[--j] == 1) count++;
            }
            if(count % 2 != p[i]) flag = 0;
        }
        if(flag) ans++;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
// This is the start of the template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define sortall(a) sort(a.begin(),a.end())
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
//this is the end of my template //
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	//input();
	ll x,ans;
	cin>>x;
	if(400<=x&&x<=599)
		ans=8;
	else if(600<=x&&x<=799)
		ans=7;
	else if(800<=x&&x<=999)
		ans=6;
	else if(1000<=x&&x<=1199)
		ans=5;
	else if(1200<=x&&x<=1399)
		ans=4;
	else if(1400<=x&&x<=1599)
		ans=3;
	else if(1600<=x&&x<=1799)
		ans=2;
	else if(1800<=x&&x<=1999)
		ans=1;

	cout<<ans<<endl;
	
}	




Measured memory_bytes: 3644
import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()
A = list(input())

C = Counter(A)
ans = 0
for i in range(C['R']):
    if A[i] == 'W':
        ans += 1
print(ans)


Measured memory_bytes: 11348
n,w_max = map(int,input().split())
w = [0]
v = [0]

for _ in range(n):
    W,V = map(int,input().split())
    w.append(W)
    v.append(V)
v_sum = sum(v)
lrg = 10**12
dp = [[lrg]*(v_sum+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
for i in range(1,n+1):
    for u in range(v_sum+1):
        if u>=v[i]:
            dp[i][u] = min(dp[i-1][u-v[i]]+w[i],dp[i-1][u])
        else:###
            dp[i][u] = min(w[i],dp[i-1][u])

ans = []
for u in range(v_sum+1):
    if dp[n][u] <= w_max:
        ans.append(u)
#print(*dp[n])
print(max(ans))


Measured memory_bytes: 120428
#include <stdio.h>

typedef long long ll;

#define MOD 1000000007
#define MAX_N 200

ll dp[MAX_N][MAX_N+1] = {0}; // dp[n][rest U] = ??´????????°

int main() {
	int N;
	char c[MAX_N];
	char buf[100];
	int sz = 0;
	ll ans = -1;
	int i, j;

	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%s", buf);
		if (buf[0] != '-') c[sz++] = buf[0];
	}
	N = sz;

	if (N == 0) {
		ans = 1;
	}
	else if (c[0] == 'D') {
		ans = 0;
	}
	else {
		dp[0][1] = 1; // c[0] : 'U'
		for (i = 0; i < N-1; ++i) {
			for (j = 0; j < N; ++j) {
				if (c[i+1] == 'U') {
					dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % MOD;
					if (j >= 1) {
						dp[i+1][j] = (dp[i+1][j] + j * dp[i][j]) % MOD;
					}
				}
				else { // D
					if (j >= 1) {
						dp[i+1][j] = (dp[i+1][j] + j * dp[i][j]) % MOD;
						dp[i+1][j-1] = (dp[i+1][j-1] + j * j * dp[i][j]) % MOD;
					}
				}
			}
		}
		ans = dp[N-1][0];
	}	

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 900
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	int N = 8;
	int[] row = new int[N];
	boolean[] col = new boolean[N];
	boolean[] dpos = new boolean[2 * N - 1];
	boolean[] dneg = new boolean[2 * N - 1];

	boolean[][] map = new boolean[N][N];

	void initialize() {
		Arrays.fill(row, -1);
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		initialize();
		int k = scanner.nextInt();
		for (int i = 0; i < k; i++) {
			int r = scanner.nextInt();
			int c = scanner.nextInt();
			row[r] = c;
			col[c] = dpos[r + c] = dneg[r - c + N - 1] = true;
		}
		recurisve(0);

	}

	boolean flag = false;

	private void recurisve(int i) {
		if (i == N) {
			printBoard();
			flag = true;
			return;
		}
		if (row[i] != -1) {
			recurisve(i + 1);
		}
		for (int j = 0; j < N; j++) {
			if (flag)
				return;
			if (row[i] != -1)
				return;
			if (col[j] || dpos[i + j] || dneg[i - j + N - 1])
				continue;
			row[i] = j;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = true;
			recurisve(i + 1);
			row[i] = -1;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = false;
		}
	}

	private void printBoard() {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				System.out.print(row[i] == j ? "Q" : ".");
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 17364
// Author: HarshKumar
#include <bits/stdc++.h>
using namespace std;
#define ll int
const ll N = 15e5 + 1;
ll root[N], L[16 * N], R[16 * N], sum[16 * N];
ll rt = 1, sz = 1;
ll lpos[N];
ll copy(ll v, ll &u)
{
    L[sz] = L[v];
    R[sz] = R[v];
    sum[sz] = sum[v];
    return u = sz++;
}
void make_root()
{
    copy(root[rt - 1], root[rt]);
    rt++;
}
void add(ll pos, ll x, ll v = root[rt - 1], ll l = 0, ll r = N)
{
    sum[v] += x;
    if (r - l == 1)
        return;
    ll m = (l + r) / 2;
    if (pos < m)
        add(pos, x, copy(L[v], L[v]), l, m);
    else
        add(pos, x, copy(R[v], R[v]), m, r);
}

ll get(ll a, ll b, ll v, ll l = 0, ll r = N)
{
    if (a <= l && r <= b)
        return sum[v];
    if (r <= a || b <= l)
        return 0;
    ll m = (l + r) / 2;
    return get(a, b, L[v], l, m) + get(a, b, R[v], m, r);
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    rt = sz = 1;
    ll n, q;
    cin >> n >> q;
    for (ll i = 1; i <= n; i++)
    {
        ll t;
        cin >> t;
        make_root();
        add(lpos[t], -1);
        lpos[t] = i;
        add(lpos[t], 1);
    }
    while (q--)
    {
        ll l, r;
        cin >> l >> r;
        cout << get(l, r + 1, root[r]) << '\n';
    }
}


Measured memory_bytes: 252780
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

n, k = inpl()
p = inpl()

for i in range(n):
    p[i] = (1 + p[i]) / 2

sm = 0
for i in range(k):
    sm += p[i]
idx = 0

mx = sm
for i in range(1, n - k + 1):
    sm = sm - p[i-1] + p[i + k - 1]
    mx = max(mx, sm)

print(mx)
        

Measured memory_bytes: 99716
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  if(S=="SUN")
    cout<<"7"<<endl;
  else if(S=="MON")
    cout<<"6"<<endl;
  else if(S=="TUE")
    cout<<"5"<<endl;
  else if(S=="WED")
    cout<<"4"<<endl;
  else if(S=="THU")
    cout<<"3"<<endl;
  else if(S=="FRI")
    cout<<"2"<<endl;
  else if(S=="SAT")
    cout<<"1"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll N; cin>>N;
    ll A[N][N];

    REP(i,N){
        REP(k,N){
            cin >> A[i][k];
        }
    }

    ll ans = 0;
    REP(i,N){
        FOR(j,i+1, N){
            int flag = 1; //-1;アウト 0; 同じ長さの組み合わせあり 1; 一番短い
            REP(k,N){
                if(k == i || k == j) continue;
                if(A[i][j] > A[i][k]+A[k][j]){
                    flag = -1;
                    break;
                }
                else if(A[i][j] == A[i][k]+A[k][j]){
                    flag = 0;
                    break;
                }
            }
            if(flag == -1){
                cout << -1 << endl;
                return 0;
            }
            else if(flag == 1){
                ans += A[i][j];
            }
        }
    }

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

Measured memory_bytes: 1024