akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll x; cin >> x;
    cout << (x/500) * 1000 + ((x % 500)/5) * 5 << endl;
    return 0;
}


Measured memory_bytes: 256
// Practice1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
    int N, R;
    
    // N=参加回数
    // R=表示レーティング

    cin >> N >> R;

    int IN;
    // IN=内部レーティング

    if (N >= 10) {
        IN = R;
    }
    else {
        int Dec = 100 * (10 - N);
        IN = R + Dec;
    }

    cout << IN;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main () {
  string s;
  cin >> s;
  if (s == "SUN") cout << 7 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
/*
    Author : Wasi Ur Rahman
*/
#include <bits/stdc++.h>
using namespace std;
// defines
#define ll long long int
#define ull unsigned long long int
#define MOD 100000
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sc scanf
#define pf printf
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(d, min(a, min(b, c)))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(d, max(a, max(b, c)))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 3.141592653589793238462643
#define no cout << "No" << endl;
#define yes cout << "Yes" << endl;
#define elif else if
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
/* important funct */
int Int()
{
    int c;
    cin >> c;
    return c;
}
ll Long()
{
    ll c;
    cin >> c;
    return c;
}
double Double()
{
    double c;
    cin >> c;
    return c;
}

#define Int Int()
#define Long Long()
#define Double Double()
void sortString(string &str)
{
    sort(str.begin(), str.end());
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
ll ManualGcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll ManualLcm(ll a,ll b)
{
    return((a)*(b)/gcd(a,b));
}
ll fact(ll n)
{
    ll res = 1;
    for(ll i = n; i>=1; i--)
        res *= i;
    return res;
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
ll nPr(ll n,ll r)
{
    return fact(n)/fact(n-r);
}
ll solve(ll n)
{
    if(n == 1)
        return 1;
    else if(n > 1)
        return ((2*solve(n/2)) + 1);
}
const string s = "hello";
// Main
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    IOS
    ll h=Long;
    cout << solve(h) << endl;;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int field[10][10];

int H = 10;
int W = 10;

bool ng(int y, int x) {
	return y < 0 || H <= y || x < 0 || W <= x;
}

int main() {
	int x, y, size;
	while (scanf("%d,%d,%d",&x,&y,&size) != EOF) {
		if (size == 1) {
			field[y][x]++;
			rep(i, 4) {
				int ny = y + dy[i];
				int nx = x + dx[i];
				if (ng(ny, nx)) continue;
				field[ny][nx]++;
			}
		}
		if (size == 2) {
			REP(ny, y-1, y+2) REP(nx, x-1, x+2) {
				if (ng(ny, nx)) continue;
				field[ny][nx]++;
			}
		}
		if (size == 3) {
			REP(ny, y-1, y+2) REP(nx, x-1, x+2) {
				if (ng(ny, nx)) continue;
				field[ny][nx]++;
			}
			rep(i, 4) {
				int ny = y + dy[i]*2;
				int nx = x + dx[i]*2;
				if (ng(ny, nx)) continue;
				field[ny][nx]++;
			}
		}
	}
	int brank_n = 0;
	int max_value = 0;
	rep(y, 10) rep(x, 10) {
		if (field[y][x] == 0) brank_n++;
		if (field[y][x] > max_value) max_value = field[y][x];
	}
	cout << brank_n << endl << max_value << endl;


	return 0;
}

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

using namespace std;

// WR という部分をつくらない
// RRRRRRR
// RRRRWWW
// RWWWWWW
// WWWWWWW

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

  cin >> c;

  int cR = 0, cW = 0;

  for (int j = 0; j < N; j++) {
    if (c[j] == 'R') {
      cR++;
    } else {
      cW++;
    }
  }

  string target = string(cR, 'R') + string(cW, 'W');

  int ans = 0;

  for (int i = 0; i < N; i++) {
    if (c[i] != target[i]) {
      ans++;
    }
  }

  cout << ans / 2 << endl;

  return 0;
}


Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
#define mod 998244353
using namespace std;

int main(){
    int sum ;cin >>sum;
    double l=(double)sum/3;
    double ans=(double)l*l*l;
    cout<<fixed<<setprecision(7) <<ans <<endl;

}


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

//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int binarySearch(vll A,ll key,ll n){
    ll left =0;
    ll right = n;
    while (left < right){
        ll mid = (left + right) / 2;
        if (A.at(mid) == key){
          left=mid+1;
          return 1;  
        }
        else if( key < A.at(mid)){
             right = mid;
        }
           
        else{
            left = mid + 1;
        }
            
    }
    return 0;
}
 
int main(){
    string order,moji;
    map<string,bool> mapdic;
    ll n;
    cin>>n;
    rep(i,n){
        cin>>order;
        if(order=="insert"){
            cin>>moji;
            mapdic[moji]=true;
            }else{
        cin>>moji;
              if(mapdic[moji])cout<<"yes"<<endl;
else cout<<"no"<<endl;
    }
}
}
  


Measured memory_bytes: 52424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
bool comp(pair<ll,ll> &a, pair<ll,ll> &b){
    return a.first<b.first;
}
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main(){
    ll N,D,A; cin>>N>>D>>A;
  	vector<ll> X(N),H(N);
  	rep(i,N) cin>>X[i]>>H[i];
  
    vector<int> ids(N);
    for (int i = 0; i < N; ++i) ids[i] = i;
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return X[i] < X[j]; });
    vector<long long> nX(N), nH(N);
    for (int i = 0; i < N; ++i) nX[i] = X[ids[i]], nH[i] = H[ids[i]];
    X = nX, H = nH;

    BIT<long long> bit(N+10);
    for (int i = 0; i < N; ++i) bit.add(i+1, i+2, H[i]); // 初期化
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        long long cur = bit.sum(i+1, i+2);
        if (cur <= 0) continue;

        // モンスター i を倒すのに必要な回数
        long long need = (cur + A - 1) / A;

        // X[i] を左端とした爆発が届く範囲を求める
        long long right = X[i] + D * 2;
        int id = upper_bound(X.begin(), X.end(), right) - X.begin();

        // 爆発させる
        bit.add(i+1, id+1, -need * A);
        res += need;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 10368
while True:
    s = input().split()
    a = int(s[0])
    operator = s[1]
    b = int(s[2])
    if operator=="?":
        break
    if operator=="+":
        print(a+b)
    elif operator=="-":
        print(a-b)
    elif operator=="*":
        print(a*b)
    elif operator=="/":
        print(int(a/b))



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

int main() {
  int k,a,b;
  cin >> k >>a>>b;
  string ans = "NG";
  int i=0;
  while(true){
    if(a<=i*k && i*k<=b){
      ans="OK";
      break;
    }else if (i*k>b)break;
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * if abs(n - m) > 1 (ans = 0)
 * let the greater one be n and if n == m + 1 (n! * m!)
 * n == m (2 * n! * m!)
 */
int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0;
		return 0;
	}
	const int N = 100 * 1000 + 5;
	vector <ll> fact(N);
	fact[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	if (abs(n - m) == 0) {
		cout << (2 * fact[n] * fact[m]) % MOD;
	}
	else {
		cout << (fact[n] * fact[m]) % MOD;
	}
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    ll k,a,b;

    cin>>k>>a>>b;
    if (b<=a+2) {
	out(1+k); // only hit
    }


    ll cur = 1;
    ll need = a-1;
    if (need >= k) {
	cur += k;
	out(cur);
    }

    cur += need;
    k -= need;

    cur += (k/2)*(b-a);
    cur += (k%2);
    cout<<cur<<endl;
    
    return 0;
}


Measured memory_bytes: 3596
h,w=map(int,input().split())
l=list(map(list,[input() for i in range(h)]))
for i in range(h):
    for j in range(w):
        if l[i][j]=="#":
            continue
        num=0

        if i!=0 and j!=0 and l[i-1][j-1]=="#":
            num+=1
        if i!=0 and l[i-1][j]=="#":
            num+=1
        if i!=0 and j!=w-1 and l[i-1][j+1]=="#":
            num+=1
        if j!=0 and l[i][j-1]=="#":
            num+=1
        if j!=w-1 and l[i][j+1]=="#":
            num+=1
        if i!=h-1 and j!=0 and l[i+1][j-1]=="#":
            num+=1
        if i!=h-1 and l[i+1][j]=="#":
            num+=1
        if i!=h-1 and j!=w-1 and l[i+1][j+1]=="#":
            num+=1

        l[i][j]=str(num)
    print("".join(l[i]))


Measured memory_bytes: 40300
#include <algorithm>

namespace rika
{
  template <typename T>
  class edge
  {
  public:
    int to;
    T cost;
    
    edge() = default;
    edge(const edge<T>&) = default;
    edge(edge<T>&&) = default;
    edge& operator =(const edge<T>&) = default;
    edge& operator =(edge<T>&&) = default;

    ~edge() = default;

    edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
}
  int N;

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
namespace rika
{
  namespace internal
  {
    template <typename TValue, typename TGraph>
    std::pair<TValue, int> visit(int from, int v, const TGraph &g)
    {
      if(v >= N)
        throw "test";
      auto r = std::make_pair(TValue(), v);
      try{
      for(auto it = g[v].begin(); it != g[v].end(); ++it)
      {
        if(it->to == from)
          continue;
        auto r2 = visit<TValue>(v, it->to, g);
        if(r2.first + it->cost >= r.first)
          r = std::make_pair(r2.first + it->cost, r2.second);
      }
      }catch(const std::out_of_range &e){throw e;}
      return r;
    }
  }

  template <typename TValue, typename TGraph>
  TValue tree_diameter(const TGraph &g)
  {
    using namespace internal;
    auto r1 = visit<TValue>(-1, 0, g);
    auto r2 = visit<TValue>(-1, r1.second, g);
    return r2.first;
  }
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
int main()
{
  cin >> N;
  vector<vector<edge<int>>> g(N * 10);
  for(int i = 0; i < N - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge<int>(t, w));
    g[t].push_back(edge<int>(s, w));
  }
  cout << tree_diameter<int>(g) << endl;
}

Measured memory_bytes: 35428
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class B81 {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        FOR(a, 1, 9) {
            if (N % a != 0) continue;
            int b = N / a;
            if (1 <= b && b <= 9) {
                cout << "Yes" << endl;
                return;
            }
        }
        cout << "No" << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    B81 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  string s;
  cin >> s;
  vector<string> divide{"dream", "dreamer", "erase", "eraser"};

  reverse(s.begin(), s.end());
  for (string &str : divide)
  {
    reverse(str.begin(), str.end());
  }

  bool can = true;
  for (int i = 0; i < s.size(); i++)
  {
    bool can2 = false;
    for (int j = 0; j < 4; j++)
    {
      string d = divide.at(j);
      if (s.substr(i, d.size()) == d)
      {
        can2 = true;
        i += d.size() - 1;
      }
    }
    if (!can2)
    {
      can = false;
      break;
    }
  }

  if (can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	if sum(a) == 0
		println("Yes")
	elseif n%3!=0
		println("No")
	else
		d = Dict{Int,Int}()
		for i in 1:n
			if haskey(d,a[i])
				d[a[i]] += 1
			else
				d[a[i]] = 1
			end
		end
		f = 0
		for j in values(d)
			if j != div(n,3)
				f = 1
				break
			end
		end
		if f == 0
			e = Int[]
			for j in keys(d)
				push!(e,j)
			end
			if e[1]$e[2]$e[3]!=0
				f = 1
			end
		end
		if f==1 && haskey(d,0)
			f = 0
			for j in keys(d)
				if (j == 0 && d[j] != div(n,3)) || (j != 0 && d[j] != 2*div(n,3))
					f = 1
					break
				end
			end
		end
		println(f==0?"Yes":"No")
	end	
end

main()

Measured memory_bytes: 119824
def calc(h,n,N):
  if 4*h*n-N*(h+n)!=0:
    return (N*h*n)//(4*h*n-N*(h+n))
  else:
    return 0

N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    w=calc(h,n,N)
    if w>0:
      if 4/N==1/h+1/n+1/w:
        print(h,n,w)
        exit()

Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int n,k,s;
    cin >> n >> k >> s;
    int inf = 1e9;
    if(s == inf) inf--;
    for(int i = 0; i < k; i++) cout << s << " ";
    for(int i = 0; i < n-k; i++) cout << inf << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int h, w, ans = 0;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	vector<vector<int>> c(h, vector<int>(w));
	
	rep(i, h) {
		int start = 0;
		int cnt = 0;
		rep(j, w) {
			if(s[i][j] == '#') {
				for(int k = start; k < j; k++) {
					c[i][k] += cnt;
				}
				start = j + 1;
				cnt = 0;
			} else {
				cnt++;
				if(j == w-1) {
					for(int k = start; k <= j; k++) {
						c[i][k] += cnt;
					}
				}
			}
		}
	}
	rep(j, w) {
		int start = 0;
		int cnt = 0;
		rep(i, h) {
			if(s[i][j] == '#') {
				for(int k = start; k < i; k++) {
					c[k][j] += cnt;
				}
				start = i + 1;
				cnt = 0;
			} else {
				cnt++;
				if(i == h-1) {
					for(int k = start; k <= i; k++) {
						c[k][j] += cnt;
					}
				}
			}
		}
	}
	
	
	
	rep(i, h) {
		rep(j, w) {
			ans = max(ans, c[i][j]-1);
			// cout << c[i][j] << " ";
		}
		// cout << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20096
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m,sum;
char s[10][10];
void solve(){
	int ans = 0;
	set<int> st;
	for(int i = 0;i < (1 << (n + m));i++){
		int tmp = 0;
		st.clear();
		for(int j = 0;j < (n + m);j++){
			if(i & (1 << j)) st.insert(j); 
		}
		for(int j = 0;j < n;j++){
			for(int k = 0;k < m;k++){
				if(s[j][k] == '#' && !st.count(j) && !st.count(k + n)) tmp++;
			}
		}
		if(tmp == sum) ans++;
	}
	cout << ans << endl;
	return;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%d %d %d",&n,&m,&sum);
	rep(i,0,n-1) scanf("%s",s[i]);
	solve();		
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3700
import numpy as np

N = int(input())
X = np.array(list(map(int, input().split())))

sort_X = np.sort(X)
l = sort_X[int(N/2 - 1)]
r = sort_X[int(N/2)]

for i in range(N):
    if (X[i] <= l):
        print(r)
    else:
        print(l)


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

vector<int> G[100000];

int dfs(int v){
	if(G[v].size()==0){
		return 0;
	}else{
		vector<int> u;
		for(int i=0;i<G[v].size();i++){
			u.push_back(dfs(G[v][i]));
		}
		sort(u.begin(),u.end());
		reverse(u.begin(),u.end());
		int ret = 0;
		for(int i=0;i<u.size();i++) ret = max(ret,u[i]+i+1);
		return ret;
	}
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a;
		scanf("%d",&a);
		G[--a].push_back(i+1);
	}
	printf("%d\n",dfs(0));
}


Measured memory_bytes: 13568
package main

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

func main() {
	N := getStdinInt()
	ans := 0
	for i := 1; i <= N; i++ {
		if keta(i)%2 == 1 {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

func keta(n int) int {
	str := strconv.Itoa(n)
	return len(str)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2676
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> s;
	while (1) {
		s.pop_back();
		s.pop_back();
		string p = "";
		string q = "";
		rep(i, s.size()) {
			if (i < s.size() / 2) {
				p += s[i];
			}
			else {
				q += s[i];
			}
		}
		if (p == q) {
			cout << p.size()*2 << endl;
			return 0;
		}
	}
}

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

namespace AtcoderProgram
{

    class Program
    {
        static Dictionary<int, int> fib = new Dictionary<int, int>();

        static void createfib(int n)
        {
            fib.Add(-1, 1);
            fib.Add(0, 1);
            fib.Add(1, 1);
            fib.Add(2, 2);
            for(int i=3; i<n;i++)
            {
                int a, b;
                fib.TryGetValue(i - 1, out a);
                fib.TryGetValue(i - 2, out b);
                fib.Add(i, (a + b)% 1000000007);
            }
        }

        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split(' ');
            int num = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);


            if (num == 1)
            {
                Console.WriteLine(1);
                return;
            }
            if (num == 2)
            {
                Console.WriteLine(m == 0 ? 2 : 1);
                return;
            }

            createfib(num+1);
            if (m == 0)
            {
                int fff;
                fib.TryGetValue(num, out fff); 
                Console.WriteLine(fff% 1000000007);
                return;
            }

            int[] elm = new int[m];
            for(int i=0; i<m; i++)
            {
                elm[i] = int.Parse(Console.ReadLine());
            }
            
            List<int> prod = new List<int>();
            for (int i = 0; i < elm.Length; i++)
            {
                if (i == 0) prod.Add(elm[i]-1);
                else
                {
                    if (elm[i] - elm[i - 1] == 1)
                    {
                        Console.WriteLine(0);
                        return;
                    }
                    prod.Add(elm[i] - elm[i - 1] - 2);
                }
            }
            prod.Add(num - elm[m-1] - 1);

            Int64 res = 1;
            foreach(int j in prod)
            {
                int k;
                fib.TryGetValue(j, out k);
                res = res * k;
                res = res % 1000000007;
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 19808
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    string str;
    cin >> str;

    bool even = str.size()%2 == 0 ? true:false;
    bool same = str[0] == str[str.size()-1];

    if(!(even^same)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    
    return 0;
}

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

int main(){
  
  int n,mon=100000;
  cin>>n;
  for(int i=0;i<n;i++){
    mon=mon*1.05;
    mon=(mon+999)-(int(mon+999)%1000);
  }
  cout<<mon<<endl;   
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i=0;i<m;i++) cin >> a[i] >> b[i];
    vector<int> c(n,0);
    for(int j=0;j<m;j++){
        c[a[j]-1]++;
        c[b[j]-1]++;
    }
    for(int i=0;i<n;i++) cout << c[i] << endl;
    return 0;
}

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

int main(){
	int n, m, d, t;
	cin >> n;
	
	multiset<int> diff;
	for(int i = 0; i < n; i++){
		cin >> d;
		diff.insert(d);
	}
	
	cin >> m;
	bool judge = true;
	for(int i = 0; i < m; i++){
		cin >> t;
		multiset<int>::iterator it = diff.find(t);
		if(it == diff.end()) judge = false;
		else	                    diff.erase(it);
	}
	
	if(judge) cout << "YES" << endl;
	else		 cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        sc.close();

        int ans = 0;

        for (int i = 1; i <= K; i++) {
            for (int j = 1; j <= K; j++) {
                for (int l = 1; l <= K; l++) {
                    ans += gcd(i, j, l);
                }
            }
        }

        System.out.println(ans);
    }

    private static int gcd(int a, int b, int c) {
        int ab = gcd(a, b);
        return gcd(ab, c);
    }

    private static int[][] memo = new int[201][201];

    private static int gcd(int a, int b) {
        if (a < b) {
            return gcd(b, a);
        }

        if (memo[a][b] != 0) {
            return memo[a][b];
        }

        if (b == 0) {
            memo[a][b] = a;
            return memo[a][b];
        }

        memo[a][b] = gcd(b, a % b);
        return memo[a][b];
    }

}


Measured memory_bytes: 38564
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */

int gcd(int a, int b)/*aとbの最大公約数*/
{
    if (a%b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a%b));
    }
}

int lcm(int a, int b)/*aとbの最小公倍数*/
{
    return a * b / gcd(a, b);
}


int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int k;
    cin >> k;
    ll sum = 0;
    for(int i = 1;i <= k;i++){
        for(int j = 1;j <=k;j++){
            for(int n = 1;n <= k;n++){
                sum += gcd(i,gcd(j,n));
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
# ABC 119 D

import bisect

def resolve():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]

    for _ in range(Q):
        i = int(input())
        s1 = -1 if bisect.bisect_left(s, i) == 0 else s[bisect.bisect_left(s, i)-1]
        s2 = -1 if bisect.bisect_right(s, i) >= A else s[bisect.bisect_right(s, i)]
        t1 = -1 if bisect.bisect_left(t, i) == 0 else t[bisect.bisect_left(t, i)-1]
        t2 = -1 if bisect.bisect_left(t, i) >= B else t[bisect.bisect_right(t, i)]
        tmp = []

        if s1 != -1 and t1 != -1:
            tmp.append(max(i-s1, i-t1))
        if s2 != -1 and t2 != -1:
            tmp.append(max(s2-i, t2-i))
        if s1 != -1 and t2 != -1:
            tmp.append(min(i-s1, t2-i) + t2-s1)
        if t1 != -1 and s2 != -1:
            tmp.append(min(i-t1, s2-i) + s2-t1)

        print(min(tmp))


if __name__ == "__main__":
    resolve()


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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n][m], b[m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }

    int output=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            output+=a[i][j]*b[j];
        }
        cout << output << endl;
        output=0;
    }
    
    return 0;
}


Measured memory_bytes: 3112
import sys
from bisect import bisect_left, bisect_right
def input(): return sys.stdin.readline().strip()


def main():
    """
    祭壇が異なるのは、サイズが異なるんじゃなくて、パーツ番号が異なる時か。。。
    """
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    C.sort()
    ans = 0
    for b in B:
        idx_a = bisect_left(A, b)
        idx_c = bisect_right(C, b)
        ans += idx_a * (N - idx_c)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 99608
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll mod=1e9+7;
ll dp[105][100005];
void solve(){
	ll n, w, i, j;
	memset(dp, 0, sizeof(dp));
	cin>>n>>w;
	int wt[n], val[n];
	for(i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=w;j++){
			if(wt[i-1]<=j){
				dp[i][j]=max(dp[i-1][j], dp[i-1][j-wt[i-1]] + val[i-1]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][w];
}

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

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

using namespace std;

const int mod = 1e9 + 7;

int add() { return 0; }
template<typename... M> int add(int a, M... b) {
  int x = add(b...);
  return a + x - mod * (a + x >= mod);
}

int mul() { return 1; }
template<typename... M> int mul(int a, M... b) {
  return int(1ll * a * mul(b...) % mod);
}

int pwr(int a, int x) {
  return (x ? mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1)) : 1);
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

const int N = 5e5;
int f[N], iv[N];

int C(int n, int k) {
  return dvd(f[n], mul(f[n - k], f[k]));
}

int solve(int n, int s) {
  return C(n + s - 1, s);
}

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

  f[0] = iv[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    iv[i] = dvd(iv[i - 1], i);
  }
  int n, k;
  cin >> n >> k;
  if (k >= n - 1) {
    cout << solve(n, n);
  } else {
    int ans = 0;
    for (int i = k; i >= 0; --i) {
      inc(ans, mul(solve(n - i, i), C(n, i)));
    }
    cout << ans;
  }

  return 0;
}

Measured memory_bytes: 4224
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

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

	string a,b;
	cin>>a>>b;

	for(int i=0;i<n;i++){
		cout<<a[i]<<b[i];
	}cout<<endl;


	

	return 0;
}

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

using namespace std;

#define fir first
#define sec second
#define ins insert
#define pb push_back
#define po pop_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265

typedef long long ll;

const ll max_n = 1e6 + 10 , max_h = 200 , Mod = 1e9 + 7 , inf = 1e18;
ll k , a , b;

void read_input(){
        cin >> k;
}

void solve(){
        a = k % 50;
        b = (k / 50) - a;

        cout << 50 << '\n';
        
        for(int i = 1 ; i <= 50 ; i++){
                if(i <= a)
                        cout <<  b + i + 50 << " ";
                else    
                        cout << b + i - 1 << " ";
        }
}

void output(){
        cout << '\n';
}

int main(){
        IOS;
        read_input();
        solve();
        output();
        return 0;
}

Measured memory_bytes: 256
n = int(input())
data = input().split()

int_data = [int(int_data) for int_data in data]
int_data.sort(reverse=True)

Alice = 0
Bob = 0

for i in range(n):
    if i % 2 == 0:
        Alice += int_data[i]
    else:
        Bob += int_data[i]
        
print(Alice - Bob)

Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    int A,B,C;
    cin >> A >> B >> C;
    vector<int> V(100);
    rep(i,100) {
        V[i] = A*(i + 1)%B;
    }
    int flag = 0;
    rep(j,100) {
        if (V[j] == C) {
            cout << "YES" << endl;
            flag++;
            break;
        }
    }
    if (flag == 0) {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 3604
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        A: i64,
        B: i64,
        C: i64,
    }

    let ans = if A + B == C || A + C == B || B + C == A {
        "Yes"
    } else {
        "No"
    };

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


Measured memory_bytes: 2064
#![allow(unused_macros, unused_imports, dead_code, non_snake_case)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(n:usize);
    for _ in 0..n {
        from_line!(y:usize, m:usize, d:usize);
        let mut ans = (y - 1) * 200 + (m - 1) * 20 + d;
        ans -= (y - 1) / 3 * 10 + (y - 1) % 3 * 5;
        if y % 3 > 0 {
            ans -= (m - 1) / 2;
        }
        println!("{}", 196471 - ans)
    }
}



Measured memory_bytes: 5024
#include <ios>
#include <iomanip>
#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;
typedef long double ld;
#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 PI (acos(-1))
#define print(x) cout << x << 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()
{
    string S;
    cin >> S;
    set<char> se;
    rep(i, S.size()) {
        se.insert(S[i]);
    }
    ll ans = MOD;
    bool flag = true;
    for(char c : se) {
        string tmpS = S;
        ll sum = 0;
        while(true) {
            rep(i, tmpS.size()) {
                if (c != tmpS[i]) flag = false;
            }
            if (flag) {
                break;
            } else {
                sum++;
                rep(i, tmpS.size() - 1) {
                    if (c != tmpS[i] && tmpS[i+1] == c) {
                        tmpS[i] = c;
                    }
                }
                tmpS.pop_back();
            }
            flag = true;
        }
        ans = min(ans, sum);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int K;
    cin >> K;
    queue<ll> que;
    for(ll i = 0;i < 9;i++) {
        que.push(i + 1);
    }
    for(int i = 0;i < K - 1;i++) {
        ll x = que.front();
        que.pop();
        if(x % 10 != 0) {
            que.push(10 * x + x % 10 - 1);
        }
        que.push(10 * x + x % 10);
        if(x % 10 != 9) {
            que.push(10 * x + x % 10 + 1);
        }
    }
    cout << que.front() << endl;
}

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

using namespace std;



int main(){
  char s[4];
  cin >> s;
  char a[4];
  a[0] = s[0];
  if(a[0] == s[1]){
    if((s[2] == s[3]) && (a[0] != s[2])){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    a[1] = s[1];
    if((s[2] == a[0] && s[3] == a[1]) || (s[2] == a[1] && s[3] == a[0])){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1e8)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

template<class E, class Q,typename C=typename remove_reference<decltype(get<0>(declval<Q&>()))>::type>
struct Dijkstra{
    C maxVal=numeric_limits<C>::max();
    int n;
    vector<vector<E>> edge;
    vector<C> distance;
    Dijkstra(int N):n(N){
        edge.resize(n);
        distance=decltype(distance)(n,INF);
    }
    void add(int a, E stat, bool dir=true){
        edge[a].push_back(stat);
        if(!dir)return;
        swap(a,get<0>(stat));
        edge[a].push_back(stat);
    }
    C dist(int s,int g){
        auto cmp=[](Q a,Q b){return get<0>(a)>get<0>(b);};
        priority_queue<Q,vector<Q>,decltype(cmp)> pq(cmp);

        pq.emplace(0,s);
        while(!pq.empty()){
            int cost,curr;
            tie(cost,curr)=pq.top(); pq.pop();
            if(distance[curr]!=INF) continue;
            distance[curr]=cost;
            if(curr==g) break;
            for(auto e:edge[curr]){
                int next,dist;
                tie(next,dist)=e;
                if(distance[next]==INF){
                    pq.emplace(cost+dist,next);
                }
            }
        }
        return distance[g]==INF?-1:distance[g];
    }
};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m,c,S,G;  //駅の数、路線の数、会社数、出発、目的
	while(cin>>n>>m>>c>>S>>G,n+m+c+S+G){
		vector<vector<vector<pii>>> route(c,vector<vector<pii>>(n));
		vi g(c);
		vvi cost(c,vi(100001,0));
		rep(_,m){
		    int x,y,d,s; cin>>x>>y>>d>>s;
		    route[s-1][x-1].emplace_back(y-1,d);
		    route[s-1][y-1].emplace_back(x-1,d);
		}
		rep(i,c) cin>>g[i];
		rep(i,c){
		    vi p(g[i],0), q(g[i],0);
		    range(j,1,g[i]) cin>>p[j];
		    rep(j,g[i]) cin>>q[j];
		    rep(j,g[i]){
		        range(k,p[j]+1,(g[i]==j+1?100000:p[j+1])+1) cost[i][k]=(k==0?0:cost[i][k-1]+q[j]);
		    }
		}
		Dijkstra<tuple<int,int>,tuple<int,int>> ds(n);
		rep(s,c){
        	vvi w(n,vi(n,INF));
    		rep(i,n){
    		    w[i][i]=0;
    		    for(auto e:route[s][i]){
    		        w[i][e.first]=min(w[i][e.first],e.second);
    		    }
    		}
    		rep(k,n)rep(i,n)rep(j,n) if(w[i][k]!=INF and w[k][j]!=INF)w[i][j]=min(w[i][j],w[i][k]+w[k][j]);
    		rep(i,n)range(j,i+1,n)if(w[i][j]!=INF){
    		    ds.add(i,make_tuple(j,cost[s][w[i][j]]));
    		}
		}
		cout<<ds.dist(S-1,G-1)<<endl;
	}
	return 0;
}



Measured memory_bytes: 13980
#include <iostream>

int main(){
   int A, B, C;
   std::cin >> A >> B >> C;
   int i=1;
   while(1){
      if (A*i % B == C){
         std::cout << "YES" << std::endl;
         break;
      }
      if (A*i % B == 0){
         std::cout << "NO" << std::endl;
         break;
      }
      i++;
   }
}



Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9??§?????? auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
struct edge{
	ll id,to;
};
vector<edge> G[100000];
bool over[200000];

ll N,M,Q;
P H[200000];
ll d[100000];
ll ans=0;
ll nyu[100000];
bool fuman[100000];
bool use[200000];

void is_gensho(ll v){
	nyu[v]--;
	if(nyu[v]==0){
		fuman[v]=1;
		ans++;
		rep(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]==d[v]+1&&!over[e.id]){
				over[e.id]=1;
				is_gensho(e.to);
			}
		}
	}
}

int main()
{
	cin>>N>>M>>Q;
	rep(i,M){
		cin>>H[i].fr>>H[i].sc;
		H[i].fr--; H[i].sc--;
		G[H[i].fr].pb(edge{i,H[i].sc});
		G[H[i].sc].pb(edge{i,H[i].fr});
	}
	memset(d,-1,sizeof(d));
	queue<ll> q;
	d[0]=0;
	q.push(0);
	while(!q.empty()){
		ll v=q.front();
		q.pop();
		rep(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]==-1){
				d[e.to]=d[v]+1;
				q.push(e.to);
				nyu[e.to]++;
				use[e.id]=1;
			}
			else if(d[e.to]==d[v]+1){
				nyu[e.to]++;
				use[e.id]=1;
			}
		}
	}
	ll id,a,b;
	rep(i,Q){
		cin>>id;
		id--;
		if(!over[id]&&use[id]){	
			a=H[id].fr;
			b=H[id].sc;
			if(d[a]<d[b]) swap(a,b);
			is_gensho(a);
		}
		over[id]=1;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 21172
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	int N, ans=0;
	cin >> N;
	vector<int> h(N+1);
	for(int i=0;i<N;i++){
		cin >> h[i];
	}
	h[N] = 0;
	for(int i=0;i<N;i++){
		if (h[i] > h[i+1]){
			ans += h[i] - h[i+1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int k;
    cin >> k;
    if (k % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    ll now = 7;
    rep2(i, 1, 1e7) {
        if (now % k == 0) {
            cout << i << endl;
            return 0;
        }
        now *= 10;
        now += 7;
        now %= k;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636