akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

bool visited[101][100001] = {false};
long long int memo[101][100001] = {0};
int weight[101] = {0};
int value[101] = {0};

long long int knap(int N, int W)
{
    
    if (!visited[N][W])
    {
        visited[N][W] = true;
        if (N == 0 || W == 0)
        {
            memo[N][W] = 0;
        } 
        else if (weight[N] > W)
        {
            memo[N][W] = knap(N-1, W);
        }
        else
        {
            memo[N][W] = max(knap(N-1, W), value[N] + knap(N-1, W - weight[N]));
        }
        return memo[N][W];
    }
    else
    {
        return memo[N][W];
    }
    
}

int main()
{
    int N, W, i, j;
    cin>>N>>W;

    for(i=1; i<=N; i++)
    {
        cin>>weight[i]>>value[i];
    }

    cout<<knap(N, W)<<endl;
    return 0;
}


Measured memory_bytes: 88576
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    p = [0] * M
    S = [0] * M
    for i in range(M):
        p[i] , S[i] = map(str, input().split())
    for i in range(M):
        p[i] = int(p[i])

    AC = 0
    WA = 0
    l = [0] * N
    for i in range(M):
        if l[p[i] - 1] != 1:
            if S[i] == 'WA':
                l[p[i] - 1] -= 1
            elif S[i] == 'AC':
                WA += l[p[i] - 1] * (-1)
                l[p[i] - 1] = 1
                AC += 1
    print(AC, WA)

if __name__ == '__main__':
    main()


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

struct Domino
{
  int id;
  int op;
  Domino(int _id, int _op) { id = _id; op = _op; }
};

vector<pair<int,int> > Dominos;
vector<Domino> graph[7];
bool visited[28];
int n;

bool dfs(int num, int d)
{
  if (d == n) { return true; }
  if (d > n) return false;
  if (graph[num].empty()) { return false; }
  for (int i=0;i<graph[num].size();i++)
  {
    int nextid = graph[num][i].id;
    int nextop = graph[num][i].op;
    if (!visited[nextid])
    {
      visited[nextid] = true;
      bool res = dfs(nextop, d+1);
      if (res) { return true; }
      else { visited[nextid] = false; }
    }
  }
  return false;
}


int main()
{
  while (cin >> n)
  {
    for (int i=0;i<7;i++) graph[i].clear();
    Dominos.clear();
    bool found = false;

    for (int i=0;i<n;i++)
    {
      int m, x, y;
      cin >> m;
      x = m / 10; y = m % 10;
      Dominos.push_back(make_pair(x, y));

      Domino dx(i, y), dy(i, x);
      if (x == y) graph[x].push_back(dx);
      else
      {
        graph[x].push_back(dx);
        graph[y].push_back(dy);
      }
    }

    for (int id=0;id<n;id++)
    {
      for (int i=0;i<n;i++) visited[i] = false;
      int x = Dominos[id].first;
      int y = Dominos[id].second;
      visited[id] = true;
      if (dfs(x, 1)) { found = true; break; }
      if (x != y) if (dfs(y, 1)) { found = true; break; }
    }
    if (found) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

main() {
    int H,W,h,w; cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000000
#define N 1000005
#define y1 ofsdf
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

ll n, kok, x1, x2, x3, y1, y2, y3;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	if(n == 1000000000000000000){
		printf("0 0 0 %d %d 0\n", inf, inf);
		return 0;
	}
	x1 = inf;
	y2 = n/inf + 1;
	x2 = 1;
	y1 = inf - n%inf;
	printf("0 0 %lld %lld %lld %lld\n", x1, y1, x2, y2);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

const int MOD = 998244353;

template<class t> class SegTreeLazy {
    vector<ll> *arr, st, lazy; int n;

    void build(int u, int i, int j) {
        if (i == j) {
            st[u] = (*arr)[i];
            return;
        }
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        build(l, i, m);
        build(r, m+1, j);
        st[u] = t::merge_op(st[l], st[r]);
    }

    void propagate(int u, int i, int j, ll x) {
        st[u] = t::range_op(st[u], i, j, x);
        if (i != j) {
            lazy[u*2+1] = t::prop_op(lazy[u*2+1], x);
            lazy[u*2+2] = t::prop_op(lazy[u*2+2], x);
        }
        lazy[u] = 0;
    }

    ll query(int a, int b, int u, int i, int j) {
        if (j < a or b < i) return t::neutro;
        if (lazy[u]) propagate(u, i, j, lazy[u]);
        if (a <= i and j <= b) return st[u];
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        ll x = query(a, b, l, i, m);
        ll y = query(a, b, r, m+1, j);
        return t::merge_op(x, y);
    }

    void update(int a, int b, ll value, int u, int i, int j) {
        if (lazy[u]) propagate(u, i, j, lazy[u]);
        if (a <= i and j <= b) propagate(u, i, j, value);
        else if (j < a or b < i) return;
        else {
            int m = (i+j)/2, l = u*2+1, r = u*2+2;
            update(a, b, value, l, i, m);
            update(a, b, value, r, m+1, j);
            st[u] = t::merge_op(st[l], st[r]);
        }
    }

public:
    SegTreeLazy(vector<ll>& v) {
        arr = &v;
        n = v.size();
        st.resize(n*4+5);
        lazy.assign(n*4+5, 0);
        build(0, 0, n-1);
    }

    ll query(int a, int b) {
        return query(a, b, 0, 0, n-1);
    }

    void update(int a, int b, ll value) {
        update(a, b, value, 0, 0, n-1);
    }
};

struct RSQ { // range sum query
    static ll const neutro = 0;
    static ll merge_op(ll x, ll y) { return (x + y)%MOD; }
    static ll range_op(ll st_u, int i, int j, ll x) { return (st_u + ((j - i + MOD + 1ll)%MOD * x%MOD))%MOD; }
    static ll prop_op(ll child, ll x) { return (child + x)%MOD; }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n, k;
    cin >> n >> k;
    vii P(k);
    for (int i = 0; i < k; ++i) cin >> P[i].ff >> P[i].ss;
    vll A(n,0);
    A[0] = 1;
    SegTreeLazy<RSQ> stl(A);
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < k; ++i) {
            int l = P[i].ff+j, r = P[i].ss+j;
            stl.update(l, r, stl.query(j,j));
        }
    }
    cout << stl.query(n-1, n-1) << "\n";
}

Measured memory_bytes: 17172
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int K, N;

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

  cin >> N >> K;

  if (K != 1) cout << N - K << endl;
  else cout << 0 << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

ll X;

void solve() {
    vi factors;
    FOR (d, 1, 100001) {
        if (X%d == 0) factors.push_back(d);
    }

    FORE (d, factors) {
        ll Y = X/d;
        FOR (a, 1, 10000) {
            ll b = a-d;
            if (a*a*a*a > 1e9+10) continue;
            if (b*b*b*b > 1e9+10) continue;
            if (a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b == Y) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

int main() {
    cin >> X;
    solve();
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>k;
  vector<int> a(n);
  for(auto&&o:a) cin >>o;
  sort(a.begin(),a.end());
  lol ans=0;
  for(int i=0;i<k;i++) ans+=a[i];
  cout <<ans<<'\n';
  return (0);
}

Measured memory_bytes: 3616
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    long[] AS;
    long max_a;
    foreach (a; readln.split.to!(long[])) {
        max_a = max(max_a, a);
        AS ~= a;
    }

    long l, r = max_a;
    while (l+1 < r) {
        auto m = (l+r)/2;
        long k;
        foreach (a; AS) {
            k += a/m;
            if (a%m == 0) --k;
        }
        if (k <= K) {
            r = m;
        } else {
            l = m;
        }
    }
    writeln(r);
}

Measured memory_bytes: 13184
'''
https://beta.atcoder.jp/contests/agc023/submissions/2426081
'''
n = int(input())
A = map(int, input().split())
B = {0:1}
s = 0
ans = 0
for a in A:
    s += a
    B_s = B.get(s, 0) 
    ans += B_s
    B[s] = B_s + 1
print(ans)

Measured memory_bytes: 44944
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,H,W,K,ans,cnt=0;
  cin>>H>>W>>K;
  rep(i,H)cnt=(cnt+(H-i)*i%mod)%mod;
  ans=cnt*W%mod*W%mod;
  cnt=0;
  rep(i,W)cnt=(cnt+(W-i)*i%mod)%mod;
  ans+=cnt*H%mod*H%mod;
  ans%=mod;
  cout<<ans*modncr(H*W-2,K-2)%mod<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	vector<int> X,Y;
	int d,n,m;
	while(scanf("%d",&d),d) {
		scanf("%d %d",&n,&m);
		X.clear();
		Y.clear();
		X.push_back(0);
		Y.push_back(0);
		for(int i=0;i<(n-1);i++) {
			int di;
			scanf("%d",&di);
			X.push_back(di);
			Y.push_back(d-di);
		}
		sort(X.begin(),X.end());
		sort(Y.begin(),Y.end());
		int sum=0;
		for(int i=0;i<m;i++) {
			int k;
			scanf("%d",&k);
			sum+=min(k-*(upper_bound(X.begin(),X.end(),k)-1),(d-k)-*(upper_bound(Y.begin(),Y.end(),d-k)-1));
		}
		printf("%d\n",sum);
	}
}

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

int main(){
  vector<int> L;
  int l;
  for(int i=0;i<3;i++){
    cin >> l;
    L.push_back(l);
  }
  sort(L.begin(),L.end());
  if(L[0]==L[2]){
    cout<< "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  

}

Measured memory_bytes: 256
N = int(input())
"""
リスト最下位までの人数は確実にいる，
あとはリスト最下位の点数が0になるまで
1刻みに人がいた場合が最大人数
"""
List = sorted([tuple(map(int, input().split(" "))) for i in range(N)],reverse=True)
print(List[0][0]+List[0][1])


Measured memory_bytes: 17800
#include <stdio.h>

int main() {
	int i, k, n, m, target[100], point[100], game[100][100];
	scanf("%d %d", &n, &m);
	for( i = 0; i < m; i++) scanf("%d", &target[i]);
	for( i = 0; i < n; i++) point[i] = 0;
	for( i = 0; i < m; i++) {
		for( k = 0; k < n; k++) {
			scanf("%d", &game[i][k]);
		}
	}
	// ????¨?
	for( i = 0; i < m; i++) {
		for( k = 0; k < n; k++) {
			if(target[i] == game[i][k]) {
				point[k]++;
			} else {
				point[target[i] - 1]++;
			}
		}
	}
	for( i = 0; i < n; i++) printf("%d\n", point[i]);
	return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

int n, m;
char s[1000000], t[1000000];

int main()
{
    n = read(), m = read();
    scanf("%s", s);
    scanf("%s", t);
    int g = __gcd(n, m);
    for (int i = 0; i < g; i++)
        if (s[n / g * i] != t[m / g * i])
            return puts("-1"), 0;
    printf("%lld\n", 1LL * n * m / g);
}


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

using ll = long long int;
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  
  // P3
 








  // P2
  // cin >> N;
  // ll sum = 0;

  // rep(i, 0, N){
  //   if(i % 3 != 0 && i % 5 != 0){
  //     sum += i;
  //   }
  // }

  // cout << sum << endl;



  string N;
  cin >> N;

  rep(i, 0, 3){
    if(N[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
#define int long long
typedef long double ld;
const long double pi= 3.14159265358979323846264338327950288;
int a[100001], dp[100001], b[100001];
vector<int>d[100001];
signed main() {
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		cin >> a[i];
		b[a[i]]++;
	}
	vector<int>v;
	queue<int>s;
	for (int i = 2; i <= n; i++) {
		if (b[i] == 0) 
			s.push(i);
	}
	while (!s.empty()) {
		int t = s.front(); s.pop();
		v.push_back(t);
		b[a[t]]--;
		if (b[a[t]] == 0)
			s.push(a[t]);
	}
	for (int i = 0; i < n; i++) {
		int t = v[i];
		if (d[t].size() == 0) {
			dp[t] = 0;
			d[a[t]].push_back(1);
		}
		else {
			int ans = 0;
			sort(d[t].begin(), d[t].end());
			reverse(d[t].begin(), d[t].end());
			for (int j = 0; j < d[t].size(); j++) {
				ans = max(ans, d[t][j] + j);
			}
			dp[t] = ans;
			d[a[t]].push_back(ans+1);
		}
	}
	cout << dp[1] << endl;
	cin >> n;
}

Measured memory_bytes: 8820
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int S=scan.nextInt();
		int h=S/3600;
		int m=(S%3600)/60;
		int s=(S%3600)%60;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  ll n,m;
  cin>>n;
  ll count=0;
  ll ans=0;
  if(n%2==1){
      cout<<0<<endl;
  }
  else{
      m=n/2;
      for(;;){
          if(m>=5){
          m=m/5;
          count++;
          }
          else{
              break;
          }
      }
      for(int i=1;i<=count;i++){
        ll p=2*pow(5,i);
        ll q=n/p;
          ans+=q;
      }
      cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int x=a[0],y=a[1];
    vector<int> v;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            v.pb(i);
            v.pb(x/i);
        }
    }
    for(int i=1;i*i<=y;i++){
        if(y%i==0){
            v.pb(i);
            v.pb(y/i);
        }
    }
    sort(be(v));
    bool maki;
    for(int i=v.size()-1;i>=0;i--){
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%v[i]){
                if(maki){
                    j=n;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                printf("%d\n", v[i]);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main(){
  int a;
  int b;
  int c;
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  if (a > c) {
    int d;
    d = c;
    c = a;
    a = d;
  }
  if(c < b) {
    int d;
    d = c;
    c = b;
    b = d;
  } else if(a > b){
    int d;
    d = a;
    a = b;
    b = d;
  }
  std::cout << a<< " " << b << " " << c << std::endl;
  return 0;
}


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

int main()
{
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  sort(p.begin(), p.end());
  int ans = 0;
  int index = 0;
  for (int i = 0; i <= 101; i++)
  {
    if (index < N && i == p.at(index))
    {
      index++;
      continue;
    }
    if (abs(ans - X) > abs(i - X)) ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
K = int(readline().rstrip())
X = list(map(int, readline().split()))

half = K / 2
ans = 0
for x in X:
    ans += min(x, K - x)
ans *= 2

print(ans)

Measured memory_bytes: 3060
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int x: arr)
            res += x;
         int[] freq = new int[100001];
         for(int x: arr)
            freq[x]++;
         StringBuilder sb = new StringBuilder();
         int Q = Integer.parseInt(infile.readLine());
         while(Q-->0)
         {
            st = new StringTokenizer(infile.readLine());
            int B = Integer.parseInt(st.nextToken());
            int C = Integer.parseInt(st.nextToken());
            long lost = (long)B*freq[B];
            long gain = (long)C*freq[B];
            res += gain-lost;
            freq[C] += freq[B];
            freq[B] = 0;
            sb.append(res+"\n");
         }
         System.out.print(sb);
      }
   }

Measured memory_bytes: 59552
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int n,k;
int a[3000];
int mod=1e9+7;
int ans;

signed main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		int pre=0;
		int post=0;
		for(int j=0;j<n;j++){
			if(j<i){
				if(a[i]>a[j])pre++;
			}
			if(i<j){
				if(a[i]>a[j])post++;
			}
		}
		ans+=k*post;
		ans%=mod;
		ans+=((k*(k-1)/2)%mod)*(pre+post);
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N, M; cin >> N >> M;
        int p, q; p = 1; q = N;
        if (N & 1) {
            rep(i, M) {
                cout << p << " " << q << endl;
                p++; q--;
            }
        }
        else {
            rep(i, M) {
                if (N / 4 + 1 == p) p++;
                cout << p << " " << q << endl;
                p++; q--;
            }
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    int ans = INF;
    for(int i = 0; i < (1 << n); i++){
        for(int j = 0; j < (1 << n); j++){
            for(int k = 0; k < (1 << n); k++){
                bool f = true;
                int x = 0, y = 0, z = 0;
                int cx = 0, cy = 0, cz = 0;
                for(int l = 0; l < n; l++){
                    int cnt = 0;
                    if(i & (1 << l)){
                        cnt++; x += d[l]; cx++;
                    }
                    if(j & (1 << l)){
                        cnt++; cy++;
                        y += d[l];
                    }
                    if(k & (1 << l)){
                        cnt++; cz++;
                        z += d[l];
                    }
                    if(cnt > 1){
                        f = false;
                        break;
                    }
                }
                if(!f) continue;
                if(cx == 0 || cy == 0 || cz == 0) continue;
                int tmp = (cx + cy + cz - 3) * 10;
                tmp += abs(a - x) + abs(b - y) + abs(c - z);
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < n; ++i)
const long long mod=1e9+7; //10^9+7

/*
  rep(i,5){
    sum+=i;
  }
*/

int main() {
    int a,b,c,n,x;

    cin >>x>>a;

    if(x<a){
      cout << 0;
    }else{
      cout << 10;
    }





  return 0;
}


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

int main() {
  long long n,d;
  cin >> n >> d;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (x*x+y*y<=d*d) cnt++;
    else continue;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int arr[a];
	for(int i=0; i<a; i++)
		cin >> arr[i];
	int count = 0;
	while(a)
	{
		count ++;
		a -= b;
		if(a <= 0) break;
		a ++;
	}
	printf("%d\n",count);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

// if we convert that bound day to x ,then person cant work for k days in any possilbe way
// bound day is o

void solve()
{
    ll n, k, c;
    cin >> n >> k >> c;
    ll i, j;
    string s;
    cin >> s;
    ll a[n];
    for (i = 0; i < n; i++)
    {
        a[i] = (s[i] == 'o');
    }
    ll next_work[n];
    ll prev_work[n];
    memset(next_work, -1, sizeof(next_work));
    memset(prev_work, -1, sizeof(prev_work));
    next_work[n - 1] = (a[n-1] ? n - 1 : -1);
    prev_work[0] = (a[0])? 0:-1;
    for(i=1;i<n;i++)
    {
        if (a[i])
        {
            prev_work[i] = i;
        }
        else
        {
            prev_work[i] = prev_work[i - 1];
        }
    }
    for (i = n - 2; i >= 0; i--)
    {
        if (a[i])
        {
            next_work[i] = i;
        }
        else
        {
            next_work[i] = next_work[i + 1];
        }
    }
    ll days=0;
    for(i=0;i<n;i)
    {
        ll nowday = next_work[i];
        if(nowday==-1)break;
        days++;
        i=nowday+c+1; 
    }
    if(days>k)
    {
        return;
    }
    // cout<<"Yet\n";
    // in these cases only max k days of work is possible
    
    ll l[k],r[k];
    memset(l,-1,sizeof(l));
    memset(r,-1,sizeof(r));
    days=0;
    for(i=0;i<n;)
    {
        ll nowday = next_work[i];
        l[days++]=nowday;
        i=nowday+c+1;
    }
    days=0;
    for(i=n-1;i>=0;)
    {
        ll nowday = prev_work[i];
        r[days++]=nowday;
        i=nowday-c-1;
    }
    reverse(r,r+k);
    for(i=0;i<k;i++)
    {
        // cout<<l[i]<<" "<<r[i]<<"\n";
        if(l[i]==r[i])
        {
            cout<<l[i]+1<<"\n";
        }
    }
    
}

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

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 11544
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m,a,b,c;
string s,t;

int main() {
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == t[i]) {
			cnt++;
		}
	}
	cout << cnt<<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] *= 2;
    }
    long long x = 0;
    for (int i = 0; i < N; ++i) {
        if (i%2 == 0) x += A[i];
        else x -= A[i];
    }
    long long ans = x / 2;
    
    for (int i = 0; i < N; ++i) {
        cout << ans << " ";
        ans = A[i] - ans;
    }
    cout << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin >> d[i];
  vector<int> v;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      v.push_back(d[i]*d[j]);
    }
  }
  sort(v.begin(),v.end(),greater<int>());
  for(int i=0;i<v.size();i++){
    string s = to_string(v[i]);
    bool ok=true;
    for(int j=1;j<s.length();j++){
      if(s[j]!=s[j-1]+1){
	ok=false;
	break;
      }
    }
    if(ok){
      cout << v[i] << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 4972
#include<iostream>
int N;
int mod[4] = {1000, 100, 10, 1};
int A[10];
int sum;

int main() {
	std::cin >> N;
	for (int i = 1; i <= 4; i++) {
		A[i] = N / mod[i - 1];
		sum += A[i];
		N %= mod[i - 1];
	}
	if (sum == 7) {
		std::cout << A[1] << "+" << A[2] << "+" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - A[2] * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "+" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - A[3] * 2 == 7) {
		std::cout << A[1] << "+" << A[2] << "-" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - A[4] * 2 == 7) {
		std::cout << A[1] << "+" << A[2] << "+" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[2]+A[3]) * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "-" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[4] + A[3]) * 2 == 7) {
		std::cout << A[1] << "+" << A[2] << "-" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[2] + A[4]) * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "+" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[2] + A[3] + A[4]) * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "-" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#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();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N, K, Q;
    cin >> N >> K >> Q;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ans = L_INF;
    Vl cand, part;
    for (int i = 0; i < N; i++) {
        cand.clear();
        part.clear();
        int n_part;
        for (int j = 0; j < N; j++) {
            if (A[i] <= A[j]) {
                part.emplace_back(A[j]);
            }
            else {
                n_part = (int)part.size();
                if (n_part >= K) {
                    sort(part.begin(), part.end());
                    cand.insert(cand.end(), part.begin(), part.begin() + (n_part - K) + 1);
                }
                part.clear();
            }
        }

        n_part = (int)part.size();
        if (n_part >= K) {
            sort(part.begin(), part.end());
            cand.insert(cand.end(), part.begin(), part.begin() + (n_part - K) + 1);
        }
        part.clear();


        if ((int)cand.size() >= Q) {
            sort(cand.begin(), cand.end());
            ans = min(ans, cand[Q - 1] - cand[0]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
let readInt _ = stdin.ReadLine() |> int


readInt ()
|> fun x ->
    seq {
        for a in 1 .. x do
            for b in 1 .. (x / a) do
                let c = x - (a * b)
                if c <> 0 then yield (a, b, c)
    }
|> Seq.length
|> printfn "%d"


Measured memory_bytes: 43076
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > x) {
                System.out.println(ans);
                System.exit(0);
            } else if (i == a.length - 1 && a[i] != x) {
                System.out.println(ans);
                System.exit(0);
            }
            x -= a[i];
            ans++;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23252
import random

class dice:
    def __init__(self, t, S, E):
        self.dice = list(map(int, input().split()))
        self.t = t
        self.S = S
        self.E = E
        self.now_dice()
    
    def roll(self, order):
        if order == 'E':
            self.t, self.E = self.W, self.t
        elif order == 'N':
            self.t, self.S = self.S, self.g
        elif order == 'S':
            self.t, self.S = self.N, self.t
        elif order == 'W':
            self.t, self.E = self.E, self.g
        self.now_dice()
    
    def now_dice(self):
        self.N = 7 - self.S
        self.g = 7 - self.t
        self.W = 7 - self.E
        self.now = [self.t, self.S, self.E, self.N, self.W, self.g]
        return self.now

if __name__ == '__main__':
    dice_1 = dice(1, 2, 3)
    dice_2 = dice(1, 2, 3)
    loop = ['N', 'N', 'N', 'E']*4
    loop_2 = ['E']*5
    p = 0
    ans = 0
    for v in loop:
        dice_1.roll(v)
        if dice_1.dice[dice_1.S-1] == dice_2.dice[dice_2.S-1]:
            for v in loop_2:
                dice_1.roll(v)
                p = 0
                for i in range(6):
                    if dice_1.dice[dice_1.now[i]-1] != dice_2.dice[dice_2.now[i]-1]:
                        break
                    p += 1
                    if p >= 6:
                        ans += 1
    if ans:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8188
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;



int main()
{
    int n;
    cin >> n;
    vector<string> a(n);

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

    int ac = 0, wa = 0, tle = 0, re = 0;

    for (int i = 0; i < n; i++) {

        if (a[i] == "AC") {
            ac++;
        }
        else if (a[i] == "WA") {
            wa++;
        }
        else if (a[i] == "TLE") {
            tle++;
        }
        else if (a[i] == "RE") {
            re++;
        }


    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;


    return 0;
}



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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 1;
    std::vector<int64_t> a(n);
    rep(i, n) {
        cin >> a[i];
        // ans *= a[i];
    }

    Sort(a);
    int64_t m = 1000000000000000000;
    if ( a[0] == 0 ) {
        ans = 0;
    } else {
        if ( a[n-1] > m ) {
            ans = -1;
        } else {
            rep(i, n) {
                ans *= a[i];
                m /= a[i];
                // cout << "a " << ans << " " << m << endl;
                if ( m < 1 ) {
                    ans = -1;
                    break;
                }
            }
        }

    }
    /*
    if ( ans > 1000000000000000000 ) {
        ans = -1;
    }*/
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4004
N=int(input())
S=input()
temp=""
ans=0
for i in range(N):
	if S[i]=="A":
		temp="A"
	elif S[i]=="B" and temp=="A":
		temp="B"	
	elif S[i]=="C" and temp=="B":
		temp=""
		ans+=1
	else:
		temp=""

print(ans)
		
	

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

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

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int N, K; cin >> N >> K;
   string S; cin >> S;


   char prv = '1'; int cnt = 0;
   vector<int> v;
   for (int i = 0; i <= N; ++i) {
      if (i == N || prv != S[i]) {
         if (i != N) prv = S[i];
         v.push_back(cnt);
         cnt = 1;
      } else {
         ++cnt;
      }
   }
   if (prv == '0') {
      v.push_back(0);
   }

   if (v.size() <= 2*K+1) {
      cout << accumulate(v.begin(), v.end(), 0LL) << endl;
      return 0;
   }
   int total = accumulate(v.begin(), v.begin()+2*K+1, 0LL);
   int ans = total;
   for (int i = 2*K+1; i+1 < v.size(); i += 2) {
      total -= v[i-(2*K+1)] + v[i-2*K];
      total += v[i] + v[i+1];
      chmax(ans, total);
   }
   cout << ans << endl;


   return 0;
}


Measured memory_bytes: 1020
#include <stdio.h>
long long gcd(long long a,long long b){
    return b ? gcd(b,a % b) : a;
}
int check(long long a,long long b,long long c,long long d){
    if(a < b || d < b)return 0;
    if(c + 1 >= b)return 1;
    long long g = gcd(b,d);
    return (a - c - 1) / g - (a - b) / g <= 0;
}
int main() {
    int t;
    long long a,b,c,d;
    scanf("%d",&t);
    while(t --){
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if(check(a,b,c,d)){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
}


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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};


bitset<150> imos[24*60+1];

int main() {
    int n;
    cin >> n;
    vector<int> t;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            int sh, sm, st, eh, em, et;
            cin >> sh >> sm >> eh >> em;
            st = sh*60+sm;
            et = eh*60+em;
            imos[st].set(i*3+j);
            imos[et+1].set(i*3+j);
            t.push_back(st);
            t.push_back(et);
        }
    }
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(),t.end()),t.end());
    for(int i=0;i<24*60;i++){
        imos[i+1] ^= imos[i];
    }
    int m = t.size(), ans = 0;
    for(int i=0;i<m;i++){
        for(int j=i+1;j<m;j++){
            for(int k=j+1;k<m;k++){
                auto a = imos[t[i]]|imos[t[j]]|imos[t[k]];
                int cnt = 0;
                for(int x=0;x<n;x++){
                    if(a[x*3]&a[x*3+1]&a[x*3+2]) cnt++;
                }
                ans = max(ans, cnt);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3204
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	inputs := strings.Split(sc.Text(), " ")
	luggageNum, _ := strconv.Atoi(inputs[0])
	trackNum, _ := strconv.Atoi(inputs[1])

	luggages := make([]int, luggageNum)
	i := 0
	sum := 0
	max := 0
	for sc.Scan() {
		luggages[i], _ = strconv.Atoi(sc.Text())

		sum = sum + luggages[i]
		if max < luggages[i] {
			max = luggages[i]
		}

		i++
	}

	tmp := sum / trackNum
	if tmp > max {
		max = tmp
	}
	for {
		if carry(luggages, max, trackNum) {
			break
		} else {
			max++
		}
	}

	fmt.Println(max)
}

func carry(luggages []int, max int, trackNum int) bool {
	result := 1
	tmp := max
	for _, v := range luggages {
		if tmp < v {
			result++
			tmp = max - v
		} else {
			tmp = tmp - v
		}

		if result > trackNum {
			return false
		}
	}

	return true
}



Measured memory_bytes: 2332
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	ll x, y; cin >> x >> y;
	if(x * y > 0){
		if(x <= y) cout << y-x << endl;
		else cout << x-y + 2 << endl;
	}
	else if(x * y < 0) cout << abs(abs(x)-abs(y)) + 1 << endl;
	else{
		if(x <= y) cout << y-x << endl;
		else cout << x-y + 1 << endl;
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define hell 1000000007
        using namespace std;
        const int N=500;
        void solve()
        {
            ll i,j,k,n,m,c=0,ans=0;
            string s;
            cin>>s;
            string s2;
            cin>>s2;
            rep(i,0,s.size())
            {
                if(s[i]!=s2[i]) c++;
            }
            cout<<c;



    }

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


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

string solve_lcs(string s, string t) {
    int dp[s.size() + 1][t.size() + 1];
    for (int i = 0; i <= s.size(); i++) {
        for (int j = 0; j <= t.size(); j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
            }
            else if (s[i - 1] == t[j - 1]) {
                dp[i][j] = (1 + dp[i - 1][j - 1]);
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    int m = s.length();
    int n = t.length();
    int index = dp[m][n];
    string lcs;
    int i = m, j = n;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
            lcs = s[i - 1] + lcs;
            i--;
            j--;
            index--; 
        }
        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;
    }
    return lcs;
}
int main() {
    ios::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    cout << solve_lcs(s, t) << endl;
    return 0;
}

Measured memory_bytes: 35456