akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch WeatherPrediction | diff WeatherPrediction.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address WeatherPrediction.cpp && ./a.out

/*
 
 9/15/2019
 
 5:00-
 
 */

string S;

void solve() {
  string res;
  if(S=="Sunny") res="Cloudy";
  if(S=="Cloudy") res="Rainy";
  if(S=="Rainy") res="Sunny";
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}



int main() {
  ll N; cin >> N;
  ll a[N+1],b[N];
  rep(i,N+1) cin >> a[i];
  rep(i,N) cin >> b[i];
  ll ans = 0;
  rep(i,N) {
    ans += min(a[i],b[i]);
    b[i] -= min(a[i],b[i]);
    ans += min(a[i+1],b[i]);
    a[i+1] -= min(a[i+1],b[i]);
  }
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
static int n, k, x, i, sum;
int abs(int x) {
    return x >= 0 ? x : -x;
}
int min(int x, int y) {
    return x <= y ? x : y;
}
int main(void) {
    scanf("%d%d", &n, &k);
    for (i = 0; i < n; ++i) {
        scanf("%d", &x);
        sum += 2 * min(x, abs(k - x));
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

//繰り返し二乗法
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}

struct perm{
private:
    int sz;
    vector<ll> p,invp;
public:
    perm(int n){
        sz=n+1;
        p.resize(sz),invp.resize(sz);
        p[0]=1;
        for(int i=1;i<=sz-1;i++){
            p[i]=p[i-1]*i%mod;
        }
        invp[sz-1]=power(p[sz-1],mod-2);
        for(int i=sz-2;i>=0;i--){
            invp[i]=invp[i+1]*(i+1)%mod;
        }
    }
    ll comb(ll x,ll y){
        if(x<y||y<0)return 0;
        return (p[x]*invp[x-y]%mod)*invp[y]%mod;
    }
};
perm p(1<<20);

int main(){
    ll h,w,a,b; cin >> h >> w >> a >> b;
    ll ans=0;
    for(int i=0;i<h-a;i++){
        ll res=1;
        res*=p.comb(i+b-1,b-1)%mod;
        res*=p.comb(h-1-i+w-1-b,w-1-b)%mod;
        (ans+=res)%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n>>m;
    ll A[m][2];
    for(i=0;i<m;i++){
        cin>>A[i][0]>>p;
        c=0;
        for(j=0;j<p;j++){
            cin>>x;
            x--;
            c=c|(1<<x);
        }
        A[i][1]=c;
    }
    p=power(2,n);
    ll B[m][p];
    for(i=0;i<m;i++){
        for(j=0;j<p;j++){
            B[i][j]=1e15;
        }
    }
    B[0][0]=0;
    B[0][A[0][1]]=A[0][0];
    for(i=1;i<m;i++){
        for(j=0;j<p;j++){
            B[i][j]=B[i-1][j];
        }
        for(j=0;j<p;j++){
            x=j|A[i][1];
            B[i][x]=min(B[i][x],B[i-1][j]+A[i][0]);
        }
    }
    x=1e15;
    if(B[m-1][p-1]>=x){
        cout<<-1;
    }
    else{
        cout<<B[m-1][p-1];
    }
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 32256
"""
同じ日に購入オペレーションと売却オペレーションを行う意味がない。
買うときは、買えるだけ買う方がよい。
売る時は売れるだけ売る方がよい。

まず１日目、株を買うかどうか判断する。
翌日以降の連続する日付の中で、
"""

N = int(input())
A = list(map(int,input().split()))
M = 1000
stock = 0
buyPrice = 0
for i in range(N):
    if stock and A[i] >= buyPrice:
        #翌日の価格が今より高ければステイ。そうでなければ売る。
        if i==N-1 or A[i] >= A[i+1]:
            M += stock*A[i]
            stock = 0
    else:
        #翌日の価格が今より安ければステイ。そうでなければ買う。
        if i!=N-1 and A[i] < A[i+1]:
            stock += M//A[i]
            M %= A[i]
            buyPrice = A[i]
print(M)


Measured memory_bytes: 61796
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

// graph template
template<typename T>
class edge{
    public:
        int src, to; T cost;

        edge(int to, T cost): src(-1), to(to), cost(cost){}
        edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

template<typename T>
void warshall_floyd(Matrix<T> &g, T INF){
    for(int k = 0; k < (int)g.size(); k++){
        for(int i = 0; i < (int)g.size(); i++){
            for(int j = 0; j < (int)g.size(); j++){
                if(g[i][k] == INF or g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int main(void){
    int H, W;
    cin >> H >> W;
    
    Matrix<int> mat(10, vector<int>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> mat[i][j];
        }
    }

    warshall_floyd(mat, INF);

    int res = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int A; cin >> A;
            if(A == -1) continue;
            else res += mat[A][1];
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int T, X;
    cin >> T >> X;

    cout << setprecision(10) << double(T) / double(X) << endl;

    return 0;
}


Measured memory_bytes: 256
($N,$M)=glob<>;
@@=(9e9)x2**$N;$@[0]=0;
$A=<>,$i=$C=0,map($C|=1<<$_-1,glob<>),map$@[$i|$C]-=$-=$@[$i++|$C]-$A-$_,@@for 1..$M;
print$@[-1]<9e9?$@[-1]:-1

Measured memory_bytes: 1280
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007
#define INF (1e9)
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;


int main()
{
    ll K;
    cin >> K;
    print((K/2) * ((K+1)/2));
    return 0;
}


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

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int main(){
	int N, i, ans = 0;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	int *B = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		B[i] = A[i];
	}
	sort(B, N);
	int l, h, r;
	for(i = 0; i < N; i += 2){
		l = -1;
		r = N;
		while(r - l > 1){
			h = (l + r) / 2;
			if(B[h] >= A[i]){
				r = h;
			}
			else{
				l = h;
			}
		}
		ans += r % 2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1280
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);
    cout << g * (a / g) * (b / g) << '\n'; 
    return 0;
}


Measured memory_bytes: 256
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

fn main() {
    input!{
        n: usize,
        a_v: [i64; n],
    }

    let ans = a_v.iter()
        .fold(0, |acc, x| acc + x - 1);

    println!("{}", ans);
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 052 B / Link: http://abc052.contest.atcoder.jp/tasks/abc052_b  ----- */


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

	LL N; cin >> N;
	string s; cin >> s;
	LL ans = 0LL;
	LL ret = 0;
	FOR(i, 0, SZ(s)) {
		if (s[i] == 'I')ret++;
		else ret--;
		ans = max(ans, ret);
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

int main(){

    string s; cin >> s;
    ll q; cin >> q;
    ll t;
    bool r = false;
    string back, front;
    rep(i, q){
        cin >> t;
        if(t==1){
            r ^= true;
        }
        if(t==2){
            ll f; cin >> f;
            char c; cin >> c;
            if(r){
                if(f==1){
                    back = back + c;
                }
                if(f==2){
                    front = front + c;
                }
            }
            else{
                if(f==1){
                    front = front + c;
                }
                if(f==2){
                    back = back + c;
                }
            }
        }
    }

    reverse(all(front));
    s = front + s + back;
    if(r) reverse(all(s));

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 4656
#include "bits/stdc++.h"
using namespace std;

int main() {
	// your code goes here
	long long int n,i,c=0;
	cin>>n;
	string s;
	cin>>s;
	if(n%2!=0)
	{
		cout<<"No"<<endl;
	}
	else
	{
		for(i=0;i<n/2;i++)
		{
			//cout<<s[i]<<" "<<s[n/2  + i]<<endl; 
			if(s[i]!=s[n/2 + i])c=1;
		}
		if(c==0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

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

int dp[1002][1002];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while (cin >> n, n) {
        int ret = 0;
        char sign;
        for (int i=1; i<=n; ++i) {
            for (int j=1; j<=n; ++j) {
                cin >> sign;
                if (sign == '.') {
                    dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                    ret = max(ret, dp[i][j]);
                } else {
                    dp[i][j] = 0;
                }
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){

    int n, m, x; cin >> n >> m >> x;
    int cnt1 = 0;
    int cnt2 = 0;
    for(int i = 0; i < m; i++){
        int a; cin >> a;
        if(a < x) cnt1++;
        else cnt2++;
    }

    cout << min(cnt1, cnt2) << endl;
    
    return 0;
}



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec L(N);
  ll S = 0;
  rep(i, N){
    cin >> L[i];
    S += L[i];
  }
  bool ans = true;
  rep(i, N){
    ans = ans and (S-L[i])>L[i];
  }
  cout <<(ans?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
            ans++;
    }
    cout << ans << endl;
}


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

const bool DEBUG = false;

int N, M;
vector<pair<int, int>> candidates;

void input() {
  cin >> N >> M;
  int a, b;
  candidates = vector<pair<int, int>>(N);
  for (size_t i = 0; i < N; i++) {
    cin >> a >> b;
    candidates[i] = make_pair(a, b);
  }
}

int main(int argc, char const *argv[]) {
  input();

  sort(candidates.begin(), candidates.end());

  priority_queue<int> buffer;

  int index = 0;
  long long total = 0;
  for (int m = 1; m <= M; m++) {
    while (index < N && candidates[index].first <= m) {
      if (DEBUG)
        cout << m << ", " << index << ", " << candidates[index].second << endl;
      buffer.push(candidates[index].second);
      index++;
    }
    if (buffer.size() == 0) continue;
    total += buffer.top();
    buffer.pop();
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 1660
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

#if (10 ** 18 + 1) in A
#    print(-1)
#    exit()

ans = 1
for i in A:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;

int main(){
  string n;
  cin >>n;

  for(int i=0; i<n.size(); i++){
    if(n.at(i)=='7') {
      cout << "Yes" <<endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A;
        if((A%2)&&(i%2))B++;
    }

    cout << B;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, in[10][3];
void out(int t){
	printf("%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60);
}

int main(){
	map<vi, vi> a;
	rep(i, 3600 * 12){
		int h = i / 12 / 60 % 60;
		int m = i / 60 % 60;
		int s = i % 60;
		vi v; v.pb(h); v.pb(m); v.pb(s);
		a[v].pb(i);
	}
	each(i, a){
		sort(all(i->second));
		i->second.erase(unique(all(i->second)), i->second.end());
	}
	while(cin >> n, n){
		vector<vi> cand;
		rep(i, n){
			rep(j, 3) cin >> in[i][j];
			sort(in[i], in[i] + 3);
			vi c;
			do{
				rep(j, 60){
					vi v;
					rep(k, 3) v.pb((in[i][k] + j) % 60);
					each(k, a[v]) c.pb(*k);
				}
			}while(next_permutation(in[i], in[i] + 3));
			sort(all(c));
			c.erase(unique(all(c)), c.end());
			cand.pb(c);
		}
		int mn = inf, mni = inf;
		rep(x, n) rep(y, n) if(x != y){
			each(a, cand[x]) each(b, cand[y]) if(*a <= *b){
				rep(i, n){
					int j = lower_bound(all(cand[i]), *a) - cand[i].begin();
					if(j >= cand[i].size() || cand[i][j] > *b) goto FAIL;
				}
				if(mn > *b - *a || mn == *b - *a && mni > *a) mn = *b - *a, mni = *a;
				FAIL:;
			}
		}
		out(mni); putchar(' '); out(mni + mn); puts("");
	}
	
	return 0;
}

Measured memory_bytes: 11984
#include <stdio.h>

int	main(void)
{
	int n;
	scanf("%d", &n);
	int a[n];
	int i = 0;
	int count = 0; //to count repeat
	while (i < n)
	{
		scanf("%d", &a[i]);
		i++;
	}
	i = 0;
	while (a[i] % 2 == 0)
	{
		a[i] /= 2;
		i++;
		if (i == n)
		{
			i = 0;
			count++;
		}
	}
	printf("%d\n", count);
	return (0);
}


Measured memory_bytes: 128
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

long long s;

bool read() {
  if (scanf("%lld", &s) < 1) {
    return false;
  }
  return true;
}

void solve() {
  long long x0 = (int) 1e9;
  long long y1 = (s + x0 - 1) / x0;
  long long y0 = x0 * y1 - s;
  long long x1 = 1;
  printf("%lld %lld %lld %lld %lld %lld\n", 0ll, 0ll, x0, y0, x1, y1);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
if (N%100)%10 == 3:
    print('bon')
elif (N%100)%10 == 0 or (N%100)%10 ==1 or (N%100)%10 ==6 or (N%100)%10 ==8:
    print('pon')
else:
    print('hon')

Measured memory_bytes: 61820
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
        }
        Arrays.sort(A);
        if (A[0] == 0) {
            System.out.println(0);
            return;
        }
        BigInteger ans = BigInteger.ONE;
        BigInteger limit = BigInteger.valueOf(1000000000000000000L);
        for (int i = 0; i < N; i++) {
            ans = ans.multiply(BigInteger.valueOf(A[i]));
            if (ans.compareTo(limit) > 0) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(ans.toString());
    }
}


Measured memory_bytes: 61816
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << min(a+b,min(a+c,b+c)) << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <functional>
#include <queue>
#include <utility>
using namespace std;

template <typename Value, typename Time, typename Compare = less<Value>>
class slidemin {
private:
    deque<pair<Value, Time>> deq;
    const Compare compare;

public:
    slidemin(Compare cmp = Compare()): compare(cmp) {}

    void push(Value val, Time t) {
        while(!deq.empty() && !compare(deq.back().first, val)) deq.pop_back();
        deq.emplace_back(val, t);
    }

    void pop(Time t) {
        while(!deq.empty() && deq.front().second < t) deq.pop_front();
    }

    pair<Value, Time> getmin() {
        return deq.front();
    }
};

#include <iostream>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, L; cin >> N >> L;
    slidemin<int, int> smin;

    for(int i=0; i<N; ++i) {
        int a; cin >> a;
        smin.push(a, i);
        smin.pop(max(i + 1 - L, 0));
        if(i + 1 >= L) cout << smin.getmin().first << (i + 1 == N ? '\n' : ' ');
    }
}


Measured memory_bytes: 3216
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n;
	cin >> n;
	vector < int > v(n), c(n);
	for (auto &el: v) {
		cin >> el;
	}
	for (auto &el: c) {
		cin >> el;
	}
	int mn = -INF;
	for (int i = 0; i < (1 << n); ++i) {
		int x = 0, y = 0;
		for (int j = 0; j < n; ++j) {
			if (i & (1 << j)) {
				x += v[j];
				y += c[j];
			}
		}
		if (x - y > mn) {
			mn = x - y;
		}
	}
	cout << mn << "\n";
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int H, W;
bool dp[80][80][12801];

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


	cin >> H >> W;
	int AB[80][80];
	rep(i, H) rep(j, W) {
		cin >> AB[i][j];
	}
	rep(i, H) rep(j, W) {
		int b;
		cin >> b;
		AB[i][j] -= b;
		AB[i][j] = abs(AB[i][j]);
	}

	bool kita[80][80] = {};
	queue<pair<int, int>> q;
	q.push(mp(0, 0));
	dp[0][0][0] = 1;
	
	while (q.size()) {
		auto hw = q.front();
		q.pop();
		int h = hw.first;
		int w = hw.second;

		if (kita[h][w]) continue;
		kita[h][w] = 1;
		if (h + 1 < H) rep(i, 12801) if (dp[h][w][i]) {
			dp[h + 1][w][i + AB[h][w]] = 1;
			dp[h + 1][w][abs(i - AB[h][w])] = 1;
		}
		if (w + 1 < W) rep(i, 12801) if (dp[h][w][i]) {
			dp[h][w + 1][i + AB[h][w]] = 1;
			dp[h][w + 1][abs(i - AB[h][w])] = 1;
		}

		if (h + 1 < H) q.push(mp(h + 1, w));
		if (w + 1 < W) q.push(mp(h, w + 1));
	}

	bool kotae[12800] = {};
	rep(i, 12801) if (dp[H - 1][W - 1][i]) {
		kotae[i + AB[H - 1][W - 1]] = 1;
		kotae[abs(i - AB[H - 1][W - 1])] = 1;
	}

	rep (i, 12800) {
		if (kotae[i]) {
			co(i);
			break;
		}
	}
	


	Would you please return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = {0,1,0};

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{
	int n,a;
	cin >> n >> a;

	if (n % 500 <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}



Measured memory_bytes: 256
package main
 
import (
	"fmt"
	"math"
)
 
func main() {
	var S string
	fmt.Scan(&S)
	N, MOD := 13, int(math.Pow(10, 9))+7
	dp, k := make([]int, N), 1
 dp[0] = 1
	for i := len(S) - 1; i >= 0; i-- {
		dp2 := make([]int, N)
	 if S[i] == '?' {
			for d := 0; d <= 9; d++ {
				for n := 0; n < N; n++ {
					index := (k*d + n) % N
					dp2[index] += dp[n]
					dp2[index] %= MOD
				}
			}
		} else {
			d := int(S[i] - '0')
			for n := 0; n < N; n++ {
				index := (k*d + n) % N
				dp2[index] += dp[n]
				dp2[index] %= MOD
			}
		}
		dp = dp2
		k *= 10
		k %=  N
	}
	fmt.Println(dp[5])
}

Measured memory_bytes: 5504
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b, c, d = (int(x) for x in list(sys.stdin.readline().rstrip()))
    s = 7 - a
    if sum([b, c, d]) == s: res = '+++'
    elif sum([-b, c, d]) == s: res = '-++'
    elif sum([b, -c, d]) == s: res = '+-+'
    elif sum([b, c, -d]) == s: res = '++-'
    elif sum([-b, -c, d]) == s: res = '--+'
    elif sum([-b, c, -d]) == s: res = '-+-' 
    elif sum([b, -c, -d]) == s: res = '+--'
    if res[0] == '-': b = -b
    if res[1] == '-': c = -c
    if res[2] == '-': d = -d
    ans = [str(a)]
    for x in [b, c, d]:
        if x >= 0 : x = '+' + str(x)
        else: x = str(x)
        ans.append(x)
    print(''.join(ans) + '=7')


if __name__ == "__main__":
    # execute only if run as a script
    main()


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int D = 2*C;
  
  long long a, b, c;
  a = A*X + B*Y;
  if (X > Y) {
    b = D*Y + A*(X - Y);
    c = D*X;
  } else {
    b = D*X + B*(Y - X);
    c = D*Y;
  }
  
  if (a < b) {
    if (a < c) {
      cout << a << endl;
    } else {
      cout << c << endl;
    }
  } else {
    if (b < c) {
      cout << b << endl;
    } else {
      cout << c << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

int main(){
    int n, k;
    cin >> n >> k;
    VI a(n);
    rep(i,n) cin >> a[i];
    int ans = 1;
    n -= k;
    ans += (n + (k-2)) / (k-1);
    view(ans);
    return 0;
}

Measured memory_bytes: 3628
N, Q = gets.split.map(&:to_i)
S = gets.chomp!

list = Array.new(N, 0)
i = 0
temp = ""
S.chars.each do |word|
    if i != 0 then
        if temp == "A" && word == "C" then
            list[i] = list[i - 1] + 1
        else
            list[i] = list[i - 1]
        end
    end
    temp = word
    i = i+1
end

Q.times do
    l, r = gets.split.map(&:to_i)
    puts list[r - 1] - list[l - 1]  
end


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	
	int count = 0;
	bool found = false;
	
	while(n --)
	{
	    int d1,d2;
	    cin>>d1>>d2;
	    
	    if(d1 == d2)
	      count++;
	    else
	      count = 0;
	      
	    if(count == 3)
	     {
	         found = true;
	         break;
	     }
	      
	}
	
	
	if(found)
	 cout<<"Yes\n";
	else
	 cout<<"No\n";
	 
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,m,k,a,b;
  cin >> n >> m >> k;
  for (a=0;a<=n;a++){
    for (b=0;b<=m;b++) if (a*(m-b)+(n-a)*b==k) break;
    if (b!=m+1) break;
  }
  if (a!=n+1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int S = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long[][] dp = new long[N][S+1];
         dp[0][0] = 2L;
         if(arr[0] <= S)
            dp[0][arr[0]] = 1L;
         for(int i=1; i < N; i++)
            for(int v=0; v <= S; v++)
            {
               dp[i][v] += (dp[i-1][v]*2)%MOD;
               dp[i][v] %= MOD;
               if(v+arr[i] <= S)
               {
                  dp[i][v+arr[i]] += dp[i-1][v];
                  dp[i][v+arr[i]] %= MOD;
               }
            }
         System.out.println(dp[N-1][S]);
      }
   }

Measured memory_bytes: 104000
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int A, B, C, X;

void solve(){
	int ans = 0;
	rep(i, A + 1)
		rep(j, B + 1)
			rep(k, C + 1)
				if(i * 500 + j * 100 + k * 50 == X)
					ans++;
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B >> C >> X;
		solve();
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

char board[110][110];
	
int main(void){
	int a, b, parity = 0;
	cin >> a >> b;
	cout << 100 << " " << 100 << endl;
	if (a == 1) {
		while (parity <= 100) {
			parity++;
			for (int i = 1;i <= 100;i++) {
				if (b > 0) {
					if (i & 1) {
						board[parity][i] = '.';
					}
					else {
						board[parity][i] = '#';
						b--;
					}
				}
				else {
					board[parity][i] = '.';
				}
			}
			parity++;
			for (int i = 1;i <= 100;i++)board[parity][i] = '.';
		}
		for (int i = 1;i <= 100;i++) {
			for (int j = 1;j <= 100;j++) {
				cout << board[i][j];
			}
			cout << endl;
		}
		return 0;
	}
	while (a > 1) {
		parity++;
		for (int i = 1;i <= 100;i++) {
			if (a > 1) {
				if (i & 1) {
					board[parity][i] = '.';
					a--;
				}
				else {
					board[parity][i] = '#';
				}
			}
			else {
				board[parity][i] = '#';
			}
		}
		parity++;
		for (int i = 1;i <= 100;i++)board[parity][i] = '#';
	}
	parity++;
	for (int i = 1;i <= 100;i++)board[parity][i] = '.';
	b--;
	if (b == 0) {
		parity++;
		for (int i = parity;i <= 100;i++) {
			for (int j = 1;j <= 100;j++)board[i][j] = '.';
		}
		for (int i = 1;i <= 100;i++) {
			for (int j = 1;j <= 100;j++) {
				cout << board[i][j];
			}
			cout << endl;
		}
		return 0;
	}
	while (parity<=100) {
		parity++;
		for (int i = 1;i <= 100;i++) {
			if (b > 0) {
				if (i & 1) {
					board[parity][i] = '.';
				}
				else {
					board[parity][i] = '#';
					b--;
				}
			}
			else {
				board[parity][i] = '.';
			}
		}
		parity++;
		for (int i = 1;i <= 100;i++)board[parity][i] = '.';
	}
	for (int i = 1;i <= 100;i++) {
		for (int j = 1;j <= 100;j++) {
			cout << board[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  ll n, a, b; cin >> n >> a >> b;
  ll x = n / (a+b);
  ll y = n % (a+b);
  ll res = a * x;
  if(y < a) res += y;
  else res += a;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256