akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO
using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[10010];

void solve() {
    ll H, N;
    cin >> H >> N;
    vector<Pll> spells(N);
    for (ll i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        spells[i] = {a, b};
    }

    for (ll i = 0; i <= H; i++) {
        dp[i] = L_INF;
    }

    dp[0] = 0;
    for (ll i = 0; i < N; i++) {
        auto [a, b] = spells[i];
        for (ll j = 0; j <= H; j++) {
            if (dp[j] == L_INF) continue;
            ll x = min(j + a, H);
            chmin(dp[x], dp[j] + b);
        }
    }
    prints()(dp[H]);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N=1e5+5;
int n,m,k,l,r,ans;
int a[N];
int main()
{
	cin>>n>>m;
	rep(i,1,n)cin>>a[i];
	ans=2e9;
	rep(i,m,n)
	{
		ans=min(ans,abs(a[i])+a[i]-a[i-m+1]);
	}
	reverse(a+1,a+1+n);
	rep(i,1,n)a[i]=-a[i];
	rep(i,m,n)
	{
		ans=min(ans,abs(a[i])+a[i]-a[i-m+1]);
	}
	cout<<ans;
}


Measured memory_bytes: 640
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)

n, k = map(int, input().split())
ans = Base_10_to_n(n, k)
print(len(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n;
               cin>>n;
               int a[2*n];
               for(int i=0;i<2*n;++i)
                    cin>>a[i];
               sort(a,a+2*n);
               int count=0;
               for(int i=0;i<2*n;i+=2)
               {
                    count += a[i];
               }
               cout<<count;
       }
}


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

int a, b, c, s[15];
int main() {
	cin >> a >> b >> c;
	s[a]++, s[b]++, s[c]++;
	cout << (s[5]==2 && s[7]==1 ? "YES" : "NO");
	return 0;
}


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

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

  string s;
  cin >> s;
  int cnt=0,ans=0;
  rep(i, 3){
    if(s[i]=='R')cnt++;
    if(s[i]=='S')cnt=0;
    ans=max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<bitset>
using namespace std;
int seq[3000];
int32_t main(){

    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1;i <= n;i++){
        cin >> seq[i];
        sum += seq[i];
    }
    bitset<2000001> a,b;
    a[0] = 1;
    for (int i= 1;i <= n;i++){
        b = a;
        b <<= seq[i];
        a |= b;
    }
    int mx;
    for (int i  = sum/ 2;i > -1;i--){
        if (a[i]){
            mx = i;
            break;
        }
    }
    cout << sum  -  mx << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int tab[MAXN][3];
int dp[MAXN][3];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> tab[i][0] >> tab[i][1] >> tab[i][2];
    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + tab[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + tab[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + tab[i][2];
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

int main () {
    int N;
    char in[10000];

    scanf("%d", &N);
    scanf("%s", in);

    for (int i = 0; i < strlen(in); i++) {
        in[i] += N;
        if (!('A' <= in[i] && in[i] <= 'Z')) {
            in[i] -=26;
        }
    }
    printf("%s\n", in);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    // BFS。計算量はO(V+E)
    vl dist(n+1, -1);  // dist[v] : 頂点svから頂点vへの最短距離(-1のとき未訪問)
    queue<ll> Q;
    const ll sv = 0;  // BFSを始める頂点(デフォルトは0)
    dist[sv] = 0;
    Q.push(sv);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(ll pow6 = 1; v + pow6 <= n; pow6 *= 6) {
            ll u = v + pow6;
            if(dist[u] == -1) {
                dist[u] = dist[v] + 1;
                Q.push(u);   
            }
        }
        for(ll pow9 = 1; v + pow9 <= n; pow9 *= 9) {
            ll u = v + pow9;
            if(dist[u] == -1) {
                dist[u] = dist[v] + 1;
                Q.push(u);   
            }
        }
    }

    out(dist[n]);
    re0;
}

Measured memory_bytes: 1152
from sys import stdin
def main():
  readline = stdin.readline
  from builtins import int, print, range
  N, K, Q = map(int, readline().split())
  score = [0] * N
  for _ in range(Q):
    a = int(readline()) - 1
    score[a] += 1
  for i in range(N):
    if score[i] + K > Q:
      print('Yes')
    else:
      print('No')
main()


Measured memory_bytes: 4680
#include <bits/stdc++.h>
#ifdef BUG
  #include "debug.hpp"
#else
  #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int main(const int argc, char **argv) {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  size_t out = s.size();
  for (size_t k = 0; k < 2; ++k) {
    size_t val = 0;
    char c = k & 1 ? '0' : '1';
    for (const auto i: s) {
      val += i != c;
      c = c == '0' ? '1' : '0';
    }
    out = min(out, val);
  }
  cout << out;


  return EXIT_SUCCESS;
}


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

int main(int argc, char const* argv[]) {
	int A, B;
	scanf("%d %d", &A, &B);
	int ans = 0;
	for (int i = A; i <= B; i++) {
		string s = to_string(i);
		string rev = s;
		reverse(rev.begin(), rev.end());
		if (s == rev) ans++;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
  int l,r,d,ans=0;
  cin>>l>>r>>d;
  for (int i = l; i <= r; i++)
  {
      if (i%d==0)
      {
          ans++;
      }
      
  }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
# solution

nim,mike=map(int,input().split())

array=[]

for i in range(mike):
    p,y=map(int,input().split())
    array.append([i,p,y])

PY_sort=sorted(array,key=lambda x: x[2])

k=list(range(1,10**5+1))

v=[0]*10**5

cnt_dict=dict(zip(k,v))

arr=[]

for i,j,k in PY_sort:
    cnt_dict[j]+=1
    arr.append([i,str(j).zfill(6)+str(cnt_dict[j]).zfill(6)])

s = sorted(arr, key=lambda x: x[0])

for a,b in s:
    print(b)

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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}
struct data {
  ll x,y ;
};

void solve()
{
  ll n; 
  read(n);
  struct data arr[n]; 
  rep(i,0,n)
  read(arr[i].x,arr[i].y) ;

  ll f= 0 ,len = 0;
  rep(i,0,n)
  {
    if(arr[i].x==arr[i].y)
    len++;
  else
  {
      if(len>=3)
      {
        f=1;
        break;
      }
      else
        len = 0 ;
    }
  }

  if(len>=3)
    f=1;

  if(f==1)
    cout<<"Yes";
  else
    cout<<"No" ;

}

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n;
    cin >> n;
    vector < ll > v(n);
    for(ll i=0;i<n ;i++) cin >> v[i];
    srt(v);
    cout << v[n/2]-v[n/2-1] << endl;
    
    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3984
import numpy as np

s = np.array(list(map(int, input())))

a01 = np.tile([0,1], len(s)//2+1)
a10 = np.tile([1,0], len(s)//2+1)

if len(s)%2 != 0:
    a01 = np.delete(a01, len(s))
    a10 = np.delete(a10, len(s))
else:
    a01 = np.delete(a01, [len(s)-1,len(s)])
    a10 = np.delete(a10, [len(s)-1,len(s)])

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))

Measured memory_bytes: 17236
<?php
$N = trim(fgets(STDIN));
list($D,$X) = explode(" ",trim(fgets(STDIN)));
for ($i = 0;$i<$N;$i++){
$A[$i] = trim(fgets(STDIN));
$X += floor($D/$A[$i])+1;
if ($D%$A[$i]==0){
  $X -= 1;
}
}
echo $X;


Measured memory_bytes: 3700
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var hn = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var h = hn[0];
        var n = hn[1];
        var magics = new Magic[n];
        for (int i = 0; i < magics.Length; ++i)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            magics[i] = new Magic(ab[0], ab[1]);
        }

        var dp = new Transitive<int>[h + 1];
        for (int i = 1; i < dp.Length; ++i)
        {
            dp[i] = int.MaxValue;
        }
        for (int i = 0; i < magics.Length; ++i)
        {
            var t = Math.Min(dp.Length, magics[i].Power);
            for (int j = 1; j < dp.Length; ++j)
            {
                var jj = j - magics[i].Power;
                var x = dp[~jj >> 31 & jj];
                x.Value += magics[i].Cost;
                dp[j] -= x;
            }
        }

        Console.WriteLine(dp[h]);
    }

    struct Transitive<T>
    where T : IComparable<T>
    {
        public T Value;
        public Transitive(T value)
        {
            Value = value;
        }

        public override string ToString() => Value.ToString();

        public static implicit operator Transitive<T>(T value) => new Transitive<T>(value);
        public static Transitive<T> operator -(Transitive<T> x, Transitive<T> y) => x.Value.CompareTo(y.Value) < 0 ? x : y;
        public static Transitive<T> operator +(Transitive<T> x, Transitive<T> y) => x.Value.CompareTo(y.Value) > 0 ? x : y;
    }

    struct Magic
    {
        public readonly int Power;
        public readonly int Cost;

        public Magic(int p, int c)
        {
            Power = p;
            Cost = c;
        }
    }
}


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

template<typename T = double, bool is_min = true>
class ConvexHullTrick {
    using P = pair<T, T>;
    deque<P> L;

    T getY(const P &a, const T &x) {
        return a.first * x + a.second;
    }

    bool check(const P &a, const P &b, const P &c) {
        return (b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first);
    }

    bool empty() const {
        return L.empty();
    }

public:
    void add_line(T a, T b) {
        if (!is_min) {
            a *= -1;
            b *= -1;
        }
        P line(a, b);
        if (!L.empty() && L.back().first == a) {
            line.second = min(line.second, L.back().second);
            L.pop_back();
        }
        while (L.size() >= 2 && check(L[L.size() - 2], L[L.size() - 1], line)) {
            L.pop_back();
        }
        L.emplace_back(line);
    }

    T query(T x) {
        assert(!empty());
        int l = -1, r = L.size() - 1;
        while (l < r - 1) {
            int m = (l + r) / 2;
            if (getY(L[m], x) >= getY(L[m + 1], x)) {
                l = m;
            } else {
                r = m;
            }
        }
        return (!is_min ? -1 : 1) * getY(L[r], x);
    }
};

int main() {
    int n;
    long long C;
    cin >> n >> C;
    vector<int> hs(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> hs[i];
    }
    vector<long long> dp(n + 1);
    ConvexHullTrick<> cht;
    cht.add_line(-2 * hs[1], 1ll * hs[1] * hs[1] + C);
    for (int i = 2; i <= n; i++) {
        dp[i] = (long long) (cht.query(hs[i])) + 1ll * hs[i] * hs[i];
        cht.add_line(-2 * hs[i], 1ll * hs[i] * hs[i] + C + dp[i]);
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    int n;
    cin>>n;
    map<int,int> sm;
    for(int i=1;i<=n;i++){
        auto pf=prime_factorize(i);
        for(auto p : pf) sm[p.first]+=p.second;
    }

    int ans=0;
    for(int a=2;a<=n;a++){
        if(74<=sm[a]) ans++;
    }

    for(int a=2;a<=n;a++){
        for(int b=2;b<=n;b++){
            if(a!=b && sm[a]>=14 && sm[b]>=4) ans++; 
        }
    }

    for(int a=2;a<=n;a++){
        for(int b=2;b<=n;b++){
            if(a!=b && sm[a]>=24 && sm[b]>=2) ans++; 
        }
    }

    for(int a=2;a<=n;a++){
        for(int b=2;b<=n;b++){
            for(int c=b+1;c<=n;c++){
                if(a!=b && a!=c && sm[a]>=2 && sm[b]>=4 && sm[c]>=4) ans++; 
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3576
n = int(input())
a = list(map(int, input().split()))

if n == 2:
    print(abs(a[1] - a[0]))
    exit()

s = [0]

for i in range(n):
    s.append(s[-1]+a[i])

s = s[1:]

ma = s[-1]

ans = 10 ** 9

for i in s[:-1]:
    ans = min(ans, abs(ma-2*i))

print(ans)

Measured memory_bytes: 24824
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>

#include <cmath>
using namespace std;

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

int main() {
    
    int N = in();
    
    cout << (N*(N+1))/2 << endl;;
    return 0;
    
}




Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int k;
    vector<int> h;
    int h_tmp;
    int ans;
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> h_tmp;
        h.push_back(h_tmp);
    }
    sort(h.begin(), h.end());
    ans = h[k-1] - h[0];
    for(int i=1; i<n-k+1; i++){
        if(ans>(h[i+k-1]-h[i])){
            ans = h[i+k-1]-h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
 
using namespace std;
 
using ll = long long;
 
vector<ll> fact;
vector<ll> ifact;
const int mod = 1e9 + 7;
 
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll ret = (n & 1) ? x : 1;
  ll half = mod_pow(x, n / 2, mod);
  ret *= half * half % mod;
  return ret % mod;
}
 
void init() {
  const int f_max = 200000;
  fact.resize(f_max + 1);
  ifact.resize(f_max + 1);
  fact[0] = 1;
  for(int i = 1; i <= f_max; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  ifact[f_max] = mod_pow(fact[f_max], mod - 2, mod);
  for(int i = f_max - 1; i >= 0; i--) {
  	ifact[i] = (ifact[i + 1] * (i + 1)) % mod;
  }
}

ll comb(ll n, ll k) {
  return fact[n] * ifact[n - k] % mod * ifact[k] % mod;
}
 
 
int main() {
  init();
  ll N, M, K;
  cin >> N >> M >> K;
  ll sum = 0;
  for(ll d = 1; d <= N; d++) {
    sum += (d * (N - d)) % mod * M % mod * M % mod;
    sum %= mod;
  }
  for(ll d = 1; d <= M; d++) {
    sum += (d * (M - d)) % mod * N % mod * N % mod;
    sum %= mod;
  }
  cout << sum * comb(N * M - 2, K - 2) % mod << endl;
}


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

int K;
ll dp[13][10];  //dp[i][j] : i桁目がjのルンルン数
vector<ll> S(14, 0);  //S[i] i桁目までのルンルン数総数
bool head = true;  //求める数の先頭桁の捜索であるか否か

int main(){
  cin >> K;
  ll sup = K;

  for(int i = 0; i < 10; i++) dp[1][i] = 1;  //初期条件

  for(int i = 1; i < 13; i++){
    for(int k = 0; k < 10; k++){
      if(k == 0) dp[i+1][k] = dp[i][k] + dp[i][k+1];
      else if(k == 9) dp[i+1][k] = dp[i][k-1] + dp[i][k];
      else dp[i+1][k] = dp[i][k-1] + dp[i][k] + dp[i][k+1];
    }
  }

  for(int i = 1; i < 14; i++){
    for(int j = 1; j < 10; j++) S[i] += dp[i][j];
    S[i] = S[i] + S[i-1];
  }

  int i = 1;
  while(K > S[i]) ++i;

    int j = 1;
    K -= S[i-1];  //i桁目に答えあり
    while(i > 0){
      if(head){ 
        while(K > dp[i][j]){ K -= dp[i][j]; ++j; } 
        head = false; 
      }else{
        if(j == 0){ 
          while(j < 2 && K > dp[i][j]){ K -= dp[i][j]; ++j; }
        }else if(j == 9){ j = 8; 
          while(j <= 9 && K > dp[i][j]){ K -= dp[i][j]; --j; }
        }else { j -= 1; 
          while(j <= j+2 && K > dp[i][j]){ K -= dp[i][j]; ++j; } 
        }
      }
      cout << j;
      i -= 1;
    }

  return 0;

}



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

int main(){
  int N, K;
  cin >> N >> K;
  double ans = 0.0;
  //cout << (double)1/N << endl;
  for (int i = 1; i <= N; i++){
    int a = i;
    double count = 0.0;
    
    double prob = 1.0;
    while (a < K){
      a *= 2;
      prob /= 2;
    }
    //cout << "prob:" << prob << endl;
    ans += (double)1/N * prob;
    //cout << "ans:" << ans << endl;
  }
  
  printf("%.12f\n",ans);
}

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

int main(void) {
  int ans = 0, i=0, N;
  cin >> N;

  while(i<=N) {
    if(1<=i&&i<=9) ans++;
    else if(100<=i&&i<=999) ans++;
    else if(10000<=i&&i<=99999) ans++;
    else ;
    i++;
  }

  cout << ans << endl;
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,i,j;
    string s;
    cin>>s;
    if(s=="SUN")
        cout<<"7"<<"\n";
    else  if(s=="MON")
        cout<<"6"<<"\n";
    else  if(s=="TUE")
        cout<<"5"<<"\n";
    else  if(s=="WED")
        cout<<"4"<<"\n";
    else  if(s=="THU")
        cout<<"3"<<"\n";
    else  if(s=="FRI")
        cout<<"2"<<"\n";
    else  if(s=="SAT")
        cout<<"1"<<"\n";

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  string s ;
  cin >> s ;
  vector<string> vec = {"SUN","MON","TUE","WED","THU","FRI","SAT"} ;
  REP(i,7){
    if(vec.at(i)==s){
      cout << 7-i <<endl ;
    }
  }
  
  return 0 ;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    IOS;
    string N; cin >> N;
    REV(N);//下からみる
    N += '0';
    int n = SZ(N);
    vector<VI> dp(n+1, VI(2, INF));//d[i][j] 下桁からi桁で繰上りがその桁で起こったか
    dp[0][0] = 0;
    REP(i, n){
        REP(j, 2){
            int d = N[i] - '0';
            d += j;
            if(d < 10) chmin(dp[i+1][0], dp[i][j]+d);//繰り下がらない
            if(d > 0) chmin(dp[i+1][1], dp[i][j]+ 10-d);//繰り下がる
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 55964
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
int main(){
  ll D,N,ans;
  cin >> D >> N;
  if(N==100){
    if(D==0) cout << 101 << endl;
    else if(D==1) cout << 10100 << endl;
    else if(D==2) cout << 1010000 << endl;
    return 0;
  }
  cout << pow(100,D)*N << endl;
  return 0;
}

Measured memory_bytes: 512
def main():
    n, m = map(int, input().split())
    DP = [10**9] * 2**n
    DP[0] = 0
    updated_patterns = {0}
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)
        new_updated = set()
        for opened in updated_patterns:
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost
                new_updated.add(pattern)

        updated_patterns |= new_updated

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3836
H, W = map(int,input().split())
s = []
for i in range(H):
    s.append(input())

dx = [0, 0 , 1, -1]
dy = [1, -1, 0, 0 ]

for y in range(H):
    for x in range(W):
        flag = False
        if s[y][x] == "#":
            for i in range(4):
                if (0 <= y + dy[i] and y + dy[i] <= H-1) and (0 <= x + dx[i] and x + dx[i] <= W-1):
                    if s[y + dy[i]][x + dx[i]] == "#":
                        flag = True
                        break
            if flag == False:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int a, b, d;
    while (cin >> a >> b >> d, a) {
        int opt_x = -1, opt_y = -1;
        int ma_xy = inf, ma_axby = inf;
        rep(x, 50001) {
            if ((a * x + d) % b == 0) {
                int y = (a * x + d) / b;
                if (x + y < ma_xy || (x + y == ma_xy && a * x + b * y < ma_axby)) {
                    opt_x = x, opt_y = y;
                    ma_xy = x + y;
                    ma_axby = a * x + b * y;
                }
            }
            if ((a * x - d) % b == 0) {
                int y = abs(a * x - d) / b;
                if (x + y < ma_xy || (x + y == ma_xy && a * x + b * y < ma_axby)) {
                    opt_x = x, opt_y = y;
                    ma_xy = x + y;
                    ma_axby = a * x + b * y;
                }
            }
        }

        cout << opt_x << " " << opt_y << endl;
    }
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  ll n,k;
  cin>>n>>k;
  vector<ll>c(n),v(n);
  rep(i,n)cin>>c[i];
  ll ans=31981921122;
  rep(i,(1<<n)){
    ll cost=0,MAX=0;
    if(__builtin_popcount(i)<k)continue;
    rep(j,n){
      if(i & (1<<j)){
        if(MAX>=c[j]){
          cost+=MAX-c[j]+1;
          ++MAX;
        }
      }
      MAX=max(MAX,c[j]);
    }
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	char a[17];
	int ans = 0;

	scanf("%s",a);
	
	if(a[0]!='C'){ans++;}
	if(a[1]!='O'){ans++;}
	if(a[2]!='D'){ans++;}
	if(a[3]!='E'){ans++;}
	if(a[4]!='F'){ans++;}
	if(a[5]!='E'){ans++;}
	if(a[6]!='S'){ans++;}
	if(a[7]!='T'){ans++;}
	if(a[8]!='I'){ans++;}
	if(a[9]!='V'){ans++;}
	if(a[10]!='A'){ans++;}
	if(a[11]!='L'){ans++;}
	if(a[12]!='2'){ans++;}
	if(a[13]!='0'){ans++;}
	if(a[14]!='1'){ans++;}
	if(a[15]!='6'){ans++;}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
	int N, C, s[100000], t[100000], c[100000], count = 0, tb[30][200000] = { 0 }, sum = 0, tmp = 0;
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> s[i] >> t[i] >> c[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 2 * s[i] - 1; j < t[i] * 2; j++) {
			tb[c[i] - 1][j] = 1;
		}
	}

	for (int i = 0; i < 200000; i++) {
		for (int j = 0; j < 30; j++) {
			tmp += tb[j][i];
			if (sum < tmp) sum = tmp;
			//if (sum == C) break;
		}
		tmp = 0;
	}
	cout << sum;
}

Measured memory_bytes: 24832
#include <cstdio>
int idx[200005];
int main()
{
	// freopen("AGC014-F.in", "r", stdin);
	int n, ans = 0, lst;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		idx[x - 1] = i;
	}
	for (int i = n - 2; i >= 0; i--)
	{
		if (!ans)
		{
			if (idx[i] > idx[i + 1])
			{
				ans++;
				lst = i + 1;
			}
			continue;
		}
		if ((idx[lst] < idx[i + 1]) + (idx[i + 1] < idx[i]) + (idx[i] < idx[lst]) == 2)
		{
			ans++;
			lst = i + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, id ;
    cin >> s >> id ;

    bool flag = 0 ;
    for( int i = 0 ; i < s.size() ; ++i )
    {
        if( s.at(i) != id.at(i) )
        {
            flag = 1 ;
        }
    }
    if(flag)
    {
        cout << "No" ;
    }
    else
    {
        cout << "Yes" ;
    }
    cout << endl ;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        if(n == m) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
use std::io::stdin;

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

fn main() {
    let s = read();
    println!(
        "{}",
        match s.as_str() {
            "ABC" => "ARC",
            _ => "ABC",
        },
    )
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  pb push_back


///shortcuts
///ctr+alr+T

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


    int n; cin>>n;
    vector<int>h(n);

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

    vector<int>cost(n,1e9+5);

    cost[0] = 0;
    for (int i = 0; i < n-1; ++i) {

        cost[i+1] = min(cost[i+1],cost[i]+abs(h[i+1]-h[i]));
        if(i<n-2)
            cost[i+2] = min(cost[i+2],cost[i]+abs(h[i+2]-h[i]));


       /* cout<<i<<endl;
        cout<<cost[i]<<endl;
        cout<<"1: "<<cost[i+1]<<endl;
        if(i<n-2)
        cout<<"2: "<<cost[i+2]<<endl;*/
    }


    cout<<cost[n-1]<<endl;



}




Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using ll = long long;
using namespace std;
int main() {
	int N;
	cin >> N;
	ll a[200001];
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	ll sum1 = 0;
	ll sum2 = 0;
	ll ans = 1e10;
	for (int i = 0; i < N-1; ++i) {
		sum1 += a[i];
		sum2 = sum - sum1;
		ll sum3 = abs(sum2 - sum1);
		ans = min(ans, sum3);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char keep = '0';
        int result = 0;
        for(int i = 0; i < N; i++){
            if(S.charAt(i) != keep){
                keep = S.charAt(i);
                result++;
            }
        }
        System.out.println(result);
    }
}


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

int main()
{
int x,n,i,y;
unordered_map<int,int> a;
cin>>x>>n;
for(i=0;i<n;i++)
{
cin>>y;
a[y]=i;
}
for(i=0;;i++)
{
int w=x-i,q=x+i;
if(a.find(w)==a.end())
{
cout<< w;
return 0;
}
if(a.find(q)==a.end())
{
cout<<q;
return 0;
}
}
return 0;
}





Measured memory_bytes: 3624
n=int(input())
if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800<=n<=999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
elif 1800<=n<=1999:
    print(1)

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

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

int main() {
  int n, m,a,b,cut = 0, ans = 0;;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  rep(i, m) cin >> a >> b, v[i] = {b, a};
  sort(v.begin(), v.end());
  for (auto x : v) if (x.second > cut) ans++, cut = --x.first;
  cout << ans << endl;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    map<string, int> m;
    map<string, int>::iterator ite;
    for(int i=0; i<N;i++){
      str ss; cin>>ss;
      m[ss]++;
    }
    int ans=0;
     for(ite = m.begin(); ite != m.end() ; ++ite){
       if((ite->second)%2==1) ans++;
     }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 12544
#include <stdio.h>
int main(void)
{
    int a,b,ans;
    char op;
    
    while( 1 ){
        scanf("%d %c %d", &a, &op, &b);
        if(op!='?'){
            switch(op) {
            case '+': ans = a + b; break;
            case '-': ans = a - b; break;
            case '*': ans = a * b; break;
            case '/': ans = a / b; break;
            }
            printf("%d\n",ans);
        }else{
            break;
        }
    }
    return 0;
}


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

int main(){
	std::vector<int> a(4, 0), b(4, 0);
	
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		int hit = 0, blow = 0;
		for(int i = 0 ; i < 4 ; ++i){
			if(a[i] == b[i]){
				++hit;
				continue;
			}
			for(int j = 0 ; j < 4 ; ++j){
				if(a[i] == b[j])
					++blow;
			}
		}
		std::cout << hit << " " << blow << std::endl;
	}
    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
vector<ii> vet;
int main(){
  int n,k, val;
  cin >> n >> k;
  for(int i= 0;i<n;i++){
    scanf("%1d",&val);
    if(vet.size() == 0 or vet.back().first != val)
      vet.push_back({val,1});
    else
      	vet.back().second++;
  }
  
  int soma=0,maxi =0;
  int r=0;
  int k1 = k;
  for(int i = 0;i<vet.size();i++){
    
    while(r < vet.size() and ( (vet[r].first == 1) or (vet[r].first == 0 and k1) ) ){
			if(vet[r].first == 0)
        	    k1--;
      soma += vet[r].second;
      r++;
    }
    maxi = max(maxi,soma);
    if(vet[i].first == 0)
    	k1++;
  	soma -= vet[i].second;
    
  }
  cout<<maxi;
  
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>

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

int32_t main()
{
    speed upp
    int x,y,n,m,k;
    cin>>x>>y>>n>>m>>k;
    int a[n],b[m],c[k];
    f(i,0,n-1)
        cin>>a[i];
    f(i,0,m-1)
        cin>>b[i];
    f(i,0,k-1)
        cin>>c[i];
    sort(a,a+n);
    sort(b,b+m);
    sort(c,c+k);
    int d[x+y+1],j=0;
    r(i,n-1,n-x)
        d[j++]=a[i];
    r(i,m-1,m-y)
        d[j++]=b[i];
    sort(d,d+x+y);
    j=k-1;
    f(i,0,x+y-1)
    {
        if(j<0)
            break;
        if(c[j]>d[i])
        {
            d[i]=c[j];
            j--;
        }
        else
            break;
    }
    int ans=0;
    f(i,0,x+y-1)
        ans+=d[i];
    cout<<ans;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> b(M);
  int ans = 0;
  for(int i = 0; i < M; i++){
    cin >> b[i];
  }
  for(int i = 0; i < N; i++){
    vector<int> a(M);
    int sum = 0;
    for(int i = 0; i < M; i++){
      cin >> a[i];
      sum += a[i] * b[i];
    }
    if(sum + C > 0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
r,g,b = map(int, input().split())
k = int(input())

a = 0
while r>=g:
  g *= 2
  a += 1

while g>=b:
  b *= 2
  a += 1

if a<=k:
  print("Yes")
else:
  print("No")

# print(r,g,b,a)



Measured memory_bytes: 9160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll b[22]; ll a[22][22];
signed main() {
	ll n, m, c, cnt = 0, ans = 0;
	cin >> n >> m >> c;
	rep(i, m)cin >> b[i];
	rep(i, n) { rep(j, m)cin >> a[i][j]; }
	rep(i, n) {
		rep(j, m) {
			cnt += b[j] * a[i][j];
		}
		if (cnt + c > 0)ans++;
		cnt = 0;
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}

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

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

typedef long long int int64;


const int N = 505;
char f[N][N];

int n;

int getRowCnt(int r)
{
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += (f[r][i] == '#');
	return ans;
}

int getColCnt(int c)
{
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += (f[i][c] == '#');
	return ans;
}

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

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%s", f[i] );

	bool hasFullRow = false;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int cnt = getRowCnt(i);
		sum += cnt;
		if (cnt == n)
			hasFullRow = true;
	}
	if (hasFullRow)
	{
		int ans = 0;
		for (int i = 0; i < n; i++)
			if (getColCnt(i) < n)
				ans++;
		printf("%d\n", ans);
		return 0;
	}
	if (sum == 0)
	{
		printf("-1\n");
		return 0;
	}
	int cntNonFullCol = 0;
	for (int i = 0; i < n; i++)
		if (getColCnt(i) < n)
			cntNonFullCol++;
	int answer = n * n;
	for (int r = 0; r < n; r++)
	{
		int cnt0 = n - getRowCnt(r);
		int ans = cnt0 + cntNonFullCol;
		if (getColCnt(r) == 0)
			ans++;
		answer = min(answer, ans);
	}
	printf("%d\n", answer);

	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(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 int maxm = 1e6 + 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 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;
int a[maxn];
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	bool ok = 0;
	int cur = 1,ans = 0;
	for(int i = 0;i < n;i++){
		if(a[i] == cur){
			ok = 1;
			cur++;
		}
		else ans++;
	}
	if(!ok) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 1024
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextLine()) {
            Path2D.Double s = new Path2D.Double();
            String[] S = sc.nextLine().split(" ");
            double[] z = new double[8];

            for (int i = 0; i < 8; i++) {
                z[i] = Double.parseDouble(S[i]);
            }

            s.moveTo(z[0], z[1]);
            s.lineTo(z[2], z[3]);
            s.lineTo(z[4], z[5]);

            Point2D.Double p = new Point2D.Double(z[6], z[7]);
            System.out.println((s.contains(p))? "YES" : "NO");
        }
    }
}

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

using namespace std;

int main(void){

    string str;
    int count = 0, max = 0;

    cin >> str;

    for(int i = 0;str[i] != '\0';i++){
        if(str[i] == 'A' || str[i] == 'T' ||
         str[i] == 'G' || str[i] == 'C'){
             count++;
             if(count >= max) max = count;
        }else{
            count = 0;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256