akhauriyash/Code-Regression huggingface dataset:
s=input()

def judge_palindrome(x):
	if x==x[::-1]:
		return True
	else:
		return False

if judge_palindrome(s)==True and judge_palindrome(s[:int((len(s)-1)/2)])==True and judge_palindrome(s[int((len(s)+3)/2)-1:])==True:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
vector<string>ans;
auto create(piii temp,int rnk){
    string an = to_string(temp.first);
    string bn = to_string(rnk);
    string a = "",b = "";
    while(a.size() + an.size() < 6)a.push_back('0');
    while(b.size() + bn.size() < 6)b.push_back('0');
    return a + an + b + bn;
}
signed main(){
    int n,m; cin >> n >> m;
    vector<piii>v;
    rep(i,m){
        piii temp; cin >> temp.first >> temp.second.first;
        temp.second.second = i;
        v.push_back(temp);
    }
    sort(all(v));
    ans = vector<string>(m);
    int now = -INF;
    int rnk = 0;
    rep(i,v.size()){
        auto t = v[i];
        ++rnk;
        if(now != t.first){
            now = t.first; rnk = 1; ans[t.second.second] = create(t,rnk);
        } else {
            ans[t.second.second] = create(t,rnk);
        }
    }
    for(auto s : ans)cout << s << endl;
}




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

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

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  double a,b,x;cin >> a >> b >> x;
  if(x<=a*a*b/2){
  double ans=atan2((double)2*x,(double)a*b*b);
  printf("%lf\n",90-ans*180.0/3.1415926535);
  return 0;
  }
  printf("%lf\n",atan2(2*a*a*b-2*x,a*a*a)*180.0/3.1415926535);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  //cout << "!" << endl;
  int n,m;
  while(cin >> m >> n, n){
    //cout << "!" << endl;
    vector <int> a;
    bool c[7368792] = {0};
    for(int i = m;i < 7368792;i++){
      if(!c[i]){
	a.pb(i);
	if(a.size() == n+1){
	  break;
	}
	for(int j = i;j < 7368792;j = j+i){
	  c[j] = true;
	}
      }
      
    }
    /*
    REP(i,100){
      cout << a[i] << endl;
      }*/
    cout << a[n] << endl;
    
  }
  return 0;
}



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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    int count = 0;

    int maxRep = max(A, B);

    vector<int> v = vector<int>();

    rep(i, maxRep + 1)
    {
        if (i == 0)
        {
            continue;
        }

        if (A % i == 0 && B % i == 0)
        {
            v.push_back(i);
        }
    }

    std::cout << v.at(v.size() - K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* 隣接する要素の間に1つの空白を出力 */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{   
    gearup;
    ll n,T; cin >> n >> T;
    vl t(n),v(n);
    rep(i,n)cin>>t[i]>>v[i];
    vvl dp(T+10,vl(n+10)); //dp[i][j] := [1, j]品目まで食べるかを選んで、iの時間がかかったときのおいしさの最大値
    vvl dp2(T+10,vl(n+10)); //dp2[i][j] := [j,n]品目

    dp[0][0] = 0;
    rep(i,T){
        rep(j,n){
            if(t[j] <= i)chmax(dp[i][j+1], dp[i-t[j]][j] + v[j]); //選ぶ
            chmax(dp[i][j+1],dp[i][j]); //選ばない
        }
    }

    dp2[0][n+1] = 0;
	rep(i,T){
		for(int j = n; j >= 1; j--){
			chmax(dp2[i][j],dp2[i][j+1]);
			if (i - t[j - 1] >= 0)chmax(dp2[i][j], dp2[i-t[j-1]][j+1] + v[j-1]);
		}
	}
    ll res = -L_INF;
    rep(i,T){
        rep(j,n){
            chmax(res,dp[i][j] + dp2[T-1-i][j+2] + v[j]);
        }
    }
    out(res);
}

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

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

    string subs;
    int length=0;

    for(int i=0; i<s.size()+1; i++){
        for(int j=0; j<s.size()-i+1; j++){
            bool judge=true;
            subs=s.substr(j,i);
            for(int k=0; k<i; k++){
                if(subs[k]!='A' && subs[k]!='C' && subs[k]!='G' && subs[k]!='T'){
                    judge=false;
                }
            }
            if(judge==true){
                length=i;
            }
        }
    }

    cout<<length<<endl;
}

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

using namespace std;

int n, a, b;

int ap[15];
int stk[15];

int dp[15][2];

void out(int nr)
{
    cout << "-1\n";

    //assert(nr == 0);
    exit(0);
}


void verif()
{
    int i, j;
    for(i = 1; i <= n; i ++)
        dp[i][0] = dp[i][1] = 0;

    int na = 0;
    int nb = 0;
    for(i = 1; i <= n; i ++)
    {
        dp[i][0] = 1;

        for(j = 1; j < i; j ++)
        {
            if(stk[j] < stk[i])
                dp[i][0] = max(dp[i][0], dp[j][0] + 1);
        }

        na = max(na, dp[i][0]);
    }

    for(i = 1; i <= n; i ++)
    {
        dp[i][1] = 1;
        for(j = 1; j < i; j ++)
        {
            if(stk[j] > stk[i])
                dp[i][1] = max(dp[i][1], dp[j][1] + 1);
        }

        nb = max(nb, dp[i][1]);
    }

//    cout << na << " " << nb << "\n";

    if(a != na || b != nb)
        return;

    cout << "DA\n";

    for(i = 1; i <= n; i ++)
        cout << stk[i] << " ";
    cout << "\n";

    exit(0);
}

void bkt(int k)
{
    if(k == n + 1)
    {
        verif();

        return;
    }

    int i;
    for(i = 1; i <= n; i ++)
    {
        if(ap[i] == 0)
        {
            ap[i] = 1;
            stk[k] = i;
            bkt(k + 1);
            ap[i] = 0;
        }
    }
}

void c1()
{
    int i;
    int grup = 1;
    for(i = 1; i <= n; i ++)
    {
        int mn = (n - b) / i + 1;
        int mx = n - b - i + 1 + 1;

      //  cout << i << " " << mn << " " << mx << " " << a << "\n";
        if(a >= mn && a <= mx)
        {
            grup = i;

            break;
        }
    }

    //cout << grup << "\n";

    if(grup > b)
    {
        out(1);
    }

    int bs = 0;
    for(i = 0; i * b + b <= n; i ++)
    {
        if(i + 1 <= a && a <= n - b - i * b + i + 1)
            bs = i;
    }

    int rest = 0;
    if(bs + 1 + (n - b - bs * b) > a)
        rest = bs + 1 + (n - b - bs * b) - a;

    //cout << bs << " " << rest << "\n";

    if(rest > 0)
    if(n - b - bs * b <= rest)
        out(0);

    int nr = 0;
    int catul = rest + (rest > 0);
    for(i = 1; i <= n - b - bs * b - (catul); i ++)
    {
        cout << i << " ";
        nr = i;
    }

    int ult = nr;
    int j;
    if(rest > 0)
    for(j = nr + rest + 1; j >= nr + 1; j --)
        cout << j << " ", ult = max(ult, j);

    for(i = 1; i <= bs; i ++)
    {
        int ant = ult;
        for(j = ult + b; j >= ult + 1; j --)
            cout << j << " ", ant = max(ant, j);

        ult = ant;
    }

    for(i = n; i >= n - b + 1; i --)
        cout << i << " ";
}

void c3()
{
    int i;
    for(i = 1; i < a; i ++)
        cout << i << " ";

    for(i = a; i <= n; i ++)
        cout << n - (i - a) << " ";
    cout << "\n";
}

void solve()
{
    if(a + b <= n)
        c1();

    if(a + b == n + 1)
        c3();
}

int main()
{

    cin >> n >> a >> b;

    if(a == 1 || b == 1)
    {
        if(a + b != n + 1)
            out(1);
    }

    if(a + b > n + 1)
        out(1);

    solve();

   // bkt(1);

    return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

int n;
map<int, int>card;

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		card[a]++;
	}
	int dbnum = 0;
	for (auto c : card)
	{
		dbnum += c.second - 1;
	}
	cout << -(dbnum % 2) + card.size() << endl;
	return 0;
}


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

int main(){
  long n, maxw;
  cin >> n >> maxw;
  
  vector<long> w(n);
  vector<long> v(n);
  long sum = 0;
  for(int i=0; i<n; i++){
    cin >> w[i] >> v[i];
    sum += v[i];
  }

  //重さの最小化
  long MAXJ = 1000000001;
  //価値jを作れる最小の重さ
  vector<vector<long>> dp(n+2, vector<long>(sum+1));
  
  for(long i=0; i<=n; i++){
    for(long j=0; j<=sum; j++){
      dp[i][j] = MAXJ;
    }
  }  
  
  dp[0][0] = 0;
  
  for(long i=0; i<n; i++){
    for(long j=0; j<=sum; j++){
      //i番目を袋に入れた場合の『重さ』
      if(j+v[i]<=sum){
        dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
      }
      //i番目を袋に入れない場合の『重さ』
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }
  
  long ret = 0;
  for(long j=sum; j>=0; j--){
    if(dp[n][j]<=maxw && dp[n][j]>0){
      ret = j;
      break;
    }
  }  
  
  cout << ret << endl;
  
  return 0;
}


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

vector<bool> visited;
vi ans;
vvi to;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, m; std::cin >> n >> m;
    to.resize(n);
    visited.resize(n);
    ans.resize(n, -1);
    rep(i, m) {
        int a, b; std::cin >> a >> b;
        --a, --b;
        to[a].pb(b), to[b].pb(a);
    }
    vi que;
    que.pb(0);
    rep(i, que.size()) {
        for (auto v : to[que[i]]) {
            if (visited[v] || ans[v] != -1) continue;
            visited[v] = true;
            ans[v] = que[i];
            que.pb(v);
        }
    }
    bool ok = true;
    srep(i, 1, n) if (!visited[i]) ok = false;
    if (ok) {
        std::cout << "Yes" << "\n";
        srep(i, 1, n) std::cout << ans[i]+1 << "\n";
    } else {
        std::cout << "No" << "\n";
    }
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3]={};
	for(int i=1;i<=2;++i)scanf("%d",&a[i]);
	if(a[1]<a[2])swap(a[1],a[2]);
	int s=a[1];a[1]-=1;
	if(a[1]<a[2])swap(a[1],a[2]);
	s+=a[1];
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  vi v(4,0);
  rep(i,3){
    int a,b;
    cin>>a>>b;
    v[a-1]++; v[b-1]++;
  }
  bool f=true;
  rep(i,4) if(v[i]==3) f=false;
  if(f) out("YES");
  else out("NO");
}

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


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

int main(){
    string s;
    cin >> s;
    set<char> seq;
    for (auto si:s) seq.insert(si);
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    for (auto a:alpha){
        if (seq.count(a) == 0){
            cout << a << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MM 1e9
#define Pair pair<int,int>

int H,W;
char ary[1001][1001];
int dist[1001][1001];
queue<pair<int, int>> que;
//int dh = { 0,-1, 0, 1};
//int dw = {-1, 0, 1, 0},;

void init(){
    rep(i,0,H) rep(j,0,W) {
        dist[i][j] = MM;
    }
}

void input() {
    cin >> H >> W;
    init();
    rep(i,0,H) rep(j,0,W) {
        cin >> ary[i][j];
        if (ary[i][j] == '#') {
            dist[i][j] = 0;
            que.push(Pair(i,j));
        }
    }
}

void solve(){
    while(que.size()) {
        Pair p = que.front();
        que.pop();
        int h = p.first;
        int w = p.second;
        // 左
        if(w > 0 && dist[h][w-1] == MM){
            dist[h][w-1] = dist[h][w] + 1;
            que.push(Pair(h,w-1));
        }
        // 上
        if(h > 0 && dist[h-1][w] == MM){
            dist[h-1][w] = dist[h][w] + 1;
            que.push(Pair(h-1,w));
        }
        // 右
        if(w < W && dist[h][w+1] == MM){
            dist[h][w+1] = dist[h][w] + 1;
            que.push(Pair(h,w+1));
        }
        // 下
        if(h < H && dist[h+1][w] == MM){
            dist[h+1][w] = dist[h][w] + 1;
            que.push(Pair(h+1,w));
        }
    }
}

void check() {
    int res=0;
    rep (i,0,H) rep (j,0,W) {
        res = max(res,dist[i][j]);
    }
    cout << res << endl;
}

int main() {
    input();
    solve();
    check();
/*
    rep(i,0,H) {
        rep(j,0,W) cout << ary[i][j] ;
        cout << endl;
    }
*/
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    while(true){
        int a, b;
        char op;
        cin >> a >> op >> b;
        if (op == '?') {
            break;
        }else if (op == '+'){
            cout << a + b << endl;
        }else if (op == '-'){
            cout << a - b << endl;
        }else if (op == '*'){
            cout << a * b << endl;
        }else{
            cout << a / b << endl;
        }
    }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  
  for (int i = 0; i < H; i++){
    cin >> A.at(i);
  }
  
  for (int i = 0; i < (W + 2); i++){
    cout << "#";
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++){
    cout << "#" << A.at(i) << "#" << endl;
  }
  
  for (int i = 0; i < (W + 2); i++){
    cout << "#";
  }
  
  cout << endl;
}


Measured memory_bytes: 3632
n, m, c = gets.chomp.split(' ').map(&:to_i)
b = gets.chomp.split(' ').map(&:to_i)
count = 0
n.times do
  a = gets.chomp.split(' ').map(&:to_i)
  sum = 0
  a.each_with_index do |v, i|
    sum += v * b[i]
  end
  sum += c
  count += 1 if sum > 0
end
puts count


Measured memory_bytes: 3836
import java.util.Scanner;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger d = new BigInteger
				("100000000000000000000000000000000000000000000000000000000000000000000000000000000");
		int times = sc.nextInt();
		for(int i = 0; i < times; i++){
			BigInteger a = new BigInteger(sc.next());
			BigInteger b = new BigInteger(sc.next());
			BigInteger c = a.add(b);
			if(c.compareTo(d) == -1){
				System.out.println(c.toString());
			}else{
				System.out.println("overflow");
			}
		}
		sc.close();
	}
}

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

int main() {
    int h,w;
    cin >> h >> w;
    for ( int i=0; i<w+2; i++ ) cout << '#';
    cout << '\n';

    for ( int i=0; i<h; i++ ) {
        cout << '#';
        string s;
        cin >> s;
        cout << s;
        cout << '#' << '\n';
    }

    for ( int i=0; i<w+2; i++ ) cout << '#';
    cout << '\n';

    return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
{a_i}をsortし、a_iのとり得る値の範囲の中でfor
和の最小が答え
*/

int main() {

  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 5000000;

  for (int x = 0 ; x < a.size(); x++) {
    cin >> a.at(x);
  }

  sort(a.begin(),a.end());
  int k = a.at(N-1) - a.at(0) + 1;
  vector<int> min(k);
  k = 0;
  for (int j = a.at(0); j <= a.at(N-1); j++) {
    for (int i = 0; i < N; i++) {
      min.at(k) += (a.at(i)-j)*(a.at(i)-j);
    }
    k++;
  }

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


  cout << min.at(0) << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		long[] A = new long[N + 1];
		long[] B = new long[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i <= N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			B[i] = Long.parseLong(tokens[i]);
		}
		long count = 0;
		for (int i = 0; i < N; ++i) {
			if (A[i] >= B[i]) {
				count += B[i];
				B[i] = 0;
			} else {
				count += A[i];
				B[i] -= A[i];
			}
			if (B[i] > 0) {
				long val = Math.min(A[i + 1], B[i]);
				count += val;
				A[i + 1] -= val;
			}
		}
		System.out.println(count);
	}
}

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

using namespace std;

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if (N <= K) {
		cout << N*X << endl;
	}
	else {
		cout << K*X + (N - K)*Y << endl;
	}

	return 0;
}


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

int main()
{
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}

	int dis_min = k;
	for (int i = 0; i < n; i++) {
		int dis = k;
		// 時計回り
		if (i == 0) {
			dis = k - (k + a.at(i) - a.at(n - 1));
		} else {
			dis = k - (a.at(i) - a.at(i - 1));
		}
		dis_min = min(dis_min, dis);
	}

	cout << dis_min << endl;
}



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

int n;
long long niz[200010];
long long levo[200010];
long long desno[200010];
stack<int> stek;

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

    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> niz[i];

        while(!stek.empty() && niz[stek.top()] > niz[i]){
            stek.pop();
        }

        if(stek.empty()){
            levo[i] = i;
        }
        else{
            levo[i] = i - stek.top();
        }
        stek.push(i);
    }

    while(!stek.empty()){
        stek.pop();
    }

    for(int i = n; i > 0; --i){
        while(!stek.empty() && niz[stek.top()] > niz[i]){
            stek.pop();
        }

        if(stek.empty()){
            desno[i] = n - i + 1;
        }
        else{
            desno[i] = stek.top() - i;
        }
        stek.push(i);
    }

    long long resenje = 0;
    for(int i = 1; i <= n; ++i){
        //cout << levo[i] << " " << desno[i] << "\n";
        resenje += levo[i] * desno[i] * niz[i];
    }
    cout << resenje << "\n";
}


Measured memory_bytes: 5760
package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}



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

using namespace std;


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(m, 0);
    for (int _ = 0; _ < n; _++) {
        int k; cin >> k;
        for (int __ = 0; __ < k; __++) {
            int x; cin >> x;
            x--;
            cnt[x]++;
        }
    }
    int res = 0;
    for (int x: cnt) {
        if (x == n)
            res++;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
n = int(input())
num_list = []
for i in range(n):
    num_list.append(input())

from collections import Counter
checked =  Counter(num_list)
before_count = 0
check_count = 0
result = []
for keyword, count in sorted(checked.items(), key=lambda x: -x[1]):
    if check_count == 0:
        check_count += 1
        result.append(keyword)
        before_count = count
    else:
        if count != before_count:
            break
        else:
            check_count += 1
            result.append(keyword)
            before_count = count

for st in sorted(result):
    print(st)

Measured memory_bytes: 46476
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 1e5 + 100;
vector <pair <int, int>> g[N];

vector <int> vs;

int used[N][3];

void dfs(int v, int k)
{
    //eprintf("v = %d, k = %d\n", v, k);
    used[v][k] = 1;
    vs.push_back(v);

    for (auto p : g[v])
    {
        int nv = p.first;
        int nk = (k + p.second) % 3;
        if (!used[nv][nk])
            dfs(nv, nk);
    }
}

int cnt[8];
int ce[8][8];


int countEdges(int a, int b)
{
    int f = 0, r = 0;
    for (int i = 0; i < 3; i++)
    {
        int j = (i + 1) % 3;
        int h = (i + 2) % 3;
        if (a & (1 << i))
        {
            if (b & (1 << j))
                f = 1;
            if (b & (1 << h))
                r = 1;
        }
    }
    return f + r;
}

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--;
        b--;
        g[a].emplace_back(b, 1);
        g[b].emplace_back(a, 2);
    }
    
    for (int i = 0; i < 8; i++)
        for (int j = i; j < 8; j++)
            ce[i][j] = countEdges(i, j);

    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (used[i][0] || used[i][1] || used[i][2])
            continue;
        vs.clear();
        dfs(i, 0);
        sort(vs.begin(), vs.end());
        vs.resize(unique(vs.begin(), vs.end()) - vs.begin());
   
        int gmask = 0;
        memset(cnt, 0, sizeof cnt);
        for (int v : vs)
        {
            int mask = (used[v][0] | (used[v][1] << 1) | (used[v][2] << 2));
            cnt[mask]++;
            gmask |= mask;
        }

        if (gmask != 7)
        {
            int cur = 0;
            for (int v : vs)
                cur += (int) g[v].size();
            cur /= 2;
            ans += cur;
            continue;
        }

        //eprintf("sz = %d\n", (int) vs.size());

        for (int a = 0; a < 8; a++)
            for (int b = a; b < 8; b++)
            {
                if (!ce[a][b] || !cnt[a] || !cnt[b])
                    continue;
                if (a == b)
                {
                    ans += cnt[a] * 1LL * cnt[a];//ce[a][b] * 1LL * cnt[a] * 1LL * (cnt[a] - 1) / 2;
                    //ans += cnt[a];
                }
                else
                    ans += ce[a][b] * 1LL * cnt[a] * 1LL * cnt[b];
            }
        //eprintf("%lld\n", ans);
    }

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


	return 0;
}




Measured memory_bytes: 26992
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        int cc = 0;

        for(int i=0; i<s.Length; i++) {
            var x = s[i];
            if (i == 0) {
                if (x != 'A') return "WA";
            } else if (2 <= i && i <= s.Length - 1 - 1 && x == 'C') {
                cc++;
            } else {
                if (!('a' <= x && x <= 'z')) return "WA";
            }
        }
        if (cc != 1) return "WA";

        return "AC";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
using namespace std;

int main(void) {
	string s;
	cin >> s;
	if (s.find('C') != -1) {
		if (s.find('F',s.find('C'))!=-1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a+b+c>21) cout << "bust" << endl;
    else cout << "win" << endl;
	return 0;
}

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

int main()
{
    string s, t;
    int len;
    string u[4] = {"dream", "erase", "eraser", "dreamer"};
    cin >> s;

    int i = s.size();
    for (int j = 0; j < 4;)
    {
        len = u[j].size();
        if (i >= len)
        {
            t = s.substr(i - len, len);
            if (t.compare(u[j]) == 0)
            {
                i -= len;
                if (i == 0)
                {
                    cout << "YES" << endl;
                    return 0;
                }
                j = 0;
                continue;
            }
        }
        j++;
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 512
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
def choose(a,b,p,fract):#(aCb)%p
    return ((fract[a]%p)*modinv(fract[b],p)*modinv(fract[a-b],p))%p
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
add=0
sub=0
p=10**9+7
#print(A)
fract=[0]*(10**5+10)
buf=1
fract[0]=1
for i in range(1,10**5+10):
    fract[i]=(fract[i-1]*i)%p
    #print(fract[i])
for i in range(N-1,-1,-1):
    #print(A[i],i-K+2)
    if i>=K-1:
    #add=add+A[i]*(i-K+2)
        #print(i,K-1)
        #print((A[i]*choose(i,K-1,p,fract))%p)
        add=(add+(A[i]*choose(i,K-1,p,fract))%p)%p
    else:
        break
#print(add)
for i in range(0,N,1):
    if K-1<=(N-1)-i:
        #print(N-1-i, K-1)
        sub=(sub+(A[i]*choose(N-1-i,K-1,p,fract))%p)%p
    else:
        break
    #input()
print((add-sub)%p)

Measured memory_bytes: 71592
def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    d = {'r':P, 's':R, 'p':S}
    T = input()
    a = 0
    for j in range(K):
        prev = None
        for i in range(j, N, K):
            if prev != T[i]:
                a += d[T[i]]
                prev = T[i]
            else:
                prev = None
    return a

print(main())


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

int* t;
int n,m,q;
int *a,*b,*c,*d;
int mx;
void f(int p){
  if(p==n){
    int s=0;
    for(int i=0;i<q;i++){
      if(t[b[i]]-t[a[i]]==c[i])s+=d[i];
    }
    if(s>mx){
      mx=s;
    }
  }else{
    for(int i=t[p-1];i<=m;i++){
      t[p]=i;
      f(p+1);
    }
  }
}
int main(){
  cin>>n>>m>>q;
  a=new int[q];
  b=new int[q];
  c=new int[q];
  d=new int[q];
  for(int i=0;i<q;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;b[i]--;
  }
  t=new int[n]{};
  mx=-1;
  for(int i=1;i<=m;i++){
    t[0]=i;
    f(1);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 3640
# AGC033A - Darker and Darker
# https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.distance_transform_cdt.html
from scipy.ndimage import distance_transform_cdt as dist


def main():
    """
    distance_transform_cdt(matric="taxicab"):
        1 1 1    2 1 2
        1 0 1 -> 1 0 1
        1 1 1    2 1 2
    """
    _, _, *A = open(0).read().split()
    B = tuple(tuple(1 if i == "." else 0 for i in a) for a in A)
    D = dist(B, metric="taxicab")
    print(D.max())


if __name__ == "__main__":
    main()

Measured memory_bytes: 48896
def ints():
  return [int(x) for x in input().split()]
def readi():
  return int(input())

N = readi()
G = [[] for _ in range(N)]
E = {}

for i in range(N-1):
  a, b = ints()
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
  E[(a, b)] = i

C = [0]*(N-1)
S = [(0, None, None)]
max_color = 0
while len(S)>0:
  node, from_node, from_color = S.pop()

  c = -1
  for n in G[node]:
    if n==from_node:
      continue
    c += 1
    if c==from_color:
      c += 1

    max_color = max(max_color, c)
    C[E[(min(n, node), max(n, node))]] = c
    S.append((n, node, c))

print(max_color+1)
for i in C:
  print(i+1)



Measured memory_bytes: 84512
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
typedef long long ll;

int digits(ll n){
    int i=1;
    while(n/=10)i++;
    return i;
}

int main(void){
    ll n;
    cin>>n;
    int res = 11;
    for(ll a = 1; a < sqrt(n)+1; a++){
        if(n%a==0){
            ll b = n/a;
            int f = max(digits(a),digits(b));
            res = min(res,f);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] ch = sc.next().toCharArray();
			int counter = 0;
			
			for (char c: ch) {
				if (c == 'o') {
					counter++;
				}
			}
			
			if (ch.length < 8) {
				System.out.println("YES");
			} else {
				if (ch.length - counter <= 7) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			}
			
			
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"
#define sqr(a)((a) *(a))
#define jor(a) !(a & 1)	// jor means EVEN number
#define bjor(a)(a & 1)	// bjor means ODD number
#define all(a) a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr))	//memset only for -1 and 0
//fill(a, a+n, 5)	//fill for any value
#define for0(i, b) for (int i = 0; i < (b); i++)
#define for1(i, b) for (int i = 1; i <= (b); i++)
#define forab(i, a, b) for (int i = (a); i <= (b); i++)
#define forba(i, b, a) for (int i = (b); i >= (a); i--)
#define rep(i, a, b, c) for (int i = (a); i != (b); i += (c))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define fileRead freopen("input.txt", "r", stdin);

void print(int a[], int n)
{
	// for testing or debugging
	for (int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;
}

//______________________________________________________\\

main()
{
    IOS;
    //fileRead;
    int x,y;
    cin>>x>>y;
    si s; 
    int n;
    while(y--) cin>>n, s.in(n);
    int l=x, r=x;
    while(1){
        if(s.count(l)==0) {cout<<l; break;}
        if(s.count(r)==0) {cout<<r; break;}
        l--,r++;
    }
}


Measured memory_bytes: 3644
chomp($a=<>);
($n,$x)=split/ /,$a;

while(<>){
    chomp;
    push @a,$_;
    $sum+=$_;
}
@a=sort{$a <=> $b}@a;
$kosu=@a;
$nokori=int(($x-$sum)/$a[0]);

print $kosu+$nokori;

Measured memory_bytes: 384
N, W = map(int, input().split(" "))
weights = []
values = []

for _ in range(N):
    w, v = map(int, input().split(" "))
    weights.append(w)
    values.append(v)

dp = [[None for _ in range(W+1)] for _ in range(N+1)]
for _ in range(W+1):
    dp[0][_] = 0

for i in range(N):
    item_weight = weights[i]
    for j in range(W+1):
        if j >= item_weight:
            dp[i+1][j] = max([dp[i][j-weights[i]] + values[i], dp[i][j]])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Measured memory_bytes: 272584
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main(void){
    int n, k;
    vector <int> a;
    int x;
    int cnt;
    int ans = INT_MAX;
    int suf;
    
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x;
        a.push_back(x);
    }
    
    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            suf = i;
            break;
        }
    }
    
    // 左側と右側で分けて考える
    for(int i = 0; i < k; i++){
        cnt = 1;
        
        int left = suf - k + 1 + i;
        int right = n - 1 - suf - i;
        
        if(left > 0 && left % (k - 1) == 0){
            cnt += left / (k - 1);
        }
        else if(left > 0 && left % (k - 1) != 0){
            cnt += left / (k - 1) + 1;
        }
        
        if(right > 0 && right % (k - 1) == 0){
            cnt += right / (k - 1);
        }
        else if(right > 0 && right % (k - 1) != 0){
            cnt += right / (k - 1) + 1;
        }
        
        ans = min(ans, cnt);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 892
from collections import defaultdict

def dfs(source, sink, flow, connect):
    if source == sink:
        return flow
    used[source] = 1
    for i, (target, cost, rev_i) in enumerate(connect[source]):
        if not used[target] and cost > 0:
            that_flow = dfs(target, sink, min(flow, cost), connect)
            if that_flow > 0:
                connect[source][i][1] -= that_flow
                connect[target][rev_i][1] += that_flow
                return that_flow
    return 0

v_num, e_num = (int(n) for n in input().split(" "))
connect = defaultdict(list)
for _ in range(e_num):
    s, t, cost = (int(n) for n in input().split(" "))
    connect[s].append([t, cost, len(connect[t])])
    connect[t].append([s, 0, len(connect[s]) - 1])

answer = 0
base_used = [0 for n in range(v_num)]
while True:
    used = base_used.copy()
    now_flow = dfs(0, v_num - 1, float("inf"), connect)
    if now_flow == 0:
        break
    answer += now_flow
print(answer)

Measured memory_bytes: 8352
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

//////////////////////////

int main(){fastio
    
    ll n;cin>>n;
    set<string>s;
    rep(i,1,n){
        string t;cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
    
    return 0;
}


Measured memory_bytes: 19272
using namespace std;
#include<bits/stdc++.h>
#define st first
#define nd second
#define FORE(i,a,b) for(int i=(a),b_=(b);i<=b_;++i)
#define FORD(i,a,b) for(int i=(a),b_=(b);i>=b_;--i)
#define TR(c, it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)

const int N = 1e5 + 1 ;
int a[N];

int main()
{
#define TASK "NAME"
    // freopen(TASK".inp","r",stdin);
    // freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cout << fixed << setprecision(2) ;
    int n ;
    cin >> n ;
    for (int i = 1; i <= n; ++i) cin >> a[i] ;
    sort(a + 1, a + n + 1);
    long double ans = a[1];
    for (int i = 2; i <= n; ++i) {
        ans = (long double)(ans + a[i]) / 2.0;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;

int main(){
	string ss;
	getline(cin,ss);
	int num=0;
	queue<string> spot;
	string str="";
	for(int i=0;i<=ss.size();i++){
		if(!isalpha(ss[i]) || ss[i]=='\0'){
			if(i>0){
				spot.push(str);
				str="";
			}
		}else{
			str+=ss[i];
		}
	}
	int often[spot.size()];
	int ll=spot.size();
	string ansoften="",anslen="";
	int flg=0;
	int mark[ll];
	for(int i=0;i<ll;i++){mark[i]=0;}
	for(int a=0;a<ll;a++){
		if(mark[a]==1){
			often[a]=0;
		}else{
			string now=spot.front();
			spot.pop();
			for(int j=0;j<ll;j++){
				string rig=spot.front();
				spot.pop();
				if(now==rig){
					often[a]++;
					mark[j]=1;
				}
				if(flg==0 && rig.size()>anslen.size())anslen=rig;
				spot.push(rig);
			}
			flg++;
			spot.push(now);
		}
	}
	int aa=0;
	for(int b=0;b<ll;b++){
		if(aa<often[b])ansoften=spot.front();
		spot.pop();
	}
	cout<<ansoften<<" "<<anslen<<endl;
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.rbegin(), l.rend());
  int ans = 0;
  rep(i, k)
    ans += l[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    ll t;
    cin >> n >> t;
    VL x(n);
    REP(i,n) scanf("%lld", &x[i]);
    ll ans = 0;
    REP(i,n){
        ans += t;
        if (i > 0 && x[i] - x[i-1] < t) ans -= (x[i-1] + t - x[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x:usize = read();
    for i in 1..=x {
        if x <= i * (1 + i) / 2 {
            println!("{}", i);
            break;
        }
    }
}


Measured memory_bytes: 2156