akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const ll mod = 998244353;

template <typename T>
T powmod(T n, T k, T mod) {
  if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    return powmod(n * n % mod, k / 2, mod);
  } else {
    return n * powmod(n, k-1, mod) % mod;
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  vector<ll> D(N); REP(i, N) cin >> D[i];
  if (D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll max_D = *max_element(ALL(D));
  vector<ll> d_map(max_D + 1, 0);
  for (ll d : D) d_map[d]++;
  if (d_map[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  FOR(i, 1, max_D + 1) {
    ans *= powmod<ll>(d_map[i-1], d_map[i], mod);
    ans %= mod;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int n=s.size();
    if (s[0]!=s[n-1])
    {
        if (n&1)
            cout<<"First\n";
        else
            cout<<"Second\n";
    }
    else
    {
        if (n&1)
            cout<<"Second\n";
        else
            cout<<"First\n";
    }
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a+b/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#include<set>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
vector<vector<PII > > roads;
set<PII > counts;
int N, M;

void func(int to, int ep){
    priority_queue<PII,vector<PII> , greater<PII> > que;
    que.push({0, to});
    vector<int> fast(N+1, INF);
    fast[to] = 0;
    while(!que.empty()){
        PII d = que.top();
        que.pop();
        REP(i, roads[d.second].size()){
            PII dd = roads[d.second][i];
            int nf = dd.first + d.first;
            if(fast[dd.second] > nf){
                fast[dd.second] = nf;
                que.push({nf, dd.second});
            }
        }
    }
    int np = ep;
    int sumf = fast[ep];
    queue<PII> qu;
    qu.push({sumf, ep});
    while(!qu.empty()){
        PII d = qu.front();
        qu.pop();
        REP(i, roads[d.second].size()){
            if(d.first - roads[d.second][i].first == fast[roads[d.second][i].second]){
                int a = d.second;
                int b = roads[d.second][i].second;
                if(a>b){
                    swap(a, b);
                }
                counts.erase({a, b});
                PII nd = {fast[roads[d.second][i].second], roads[d.second][i].second};
                qu.push(nd);
            }
        }
    }
}
int main(){
    cin >> N >> M;
    roads.resize(N+1);
    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        roads[a].push_back({c, b});
        roads[b].push_back({c, a});
        if(a>b){
            swap(a, b);
        }
        counts.insert({a, b});
    }
    REPA(i, N+1){
        REPA(j, N+1){
            if(i < j){
                func(i, j);
            }
        }
    }
    cout << counts.size() << endl;
    return 0;
}


Measured memory_bytes: 384
// ABC162D - RGB Triplets

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;

	long long int R = 0, G = 0, B = 0;
	for (int i = 0; i < N; i++) {
		switch (S[i]) {
			case 'R':
				R++;
				break;
			case 'G':
				G++;
				break;
			case 'B':
				B++;
				break;
			default:
				break;
		}
	}

	long long int ans = R * G * B;
	for (int i = 1; i <= N / 2; i++) {
		for (int j = 0; j + 2 * i < N; j++) {
			if ((S[j] != S[j + i])
			  &&(S[j] != S[j + 2 * i])
			  &&(S[j + i] != S[j + 2 * i])) {
				ans--;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    string s, t;
    int ans = 0;
    cin >> s >> t;
    vector<char> cs(s.size()), ct(t.size());
    for (int i = 0; i < s.size(); ++i) {
        cs.at(i) = s[i];
        ct.at(i) = t[i];
        if (cs.at(i) != ct.at(i)) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S0, S1, S2;
	std::cin >> S0 >> S1 >> S2;
	std::cout << S0[0] << S1[1] << S2[2] << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int X, A;

int main(int argc, char **argv) {
    std::cin >> X >> A;

    if (X < A) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << 10 << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (n, mut h): (usize, isize);
    input!(n, h);
    let mut va = vec![];
    let mut vb = vec![];

    for _ in 0..n {
        let (a, b): (isize, isize);
        input!(a, b);
        va.push(a);
        vb.push(b);
    }

    va.sort();
    vb.sort();
    vb.reverse();

    let va = *va.last().unwrap();

    let mut ans = 0;

    for z in vb {
        if va > z {
            break;
        }
        h -= z;
        ans += 1;
        if h <= 0 {
            p(ans);
            return;
        }
    }
    if h % va == 0 {
        p(ans + h / va);
    } else {
        p(ans + h / va + 1);
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(c) (c).begin(),(c).end()
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void dump() {}
template <class H, class... T>void dump(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); dump(forward<T>(tail)...);}

vector<int> z_algorithm(string& s, int s0 = 0){
  int n = s.size();
  vector<int> z(n-s0,0);

  int l = s0+1, k = 0;
  while(l < n){
    while(l+k < n && s[l+k] == s[s0+k]) ++k;
    z[l-s0] = k;
    if(k==0){++l; continue;}
    int i = 1;
    while(l+i < n && i+z[i] < k){
      z[l-s0+i] = z[i];
      ++i;
    }
    l += i; k -= i;
  }
  z[0] = n-s0;

  return z;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i < n-1; ++i){
    auto z = z_algorithm(s, i);
    //dump(i, z);
    for(int j = 0; j < z.size(); ++j){
      ans = max(ans, min(j,z[j]));
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    long long a, b, k, t, s;
    cin >> a >> b >> k;
    if(a>=k) {
        t=a-k;
        s=b;
    }
    else if(a+b<=k) {
        t=0;
        s=0;
    }
    else {
        t=0;
        s=b-(k-a);
    }
    cout << t << " " << s << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] let = sc.next().toCharArray();
        int a = 0, b = 0, c = 0;
        for(int i = 0; i < n; i++){
            if(let[i] == 'R') a++;
            if(let[i] == 'B') b++;
            if(let[i] == 'G') c++;
        }
        long ans = (long)a * b * c;
        long sub = 0;
        for(int i = 0; i < n; i++){
           for(int j = i + 1; j < n; j++){
               if(let[i] != let[j] && 2 * j - i < n){
                   if(let[i] != let[2 * j - i] && let[j] != let[2 * j - i]) sub++;
               }
           }
        }
        System.out.println(ans - sub);
    }
}


Measured memory_bytes: 35768
#include<stdio.h>
long long int gcd(long long int a,long long b){
if(b==0)
    return a;
else
    return gcd(b,a%b);
}
int main(){
long long int a,b;
while(scanf("%lld %lld",&a,&b)!=EOF){
    printf("%lld %lld\n",gcd(a,b),a/gcd(a,b)*b);
}
return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    vector<int> cnta(n, 0), cntc(n, 0), cntl(n, 0), cntr(n, 0);
    for (int i = 1; i < n; i++) {
        cnta[i] = cnta[i - 1] + (s[i - 1] == 'A');
        cntl[i] = cntl[i - 1] + (s[i - 1] == '?');
    }

    for (int i = n - 2; i >= 0; i--) {
        cntc[i] = cntc[i + 1] + (s[i + 1] == 'C');
        cntr[i] = cntr[i + 1] + (s[i + 1] == '?');
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != 'B' && s[i] != '?') continue;
        ll tmp = cnta[i] * modpow(3, cntl[i]) % MOD;
        if (cntl[i] > 0) (tmp += cntl[i] * modpow(3, cntl[i] - 1) % MOD) %= MOD;
        ll tmp2 = cntc[i] * modpow(3, cntr[i]) % MOD;
        if (cntr[i] > 0) (tmp2 += cntr[i] * modpow(3, cntr[i] - 1) % MOD) %= MOD;
        (ans += tmp * tmp2 % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int w,h,n,x,y;
  int grid[20][20];

  while(cin >> w >> h, w){
    memset(grid,0,sizeof(grid));
    grid[0][0] = 1;
    cin >> n;
    for(int i=0;i<n;i++)cin >> x >> y, grid[y-1][x-1] = -1;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(grid[i][j] < 0)continue;
	if(grid[i+1][j] >=0)grid[i+1][j] += grid[i][j];
	if(grid[i][j+1] >=0)grid[i][j+1] += grid[i][j];
      }
    }

    cout << grid[h-1][w-1] << endl;
  }
}
  

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

int N;
int x[100], y[100], h[100];
int ansx, ansy, ansh;

/* return
    bool success or not.
    int value of ansh.
 */
pair<bool, int> simulate(int cx, int cy){
  int calcH=0;
  for (int i = 0; i < N; i++) { 
    if (h[i] > 0){
      calcH=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
      break;
    }
  }

  for (int i = 0; i < N; i++) {
    if ( max(calcH - abs(x[i]-cx) - abs(y[i]-cy ), 0) != h[i] ){
        return {false, -1};
    }
  }
  return {true, calcH};
}

void solve(){

  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      pair<bool, int> result = simulate(cx, cy);
      if(result.first){
        ansx=cx;
        ansy=cy;
        ansh=result.second;
        return;
      }
    }
  }
}

int main() {
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  solve();

  cout << ansx << " " << ansy << " " << ansh << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/rdmd
import std.cstream;

int main(){
	int n,i,y,m,d;
	din.readf(&n);
	for(i=0;i<n;i++){
		din.readf(&y,&m,&d);
		dout.writefln("%d",(196471-(--y)*195-y/3*5-(--m)*20+(y%3-2?m/2:0)-d));
	}
	return 0;
}

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

int main(){
    string s;cin>>s;
    bool judge = false;
    if (s.size() < 4){
        cout << "No" << endl;
        return 0;
    }
    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;

}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n;
void solve(){
	cin >> n;
	
	for(int k = 1; k <= n; k++){
		int cnt = 0;
		for(int i = 1; i*i <= k; i++){
			for(int j = 1; j*j <= k; j++){
				int ans = i*i+j*j+i*j;
				if(ans >= k) break;
				int m = k-ans;
				int l = 0, r = m;
				while(r-l > 1){
					int c = (l+r)/2;
					int C = c*c + c*i + c*j;
					if(C == m){
						cnt++;
						break;
					}
					else if(C > m){
						r = c;
					}
					else l = c;
				}
			}
		}
		cout << cnt << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int check(int n)
{
    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;

    return 0;
}
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int ans=0;
    for (int i = 1; i <= n; i++) {
        if(check(i)%2==1){
            ans++;
        }
        
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <map>
using namespace std;
int main(){
  string s; cin >> s;
  map<char,int> c;
  for(int i=0;i<s.length();i++){
    c[s[i]]++;
  }
  string ans="Yes";
  for(auto a:c) {
    if(a.second%2!=0) ans="No";
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{ int n,cnt=0,r=0;
 cin>>n;
 string s;
 cin>>s;
 for(auto &i:s) { if(i=='R') r++;}
 for(int i=0;i<r;i++)
 { if(s[i]=='W') cnt++;
 }
 cout<<cnt;
   
 
 
}

Measured memory_bytes: 3744
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int hoge(int x){
    int res = 0;
    while(x){
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main(){

    int N;
    cin >> N;
    int ans = 1 + hoge(N-1);
    for(int A = 1; A < N; A++){
        int B = N - A;
        ans = min(ans, hoge(A) + hoge(N - A));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int h[200005];
long long a[200005];
long long dp[200005];
long long bit[200005];
long long query(int x) {
	long long res = 0;
	while (x) {
		res = max(res, bit[x]);
		x -= x & (-x);
	}
	return res;
}
void update(int x, long long val) {
	while (x <= 200000) {
		bit[x] = max(bit[x], val);
		x += x & (-x);
	}
}
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> h[i];
	for (int i = 1; i <= N; i++) cin >> a[i];
	long long mx = 0;
	for (int i = 1; i <= N; i++) {
		dp[h[i]] = max(dp[h[i]], a[i] + query(h[i] - 1));
		mx = max(mx, dp[h[i]]);
		update(h[i], dp[h[i]]);
	}
	cout << mx << endl;
}


Measured memory_bytes: 5760
numbers = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"

K = int(input())

print(numbers.split(", ")[K - 1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int idx = -1;
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	cout << (N - 1 + K - 2) / (K-1) << endl;
	return 0;
}


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

int main(){
    int i,n,c,m;
    scanf("%d %d",&n,&m);
    int p[n+1],q[n+1],r[m];
    fill(r,r+m,0);
    fill(p,p+n+1,0);
    fill(q,q+n+1,0);

    for(i=0;i<m;i++){
        scanf("%d",&c);
        p[c]=1;
        r[i]=c;
    }
    for(i=m-1;i>=0;i--){
        if(!q[r[i]]){q[r[i]]=1;printf("%d\n",r[i]);}
    }
    for(i=1;i<n+1;i++){
        if(!p[i]){printf("%d\n",i);}
    }
    return 0;
} 



Measured memory_bytes: 4676
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var [n,q]=arr.shift().split(" ").map(Number);
var ary=arr.shift().split(" ").map(Number);
ary.sort((a,b)=>a-b);
var tansaku=function(x,str){
    var first=-1;
    var last=ary.length;
    while (last-first>1){
        var mid=first+Math.floor((last-first)/2);
        if(ary[mid]<x)first=mid;
        else if(str=="ookii" && ary[mid]==x)first=mid;
        else last=mid;
    }
    return last;
};
var ans=[];
arr.forEach(v=>{
   var [l,r]=v.split(" ").map(Number);
   ans.push(tansaku(r,"ookii")-tansaku(l,"izyou"));
});
console.log(ans.join("\n"));


Measured memory_bytes: 48900
#include <iostream>
#include <string>
#include <sstream>

struct J {
    int cost = 0;
    int price = 0;
};

int main()
{
    int n = 0;
    std::scanf("%d\n",&n);
    J* table = new J[n];
    
    {
        std::string s;
        std::getline(std::cin, s);
        std::stringstream ss(s);
        std::string v;
        int c = 0;
        while (std::getline(ss, v,' ')) {
            table[c].price = std::atol(v.c_str());
            c++;
        }
    }
    {
        std::string s;
        std::getline(std::cin, s);
        std::stringstream ss(s);
        std::string v;
        int c = 0;
        while (std::getline(ss, v,' ')) {
            table[c].cost = std::atol(v.c_str());
            c++;
        }
    }
    int result = 0;
    for (int i = 0; i < n; ++i) {
        int v = table[i].price - table[i].cost;
        if (v > 0) result += v;
    }
    std::cout << result;
    delete[] table;

}

Measured memory_bytes: 256
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str1;
	int count=0;
	while((str1=input.readLine())!=null)
	    {
		char str2[]=new char[str1.length()];
		for(int i=0;i<str1.length();i++)
		    {
			str2[i]=str1.charAt(str1.length()-(1+i));
		    }
		String str3=String.valueOf(str2);
		
		
		if(str1.equals(str3))count++;
		
	    }
	System.out.println(count);
    }
}

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

int main()
{
    int N;

    cin >> N;

    int x = 0;
    for (int i=1; i<=9; i++){
        for (int j=1; j<=9; j++){
            if (i*j == N){
                x = 1;
            }
        }
    }

    switch (x) {
        case 0: cout << "No" << endl; break;
        case 1: cout << "Yes" << endl; break;
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, MA, MB;
	cin >> N >> MA >> MB;
	vector<int> A(N), B(N),C(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i] >> C[i];
	}
	vector<vector<vector<int>>> DP(N + 1,
		vector<vector<int>>(401, vector<int>(401, INF)));
	DP[0][0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int a = 0; a <= 400; ++a) {
			for (int b = 0; b <= 400; ++b) {
				if (DP[i][a][b] == INF)continue;
				DP[i + 1][a][b] = min(DP[i + 1][a][b], DP[i][a][b]);
				DP[i + 1][a + A[i]][b + B[i]] =
					min(DP[i + 1][a + A[i]][b + B[i]],
						DP[i][a][b] + C[i]);
			}
		}
	}
	
	int ans = INF;
	int AA = MA;
	int BB = MB;
	for (int i = 0; i <= 400; ++i) {
		if (AA > 400 || BB > 400) {
			break;
		}
		if (ans > DP[N][AA][BB]) {
			ans = DP[N][AA][BB];
		}
		AA += MA;
		BB += MB;
	}
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

using namespace std;

int main(){
    int N ,K;
    string S;
    char tmp;

    cin >> N >> S >> K;
    tmp = S[K-1];
   // cout << tmp << endl;
    for(int i = 0; i < N; i++){
        if(S[i] != tmp){
            S[i] = '*';
        }


    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int l, r;
	cin >> l >> r;
	ll ans = 2018;
	for (ll i = l; i < r; i++) for (ll j = l + 1; j <= r; j++) {
		chmin(ans, i * j % 2019);
		if (ans == 0) {
			puts("0");
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int[][] array = new int[4][13];
		for (int i = 0; i < a; i++) {
			String b = scanner.next();
			int c = scanner.nextInt();
			if (b.equals("S"))
				array[0][c - 1] = 1;
			else if (b.equals("H"))
				array[1][c - 1] = 1;
			else if (b.equals("C"))
				array[2][c - 1] = 1;
			else
				array[3][c - 1] = 1;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (array[i][j] == 0)
					if (i == 0)
						System.out.println("S " + (j + 1));
					else if (i == 1)
						System.out.println("H " + (j + 1));
					else if (i == 2)
						System.out.println("C " + (j + 1));
					else
						System.out.println("D " + (j + 1));
			}
		}
	}
}


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


struct Q{
	long long lim;
	long long sum = 0;
	priority_queue<long long> Q;
	void add(long long x){
		Q.push(x);
		sum += x;
		while( Q.size() > lim ){
			sum -= Q.top();
			Q.pop();
		}
	}
};

long long hoge(long long N,vector<long long> a){
	long long ans = -1e18;
	for(int i = 0 ; i < (1<<a.size()) ; i++){
		vector<int> b;
		for(int j = 0 ; j < 3 * N ; j++){
			if( i >> j & 1 ) b.push_back(a[j]);
		}
		if( b.size() == 2*N ){
			long long c = accumulate(b.begin(),b.begin()+N,0ll);
			long long d = accumulate(b.begin()+N,b.begin()+2*N,0ll);
			ans = max(ans,c - d);
			
		}
	}
	return ans;
}

long long solve(long long N, vector<long long> a){
	Q q1,q2;
	q1.lim = N;
	q2.lim = N;
	vector<long long> fv(3*N),bv(3*N);
	for(int i = 0 ; i < 3 * N ; i++){
		q1.add(-a[i]);
		fv[i] = q1.sum;
	}
	for(int i = 3 * N - 1 ; i >= 0 ; i--){
		q2.add(a[i]);
		bv[i] = q2.sum;
	}
	
	long long ans = -1e18;
	for(int i = N-1 ; i < 2 * N ; i++){
		//cout << -fv[i] << " " << bv[i+1] << endl;
		ans = max(-fv[i]-bv[i+1],ans);
	}
	return ans;	
	

	
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(3*N-1+1);
	for(int i = 0 ; i <= 3*N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	while(0){
		int N = rand() % 3 + 1;
		vector<long long> a;
		cout << "===" << endl;
		for(int i = 0 ; i < 3 * N ; i++) a.push_back(rand() % 100 - 100);
		if( hoge(N,a) != solve(N,a) ){
			cout << hoge(N,a) << " " << solve(N,a) << endl;
			for(int i = 0 ; i < a.size() ; i++){
				cout << a[i] << " ";
			}
			cout << endl;
			return 0;
		}

			
	}
	cout << solve(N, a) << endl;
	return 0;
}


Measured memory_bytes: 11892
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;

int l[605][605];
int n;

bool check(int a,int b){
    rep(i,n){
        rep(j,n){
            //cerr<<l[a+i][b+j]<<' ';
            if(l[a+i][b+j]!=l[a+j][b+i]){
                return 0;
            } 
        }
        //cerr<<endl;
    }
    return 1;
}

int main(){
    cin >> n;
    rep(i,n){
        rep(j,n){
            char s;
            cin >> s;
            int t=s-'a';
            l[i][j]=t;
            l[i+n][j]=t;
            l[i][j+n]=t;
            l[i+n][j+n]=t;
        }
    }
    int ans=0;
    rep(k,n){
        if(check(k,0)==1){
            ans+=n-k;
            //cerr<<k<<' '<<ans<<endl;
        }
    }
    
    rep(k,n){
        if(check(0,k)==1){
            ans+=n-k;
        }
    }
    if(check(0,0)==1)ans-=n;
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4972
n,m = map(int, input().split())

a = [0]*n
b = [False]*n
for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if s == 'AC':
    b[p] = True
  elif b[p] == False:
    a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
  if b[i] == True:
    wa += a[i]
print(ac,wa)

Measured memory_bytes: 4596
#include <iostream>  
using namespace std;  
 
  
const int MAX_NUM = 100;  
const int MAX_WEIGHT = 10000;  

  
int weight[MAX_NUM];  
int value[MAX_NUM];  
 
int dp[MAX_WEIGHT];  
  

void Solve( int n, int w )  
{     
    for( int i=1; i<=n; i++ )  
    {  
        for( int j=w; j>=weight[i]; j-- )  
        {             
            if( dp[j-weight[i]] + value[i] > dp[j] )  
                dp[j] = dp[j-weight[i]] + value[i];           
        }  
    }  
    cout << dp[w] << endl;  
}  

int main()  
{    
    int n, w;  
    cin >> n >> w;        
    for( int i=1; i<=n; i++ )  
    {  
        cin >> value[i] >> weight[i];  
    }  
    Solve( n, w );  
 
    return 0;  
}  

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string flag;
  vector<int> vec(n);
  for (int i=0 ; i<n; i++){
    cin >> vec.at(i);
  }
  for (int i=n-1 ;i>=1 ; i--){
    if(vec.at(i) <= vec.at(i-1) -2){
      flag = "No";
      break;
    }
    if(vec.at(i) == vec.at(i-1)-1){
      vec.at(i-1) += -1;
    }
  }
  if(flag=="No"){cout << flag;}
  else{cout << "Yes";}
}


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin >> arr[i];
        arr[i] -= (i+1);
    }
    sort(arr,arr+n);
    long long ans = 0;
    for(int i=0;i<n;i++){
        ans += abs(arr[i]-arr[n/2]);
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n, k;
    cin >> n >> k;
    VI h(n);
    for (Int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    Int result = 0;
    for (Int i = 0; i < n - k; ++i) {
        result += h[i];
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 4752
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        for _ in range(num): return []
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list,zip(*read_all))

#################

H,W = II()
s = [list(map(str, input())) for _ in range(H)]

w_count = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            w_count += 1


v = (0,0)
check_visited = [[False]*W for _ in range(H)]
check_visited[v[0]][v[1]] = True
S = [v]
flag = False
c = 1
while S:
    S1 = []
    for v1 in S:
        if v1[0]==H-1 and v1[1]==W-1:
            flag = True
            break
        if v1[0]-1>=0:
            if check_visited[v1[0]-1][v1[1]] == False and s[v1[0]-1][v1[1]] == '.':
                check_visited[v1[0]-1][v1[1]] = True
                S1.append((v1[0]-1,v1[1]))
        if v1[0]+1<=H-1:
            if check_visited[v1[0]+1][v1[1]] == False and s[v1[0]+1][v1[1]] == '.':
                check_visited[v1[0]+1][v1[1]] = True
                S1.append((v1[0]+1,v1[1]))
        if v1[1]-1>=0:
            if check_visited[v1[0]][v1[1]-1] == False and s[v1[0]][v1[1]-1] == '.':
                check_visited[v1[0]][v1[1]-1] = True
                S1.append((v1[0],v1[1]-1))
        if v1[1]+1<=W-1:
            if check_visited[v1[0]][v1[1]+1] == False and s[v1[0]][v1[1]+1] == '.':
                check_visited[v1[0]][v1[1]+1] = True
                S1.append((v1[0],v1[1]+1))
    else:
        S = S1
        c += 1
        continue
    break

if flag:
    print(w_count-c)
else:
    print(-1)

Measured memory_bytes: 40560
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	string S;
	cin >> S;

	string odd = "";
	string even = "";

	for (int i = 0; i < S.size(); i++) {
		if (0 == i % 2) {
			// �
			odd += S[i];
		}
		else {
			// ����
			even += S[i];
		}
	}

	if (odd.find("L") == string::npos && even.find("R") == string::npos) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
prev_t = 0
prev_x = 0
prev_y = 0

n = int(input())
ans = True
for _ in range(n):
    t, x, y = map(int, input().split())
    dist = (x - prev_x) + (y - prev_y)
    time = t - prev_t
    if dist > time or dist % 2 != time % 2:
        ans = False
        break

    prev_x = x
    prev_y = y
    prev_t = t

if not ans:
    print('No')
else:
    print('Yes')

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

int main(){
  int N;
  string s,s1="",s2="";
  cin>>N>>s;
  if(s.size()%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  else{
    for(int i=0;i<s.size();i++){
      if(i<s.size()/2)
        s1+=s.at(i);
      else
        s2+=s.at(i);
    }
  }
  if(s1==s2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

vector<int> v[222222],dp1,dp2;
int f,s,ans[222222];
void recur(int now,int left,int dep){
	if(dep%2==0) dp1.push_back(now);
	else dp2.push_back(now);
	for(int e=0;e<v[now].size();e++){
		int next = v[now][e];
		if(next!=left) recur(next,now,dep+1);
	}
}
int main(void){
	int n;
	scanf("%d",&n);
	for(int e=0;e<n-1;e++){
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	recur(1,-1,0);
	if((int)dp1.size()>(int)dp2.size()) swap(dp1,dp2);
	if((int)dp1.size()<=(n/3)){
		int q = 3;
		for(int p=0;p<dp1.size();p++){
			 ans[dp1[p]] = q;
			 q += 3;
		}
		q -= 3;
		int tmp = 1;
		for(int e=1;e<=n;e++){
			if(ans[e]==0){
				ans[e] = tmp;
				tmp++;
				if(tmp%3==0&&tmp<=q) tmp++;
			}
		}
		for(int e=1;e<=n;e++) printf("%d ",ans[e]);
	}else{
		for(int q=0,tmp=1;q<dp1.size()&&tmp<=n;q++,tmp+=3){
			ans[dp1[q]] = tmp;
		}
		for(int q=0,tmp=2;q<dp2.size()&&tmp<=n;q++,tmp+=3){
			ans[dp2[q]] = tmp;
		}
		int tmp = 3;
		for(int e=1;e<=n;e++){
			if(ans[e]==0){
				ans[e] = tmp;
				tmp += 3;
			}
		}
		for(int e=1;e<=n;e++) printf("%d ",ans[e]);
	}
	return 0;
}


Measured memory_bytes: 19700
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int A, B;
    cin >> A >> B;
    int cur = 1;
    int cnt = 0;
    while (cur < B) {
        cur = cur - 1 + A;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B,C;
	cin>>A>>B>>C;
	int Max=max(A,max(B,C));
	int Min=min(A,min(B,C));
	int Mid=A+B+C-Max-Min;
	cout<<Max*10+Min+Mid<<endl;

	return 0;
}

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> P;
#define rep(i,n) for(int i=0;i<n;++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
//vector<vector<int>> z(n,vector<int>(2));
//n番目から数えてm個の文字列をXに置換したい場合はreplace(n,m,X) teWttest
//s1.substr(3,3);
//n番目以降の文字列をm個取り出す、上だとtte

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

  ll c;
  c=gcd(a,b);
  vector<pair<ll, int>> res;

  for(ll i=2;i*i<=c;i++){
  //  cout<<i<<endl;
    if(c%i)continue;
    res.push_back(make_pair(i,0));
    while (c%i==0){
      c/=i;
      res.back().second++;
    }
  }
  if (c!=1) res.push_back(make_pair(c,1));
  ll ans;
  ans=res.size()+1;
  cout<<ans;


  }


Measured memory_bytes: 256
h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
Ans = []

for hi in range(h):
    for wi in range(w):
        if A[hi][wi]%2:
            if hi+1<h:
                A[hi][wi] -= 1
                A[hi+1][wi] += 1
                Ans.append((hi+1, wi+1, hi+1+1, wi+1))
            elif wi+1<w:
                A[hi][wi] -= 1
                A[hi][wi+1] += 1
                Ans.append((hi+1, wi+1, hi+1, wi+1+1))
print(len(Ans))
for _ans in Ans:
    print(*_ans)

Measured memory_bytes: 30504
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,a[1 << 21];

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
    bool rev = 0;
    deque<int>dq;
    for(int i = 1;i <= n;i++)
    {
		cin >> a[i];
		if(!rev) dq.push_back(a[i]);
		else dq.push_front(a[i]);
		rev = !rev;
	}
	if(rev) reverse(dq.begin(),dq.end());
	for(auto it : dq) cout << it << ' ';
	return 0;
}


Measured memory_bytes: 3840
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
lst=[0]*M
for i in range(M):
 a,b=map(int,input().split())
 c=set(map(int,input().split()))
 d=0
 for n in c:
  d+=2**(n-1)
  lst[i]=(a,d)
ans=[[float("inf") for e in range(2**N)] for f in range(M+1)]
ans[0][0]=0
for j in range(M):
 for i in range(2**N):
  e= i-(lst[j][1]&i)
  ans[j+1][i]=min(ans[j][e]+lst[j][0],ans[j][i])
if ans[M][2**N-1]==float("inf"):
 print(-1)
else:
 print(ans[M][2**N-1])

Measured memory_bytes: 138460
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

const int INF = 1e6;
typedef vector<int> Edge;
typedef vector<Edge> Graph;
Graph graph;

struct Node{
    int next;
    int parent;
    int dist;
    int timestamp;
    Node(){}
    Node(int n,int p,int d,int t){
        next = n;
        parent = p;
        dist = d;
        timestamp = t;
    }
    bool operator<(const Node &n)const{
        return timestamp < n.timestamp;
    }
};

struct Query{
    int v, d, c;
};

void solve(){
    int N, M, Q;
    cin >> N >> M;
    graph.assign(N, Edge());
    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cin >> Q;
    vector<Query> query(Q);
    REP(i, Q){
        int v, d, c;
        cin >> v >> d >> c;
        v--;
        query[i].v = v;
        query[i].d = d;
        query[i].c = c;

    }
    reverse(ALL(query));

    vector<int> res(N);
    vector<vector<int> > used(N, vector<int>(11));
    REP(i, Q){
        queue<pair<int, int> > que;
        que.push(make_pair(query[i].v, query[i].d));
        while(!que.empty()){
            pair<int,int> node = que.front();que.pop();
            int v = node.first;
            int d = node.second;
            if(used[v][d])continue;
            used[v][d] = 1;
            if(res[v]==0)res[v] = query[i].c;
            if(d-1<0)continue;
            REP(j, graph[v].size()){
                int u = graph[v][j];
                if(used[u][d-1])continue;
                que.push(make_pair(u, d-1));
            }
        }
    }

    REP(i, N)cout << res[i] << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 17916
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        HashMap<Integer, Integer> m1 = new HashMap<>();
        HashMap<Integer, Integer> m2 = new HashMap<>();
        ArrayList<Integer> v1 = new ArrayList<>();
        ArrayList<Integer> v2 = new ArrayList<>();

        for (int i = 0; i < n; i += 2) {
            if (m1.containsKey(v[i])) {
                m1.put(v[i], m1.get(v[i]) + 1);
            } else {
                m1.put(v[i], 1);
                v1.add(v[i]);
            }

            if (m2.containsKey(v[i + 1])) {
                m2.put(v[i + 1], m2.get(v[i + 1]) + 1);
            } else {
                m2.put(v[i + 1], 1);
                v2.add(v[i + 1]);
            }
        }
        int Amax1 = 0;
        int Amax2 = 0;
        int Bmax1 = 0;
        int Bmax2 = 0;
        int Av1 = 0;
        int Av2 = 0;
        int Bv1 = 0;
        int Bv2 = 0;

        for (int i = 0; i < v1.size(); i++) {
            int tmp = m1.get(v1.get(i));
            if (tmp >= Amax1) {
                Amax2 = Amax1;
                Amax1 = tmp;
                Av2 = Av1;
                Av1 = v1.get(i);
            } else if (tmp >= Amax2) {
                Amax2 = tmp;
                Av2 = v1.get(i);
            }
        }
        for (int i = 0; i < v2.size(); i++) {
            int tmp = m2.get(v2.get(i));
            if (tmp >= Bmax1) {
                Bmax2 = Bmax1;
                Bmax1 = tmp;
                Bv2 = Bv1;
                Bv1 = v2.get(i);
            } else if (tmp >= Bmax2) {
                Bmax2 = tmp;
                Bv2 = v2.get(i);
            }
        }
        int ans = 0;
        if (Av1 == Bv1) {
            if (Amax1 + Bmax2 > Amax2 + Bmax1) {
                ans = n - Amax1 - Bmax2;
            } else {
                ans = n - Amax2 - Bmax1;
            }
        } else {
            ans = n - Amax1 - Bmax1;
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 56524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  cin >> s1s2s3 ;
  int a =s1s2s3/100;
  int b =s1s2s3/10-10*a;
  int c =s1s2s3-10*b-100*a;
  cout << a+b+c <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 100005
using namespace std;

int fac[maxn], n, m, sn, ifac[maxn], inv[maxn], f[21][maxn], ans, a[21], digit[maxn];
int C(int u, int v){
	if(u < v) return 0;
	return 1ll * fac[u] * ifac[v] % mod * ifac[u - v] % mod; 
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n; cin >> m; sn = 1 << n;
	fac[0] = 1; inv[0] = 1; ifac[0] = 1;
	for(int i = 1; i <= sn; i++) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = (i == 1) ? 1 : 1ll * inv[mod % i] * (mod - mod / i) % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod; 
	}
	for(int i = 1; i <= m; i++) cin >> a[i];
	sort(a + 1, a + m + 1);
	f[m + 1][0] = 1;
	for(int i = m; i >= 1; i--)
		for(int j = 0; j < sn; j++){
			(f[i][j] += f[i + 1][j]) %= mod;
			for(int k = 0; k < n; k++){
				if(j & (1 << k)) continue;
				int p = sn - j - a[i];
				(f[i][j + (1 << k)] += 1ll * f[i + 1][j] * C(p, (1 << k) - 1) % mod * fac[1 << k] % mod) %= mod;
			}
		}
	for(int i = 0; i < sn; i++) {
		digit[i] = digit[i >> 1] + (i & 1);
		f[1][i] = 1ll * f[1][i] * fac[sn - i - 1] % mod;
		if(digit[i] % 2 == 0) ans = (ans + f[1][i]) % mod;
		else ans = (ans + mod - f[1][i]) % mod;
	}
	cout << 1ll * ans * sn % mod<< endl;
	return 0;
}

Measured memory_bytes: 8320