akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
int a[3][3];
int b[3][3];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    rep(i,3)
    {
        rep(j,3)
        cin>>a[i][j];
    }
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        for (int j=0;j<3;j++)
        {
            for (int f=0;f<3;f++)
            {
                if (a[j][f]==x)
                    b[j][f]=1;
            }
        }
    }
    string ans="No";
    for (int i=0;i<3;i++)
    {
        bool ko=true;
        for (int j=0;j<3;j++)
        {
            if (b[i][j]==0)
                ko=false;
        }
        if (ko)
            ans="Yes";
    }
    for (int i=0;i<3;i++)
    {
        bool ko=true;
        for (int j=0;j<3;j++)
        {
            if (b[j][i]==0)
                ko=false;
        }
        if (ko)
            ans="Yes";
    }
    if (b[0][0]==1&&b[1][1]==1&&b[2][2]==1)
        ans="Yes";
    if (b[0][2]==1&&b[1][1]==1&&b[2][0]==1)
        ans="Yes";


    cout<<ans;





}

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

using namespace std;

int main(){
  bool ans=false;
  int n,m; cin >> n >> m;
  vector<int> g[n+1];
  for(int i=0;i<m;i++){
    int a,b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i=0;i<g[1].size();i++){
    int mid=g[1][i];
    for(int j=0;j<g[mid].size();j++){
      if(g[mid][j]==n){
        ans=true;
        break;
      }
    }
  }
  if(ans) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

int main(){
    string S;
    cin >> S;
    int len = S.size();
    bool varied = true;
    rep(i,len){
        for (int j = i + 1; j < len; j++){
            if (S[i] == S[j]){
                varied = false;
            }
        }
    }
    if (varied){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
 
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
 
ll func(ll num){
    return (ll)(num * (num - 1)) / 2;
}
 
int main(){
    ll N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    map<ll, ll> mp;
    rep(i, N) mp[A[i]]++;
    ll sum = 0;
    for(auto p = mp.begin(); p != mp.end(); p++){
        sum += func(p->second);
    }
    for(ll i = 0; i < N; i++){
        ll res = sum;
        ll value = mp[A[i]];
        res -= (value-1);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int s;
    cin >> s;

    if(s==1 || s==2){
        cout << 4 << endl;
        return 0;
    }

    int ans=1;
    while(s!=4){
        if(s%2)s=s*3+1;
        else s/=2;
        ans++;
    }

    cout << ans + 3 << endl;

    return 0;
}


Measured memory_bytes: 3568
targets = ['A', 'C', 'G', 'T']

S = str(input())

cnt = 0
ans = 0
for i in range(len(S)):
    if S[i] in targets:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0


ans = max(ans, cnt)
print(ans)


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

int main(){
    using namespace std;

    constexpr unsigned long N{200000}, register_length{100}, reg{N - register_length + 1}, one_reg{reg - 1};

    unsigned long cnt{0};
    vector<unsigned long> sim(N);
    const auto& cmp = [&cnt, &sim](unsigned long i, unsigned long j, unsigned long k) -> void {
        cout << "< " << i << " " << j << " " << k << endl;
        ++cnt;
        sim[k] = static_cast<unsigned long>(sim[i] < sim[j]);
    };
    const auto& add = [&cnt, &sim](unsigned long i, unsigned long j, unsigned long k) -> void {
        cout << "+ " << i << " " << j << " " << k << endl;
        ++cnt;
        sim[k] = sim[i] + sim[j];
    };
    const auto& set_one = [&cmp, &add]() -> void {
        add(0, 1, one_reg);
        cmp(2, one_reg, one_reg);
    };
    const auto& bit_and_add = [&cmp, &add](unsigned long i, unsigned long j, unsigned long k) -> void {
        add(i, j, reg);
        cmp(one_reg, reg, reg + 1);
        add(k, reg + 1, k);
    };
    const auto& binary_mul = [&bit_and_add](unsigned long i, unsigned long i_len, unsigned long j, unsigned long j_len, unsigned long k) -> void {
        for(unsigned long i_ofs{0}; i_ofs < i_len; ++i_ofs)for(unsigned long j_ofs{0}; j_ofs < j_len; ++j_ofs)bit_and_add(i + i_ofs, j + j_ofs, k + i_ofs + j_ofs);
    };
    const auto& bin_to_int = [&add](unsigned long beg, unsigned long len, unsigned long k) -> void {
        for(unsigned long i{len}; i--; ) {
            if(i + 1 != len)add(k, k, k);
            add(beg + i, k, k);
        }
    };
    const auto& zero_clear = [&cmp](unsigned long i) -> void {
        cmp(i, i, i);
    };
    const auto& one_clear = [&cmp](unsigned long i) -> void {
        cmp(2, one_reg, i);
    };
    const auto& bit_shift = [&add](unsigned long i, unsigned long s) -> void {
        for(unsigned long itr{0}; itr < s; ++itr)add(i, i, i);
    };
    const auto& int_to_bin = [&sim, &bin_to_int, &bit_shift, &zero_clear, &one_clear, &cmp](unsigned long idx, unsigned long i, unsigned long len) -> void {
        one_clear(reg + 2);
        for(unsigned long itr{1}; itr <= len; ++itr){
            zero_clear(reg);
            one_clear(i + len - itr);
            bin_to_int(i + len - itr, itr, reg);
            bit_shift(reg, len - itr);
            cmp(idx, reg, reg + 1);
            cmp(reg + 1, reg + 2, i + len - itr);
        }
    };

    cout << 5733 << endl;
    sim[0] = 100;
    sim[1] = 1987;
    set_one();
    int_to_bin(0, 100, 30);
    int_to_bin(1, 200, 30);
    binary_mul(100, 30, 200, 30, 300);
    bin_to_int(300, 60, 2);
    cerr << sim[2] << " : " << cnt << endl;
    return 0;
}


Measured memory_bytes: 4640
from random import randrange

scorelist = [0]
def score(d,c,s,t):
    ans = scorelist[d]
    scorelast = [0] * 26
    for i in range(d,365):
        ans += s[i][t[i]]
        scorelast[t[i]] = i + 1
        for j in range(26):
            ans -= c[j] * (i + 1 - scorelast[j])
        scorelist.append(ans)
    return ans

D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D): s.append(list(map(int,input().split())))
d = 0
t = []
last = [-1] * 26
for i in range(D):
    maximum = 0
    maxs = 0
    for j in range(26):
        if maximum < s[i][j] + c[j] * (i - last[j]):
            maxs = j
            maximum = s[i][j] + c[j] * (i - last[j])
    last[maxs] = i
    t.append(maxs)
point = score(d,c,s,t)
for i in range(5000):
    d = randrange(D)
    q = randrange(26)
    old = t[d]
    t[d] = q
    if point > score(d,c,s,t): t[d] = old
for i in t: print(i + 1)


Measured memory_bytes: 127036
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int n;
    cin>>n;
    ll res=1;
    ll arr[n];
    loop(n,i,0){
        cin>>arr[i];
        if(!arr[i]){
            cout<<0<<Endl;
            return;
        }
    }
    loop(n,i,0){
        if(arr[i]>(ll)1e18/res){
            cout<<-1<<endl;
            return;
        }
        res*=arr[i];
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 4388
#include<stdio.h>
#include<string.h>
int n,m,i,j,k;
int num,id,cnt;
 
char A[10];
char B[10];
char tmp;
 
int flg[1001];
 
int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0)break;
     
    for(i=1;i<=n;i++)flg[i]=0;
    id=1;
    cnt=n;
     
    for(i=1;i<=m;i++){
 
      //printf("%d %d\n",i,id);
      if(i%15==0){
        strcpy(A,"FizzBuzz");
      }else if(i%5==0){
        strcpy(A,"Buzz");
      }else if(i%3==0){
        strcpy(A,"Fizz");
      }else{
        j=0;
        num=i;
        while(num>0){
          A[j]=num%10+'0';
          j++;
          num/=10;
        }
        for(k=0;k<j/2;k++){
          tmp=A[k];
          A[k]=A[j-1-k];
          A[j-1-k]=tmp;
        }
        A[j]='\0';
      }
       
      scanf("%s",B);
       
      if(cnt==1)continue;
 
 
      //printf("%s %s %d %d\n",A,B,strcmp(A,B),id);
      if(strcmp(A,B)!=0){
        flg[id]=1;
        //printf("%d\n",id);
        cnt--;
      }
       
      while(1){
        id++;
        if(id==n+1)id=1;
        if(flg[id]==0)break;
      }
       
    }
     
    j=0;
    for(i=1;i<=n;i++){
 
      if(flg[i]==0){
        if(j!=0)printf(" ");
        j=1;
        printf("%d",i);
      }
       
    }
    printf("\n");
     
  }
  return 0;
}

Measured memory_bytes: 620
const MOD = Int64(10^9 + 7)

function main()
  n, m = map(s -> parse(Int64, s), split(readline()))
  answer = Int64(1)
  i = Int64(2)

  while i * i <= m
    if mod(m, i) == 0
      count = Int64(0)
      while mod(m, i) == 0
        count += 1
        m /= i
      end
      answer = mod(answer * modcomb(n + count - 1, count), MOD)
    end
    i += 1
  end

  if m > 1
    answer = mod(answer * n, MOD)
  end

  println(answer)
end

function modcomb(n::Integer, k::Integer)
  if n - k < k return modcomb(n, n - k) end
  numer = one(n)
  denom = one(n)
  for i = 0:k - 1
    numer = mod(numer * (n - i), MOD)
    denom = mod(denom * (i + 1), MOD)
  end
  return mod(numer * modpow(denom, MOD - 2), MOD)
end

function modpow(a::Integer, p::Integer)
  if p == 0
    return one(a)
  elseif mod(p, 2) == 0
    return mod(modpow(a, div(p, 2))^2, MOD)
  else
    return mod(a * modpow(a, p - 1), MOD)
  end
end

main()


Measured memory_bytes: 117884
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
//ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N;
	ll S = 0, k = 0;
	scanf("%d", &N);
	vector<int> a(N), b(N);
	rep(i, 0, N)scanf("%d", &a[i]), S -= a[i];
	rep(i, 0, N)scanf("%d", &b[i]), S += b[i];
	rep(i, 0, N) {
		if (a[i] < b[i])k+=(b[i] - a[i] + 1) / 2;
	}
	//printf("%d %d %lld\n", k, k2, Sb - Sa);
	puts(k <= S ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int a,b,c,x,y,ans=INF;
    cin>>a>>b>>c>>x>>y;
    rep(i,0,1e5+1){
        int num=i*2*c+max(0,x-i)*a+max(0,y-i)*b;
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int N,A[100000];
    int cnt = 1,upper = 0;
    cin >> N;
    for(int i = 0;i < N;i++)cin >> A[i];
    for(int i = 1;i < N;i++){
        if(A[i] == A[i-1])continue;
        if(upper == 0){
            upper = (A[i-1] < A[i])*2-1;
            continue;
        }
        if((upper==1) ^ (A[i-1] < A[i])){
            upper = 0;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

#define MAX 100005

int main(){

  int i, n, A[MAX];

  scanf("%d", &n);

  for(i = 1; i <= n; i++)
    scanf("%d", &A[i]);

  for(i = 1; i <= n; i++){

  printf("node %d: key = %d, ", i, A[i]);

  if(i / 2 != 0)
    printf("parent key = %d, ", A[i / 2]);

  if(2 * i <= n)
    printf("left key = %d, ", A[2 * i]);

  if(2 * i + 1 <= n)
    printf("right key = %d, ", A[2 * i + 1]);

  printf("\n");
}

  return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 4000001;

bitset<N> b, c;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
    }
    s = (s + 1) / 2;
    sort(a.begin(), a.end());
    b[0] = 1;
    for (int i = 0; i < n; ++i) {
        c = b;
        c <<= a[i];
        b |= c;
    }
    for (int i = s;; ++i) {
        if (b[i]) {
            cout << i;
            break;
        }
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int max_x[2][2] = {}, max_y[2][2] = {};
    vector<int> v(n), x(100000, 0), y(100000, 0);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        if (i & 1)
        {
            ++y[v[i] - 1];
            if (y[v[i] - 1] > max_y[0][0]) max_y[0][0] = y[v[i] - 1], max_y[0][1] = v[i];
            else if (y[v[i] - 1] > max_y[1][0]) max_y[1][0] = y[v[i] - 1], max_y[1][1] = v[i];
        }
        else
        {
            ++x[v[i] - 1];
            if (x[v[i] - 1] > max_x[0][0]) max_x[0][0] = x[v[i] - 1], max_x[0][1] = v[i];
            else if (x[v[i] - 1] > max_x[1][0]) max_x[1][0] = x[v[i] - 1], max_x[1][1] = v[i];
        }
    }
    
    if (max_x[0][1] != max_y[0][1])
    {
        cout << n - max_x[0][0] - max_y[0][0] << endl;
    }
    else
    {
        cout << n - max(max_x[0][0] + max_y[1][0], max_x[1][0] + max_y[0][0]) << endl;
    }
}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector <int> a(n);
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    sort(ALL(a));
    reverse(ALL(a));
    if (double(a[m-1]) >= double(sum/double(4*m))){
        cout << "Yes";
    }
    else cout << "No";
}

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

int main(){
    
    int r,g,b;
    cin >> r >> g >> b;
    
    if((10*g+b)%4==0){
        cout << "YES" <<endl;
    }
    else{
        cout << "NO" <<endl;
        }
    
}
    
    
    

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
//#define push_back pb
#define int long long int
unordered_map<string, bool>mp;
string factorial(long long n)
{
	if (n > 1000) {
		cout << " Integer Overflow"
		     << endl;
		return "";
	}

	long long counter;
	long double sum = 0;

	// Base case
	if (n == 0)
		return "1";

	// Calculate the sum of
	// logarithmic values

	for (counter = 1; counter <= n;
	        counter++) {
		sum = sum + log(counter);
	}
	cout << sum << endl;

	// Number becomes too big to hold in
	// unsigned long integers.
	// Hence converted to string
	// Answer is sometimes under
	// estimated due to floating point
	// operations so round() is used
	string result
	    = to_string(round(exp(sum)));

	return result;
}
bool solve(string a, string b)
{
	if (a.compare(b) == 0)
		return true;

	if (a.length() <= 1)  //if a ki length is 1 it means a!=b(becz we checked for equality above so it returns false
		return false;

	string key = a;
	key.push_back(' ');
	key.append(b);
	if (mp.find(key) != mp.end())
		return mp[key];

	int n = a.length();
	bool flag = false;

	for (int i = 1; i < n; i++)
	{
		bool cond_1 = false, cond_2 = false;
		if ((solve(a.substr(0, i), b.substr(n - i, i)) == true) && (solve(a.substr(i, n - i), b.substr(0, n - i)) == true))
			cond_1 = true;

		if ((solve(a.substr(0, i), b.substr(0, i)) == true) && (solve(a.substr(i, n - i), b.substr(i, n - i)) == true))
			cond_2 = true;

		if (cond_1 || cond_2)
		{
			flag = true;
			break;
		}
	}
	return mp[key] = flag;
}
int result(int n, unordered_map<int, int>&m)
{
	if (n <= 2)
		return 1;
	if (m.find(n) != m.end())
		return m[n];

	int ans = result(n - 1, m) + result(n - 2, m);
	return m[n] = ans;

}
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int m1 = b * d;
	int m2 = a * c;
	int m3 = a * d;
	int m4 = b * c;
	int ans = max(m1, max(m2, max(m3, m4)));
	cout << ans;
	return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double p = Math.PI;
        double area = r * r * p;
        double length = r * 2 * p;
        System.out.printf("%f %f", area, length);
    }
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<LL> A(N);

    LL h = 0;
    LL r = 0;
    REP(i, N) {
        cin >> A[i];
    }

    REP(i, N) {
        if(A[i] < h) {
            r += h - A[i];
        }else{
            h = A[i];
        }
    }
    cout << r << endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
  int n;cin>>n;
  vector<int>a(n);
    for (int i = 0; i < n; ++i)cin >>a[i];
    sort(all(a));
    if(a.back()==0)puts("Yes");
    else if(n%3!=0)puts("No");
    else {
        bool flg = true;
        int m=n/3;
        if (a[0]!=a[m-1])flg=false;
        if (a[m]!=a[2*m-1])flg=false;
        if (a[2*m]!=a[3*m-1])flg=false;
        if((a[0]^a[m])!=a[2*m])flg=false;
        if(flg)puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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() {
    string s;
    cin >> s;
    ll n = s.size();

    string t;
    rep(i, n) {
        if(i < n-1 && s[i] == 'B' && s[i+1] == 'C') {
            t.pb('D');
            i++;
        }
        else {
            t.pb(s[i]);
        }
    }

    ll m = t.size();
    ll cntA = 0;
    ll ans = 0;
    rep(i, m) {
        if(t[i] == 'A') {
            cntA++;
        }
        else if(t[i] == 'D') {
            ans += cntA;
        }
        else {
            cntA = 0;
        }
    }
    
    out(ans);
    re0;
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main(){
    int N, M; cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    for (int i = 0; i < M; i++) {
        cin >> s.at(i) >> c.at(i);
    }
    int ans = -1;
    for (int i = 0; i < pow(10, N); i++) {
        string I = to_string(i);
        bool J = true;
        if (I.size() == N) {
            for (int j = 0; j < M; j++) {
                if (I.at(s.at(j) - 1) != c.at(j)) {
                    J = false;
                    continue;
                }
            }
        }
        else {
            continue;
        }
        if (J) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

int main(){
	string s;
	cin >> s;
	bool ncounts = false;
	bool wcounts = false;
	bool scounts = false;
	bool ecounts = false;
	rep(i,(int)s.size()){
		if(s[i] == 'N') ncounts = true;
		else if(s[i] == 'W') wcounts = true;
		else if(s[i] == 'S') scounts = true;
		else if(s[i] == 'E') ecounts = true;
	}
	if(ncounts && !scounts) cout << "No" << endl;
	else if(scounts && !ncounts) cout << "No" << endl;
	else if(ecounts && !wcounts) cout << "No" << endl;
	else if(wcounts && !ecounts) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cerr<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e3+69, base=1024*1024,mod=1e9+7;
int xx[]={-1,0,1,0};
int yy[]={0,1,0,-1};
queue <pii> q;
string S;
int n,m,odw[N][N],odl[N][N],t[N][N],wyn;
void bfs() {
    q.push(MP(0,0));
    odw[0][0]=1;
    while(!q.empty()) {
        pii v=q.front();
        q.pop();
        f0(i,4) {
            pii u=v;
            u.f+=xx[i];
            u.s+=yy[i];
            if(u.f<0||u.f>=n) continue;
            if(u.s<0||u.s>=m) continue;
            if(odw[u.f][u.s]==1) continue;
            if(t[u.f][u.s]==1) continue;
            odw[u.f][u.s]=1;
            odl[u.f][u.s]=odl[v.f][v.s]+1;
            q.push(u);
        }
    }
}
int32_t main(void) {
    boost;
    cin>>n>>m;
    f0(i,n) {
        cin>>S;
        f0(j,m) {
            if(S[j]=='#') t[i][j]=1;
            else wyn++;
        }
    }
    bfs();
    if(odw[n-1][m-1]==0) {
        cout<<"-1\n";
        return 0;
    }
    /*f0(i,n) {
        f0(j,m) {
            cout<<odl[i][j]<<" ";
        }
        cout<<endl;
    }*/
    wyn-=odl[n-1][m-1]+1;
    cout<<wyn<<endl;
}



Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n = 0;
	scanf("%d", &n);
	int* a = (int *)malloc(sizeof(int) * n);
	int ch,k=0;

	while(scanf("%d", &ch) != EOF){
		a[k] = ch;
		k++;
	}

	int change_count = 0;

	for (int i = 0; i < n; i++)
	{
		int minj = i;
		for (int j = i; j < n; j++)
		{
			if(a[j] < a[minj])
			{
				minj = j;
			}
		}
		if(i != minj){
			int tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			change_count ++;
		}
	}

	for(int j = 0; j < n; j++){
		printf("%d", a[j]);
		if(j != n-1) printf(" ");
	}
	printf("\n%d\n", change_count);

	return 0;
}


Measured memory_bytes: 1968
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

char str[200005];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    scanf("%s", str);

    ll x0=0;
    int i;
    for(i=0; i<n; i++) {
        x0=(x0*2+(str[i]-'0'))%MOD;
    }

    vector<int> a;
    for(i=3; i<=n; i+=2) {
        if(n%i==0) {
            a.push_back(n/i);
        }
    }
    reverse(a.begin(), a.end());

    ll ans=n*2*(x0+1)%MOD;

    int siz=(int)a.size();
    vector<ll> ans0(siz);

    int t;
    for(t=0; t<siz; t++) {
        int kk=a[t];

        for(i=0; i<n; i++) {
            if(str[i]=='1') {
                int bad=0;
                if(i>=kk) {
                    int i0=i%kk;
                    int step=(i-i0)/kk;
                    if(step%2==0 && str[i0]=='1') {
                        bad=1;
                    }
                    if(step%2==1 && str[i0]=='0') {
                        bad=1;
                    }
                }
                if(bad==0) {
                    int defined=MIN(kk, i+1);
                    int not_defined=kk-defined;
                    ans0[t] = (ans0[t] + mpow(2, not_defined))%MOD;
                }
            }

            {
                int bad=0;
                if(i>=kk) {
                    int i0=i%kk;
                    int step=(i-i0)/kk;
                    if(step%2==0 && str[i0]!=str[i]) {
                        bad=1;
                    }
                    if(step%2==1 && str[i0]==str[i]) {
                        bad=1;
                    }
                }
                if(bad) {
                    break;
                }
            }
        }
        if(i==n) {
            ans0[t]=ans0[t]+1;
        }
    }

    for(t=0; t<siz; t++) {
        int t2;
        for(t2=t+1; t2<siz; t2++) {
            if(a[t2]%a[t]==0) {
                //printf("%d %d\n", a[t2], a[t]);
                ans0[t2]=(ans0[t2]-ans0[t]+MOD)%MOD;
            }
        }
    }

    for(t=0; t<siz; t++) {
        ans0[t] = ans0[t] * (n*2-a[t]*2) %MOD;
        ans = (ans - ans0[t] +MOD)%MOD;
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;

	int n;
	cin >> n;
	
	cout << (n % 1000 == 0 ? 0 : 1000 - n % 1000);
	
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,K; cin>>N>>K;
	double P[N];
	rep(i,0,N){ cin>>P[i]; (++P[i]) /= 2; }
	double ans, sum = 0;
	rep(i,0,K) sum += P[i];
	ans = sum;
	rep(i,0,N-K){
		sum += P[i+K] - P[i];
		ans = max(ans, sum);
	}
    cout.precision(3);
    cout<<fixed<<ans<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Security;
using System.Threading;
using System.Xml.Serialization;

namespace AtCoderCs
{

    class Program
    {

        const int mod = 1000000007;

        static void Main()
        {

            var str = Console.ReadLine();
            var min = new List<int>();
            var max = new List<int>();
            var num = str.Length;
            var startIdx = 0;
            var count = 0;
            var result = 0L;

            for (int i = 0, l = str.Length; i + 1 < l; i++)
            {

                if (str[i] == '<' && str[i + 1] == '>')
                    max.Add(i + 1);
                else if (str[i] == '>' && str[i + 1] == '<')
                    min.Add(i + 1);

            }

            if (min.Count == 0 && max.Count == 0)
            {
                Console.WriteLine(Enumerable.Range(1, str.Length).Sum(x => (long)x));
                return;
            }

            var buf = new long[num];

            if (max.Count == 0) 
                result += Enumerable.Range(1, min[0]).Sum(x => (long)x) + Enumerable.Range(1, num - min[0]).Sum(x => (long)x);
            else if (min.Count != 0 && min[0] < max[0])
                result += Enumerable.Range(1, min[0]).Sum(x => (long)x);
            else
            {
                var right = ((min.Count != 0 ? min[0] : num) - max[0]);
                result +=
                    Enumerable.Range(1, max[0] - 1).Sum(x => (long)x) +
                    Enumerable.Range(1, right - 1).Sum(x => (long)x) +
                    (right < max[0] ? max[0] : right);
                startIdx = 1;

            }

            if (min.Count != 0 && max.Count != 0)
            {

                if (min[min.Count - 1] < max[max.Count - 1])
                {

                    var right = num - max[max.Count - 1];
                    var left = max[max.Count - 1] - min[min.Count - 1];

                    result += Enumerable.Range(1, right - 1).Sum(x => (long)x) +
                        Enumerable.Range(1, left - 1).Sum(x => (long)x) +
                        (right < left ? left : right);

                    count = max.Count - 1;

                }
                else
                {

                    result += Enumerable.Range(1, num - min[min.Count - 1]).Sum(x => (long)x);

                    count = max.Count;

                }

                for (int i = startIdx; i < count; i++)
                {

                    var left = max[i] - min[i - startIdx];
                    var right = min[i + 1 - startIdx] - max[i];

                    result +=
                        Enumerable.Range(1, left - 1).Sum(x => (long)x) +
                        Enumerable.Range(1, right - 1).Sum(x => (long)x) +
                        (right < left ? left : right);

                }

            }
            

            Console.WriteLine(result);

        }



    }
}


Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000



int main(){

    //nCk
    vector<vector<long long> > comb(52, vector<long long> (1, 1));
    comb[1].push_back(1);
    for(int i = 2; i <= 51; i++){
        for(int j = 1; j <= i; j++){
            if(j != i) comb[i].push_back(comb[i - 1][j] + comb[i - 1][j - 1]);
            else comb[i].push_back(1);
        }
    }
    

    
    int n, p; cin >> n >> p;
    long long even = 0, odd = 0;
    for(int i = 0; i < n; i++){
        int input; cin >> input;
        if(input % 2 == 0) even++;
        else odd++;
    }

    /*for(int i = 0; i < 5; i++){
        for(int j = 0; j < comb[i].size(); j++){
            cout << comb[i][j] << " ";
        }
        cout << endl;
    }*/

    long long e = 0;
    for(int i = 0; i <= even; i++){
        e += comb[even][i];
    }

    if(p == 0){
        long long sum = 0;
        for(int i = 0; i <= odd; i += 2){
            sum += comb[odd][i];
        }

        cout << e * sum << endl;
    }else{
        long long sum = 0;
        for(int i = 1; i <= odd; i += 2){
            sum += comb[odd][i];
        }

        cout << e * sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans=ans%mod
    cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Measured memory_bytes: 9204
#include <stdio.h>
#include<stdlib.h>


#define MAX 100000
typedef struct{
    int forward;
    int backward;
    int weight;
}Node;
  
int size,car[MAX];
Node a[1000000];
void SearchShortestWay(int b)
{
    int pointer=1;
    for(int i=0;i<size;i++)
    {
        car[i]=1000000;
    }
    car[0]=0;
      
    while(pointer!=0)
    {
        pointer=0;
        for(int i=0;i<b;i++)
        {
            if(a[i].weight+car[a[i].backward]<car[a[i].forward])
            {
                car[a[i].forward]=a[i].weight+car[a[i].backward];
                pointer=1;
            }
        }
    }
}
  
int main(void){
    int u,k,count=0;
    scanf("%d",&size);
    for(int i=0;i<size;i++)
    {
        scanf("%d%d",&u,&k);
        for(int j=0;j<k;j++)
        {
            a[count].backward=u;
            scanf("%d%d",&a[count].forward,&a[count].weight);
            count++;
        }
    }
    SearchShortestWay(count);
    for(int i=0;i<size;i++) printf("%d %d\n",i,car[i]);
    return 0;
}





Measured memory_bytes: 7632
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (max(a, b) - min(a, b) < max(a, c) - min(a, c)) cout << "A" << endl;
	else cout << "B" << endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
a = list(map(int, input().split()))
a = [0] + a
acc = list(itertools.accumulate(a))
pre = {}
ans = 0
for i in range(n+1):
    if acc[i] in pre:
        ans += pre[acc[i]]
        pre[acc[i]] += 1
    else:
        pre[acc[i]] = 1
print(ans)



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const ll  INF=1000000000000000100;//10の18乗
const int mod=(int)1e9+7;

int n,q;
vector<vector<int>>g;
vector<ll>c;
void dfs(vector<vector<int>>&g,vector<ll>&c,int pa,int i){
    for(auto ch:g.at(i)){
        if(ch==pa)continue;
        c.at(ch)+=c.at(i);
        dfs(g,c,i,ch);
    }
}
int main(){
    cin>>n>>q;
    g.resize(n);
    c.resize(n);
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }
    rep(i,0,q){
        int p,x;
        cin>>p>>x;
        p--;
        c.at(p)+=x;
    }
    dfs(g,c,-100,0);
    rep(i,0,n){
        cout<<c.at(i)<<endl;
    }
return 0;
}

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

using namespace std;

#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define mp make_pair
#define pb push_back
#define eps 1e-9
#define PI acos(-1.0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pii> iii;
typedef vector<pii> vii;
typedef vector<iii> vip;
typedef long double ld;
int INF = 1e9 + 5;
// const ll INF = 1e18L + 5;

bool prime(ll x)
{
    if(x == 2)
        return true;
    for(int i = 2 ; i * i <= x ; i++)
        if(x % i == 0)
            return false;
    return true;
}


template <typename T> void self_max(T& a, T b)
{
    a = max(a, b);
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio (0);
    cin.tie(0);
    int n, m;
    string str, t;
    cin >> str >> t;
    n = str.length(), m = t.length();
    vector<vector<pair<int, pair<int, int>>>> dp(n + 1, vector<pair<int, pair<int, int>>>(m + 1, {-INF, {0, 0}}));
    dp[0][0] = {0, {0, 0}};
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if(str[i] == t[j])
                self_max(dp[i + 1][j + 1], make_pair(dp[i][j].first + 1, make_pair(i, j)));
            self_max(dp[i + 1][j], make_pair(dp[i][j].first, make_pair(i, j)));
            self_max(dp[i][j + 1], make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    iii ans = {0, {0, 0}};
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= m; ++j)
        {
            self_max(ans, make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    string s;
    pii cur = ans.second;
    while(!(cur.first == 0 || cur.second == 0))
    {
        int i = cur.first, j = cur.second;
        pii prev = dp[i][j].second;
        if(prev == make_pair(i - 1, j - 1))
            s += str[i - 1];
        cur = prev;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 105984
s=input()
ls=len(s)
ans=[0]*ls
s+="R"
rst=lst=lend=0
for i in range(1,ls):
  if s[i]=="L" and lst==0:
    lst=i
  if lst==0:
    continue
  if s[i+1]=="R":
    lend=i
  if lend==0:
    continue
  ans[lst-1]=(lst-1-rst)//2+1+(lend-lst+1)//2
  ans[lst]=(lst-1-rst+1)//2+(lend-lst)//2+1
  rst=lend+1
  lst=lend=0

an=[str(i) for i in ans]
print(" ".join(an))

Measured memory_bytes: 10876
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

LLI dp[200][4][2];

int main(){
  string N;
  int K;

  while(cin >> N >> K){

    fill_array(dp, 0);

    dp[0][0][0] = 1;

    int s = N.size();

    REP(i,s){
      REPE(j,K){
        REP(k,2){
          FORE(d,0,9){
            int nj = j + (d == 0 ? 0 : 1);
            if(nj <= 3){
              if(k or N[i] - '0' >= d){
                dp[i+1][nj][k or N[i]-'0' > d] += dp[i][j][k];
              }
            }
          }
        }
      }
    }


    LLI ans = 0;
    ans = dp[s][K][0] + dp[s][K][1];

    puts_all(ans);
  }


  return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k; cin >> n >> k;
  vector<int> a;
  map<int, int> b;
  vector<int> c;
  int tmp;

  REP(i, n) {
    cin >> tmp;
    if(b[tmp] == 0) a.pb(tmp);
    b[tmp]++;
  }

  REP(i, a.size()) {
    c.pb(b[a[i]]);
  }

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

  int count = 0;
  
  REP(i, max((int)0, (int)c.size()-k)) {
    count += c[i];
  }

  cout << count << endl;
  
}


Measured memory_bytes: 17392
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
string st,st1;
int n,m,i,j,cnt,f[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin>>st;
	n=st.length();
	for (i=0;i<n;i++)
	{
		if (st[i]=='x')
		{
			/*if (st[n-i-1]!='x') */cnt++;
			f[st1.size()]++;
		}
		else st1.push_back(st[i]);
	}
	for (i=0;i<=st1.size();i++)
	{
		cnt-=min(f[i],f[st1.size()-i]);
	}
	st=st1;
	reverse(st1.begin(),st1.end());
	if (st==st1) cout<<cnt; else cout<<-1;
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin >> n;
    string s;cin >> s;
    ll R = count(ALL(s),'R');
    ll G = count(ALL(s),'G');
    ll B = count(ALL(s),'B');
    ll tmp1 = R * G * B;

    ll tmp2 = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int k = 2*j - i;
            if(k>=n)break;
            if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k])tmp2++;
        }
    }
    cout << tmp1 - tmp2 << endl;
    return 0;
}

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

void func() {
int k,a,b;
cin>>k;
cin>>a>>b;
for(int i=a;i<b+1;i++){
if(i%k==0){
cout<<"OK"<<endl;
 return;
}
}
cout<<"NG"<<endl;


}
int main() {
  func();
}


Measured memory_bytes: 3620