akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
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;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll H, W;
  cin >> H >> W;

  ll B = 0;
  vector<vector<char>> S(H + 2, vector<char>(W + 2, '#'));
  for (ll i = 1; i < H + 1; i++)
  {
    for (ll j = 1; j < W + 1; j++)
    {
      cin >> S.at(i).at(j);
      if (S.at(i).at(j) == '#')
        B++;
    }
  }

  vector<vector<ll>> mv = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  vector<vector<ll>> L(H + 2, vector<ll>(W + 2, -1));
  queue<pair<ll, ll>> Q;
  Q.push(make_pair(1, 1));
  L.at(1).at(1) = 0;
  while (!Q.empty())
  {
    ll Y = Q.front().first;
    ll X = Q.front().second;
    //cerr << X << " " << Y << endl;
    if (Y == H && X == W)
      break;
    Q.pop();
    for (ll i = 0; i < 4; i++)
    {
      ll y = Y + mv.at(i).at(0);
      ll x = X + mv.at(i).at(1);
      if (S.at(y).at(x) != '#' && L.at(y).at(x) == -1)
      {
        Q.push(make_pair(y, x));
        L.at(y).at(x) = L.at(Y).at(X) + 1;
      }
    }
  }

  ll ans = (Q.empty()) ? -1 : H * W - L.at(H).at(W) - 1 - B;
  cout << ans << endl;

  /*
  for (ll i = 1; i < H + 1; i++)
  {
    for (ll j = 1; j < W + 1; j++)
    {
      cerr << L.at(i).at(j) << " ";
    }
    cerr << endl;
  }
  */
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX(a, b) ((a < b) ? b : a)

int main(void) {
  int N;
  char S[101];
  scanf("%d %s", &N, S);

  int max = 0;
  int x = 0;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'I') x++;
    if(S[i] == 'D') x--;
    max = MAX(max, x);
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
from collections import deque

N = int(input())
Monsters = deque(map(int, input().split()))
Fighters = deque(map(int, input().split()))

Knockouts = 0
prev_ftr = 0

while len(Monsters) > 0:
  mon = Monsters.popleft()
  ko1 = min(mon, prev_ftr)
  #print(mon, prev_ftr, ko1)
  Knockouts += ko1
  mon -= ko1

  if len(Fighters) > 0:
    ftr = Fighters.popleft()
    ko2 = min(mon, ftr)
    #print(mon, ftr, ko2)
    Knockouts += ko2
    mon -= ko2
    prev_ftr = ftr - ko2

print(Knockouts)

Measured memory_bytes: 19884
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int y,m,d,Y;
    while (cin>>y>>m>>d) {
        if ( (y>=1989&&m>=1&&d>=8)||(y>1990) ) {
            Y=y-1989+1;
            cout<<"heisei"<<" "<<Y<<" "<<m<<" "<<d<<endl;
        } else if ( (y>=1926&&m>=12&&d>=25)||(y>1927&&y<=1989) ) {
            Y=y-1926+1;
            cout<<"showa"<<" "<<Y<<" "<<m<<" "<<d<<endl;
        } else if ( (y>=1912&&m>=7&&d>=30)||(y>=1912&&m>8)||(y>1913&&y<=1926) ) {
            Y=y-1912+1;
            cout<<"taisho"<<" "<<Y<<" "<<m<<" "<<d<<endl;
        } else if ( (y>=1868&&m>=9&&d>=8)||(y>=1868&&m>10)||(y>1869&&y<=1912) ) {
            Y=y-1868+1;
            cout<<"meiji"<<" "<<Y<<" "<<m<<" "<<d<<endl;
        } else {
            cout<<"pre-meiji"<<endl;
        }
    }
}



Measured memory_bytes: 3092
import java.util.*;

/**
 * 区間スケジューリング問題
 */
public class Main {
    public static final int MOD = 1_000_000_007;

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] X = new int[N];
        int[] L = new int[N];
        for (int i=0; i<N; i++) {
            X[i] = sc.nextInt();
            L[i] = sc.nextInt();
        }

        int ans = solve(N, X, L);

        System.out.println(ans);
    }

    private static int solve(int N, int[] X, int[] L) {
        Pair[] list = new Pair[N];
        for (int i=0; i<N; i++) {
            list[i] = new Pair(X[i] - L[i], X[i] + L[i]);
        }

        Arrays.sort(list, new PairComparator());
        int count = 0;
        int pos = Integer.MIN_VALUE;
        for (int i=0; i<N; i++) {
            if (pos > list[i].first) continue;
            count++;
            pos = list[i].second;
        }

        return count;

    }

    static class Pair {
        int first;
        int second;

        public Pair(int a, int b) {
            this.first = a;
            this.second = b;
        }
    }

    static class PairComparator implements Comparator {

        public int compare(Object a0, Object b0) {
            Pair a = (Pair)a0;
            Pair b = (Pair)b0;

            return a.second - b.second;
        }
    }
}


Measured memory_bytes: 65012
import collections

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))
num = [[float("inf") for i in range(w)] for i in range(h)]
flag = [[False for i in range(w)] for i in range(h)]
num[ch - 1][cw - 1] = 0
queue = collections.deque([[ch, cw]])
d1 = [[-1, 0], [1, 0], [0, -1], [0, 1]]
d2 = [[-1, -1], [-1, 1], [1, -1], [1, 1], [-2, 0], [2, 0], [0, -2], [0, 2]]
d3 = [[-2, -1], [-1, -2], [2, -1], [1, -2], [-2, 1], [-1, 2], [2, 1], [1, 2]]
d4 = [[-2, -2], [-2, 2], [2, -2], [2, 2]]
while queue:
    test = queue.popleft()
    x = test[1]
    y = test[0]
    if flag[y - 1][x - 1] == True:
        continue
    #print(num)
    #print(test)
    flag[y - 1][x - 1] = True
    temp = num[y - 1][x - 1]
    for i in d1:
        x2 = x + i[0]
        y2 = y + i[1]
        if 1 <= x2 <= w and 1 <= y2 <= h and s[y2 - 1][x2 - 1] == ".":
            num[y2 - 1][x2 - 1] = min(num[y2 - 1][x2 - 1], temp)
            queue.appendleft([y2, x2])
    for i in d2:
        x2 = x + i[0]
        y2 = y + i[1]
        if 1 <= x2 <= w and 1 <= y2 <= h and s[y2 - 1][x2 - 1] == ".":
            num[y2 - 1][x2 - 1] = min(temp + 1, num[y2 - 1][x2 - 1])
            queue.append([y2, x2])
    for i in d3:
        x2 = x + i[0]
        y2 = y + i[1]
        if 1 <= x2 <= w and 1 <= y2 <= h and s[y2 - 1][x2 - 1] == ".":
            num[y2 - 1][x2 - 1] = min(temp + 1, num[y2 - 1][x2 - 1])
            queue.append([y2, x2])
    for i in d4:
        x2 = x + i[0]
        y2 = y + i[1]
        if 1 <= x2 <= w and 1 <= y2 <= h and s[y2 - 1][x2 - 1] == ".":
            num[y2 - 1][x2 - 1] = min(temp + 1, num[y2 - 1][x2 - 1])
            queue.append([y2, x2])
if num[dh - 1][dw - 1] == float("inf"):
    print(-1)
else:
    print(num[dh - 1][dw - 1])


Measured memory_bytes: 268124
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, X; cin >> N >> X;
    vec<lint> m_list(N);
    range(i, 0, N) cin >> m_list.at(i);
    sort(m_list.begin(), m_list.end());
    lint sum = 0;
    range(i, 0, N) sum += m_list.at(i);
    lint max_num = N + max(0LL, (X - sum)) / m_list.at(0);
    cout << max_num << "\n";
}

Measured memory_bytes: 384
h, w = map(int, input().split())
s = [input() for _ in range(h)]

sd = {}
for i in range(0, h + 2):
    for j in range(0, w + 2):
        if (i == 0) or (i == h + 1) or (j == 0) or (j == w + 1):
            sd[(i, j)] = 0
        elif s[i - 1][j - 1] == '.':
            sd[(i, j)] = 0
        else:
            sd[(i, j)] = 1

for i in range(1, h + 1):
    line = ""
    for j in range(1, w + 1):
        if s[i - 1][j - 1] == '.':
            num = 0
            num += sd[(i - 1, j - 1)]
            num += sd[(i - 1, j)]
            num += sd[(i - 1, j + 1)]
            num += sd[(i, j - 1)]
            num += sd[(i, j)]
            num += sd[(i, j + 1)]
            num += sd[(i + 1, j - 1)]
            num += sd[(i + 1, j)]
            num += sd[(i + 1, j + 1)]
            line += str(num)
        else:
            line += s[i - 1][j - 1]
    print(line)




Measured memory_bytes: 9204
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int h[n];
    forn(i,n)   cin>>h[i];

    int max_h=0, curr_h=0;
    for(int i=1;i<n;i++){
        if(h[i]<=h[i-1]){
            curr_h++;
        }
        else{
            //start=i;
            max_h = max(max_h, curr_h);
            curr_h=0;
        }
    }
    max_h = max(max_h, curr_h);
    cout<<max_h<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int N, M, t, x, y;
  t = 0;
  scanf("%d %d\n", &N, &M);
  x = 1;
  for (int i = 0;i < M; i++){
    x *= 2;
  }
  y = 100 * (N - M) + 1900 * M;
  t += y * x;

  printf("%d\n", t);
  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=INF,a[100000],b,c,d,cmp=INF*-1,cmpp=INF,m,h,w,x,y,sum=0,pos=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n;
       rep(i,n){
           cin>>a[i];
           cmp=max(cmp,a[i]);
           cmpp=min(cmpp,a[i]);
       }
      // Cout(cmp);
       //Cout(cmpp);
       if(cmp==cmpp){
        //   Cout("aa");
           Cout(0);
           return 0;       }
       else{
           rrep(i,cmpp,cmp+1){
               rep(j,n){
                   pos+=(a[j]-i)*(a[j]-i);
               }
               ans=min(ans,pos);
               pos=0;
           }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s, t;
long long n, c, a[200000], b[200000], sum;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];
		
	for (int i = 2; i <= n; i ++)
	{
		if (a[i] <= a[i-1])
			b[i] = b[i-1] + 1;
				
	}		
	for (int i = 1; i <= n; i ++)
		sum = max (sum, b[i]);
	cout << sum;	
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, m; std::cin >> n >> m;
    std::priority_queue<long long> que;
    for (int i = 0; i < n; i++) {
        long long a; std::cin >> a;
        que.push(a);
    }
    for (int i = 0; i < m; i++) {
        long long a = que.top();
        que.pop();
        que.push(a >> 1);
    }
    long long ans = 0;
    while (!que.empty()) {
        long long a = que.top();
        que.pop();
        ans += a;
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 1400
var
n,i:longint;
x,o:int64;
a:array [0..100001] of int64;
begin
readln(n,x);
for i := 1 to n do
begin
read(a[i]);
if a[i]>x then
begin
o:=o+(a[i]-x);
a[i]:=x;
end;
end;
for i := 1 to n-1 do
begin
if a[i]+a[i+1]>x then
begin
o:=o+(a[i]+a[i+1]-x);
a[i+1]:=x-a[i];
end;
end;
writeln(o);
end.


Measured memory_bytes: 896
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  cin>>N;
  vector<pair<pair<string,int>,int>> data(N);
  rep(i,0,N){
    cin>>data[i].first.first>>data[i].first.second;
    data[i].second=i+1;
    data[i].first.second=-data[i].first.second;
  }
  sort(data.begin(),data.end());
  rep(i,0,N) cout<<data[i].second<<endl;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

string get_min(string s, string t, const int pos)
{
    const int n = s.size();
    const int m = t.size();

    if (pos + m - 1 >= n)
        return "";

    for (int i = pos, j = 0; i < n && j < m; i++, j++)
        if (s[i] == '?')
            s[i] = t[j];
        else if (s[i] != t[j])
            return "";

    for (char& c : s)
        if (c == '?')
            c = 'a';

    return s;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    string s, t;
    cin >> s >> t;

    vector<string> v;
    for (int i = 0; i < s.size(); i++)
    {
        auto good = get_min(s, t, i);
        if (good.size() > 0)
            v.push_back(good);
    }

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

    cout << (v.empty() ? "UNRESTORABLE" : v[0]);
}

Measured memory_bytes: 256
import collections
import itertools
import sys

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s=input()
k=getint()

substr = set()
for slen in range(1, k+1):
    for i in range(len(s)):
        end = i + slen
        if end <= len(s):
            substr.add(s[i:end])

substr = list(sorted(substr))

print(substr[k-1])

Measured memory_bytes: 4976
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define flush fflush(stdout)
using namespace std;

string s;

int solve(string s, char l)
{
	if(s.empty())
		return 0;

	for(int i = 0; i < s.size(); ++i)
	{
		if(s[i]!=l)
			break;

		if(i==s.size()-1)
			return 0;
	}

	string t;

	for(int i = 0; i < s.size()-1; ++i)
	{
		if(s[i]==l || s[i+1]==l)
			t += l;
		else
			t += s[i];
	}

	return solve(t, l)+1;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> s;

	int res = inf;

	for(char i = 'a'; i <= 'z'; ++i)
	{
		res = min(res, solve(s, i));
	}

	cout << res;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){
    long long int X,K,D;
    scanf("%lld %lld %lld%*c",&X,&K,&D);
    if(X<0)X *= -1;;
    long long int goz = X/D;
    long long int goal;
    if(goz > K){
        goal = X-K*D;
    }else if((K-goz)%2==0){
        goal = X - goz * D;
    }else
    {
        goal = X - (goz+1) *D; 
    }
    if(goal<0)goal *= -1;
    printf("%lld\n",goal);
    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <string>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  string sd, t;
  cin >> sd >> t;

  int f = -1;
  for(int i=sd.size()-t.size(); i>=0;i--){
    bool ok = true;
    rep(j,t.size()){
      if(sd[i+j] != t[j] && sd[i+j] != '?'){
	ok = false;
      }
    }
    if(ok){
      f = i;
      break;
    }
  }
  if(f == -1) cout << "UNRESTORABLE" << endl;
  else{
    rep(i,t.size()){
      sd[f+i] = t[i];
    }
    rep(i,sd.size()){
      if(sd[i] == '?') sd[i] = 'a';
    }
    cout << sd << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n;

int main(){
	cin>>n;
	ll x,s,res,X,M;
	cin>>x>>s;
	X=x;
	res=M=s;
	for(int i=1;i<n;i++){
		cin>>x>>s;
		M=max(M-x+X,0ll)+s;
		res=max(res,M);
		X=x;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 177
# B - Substring

S=input()
T=input()

Slen=len(S)
Tlen=len(T)

m=0

for i in range (Slen-Tlen+1):
    temp=0
    for j in range (Tlen):
        if T[j]==S[i+j]:
            temp+=1
        else:
            continue
    else:
        if temp>m:
            m=temp
print(Tlen-m)

        


Measured memory_bytes: 8912
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	for (int i = 0, l = s.size(); i < l; ++i)
		if (i % 2 == 0)
			cout << s[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

char ba[100][100];

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

struct P {
  int y, x;
  int d;
  int a, b;
  P(int y, int x, int d, int a, int b) : y(y),x(x),a(a),b(b),d(d) {}
};

bool ok[100][100][4][11][11];

int main() {
  int h, w, A;
  while(cin>>h>>w>>A) {
    int sx, sy;
    int gx, gy;
    REP(i,h) REP(j, w) {
      cin >> ba[i][j];
      if (ba[i][j] == 'S') {
        sy = i;
        sx = j;
      } else if (ba[i][j] == 'G') {
        gy = i;
        gx = j;
      }
    }
    queue<P> Q;
    memset(ok, 0, sizeof(ok));
    Q.push(P(sy,sx,1,A, A));
    bool hoge = 0;
    while(!Q.empty()) {
      P p = Q.front(); Q.pop();
      if (ok[p.y][p.x][p.d][p.a][p.b]) continue;
      ok[p.y][p.x][p.d][p.a][p.b] = 1;

      //cout << p.x << " " << p.y << " " << p.d << " " << p.a << " " <<p.b << endl;
      int yy = p.y + dy[p.d];
      int xx = p.x + dx[p.d];
      if (ba[p.y][p.x] == 'S' && p.d == 3) continue;
      if (!(yy<0||yy>=h||xx<0||xx>=w || ba[yy][xx] == '#'))
        Q.push(P(yy,xx,p.d,p.a,p.b));

      if (ba[p.y][p.x] == 'S') continue;
      
      if (p.a) {
        int yy, xx;
        int dd;
        if (p.d % 2) {
          dd = (p.d+3)%4;
        } else {
          dd = (p.d+1)%4;
        }
        yy = p.y + dy[dd];
        xx = p.x + dx[dd];
        if (!(yy<0||yy>=h||xx<0||xx>=w || ba[yy][xx] == '#'))
          Q.push(P(yy,xx,dd,p.a-1,p.b));
      }
      if (p.b) {
        int yy, xx;
        int dd;
        if (p.d % 2) {
          dd = (p.d+1)%4;
        } else {
          dd = (p.d+3)%4;
        }
        yy = p.y + dy[dd];
        xx = p.x + dx[dd];
        if (!(yy<0||yy>=h||xx<0||xx>=w || ba[yy][xx] == '#'))
          Q.push(P(yy,xx,dd,p.a,p.b-1));
      }
    }
    int ans = -1;
    REP(i, 4) {
      REP(j, A+1) {
        REP(k, A+1) {
          if (ok[gy][gx][i][j][k]) {
            //cout << i << "," << j <<"," << k << endl;
            if (ans == -1) ans = A*2-(j+k);
            else ans = min(ans, A*2-(j+k));
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 5952
#include <bits/stdc++.h>
//#include <atcoder/fenwicktree>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
//#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll M = A + B;
    ll count_1 = N / M;
    ll count_2 = N % M;
    cout << count_1 * A + min(count_2, A) << "\n"; 
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    double ans=0;
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++){
        double x;
        char u[5];
        scanf("%lf %s",&x,u);
        if (u[0]=='J'){
            ans+=x;
        } else {
            ans+=x*380000;
        }
    }
    printf("%lf\n",ans);
    return 0 ;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// #define rep(i, n) for(int i = 0; i < (int)(n); i++)
// #define all(a) (a).begin(),(a).end()
// #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
// int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

#define int long long
#define SIZE 100000

using namespace std;

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

  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int n; cin >> n;

  int k; cin >> k;

  if (k + k - 1 <=n)  cout << "YES" << endl;
  else cout << "NO" << endl;
  
  // array<int, SIZE> a;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) cin >> *it;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) num += *it;

  // cout << num << endl;
  return 0;
}


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

int main() {
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n), y(m);
	for (auto &e : x) cin >> e;
	for (auto &e : y) cin >> e;
	x.push_back(X);
	y.push_back(Y);
	cout << (*max_element(x.begin(), x.end()) < *min_element(y.begin(), y.end()) ? "No " : "") << "War" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long int n,k,i =0;
	string s;
	cin >>n>>k>>s;
	while(i <n){
		if(i==k-1){
			cout <<char(int(s[i]+32));
			}
		else cout <<s[i];
		i++;
		}
	return 0;
	}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<chrono>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;

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

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

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

namespace Q3
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            bool[] staris_broken = new bool[N];
            for (int i = 0; i < N; i++) staris_broken[i] = false;
            for(int i = 0; i < M; i++)
            {
                staris_broken[int.Parse(Console.ReadLine())] = true;
            }

            long[] count = new long[N+1];
            for (int i = 0; i <= N; i++) count[i] = 0;
            count[0] = 1;
            for(int i = 0; i < N; i++)
            {
                if ((i + 1 < N && !staris_broken[i + 1]) || i + 1 == N)
                {
                    count[i + 1] += count[i];
                    count[i + 1] %= 1000000007;
                }
                if ((i + 2 < N && !staris_broken[i + 2]) || i + 2 == N)
                {
                    count[i + 2] += count[i];
                    count[i + 2] %= 1000000007;
                }
            }

            Console.WriteLine(count[N]);
        }
    }
}


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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int cnt[100005];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n) {
		int l, r;
		scanf("%d%d", &l, &r);
		r++;
		int ma = -1, mi = 1e9;
		FOR(jump, 1, 320) {
			int tl = (l - 1) / jump + 1;
			int tr = min((r - 1) / jump + 1, mi);
			mi = min(mi, tl);
			cnt[tl]++;
			cnt[tr]--;
		}
		FOR(d, 1, mi) {
			if (((l - 1) / d + 1) * d < r) {
				cnt[d]++;
				cnt[d + 1]--;
			}
		}
	}
	REP(i, m)cnt[i + 1] += cnt[i];
	REP(i, m)printf("%d\n", cnt[i + 1]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
std::vector<int> v;
int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	for(int i=0;i<n;i++){
	     int x;
	     cin >> x;
	     v.push_back(x);
	}
	for(int i=0;i<(n-k);i++){
	     if(v[i+k]>v[i]){
	     
	          cout << "Yes";
	     }else{
	          cout << "No";    
	     }
	     cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4224
d, n = map(int, input().split())
if d == 0:
    if n != 100:
        ans = n
    else:
        ans = 101
if d == 1:
    if n != 100:
        ans = n * 100
    else:
        ans = 10100
if d == 2:
    if n != 100:
        ans = n * 10000
    else:
        ans = 1010000
print(ans)

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

using namespace std;

int dp[3001][3001];

int init_dp(string &s,string &t,int i,int j){
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(s[i]=='\0' || t[j]=='\0'){
        return 0;
    }
    if(s[i]==t[j]){
        return dp[i][j]=1+init_dp(s,t,i+1,j+1);
    }
    return dp[i][j]=max(init_dp(s,t,i+1,j),init_dp(s,t,i,j+1));
}

string r;

void print(string &s,string &t,int i,int j){
    if(s[i]=='\0' || t[j]=='\0'){
        cout<<r<<endl;
        return;
    }
    if(s[i]==t[j]){
        r.push_back(s[i]);
        print(s,t,i+1,j+1);
    }
    else{
        if(dp[i+1][j]>dp[i][j+1]){
            print(s,t,i+1,j);
        }
        else{
            print(s,t,i,j+1);
        }
    }
}

int main(){
    string s,t;
    cin>>s>>t;
    int i=0,j=0;
    memset(dp,-1,sizeof(dp));
    int l=init_dp(s,t,i,j);
    print(s,t,0,0);
    return 0;
}

Measured memory_bytes: 35968
import collections
n_co = collections.Counter()
m_co = collections.Counter()

n = int(input())

for i in range(n):
	ni = input()
	n_co[ni] += 1

m = int(input())

for j in range(m):
	mi = input()
	m_co[mi] += 1

ans = (n_co - m_co)

if len(ans) == 0:
	print(0)
else:
	ans = ans.most_common(1)
	print(ans[0][1])

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int n,x,a[100010],ans=-1;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=100000;i++)
		ans=max(a[i-1]+a[i]+a[i+1],ans);
	cout<<ans<<endl;
 	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;

ll  setBitNumber(ll n) 
{ 
    n |= n >> 1; 
  
    n |= n >> 2; 
  
    n |= n >> 4; 
    n |= n >> 8; 
    n |= n >> 16; 
    n |= n >> 32;
  
    n = n + 1; 
  
    return (n >> 1); 
} 

ll setleftmostunsetbit(ll n) 
{ 
    if ((n & (n + 1)) == 0) 
        return n; 
  
    ll pos = 0; 
    for (ll temp=n, count=0; temp>0; 
                        temp>>=1, count++) 
  
        if ((temp & 1) == 0)  
            pos = count;    
  
    return (n | (1 << (pos))); 
} 
int main()
{
	fastio
  int n, m;
  cin >> n >> m;
  bool a[n+1]={};
  int dp[n+1]={};
  for(int i=1; i<=m; i++)
  {
    int x;
    cin >> x;
    a[x]=true;
  }

  dp[0]=1;
  dp[1] = (a[1]==0);

  for(int i=2; i<=n; i++)
  {
    if(a[i]) continue;
    dp[i] = (dp[i-1] + dp[i-2])%MOD;
  }
  cout << dp[n];




	return 0;
}





Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;

int n;

signed main()
{
	cin>>n;
	vector<int> a(n),b(n);
	for(int i=0;i<=n-1;i++)
	{
		scanf("%d",&a[i]);
		b[i]=abs(i-(n-i-1));
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	if(a!=b)
	{
		cout<<0<<endl;
		return 0;
	}
	long long ans=1ll;
	for(int i=0;i<n/2;i++)
	{
		ans*=2;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}





Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int num = s.nextInt();
        int[] a = new int[num];
        int cnt = 0;
        for (int i = 0; i < num; i++) {
            a[i] = s.nextInt();
        }

        while (allEven(a)) {
            division(a);
            cnt++;
        }
        System.out.println(cnt);
        s.close();
    }

    public static void division(int[] num) {
        for (int i = 0; i < num.length; i++) {
            num[i] /= 2;
        }
    }

    public static boolean allEven(int[] num) {
        int cnt = 0;
        boolean ret = false;
        for (int i = 0; i < num.length; i++) {
            if (num[i] % 2 == 0) {
                cnt++;
            }
        }
        if (cnt == num.length) {
            ret = true;
        }
        return ret;
    }
}

Measured memory_bytes: 36008
integer = [list(map(int, s.split())) for s in open(0)][0][0]
dlist = [divmod(integer, i) for i in range(1, 10)]
found = 0
for d in dlist:
    if d[0] <= 9 and d[1] ==0:
        print("Yes")
        found += 1
        break 
if found == 0:
    print("No")
        

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

ll n, a, b;

bool f(ll x, V<ll> &h) {
  ll c = a-b;
  ll d = x*b;
  rep(i,n) {
    if(h[i]-d > 0) x -= ceil(h[i]-d, c);
  }
  return x >= 0;
}

int main(){
  cin >> n >> a >> b;
  V<ll> h(n);
  rep(i,n) cin >> h[i];
  ll l = 2e9;
  ll r = 0;
  while(abs(l-r) > 1) {
    ll mid = (l+r)/2;
    if(f(mid, h)) l = mid;
    else r = mid;
  }
  cout << l << endl;
}

Measured memory_bytes: 4028
n, x, y = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n - 1, 0)
1.upto(n - 1) do |i|
  (i + 1).upto(n) do |j|
    ans[[j - i, (x - i).abs + 1 + (y - j).abs, (y - i).abs + 1 + (x - j).abs].min - 1] += 1
  end
end
puts ans

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> /*inline*/ bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> /*inline*/ bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const int MOD = 1e9+7;
const int MAX_N = 100100;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a,b); u -= t*v; swap(u,v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x; is >> x; a = ModInt<mod>(x); return (is);
    }
};
using modint = ModInt<MOD>;

signed main() {
    string S;
    cin >> S;
    int N = S.length();
    // dp[i][j]...i桁目までで13で割ってj余る数が何通りあるか
    vector<vector<modint>> dp(MAX_N, vector<modint>(13,0));
    dp[0][0] = 1;
    
    for (int i = 0; i < N; i++) {
        int c = ((S[i] == '?') ? -1 : S[i]-'0');
        for (int j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (int k = 0; k < 13; k++) {
                dp[i+1][(k*10 + j) % 13] += dp[i][k];
            }
        }
    }
    
    cout << dp[N][5] << endl;
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector <int>  tako(N);
  int sum=0;
  for ( int  k = 0;  k < N; k++){
      cin>>tako[k];
  }
  for ( int  i = 0;  i < N; i++){
     for ( int  j = i+1;  j < N; j++){
         sum+=tako[i]*tako[j];
     }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
//*-- ILSH --*//
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
ll brr[100000][2];
void solve(){
	
	ll h;
	cin>>h;
	int n;
	cin>>n;
	int arr[n][2];
	for (int i=0;i<n;i++)
		cin>>arr[i][0]>>arr[i][1];
	memset( brr,0,sizeof ( brr));
	brr[0][0]=1;brr[0][1]=0;

	for ( int i=1;i<20000;i++)
		brr[i][1]=1e9;

	for (int i=0;i<20000;i++){
		for ( int j=0;j<n;j++){
			if ( i-arr[j][0]>=0&&brr[i-arr[j][0]][0]==1){
				brr[i][0]=1;
				brr[i][1]=min( brr[i][1],brr[i-arr[j][0]][1]+arr[j][1]);
			}
		}
	}
	ll mi=1e9;
	for ( int i=h;i<20000;i++)
		mi=min( mi,brr[i][1]);
	cout<<mi<<'\n';

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

bool dp[200005][103];
int stat[200005];

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int k; cin >> k;
	vector<int> a(n); for (int o = 0; o < n; o++) { cin >> a[o]; }
	for (int i = 0; i <= k; ++i) {
		int j = 0; 
		while (dp[i][j]) j++; 
		stat[i] = j;
		for (int l = 0; l < n; ++l) 
			dp[i + a[l]][stat[i]] = true;
	}
	// print(pair(stat, k + 1));
	cout << (stat[k] ? "First" : "Second");
}

Measured memory_bytes: 20608
n=int(input())

if 2**0<=n<2**1:
    print(2**0)
elif 2**1<=n<2**2:
    print(2**1)
elif 2**2<=n<2**3:
    print(2**2)
elif 2**3<=n<2**4:
    print(2**3)
elif 2**4<=n<2**5:
    print(2**4)
elif 2**5<=n<2**6:
    print(2**5)
elif 2**6<=n<2**7:
    print(2**6)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX = 1e5+5;


int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        LL a[n+2][3] , dp[n+2][3];
        for(int i = 1 ; i <= n ; i++)
        {
                cin >> a[i][0] >> a[i][1] >> a[i][2];
        }
        dp[1][0] = a[1][0];
        dp[1][1] = a[1][1];
        dp[1][2] = a[1][2];
        for(int i = 2 ; i <= n ; i++)
        {
                dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i][0];
                dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + a[i][1];
                dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + a[i][2];
        }
        cout << max(dp[n][0] , max(dp[n][1] , dp[n][2]));
        return 0;
}

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int ans = a * x + b * y;
    int tmp = 0;
    if(a + b > 2 * c){
        for(int numC = 1; numC <= max(x,y); ++numC){
                if(x < numC){
                    tmp = a * (x - numC) + b * (y - numC) + 2 * c * numC;
                    tmp += a * (numC - x);
                    // cout << ans << endl;
                }else if(y < numC){
                    tmp = a * (x - numC) + b * (y - numC) + 2 * c * numC;
                    tmp += b * (numC - y);
                    // cout << ans << endl;
                }else {
                    tmp = a * (x - numC) + b * (y - numC) + 2 * c * numC;
                    // cout << ans << endl;
                }
            if(tmp < ans){
                ans = tmp;
            }
            else {
                break;
            }
        }
    }    
    cout << ans << endl;
}




Measured memory_bytes: 256
h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]
hlist = [0]*(h+1)
wlist = [0]*(w+1)
for x,y in hw:
    hlist[x]+=1
    wlist[y]+=1
hmax=max(hlist)
h_index = {n for n, v in enumerate(hlist) if v == hmax}
wmax=max(wlist)
w_index = {n for n, v in enumerate(wlist) if v == wmax}
count = sum(x in h_index and y in w_index for x,y in hw)
print(hmax+wmax-(len(h_index)*len(w_index)==count))


Measured memory_bytes: 110332