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

using namespace std;

using ll = long long;
using P = pair<int, int>;

typedef vector<vector<int> > Matrix; //隣接行列

const int INF = 1000000000;

Matrix dist;

//trueなら負の閉路を検出
bool warshall_floyd(int n) { //nは頂点数
    for (int k = 0; k < n; k++) { //経由点
        for (int i = 0; i < n; i++) { //始点
            for (int j = 0; j < n; j++) { //終点
                if (dist[i][k] != INF && dist[k][j] != INF) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }

    //負の閉路を検出
    for (int i = 0; i < n; i++) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}

const int dh[] = {1, -1, 0, 0};
const int dw[] = {0, 0, 1, -1};

int solve(int ch, int cw, vector<string>& s) {
    queue<P> q;
    q.emplace(ch, cw);
    int H = s.size(), W = s[0].size();
    vector< vector<int> > dist(s.size(), vector<int>(s[0].size(), INF));
    dist[ch][cw] = 0;
    int maxv = 0;
    while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        q.pop();
        for (int k = 0; k < 4; ++k) {
            int ii = i + dh[k], jj = j + dw[k];
            if (ii < 0 || ii >= H || jj < 0 || jj >= W) continue;
            if (s[ii][jj] == '#') continue;
            if (dist[ii][jj] != INF) continue;
            dist[ii][jj] = dist[i][j] + 1;
            q.emplace(ii, jj);
            maxv = max(maxv, dist[ii][jj]);
        }
    }
    return maxv;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int n = H * W;
    dist.resize(n, vector<int>(n, INF));
    vector<string> s(H);
    for (int i = 0; i < H; ++i) {
        cin >> s[i];
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '#') continue;
            ans = max(ans, solve(i, j, s));
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)

using namespace std;

typedef long long LL;

const int N = 5010;
const int M = 210;

int n, m, b[N][M], a[N], st[N], nxt[M][N], f[M];

LL sa[N];

struct T{ LL x, tg;} t[N * 4];

void up(int x) { t[x].x = max(t[x << 1].x, t[x << 1 | 1].x);}

void pushdown(int x)
{	
	t[x << 1].x += t[x].tg, t[x << 1 | 1].x += t[x].tg;
	t[x << 1].tg += t[x].tg, t[x << 1 | 1].tg += t[x].tg;
	t[x].tg = 0; 
}

void modify(int x, int l, int r, int l0, int r0, LL c)
{
	if (l0 <= l && r <= r0){
		t[x].x += c, t[x].tg += c;
		return;
	}
	pushdown(x);
	int mid = (l + r) >> 1;
	if (l0 <= mid) modify(x << 1, l, mid, l0, r0, c);
	if (r0 > mid) modify(x << 1 | 1, mid + 1, r, l0, r0, c);
	up(x);
}

LL query(int x, int l, int r, int l0, int r0)
{
	if (l0 <= l && r <= r0) return t[x].x;
	pushdown(x);
	int mid = (l + r) >> 1; LL ret = -1e18;
	if (l0 <= mid) ret = query(x << 1, l, mid, l0, r0);
	if (r0 > mid) ret = max(query(x << 1 | 1, mid + 1, r, l0, r0), ret);
	return ret;
}

int main()
{
	//freopen("bar.in", "r", stdin);
	//freopen("bar.out", "w", stdout);
	
	scanf("%d%d", &n, &m);
	
	for (int i = 2; i <= n; i ++) scanf("%d", &a[i]);
	Rep(i, n) Rep(j, m) scanf("%d", &b[i][j]);
	
	Rep(k, m) {
		int top = 0;
		for (int i = n; i; i --) {
			while (top && b[st[top]][k] <= b[i][k]) top --;
			if (top) nxt[k][i] = st[top];
			else nxt[k][i] = n + 1;
			st[++ top] = i;
		}
	}
	
	Rep(i, n) {
		LL sum = 0;
		Rep(k, m){
			f[k] = max(f[k], b[i][k]);
			sum += f[k];
		}
		sa[i] = sa[i - 1] + a[i], sum -= sa[i];
		modify(1, 1, n, i, i, sum);
	}
	
	LL ans = query(1, 1, n, 1, n);
	
	Rep(i, n - 1) {
		Rep(k, m) for (int j = i + 1; j != nxt[k][i]; j = nxt[k][j])
			modify(1, 1, n, j, nxt[k][j] - 1, b[j][k] - b[i][k]);
		LL tmp = query(1, 1, n, i + 1, n) + sa[i + 1];
		ans = max(ans, tmp);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}
/*
4 3
7 4 9
0 1 4
8 2 1
1 6 6
7 5 3
*/

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

const int MAX_SUPPLIERS = 1000;

void Sort(int Array[], int array_num);
void Sort(int Array[][2], int arraynum);
bool BinarySearch(int target, int ar[], int array_num);
bool BinarySearch(int target, int ar[][2], int array_num);

int main()
{
	int lastmonth[MAX_SUPPLIERS],
		thismonth[MAX_SUPPLIERS],
		i=0, j=0, num[MAX_SUPPLIERS][2], samesupnum=0;
	while(true){
		char buf[1024], supplier[256];
		cin.getline(buf, sizeof(buf));
		if(buf[0] == '\0') break;
		for(int k=0; buf[k]!=','; k++){
			supplier[k] = buf[k];
			supplier[k+1] = ' ';
		}
		lastmonth[i] = atoi(supplier);
		for(int k=0; supplier[k] != ' '; k++){
			supplier[k] = ' ';
		}
		i++;
		cin.clear();
	}
	Sort(lastmonth, i);
	while(true){
		char buf[1024], supplier[256];
		cin.getline(buf, sizeof(buf));
		if(buf[0] == '\0') break;
		for(int k=0; buf[k]!=','; k++){
			supplier[k] = buf[k];
			supplier[k+1] = ' ';
		}
		thismonth[j] = atoi(supplier);
		for(int k=0; supplier[k] != ' '; k++){
			supplier[k] = ' ';
		}
		if(BinarySearch(thismonth[j], lastmonth, i)){
			if(!BinarySearch(thismonth[j], num, samesupnum)){
				num[samesupnum][0] = thismonth[j];
				samesupnum++;
				Sort(num, samesupnum);
			}
		}
		j++;
		cin.clear();
	}
	for(int k=0; k<samesupnum; k++){
		num[k][1] = 0;
		for(int l=0; l<i; l++){
			if(num[k][0] == lastmonth[l]) num[k][1]++;
		}
		for(int m=0; m<j; m++){
			if(num[k][0] == thismonth[m]) num[k][1]++;
		}
		cout << num[k][0] << " " << num[k][1] << endl;
	}
	return 0;
}

void Sort(int Array[], int arraynum)
{
	int tmp;
	for(int i=0; i<arraynum; i++){
		for(int j=i; j<arraynum; j++){
			if(Array[j] < Array[i]){
				tmp = Array[i];
				Array[i] = Array[j];
				Array[j] = tmp;
			}
		}
	}
}

void Sort(int Array[][2], int arraynum)
{
	int tmp;
	for(int i=0; i<arraynum; i++){
		for(int j=i; j<arraynum; j++){
			if(Array[j][0] < Array[i][0]){
				tmp = Array[i][0];
				Array[i][0] = Array[j][0];
				Array[j][0] = tmp;
			}
		}
	}
}

bool BinarySearch(int target, int ar[], int array_num)
{
	int L=0, R=array_num-1, M;
	while(L<=R){
		M = (L+R)/2;
		if(ar[M] == target) return true;
		else if(ar[M]<target)L=M+1;
		else R=M-1;
	}
	return false;
}

bool BinarySearch(int target, int ar[][2], int array_num)
{
	int L=0, R=array_num-1, M;
	while(L<=R){
		M = (L+R)/2;
		if(ar[M][0] == target) return true;
		else if(ar[M][0]<target)L=M+1;
		else R=M-1;
	}
	return false;
}

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

int main() {
    ll a;
    string s, t;
    cin >> a >> s;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '.')
            continue;
        t += s[i];
    }
    while (t.size() != 3)
        t += '0';
    ll b = stoi(t);
    cout << a*b / 100 << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n,k;
    cin >> n >> k;
    int a[n];
    int count = 0;
    rep(i,n){
        cin >> a[i];
        if(a[i]<k)count++;
    }
    sort(a,a+n);
    int b[count];
    rep(i,count){
        b[count-1-i] = a[i];
    }
    
    rep(i,count){
        //cout << b[i] << ' ';
    }
    cout << endl;
    
    //cout << count;

    int last = count;
    //cout << last << endl;

    int dp[k] = {};
    int dp2[k] = {};

    rep(i,count){
        rep(j,k){
            dp2[j] = dp[j];
        }
        rep(j,k){
            if(j==b[i]){
                dp2[j] = 1;
            }
            if(dp[j]>0){
                //cout << j << ' ';
                if(j+b[i]>=k){
                    last = count - 1 - i;
                }else{
                    dp2[j+b[i]] = 1;
                }
            }
        }
        rep(j,k){
            dp[j] = dp2[j];
        }
    }


    cout << last << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        int N = readInt();
        int count = 0;
        for (int i = 1; i <= N; i++) {
            if ( readInt() % 2 == 1 && i % 2 == 1) count ++;
        }

        pw.println(count);
        pw.close();
    }
}


Measured memory_bytes: 32828
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int r,c,m;
int fie[51][51];
ll data[51][51][3];
int x[1001],y[1001];
bool used[51][51];
int px[51][51],py[51][51];
ll on[51][51];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void dfs(int x,int y){
	used[x][y]=true;
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>=0 && nx<c && ny>=0 && ny<r){
			if(fie[nx][ny]==0 && !used[nx][ny]){
				px[nx][ny]=x;
				py[nx][ny]=y;
				dfs(nx,ny);
			}
		}
	}
}

int main(void){
	scanf("%d %d %d",&r,&c,&m);
	for(int i=0;i<r;i++){
		string str;
		cin >> str;
		for(int j=0;j<c;j++){
			if(str[j]=='.')fie[j][i]=0;
			else fie[j][i]=-1;
		}
	}
	for(int k=0;k<3;k++){
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				scanf("%d",&data[j][i][k]);
			}
		}
	}
	for(int i=0;i<m;i++){
		scanf("%d %d",&y[i],&x[i]);
	}
	vector<P> route;
	route.push_back(P(x[0],y[0]));
	for(int i=1;i<m;i++){
		memset(used,false,sizeof(used));
		dfs(x[i-1],y[i-1]);
		vector<P> go;
		P p=P(x[i],y[i]);
		while(p.first!=x[i-1] || p.second!=y[i-1]){
			go.push_back(p);
			P np;
			np.first=px[p.first][p.second];
			np.second=py[p.first][p.second];
			p=np;
		}
		reverse(go.begin(),go.end());
		for(int i=0;i<go.size();i++){
			route.push_back(go[i]);
		}
	}
	ll res=0;
	memset(on,-1,sizeof(on));
	for(int i=0;i<route.size();i++){
		int nx=route[i].first,ny=route[i].second;
		if(on[nx][ny]==-1){
			res+=data[nx][ny][1];
			on[nx][ny]=i;
		}else{
			res+=min(data[nx][ny][1]+data[nx][ny][2],data[nx][ny][0]*(ll)(i-on[nx][ny]));
			on[nx][ny]=i;
		}
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(on[j][i]!=-1)res+=data[j][i][2];
		}
	}
	printf("%lld\n",res);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

bool kaibun(string s) {
  int len = s.size();
  rep(i,len/2) {
    if(s.at(i) != s.at(len - i - 1)) {
      return false;
    }
  }
  return true;
}

int main() {
	string s;
	cin >> s;
  int len = s.size();
  bool first = kaibun(s);
  bool second = kaibun(s.substr(0, (len-1)/2));
  bool third = kaibun(s.substr((len+1)/2, (len-1)/2));
  if(first && second && third) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main()
{
    int m=0, f=0, r=0;
    
    while(1){
        cin >> m >> f >> r;
        if(m==-1&&f==-1&&r==-1) return 0;
        
        if(m==-1||f==-1) cout << "F" << endl;
        else if(m+f>=80) cout << "A" << endl;
        else if(m+f>=65) cout << "B" << endl;
        else if(m+f>=50) cout << "C" << endl;
        else if(m+f>=30)
            if(r>=50) cout << "C" << endl;
            else cout << "D" << endl;
        else cout << "F" << endl; 
    }
}


Measured memory_bytes: 3092
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


left, right = MI()
if right - left >= 2019:
    print(0)
else:
    ans = INF
    for i in range(left, right+1):
        for j in range(i+1, right+1):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                print(0)
                exit()
    print(ans)
            


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

int main(int argc, char *argv[])
{
    const double PI = 3.141592653589793;
    double r;
    cin >> r;

    double l = 2 * PI * r;
    double a = (l * r) / 2;
    cout << fixed << setprecision(5) << a << " " << l << endl;

    return 0;
}

Measured memory_bytes: 3292
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int i,j;
  for(i=0;i<N;i++)cin >> S[i];
  sort(S.begin(),S.end());
  int cnt = 1;
  bool f;
  for(i=1;i<N;i++) {
    f = (S[i].length() == S[i-1].length());
    for(j=0;f && j<S[i].length();j++) {
      if(S[i][j] != S[i-1][j])f = false;
    }
    if(!f)cnt++;
  }
  cout << cnt << endl;
}

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

void PrintVector(const vector<string> &vec){
    for(const string s:vec){
        cout<<s;
    }
    cout<<"\n";
}

void test(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H = 0;//m
    int W = 0;//houses

    cin >> H;
    cin >> W;
    vector<string> A(H);
    vector<string> header(W+2,"#");
    int k=0;
    while (cin >> A[k]) {
        k++;
    }

    PrintVector(header);
    for (int i = 0; i <A.size() ; ++i) {
        cout<<"#";
        cout<<A[i];
        cout<<"#"<<"\n";
    }
    PrintVector(header);
}


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




Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    rep(i, k) ans += a[i];
    print(ans);




}


Measured memory_bytes: 3652
def main():
    N, K = map(int, input().split())
    ans = 0
    for n in range(1, N + 1):
        s = n
        c = 0
        while K > s:
            s *= 2
            c += 1
        ans += (1 / N) * (1 / 2) ** c
    print(ans)


main()


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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	str st;
	cin >> st;
	cin >> t;
	deque <char> g;
	char p;
	deque <char> :: iterator it;
	for(i=0;i<st.size();i++)
	{
		g.push_back(st[i]);
	}
	j=1;
	while(t--)
	{
		cin >> a;
		if(a==2)
		{
			cin >> b >> p;
			if(j>0)
			{
				if(b==1)
					g.push_front(p);
				else
					g.push_back(p);
			}
			else
			{
				if(b==1)
					g.push_back(p);
				else
					g.push_front(p);
			}
		}
		else
		{
			j*=-1;
		}
	}
	if(j>0)
	{
		for(it=g.begin();it!=g.end();it++)
		{
			cout << *it;
		}
	}
	else
	{
		for(it=g.end()-1;it>=g.begin();it--)
		{
			cout << *it;
		}
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int N;
int A[210000];

int main(void){

    cin >> N; 
    for (int i = 0;i < N;i++) cin >> A[i];

    int Sum = 0;
    for (int i = 0;i < N;i++) Sum = Sum ^ A[i];

    int Ans;
    for (int i = 0;i < N;i++){
        Ans = Sum ^ A[i];
        cout << Ans << " ";
    } 
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 4372
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include<random>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

int ar[400500];
int check(int pos, int n) {
    int ans = pos;
    for (int i = pos; i < n; ++i) {
        ans = i;
        if (ar[i + 1]) {
            continue;
        }
        if (ar[i + 2]) {
            ++i;
            continue;
        }
        break;
    }
    return ans;
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
    //  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    --a, --b, --c, --d;
    assert(n < 400500);
    assert(a < b);
    forn(i, n) {
        char q;
        cin >> q;
        ar[i] = (q == '.');
    }
    if (c < d) {
        a = check(a, n);
        b = check(b, n);
        if (a >= c && b >= d)
            cout << "Yes";
        else
            cout << "No";
        return 0;
    }
    int pos = n;
    for (int i = b; i + 1 < n; ++i) {
        if (i && ar[i - 1] && ar[i] && ar[i + 1]) {
            pos = i;
            break;
        }
    }
    if (check(a, n) < pos - 1 || check(b, n) < pos) {
        cout << "No";
        return 0;
    }
    b = pos, a = pos + 1;
    if (a > c || b > d) {
        cout << "No";
        return 0;
    }
    a = check(a, n);
    b = check(b, n);
    if (a >= c && b >= d)
        cout << "Yes";
    else
        cout << "No";
    return 0;

    return 0;
}

Measured memory_bytes: 1024
h, w, n = map(int, input().split())
sy, sx = map(lambda x: int(x)-1, input().split())
s, t =  input(), input()
l, r, u, d = sx, sx, sy, sy

for i in range(n):
    if s[i] == "L": l -= 1
    elif s[i] == "R": r += 1
    elif s[i] == "U": u -= 1
    else: d += 1
    if l < 0 or r >= w or u < 0 or d >= h:
        print("NO")
        break
    if t[i] == "L" and r > 0: r -= 1
    elif t[i] == "R" and l < w-1: l += 1
    elif t[i] == "U" and d > 0: d -= 1
    elif t[i] == "D" and u < h-1: u += 1
else: print("YES")


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
long long h[100010];
long long dp[100010];

int main(){
int N;cin >> N;
int K;cin >> K;
int h[N];

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

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

dp[0] = 0;

for(int i = 0; i < N; i++){
    for (int j = 1; j <= K; j++){
        chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
    
}

cout << dp[N-1] << endl;

return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#define int long long
#define MOD (long long)(1e9+7)
#define MAX_V (long long)(1e5*2+100)

long long MAX_VAL;
long long fac[MAX_V], mmi[MAX_V], temp[MAX_V];

inline void factorial(){
	fac[0] = fac[1] = 1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}

inline long long power_mod(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

inline void modular_multiplicatibe_inverse(){
	mmi[MAX_VAL-1] = power_mod(fac[MAX_VAL-1],MOD-2);
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

inline long long combination(long long n, long long r){
	return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

signed main(){
	int H, W, A, B, ans = 0;
	cin>>H>>W>>A>>B;
	MAX_VAL = max(W+H-A-2,A+W-1)+100;
	factorial();
	modular_multiplicatibe_inverse();

	for(int i = B+1; i <= W; ans%=MOD,i++)
		ans += combination(i+H-A-2,H-A-1)*combination(A+W-i-1,W-i)%MOD;
	
	cout<<ans<<endl;

}

Measured memory_bytes: 3328
nums = []
flag = True
while flag:
    nums.append(list(map(int, input().split())))
    if nums[-1][0] == nums[-1][1] == 0:
        flag = False
nums.pop()
for num in nums:
    x_set = set()
    for a in range(1, num[0]+1):
        for b in range(1, num[0]+1):
            for c in range(1, num[0]+1):
                if a + b + c == num[1] and a != b and b != c and c != a:
                    x_set.add((a, b, c))
    print(int(len(x_set)/6))



Measured memory_bytes: 6676
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();

    System.out
        .println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos((11 * m - 60 * h) * Math.PI / 360)));

  }

}

Measured memory_bytes: 35976
import functools
import sys
import math
from functools import reduce

input = lambda :sys.stdin.readline()
@functools.lru_cache(maxsize=10000)

def prime_numbers(limit=50001):
    yield 2
    sub_limit = int(limit**0.5)
    flags = [True, True] + [False] * (limit - 2)
    for i in range(3, limit, 2):
        if flags[i]:
            continue
        yield i

        if i <= sub_limit:
            for j in range(i*i, limit, i<<1):
                flags[j] = True

p=list(prime_numbers())


n=int(input())
d=[]
pr=1
for num in p:
    if num<=n:
        exp=1
        s=0
        while n>=num**exp:
            s+=int(n/(num**exp))
            exp+=1
        pr*=(s+1)
        # d.append(s)
    else:
        break
print (pr%1000000007)

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

char str[1010];

void MAIN() {
    scanf("%s", str);
    int n = strlen(str);
    std::vector<bool> x(4);
    for(int i = 0; i < n; ++ i) {
        if(str[i] == 'N') {
            x[0] = true;
        } else if(str[i] == 'S') {
            x[2] = true;
        } else if(str[i] == 'E') {
            x[1] = true;
        } else {
            x[3] = true;
        }
    }
    if((x[0] ^ x[2]) == 1 || (x[1] ^ x[3]) == 1) {
        puts("No");
    } else {
        puts("Yes");
    }
}

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


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

int main(){
	int n,a,b;
	string s;
	cin >> n >> a >> b >> s;
	int ca=0, cb=0;
	for(int i=0; i<n; i++){
		if(s[i]=='a' && ca+cb<a+b){
			cout << "Yes" << endl;
			ca++;
		}else if(s[i]=='b' && ca+cb<a+b && cb<b){
			cout << "Yes" << endl;
			cb++;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 896
import java.io.*;
import java.util.*;

public class Main{

	static int n;
	static double []p;
	static double[][]memo;
	static double dp(int h,int t) {
		int idx=h+t;
		if(idx==n)
			return h>t?1:0;
		if(memo[h][t]!=-1)
			return memo[h][t];
		double ans=p[idx]*dp(h+1,t)+(1-p[idx])*dp(h,t+1);
		return memo[h][t]=ans;
		
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		n=sc.nextInt();
		p=new double[n];
		memo=new double[n+1][n+1];
		for(int i=0;i<n;i++) {
			p[i]=sc.nextDouble();
			Arrays.fill(memo[i],-1);
		}
		Arrays.fill(memo[n], -1);
		out.println(dp(0, 0));
		out.close();
	}
	
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 131408
using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
    private int N, K;
    private int[] A;
    private int Ans = 0;
    private List<int>[] Child;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.IntArray();
        for (int i = 0; i < N; i++)
        {
            A[i]--;
        }

        Child = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            Child[i] = new List<int>();
        }

        for (int i = 1; i < N; i++)
        {
            Child[A[i]].Add(i);
        }

        Ans = A[0] == 0 ? 0 : 1;
        A[0] = 0;
        Height(0);
        Console.WriteLine(Ans);
    }

    private int Height(int pos)
    {
        int result = 0;
        foreach (int i in Child[pos])
        {
            result = Math.Max(result, Height(i));
        }

        result++;

        if (result >= K)
        {
            if(A[pos] != 0)
                Ans++;
            return 0;
        }

        return result;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

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

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

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

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 43168
from sys import stdin
from math import ceil, floor
n = stdin.readline().rstrip()
data = [int(x) for x in stdin.readline().rstrip().split()]
m = sum(data) / len(data)
cm = ceil(m)
fm = floor(m)
ceil_m = floor_m = 0
for i in data:
    ceil_m += (i-cm)**2
    floor_m += (i-fm)**2
print(min(ceil_m, floor_m))

Measured memory_bytes: 9056
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    for(ll i=0;i<n;i+=2){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 3708
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];
    long[] p = readln.split.to!(long[]);
    p[] -= 1;

    auto tree = UnionFind(n);
    foreach (i; 0 .. m)
    {
        tmp = readln.split.to!(long[]);
        long x = tmp[0] - 1, y = tmp[1] - 1;
        tree.unite(p[x], p[y]);
    }

    long cnt;
    foreach (i; 0 .. n)
    {
        if (tree.same(i, p[i])) ++cnt;
    }

    cnt.writeln;
}

struct UnionFind
{
    long[] par;

    this(long n)
    {
        par = new long[n];
        foreach (i; 0 .. n)
        {
            par[i] = i;
        }
    }

    long root(long x)
    {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

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

    void unite(long x, long y)
    {
        x = root(x), y = root(y);
        if (x == y) return;
        par[x] = y;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 5436
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    int arr[] = {a1,a2,a3};
    sort(begin(arr), end(arr));
    cout << (arr[1] - arr[0]) + (arr[2] - arr[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

int main(){

    ll l, r, d;
    cin>>l>>r>>d;

    ll ans = 0;
    for(ll i=l;i<=r;i++){
        if(i%d == 0){
            ans++;
        }
    }

    std::cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(){
int s1,s2,h1,h2;
scanf("%d%d%d%d",&h1,&s1,&h2,&s2);
int flag=-1;
while(flag==-1){
    h2=h2-s1;
    if(h2<=0){
        flag=0;
    }
    h1=h1-s2;
    if((h1<=0)&&(flag!=0)){
        flag=1;
        break;
    }
}
if(flag==0){
    printf("Yes\n");
}
else{
    printf("No\n");
}
return 0;
}


Measured memory_bytes: 1560
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
using namespace std;
const int N = 5e5 + 555;
int dp[N];
void solve()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(!i){
			dp[0] = a[0];
			continue;
		}
		if(i == 1) dp[i] = abs(a[i - 1] - a[i]);
		else if(i == 2) dp[i] = min(abs(a[i - 1]- a[i] + dp[i - 1]), abs(a[i - 2] - a[i]));
		else{
			dp[i] = abs(min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i])));
		}
	}
	
	cout << dp[n - 1];


}

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

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

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    rep(i,N){
        string str = to_string(i+1);
        if(str.length()%2!=0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
  val n = readLine()!!
  var xs = readLine()!!.split(" ").map(String::toInt)

  val quads = xs.filter { it%4 == 0 }.size
  xs = xs.filter { it%4 != 0 } 

  val twices = xs.filter { it%2 == 0 }.size
  xs = xs.filter { it%2 != 0 } 

  val noks = xs.size

  when { 
    (noks - quads) <= 1 && twices == 0  -> "Yes"
    noks <= quads && twices > 0  -> "Yes"
    else -> "No"
  }.run(::println)

  //println( noks -  quads )
}


Measured memory_bytes: 57836
def pathnumber(N, M) : 
  path = [0] * (N + 1)
  for i in range(M) : 
    x, y = tuple(map(int, input().split()))
    path[x] += 1 
    path[y] += 1
  return path

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

path = pathnumber(N, M)

for i in range(1, N + 1) : 
  print(path[i])
  


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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var ans = 0L;
        for (int i = 0; i < n; i++)
        {
            var x = Math.Min(a[i], b[i]);
            a[i] -= x;
            b[i] -= x;
            ans += x;

            x = Math.Min(a[i + 1], b[i]);
            a[i + 1] -= x;
            b[i] -= x;
            ans += x;
        }

        Console.WriteLine(ans);
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  REP(i, s.size()) {
    if (s[i] == '1') s[i] = '9';
    else if (s[i] == '9')  s[i] = '1';
  }
  cout << s << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n;

int fn(int n)
{
    if(n==0)return 1;
    if(n<0)return 0;
    return fn(n-1)+fn(n-2)+fn(n-3);
}

int main()
{
    while(1)
    {
        scanf("%d",&n);
        if(n==0)break;
        printf("%d\n",(((fn(n)+10-1)/10)+365-1)/365);
    }
    return 0;
}

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

using namespace std;

const long long MOD = 1000000007;

bool check(int p, long long W)
{
    for (int i = 1; i <= W-1; ++i) {
        if (((p >> i) & 1) && ((p >> i-1) & 1)) return false;
    }
    return true;
}

void solve(long long H, long long W, long long K)
{
    --W, --K;
    vector<vector<long long>> dp(H+1, vector<long long>(W+1));
    dp[0][0] = 1;
    for (int h = 0; h < H; ++h) for (int w = 0; w <= W; ++w) if (dp[h][w]) {
        for (int p = 0; p < (1<<W); ++p) {
            if (check(p, W)) {
                if (w > 0 && ((p >> (w-1)) & 1)) {
                    (dp[h+1][w-1] += dp[h][w]) %= MOD;
                } else if (w+1 <= W && ((p >> w) & 1)) {
                    (dp[h+1][w+1] += dp[h][w]) %= MOD;
                } else {
                    (dp[h+1][w] += dp[h][w]) %= MOD;
                }
            }
        }
    }
    /*
    for (int h = 0; h <= H; ++h) {
        for (int w = 0; w <= W; ++w) {
            cerr << dp[h][w] << ' ';
        }
        cerr << endl;
    }
    */
    cout << dp[H][K] << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long H;
    cin >> H;
    long long W;
    cin >> W;
    long long K;
    cin >> K;
    solve(H, W, K);
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
def lcm(x, y):
  return (x * y) // gcd(x, y)
def ll(numbers):
  return reduce(lcm, numbers, 1)
def modinv(a):
    return pow(a,m-2,m)
n=int(input())
a=list(map(int,input().split()))
l=ll(a)
x=0
m=10**9+7
lm=l%m
for i in range(n):
  x+=(lm*modinv(a[i]))%m
  x=x%m
print(x)

Measured memory_bytes: 68824
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int a,b;
  cin >> a >> b;
  int c = 1;
  int res = 0;
  while(b > c){
    c += a-1;
    res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
MOD = 10**9+7

if m >= n//2+1:
    print(0)
    exit()

a = [True]*(n+1)
for i in range(m):
    a[int(input())] = False

p = [0]*(n+1)
for i in range(1, n+1):
    if i == 1:
        if a[i]:
            p[i] += 1
        continue
    if i == 2:
        if a[i]:
            p[i] += 1

    if a[i]:
        p[i] += p[i-1] + p[i-2]
        p[i] %= MOD
print(p[n])

Measured memory_bytes: 13496
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif

ll a,b;
cin>>a;
cin>>b;

if(b*2>a){
	cout<<"0"<<endl;
}
else {
	cout<<a-b*2<<endl;
}
return 0;
}

Measured memory_bytes: 504
N,K = map(int, input().split())
A = list(map(int, input().split()))
# S =[1]*N
# for j in range(N-K+1):
#   for i in range(j,K+j):
#     S[j]*=A[i]
#     # print(S[j])
#   if j!=0:
#     if S[j-1]<S[j]:
#       print("Yes")
#     else:
#       print("No")
for i in range(N-K):
  if A[i]<A[i+K]:
    print("Yes")
  else :
    print("No")

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

int main(){
	int N,K;
	string S;
	cin >> N >> K >> S;
	for(int i=0;i<N;i++){
		if(i==K-1)cout << (char)('a'+S[i]-'A');
		else cout << S[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp make_pair
#define pb push_back
#define mes(a,b) memset(a,b,sizeof(a))
#define mes0(a) memset(a,0,sizeof(a))
#define lson l,mid,pos<<1
#define rson mid+1,r,pos<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define sss(a) a::iterator
#define all(a) a.begin(),a.end()

using namespace std;

typedef double DB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<long long ,int> pli;
typedef pair<int,long long > pil;
typedef pair<string,int> psi;
typedef pair<long long ,long long > pll;

const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const int maxn = 100000+10;
const int mod = 1e9+7;
int tree[212345*4];
int y[223456];
pair<int,int> que[223456];
void push_up(int pos)
{
    tree[pos]=max(tree[pos<<1],tree[pos<<1|1]);
}
void upd(int l,int r,int pos,int x,int v)
{
    if (l==r){
        tree[pos]=v;
        return ;
    }
    int mid=(l+r)>>1;
    if (mid>=x)upd(lson,x,v);
    else upd(rson,x,v);
    push_up(pos);
}
int query(int l,int r,int pos,int l1,int r1)
{
    if (l1<=l&&r1>=r){
        return tree[pos];
    }
    int mid=(l+r)>>1;
    int ret=0;
    if (mid>=l1)ret=query(lson,l1,r1);
    if (mid+1<=r1)ret=max(ret,query(rson,l1,r1));
    return ret;
}
int main()
{

    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    if (x1==x2&&y1>y2)swap(y1,y2);
    if (x1>x2)swap(x1,x2),swap(y1,y2);
    int n;
    scanf("%d",&n);
    int tot=0;
    int xx,yy;
    for (int i=0;i<n;i++){
        scanf("%d%d",&xx,&yy);
        if (xx>=min(x1,x2)&&xx<=max(x1,x2)&&yy>=min(y1,y2)&&yy<=max(y1,y2)){
            if (y1<=y2){
                que[tot].fi=xx;
                que[tot].se=yy;
                y[tot++]=yy;
            }else {
                que[tot].fi=xx;
                que[tot].se=-yy;
                y[tot++]=-yy;
            }
        }
    }
    sort(y,y+tot);
    sort(que,que+tot);
    for (int i=0;i<tot;i++){
        int p=upper_bound(y,y+tot,que[i].se)-y;
        upd(1,tot,1,p,query(1,tot,1,1,p)+1);
    }
    int t=tree[1];
    double ans=(abs(x1-x2))*(DB)100+abs(y1-y2)*(DB)100;
    if (t>min(abs(y1-y2),abs(x1-x2)))ans+=(t-1)*pi*10/2-t*20+pi*10;
    else ans+=t*pi*10/2-t*20;
    printf("%.15f",ans);
    return 0;
}


Measured memory_bytes: 4736