akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
//#define int long long
#define PI 3.14159265
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool vis[100005];
vector< vector<int> >al(100005);
vector<int> rt;
void dfs(int x)
{
    vis[x]=true;
    for(int i=0;i<al[x].size();i++)
    {
        if(!vis[al[x][i]])
        dfs(al[x][i]);
    }
    rt.push_back(x);
}
int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        al[a].push_back(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        dfs(i);
    }
    int dp[n+1]={};
    reverse(rt.begin(),rt.end());
    for(int i=0;i<rt.size();i++)
    {
        for(int j=0;j<al[rt[i]].size();j++)
        {
            dp[al[rt[i]][j]]=max(dp[al[rt[i]][j]],dp[rt[i]]+1);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7804
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
int main(){
    int l=0,r=0;
    int n; string s;
    cin >> n >> s;
    int res=0;
    rep(i,n){
        if(s[i]=='(') res++;
        else{
            if(res==0) l++;
            else res--;
        }
    }
    r=res;
    rep(i,l) cout << '(';
    cout << s;
    rep(i,r) cout << ')';
        
}


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

 
int main() {

    string n;

    cin >>n;
    
    int len;
    len = n.length();

    n = n.at(len-1);

     if(n == "2"||n == "4"|| n == "5" || n == "7" || n == "9"){
        cout << "hon";
    }else if(n == "0"|| n == "1" || n == "6" || n == "8"){
        cout << "pon";
        
    }else{
        cout << "bon";
    }


}
   




   


Measured memory_bytes: 3628
package main

import (
	"fmt"
	"math"
)

//const pi = math.Pi

func main() {
	var d, n float64
	fmt.Scan(&d, &n)
	if n != 100 {
		fmt.Println(math.Pow(100, d) * n)
	} else {
		fmt.Println(int(math.Pow(100, d) * 101))
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main(){
  int n,h,a,ma=0,cnt=0;
  cin>>n>>h;
  vector<int> v(n);
  rep(i,n){
     cin>>a>>v[i];
     ma=max(ma,a); 
  }
  sort(v.begin(),v.end());
  for(auto i=v.rbegin();i!=v.rend()&&*i>ma;i++){
    h-=*i;
    cnt++;
     if(h<=0){
        cout<<cnt;
        return 0;
     }
  }
  cnt+=h/ma+(h%ma?1:0);
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <uint64_t N>
class Combination {
  using _Tp = long long;
public: 
  array<_Tp, N> fac, finv, inv;

  constexpr
  Combination() {
    init();     
  }

  constexpr
  void init() {
    fac[0] = fac[1] = 1;        
    finv[0] = finv[1] = 1;      
    inv[1] = 1; 
    for(int i = 2; i < N; i++){    
      fac[i] = fac[i-1] * i % MOD;      
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;        
      finv[i] = finv[i-1] * inv[i] % MOD;       
    }
  }

  // n!! * k!^(-1) * ((n - k)!)^(-1)   
  constexpr
  _Tp comb(_Tp n, _Tp k) const {
    if (n < k) return 0;        
    if (n < 0 || k < 0) return 0;       
    return fac[n] * (finv[k]* finv[n - k] % MOD) % MOD; 
  }

  constexpr
  _Tp operator ()(_Tp n, _Tp k) const {
    return comb(n, k);
  }
};

int main() {
  ll n,m,k;
  cin >> n >> m >> k;

  ll ans1 = 0, ans2 = 0;

  // 横
  for (int d = 1; d < m; ++d) {
    ans1 += d * (n * n) * (m-d) % MOD;
  }

  for (int d = 1; d < n; ++d) {
    ans2 += d * (m * m) * (n-d) % MOD;
  }

  Combination<200010> comb;
  cout << (((ans1 + ans2) % MOD) * comb(n*m-2, k-2)) % MOD << endl;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <algorithm>
using std::string;
const int MAXN=1e9;
int dp[1000010][2];
int main()
{
    string s;
    std::cin>>s;
    s+='0';
    reverse(s.begin(),s.end());
	s+='0';
	for(int i=0; i<s.size(); ++i)  
		s[i]-='0';
    
    dp[0][1]=MAXN;
    
	for(int i=1; i<=s.size()-1; ++i){
      dp[i][0]=std::min(dp[i-1][0]+s[i],dp[i-1][1]+s[i]+1);
      dp[i][1]=std::min(dp[i-1][0]+10-s[i],dp[i-1][1]+9-s[i]);
    }
    
    std::cout<<dp[s.size()-1][0];
    return 0;
}

Measured memory_bytes: 9220
#include<iostream>
#include<cstdio> 
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define fi first
#define se second 
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f; 
const int N=2e5+10;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll n,m,q,k;
	cin>>n>>m;
	cout<<min(n%m,abs(m-n%m));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  string s; ll k; cin >> s >> k;
  ll n = s.size(), cnt1 = 1, cnt2 = 1, cnt3 = 1, cnt4 = 0, cnt5 = 0;
  if (s[0] == s[n-1]) {
    for (int i = 1; i < n; i++) {
      if (s[0] == s[i]) cnt1++;
      else break;
    }
    if (cnt1 == n) {
      cout << n * k / 2;
      return 0;
    }
    for (int i = n-2; i >= 0; i--) {
      if (s[n-1] == s[i]) cnt2++;
      else break;
    }
    cnt5 = ((cnt1 + cnt2)/2 - cnt1/2 - cnt2/2) * (k - 1);
  }

  for (int i = 1; i < n; i++) {
    if (s[i] == s[i-1]) {
      cnt3++;
    }
    else {
    cnt4 += cnt3/2;
    cnt3 = 1;
    }
    if (i == n-1) cnt4 += cnt3/2;
  }
  cout << cnt4 * k + cnt5 << endl;
  return 0;
}

Measured memory_bytes: 256
dic = {
  "yotta":24,
  "zetta":21,
  "exa"  :18,
  "peta" :15,
  "tera" :12,
  "giga" :9,
  "mega" :6,
  "kilo" :3,
  "hecto":2,
  "deca" :1,
  "deci" :-1,
  "centi":-2,
  "milli":-3,
  "micro":-6,
  "nano" :-9,
  "pico" :-12,
  "femto":-15,
  "ato"  :-18,
  "zepto":-21,
  "yocto":-24
}

n = int(input())
for _ in range(n):
  lst = input().split()
  if len(lst) == 2:
    x, z = lst
    sisuu = 0
  else:
    x, y, z = lst
    sisuu = dic[y]

  if "." not in x:
    x = x + "."
  ind = x.index(".")
  x = x[:ind] + x[ind+1:]
  
  while x[0] == "0":
    x = x[1:]
    ind -= 1
  if len(x) != 1:
    x = x[0] + "." + x[1:]

  sisuu += (ind - 1)

  print(x , "*", "10^"+str(sisuu), z)


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

signed main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(begin(A),end(A));
  int ans=0;
  rep(i,K){
    ans+=A[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc111_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            if(100<=n && n<=111){
                WriteLine("111");
            }
            if(111<n && n<=222){
                WriteLine("222");
            }
            if(222<n && n<=333){
                WriteLine("333");
            }
            if(333<n && n<=444){
                WriteLine("444");
            }
            if(444<n && n<=555){
                WriteLine("555");
            }
            if(555<n && n<=666){
                WriteLine("666");
            }
            if(666<n && n<=777){
                WriteLine("777");
            }
            if(777<n && n<=888){
                WriteLine("888");
            }
            if(888<n && n<=999){
                WriteLine("999");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	long long int n, k;
	cin >> n >> k;
	vector<long long int> h(n);
	rep(i, n) cin >> h[i];
	sort(all(h));
	long long int ans = 0;
	rep(i, n - k) ans += h[i];
	cout << ans << endl;

	return 0;
}

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

#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int N;
    cin >> N;
    int tmp = N %1000;
    if(tmp!=0){
      printl(1000 - tmp);
    }else{
      printl(0);
    }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N + 1), B(N + 1);
    for(int i = 1; i <= N; i++) {
        cin >> A[i] >> B[i];
    }
    int dp[N + 1][H + 1];
    for(int i = 0; i <= N; i++) for(int j = 0; j <= H; j++) dp[i][j] = inf;
    dp[0][0] = 0;
    for(int i = 1; i <= N; i++) dp[i][0] = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= H; j++) {
            int value = (j + A[i] - 1) / A[i];
            dp[i][j] = min(dp[i - 1][j], B[i] * value);
            if(j >= A[i]) dp[i][j] = min(dp[i - 1][j], dp[i][j - A[i]] + B[i]);
            //cout << dp[i][j] <<" ";
        }
        //cout << endl;
    }
    cout << dp[N][H] << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N=S.length();
  int childr[N]={};
  
  int i=0, j=0;
  
  int nownum=0;
  int Lnum=0;
  int Rnum=0;
  bool Rbool;
  bool Lbool;
  while(nownum<N-1){
    Lnum=0;
    Rnum=0;
    Rbool=(S[i]=='R');
    while(Rbool){
      i+=1;
      Rnum+=1;
      Rbool=(S[i]=='R');
    }
    Lbool=(S[i]=='L');
    while(Lbool){
      i+=1;
      Lnum+=1;
      Lbool=(S[i]=='L');
    }
    childr[nownum+Rnum-1]=Lnum/2+(Rnum-Rnum/2);
    childr[nownum+Rnum]=Lnum+Rnum-childr[nownum+Rnum-1];
    nownum=nownum+Lnum+Rnum;
  }
  for(j=0;j<N;j++){
  	cout << childr[j] << " ";
  }
  cout <<endl;
  
  return 0;
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  int MIN = INF;
  int check = 0;
  for (int i = N-1; i >= 0; i--) 
  {
    chmin(MIN,vec[i]);
    if(vec[i] - MIN > 1) check = 1;
  }
  if(check)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FORR(i, m, n) for(int i = m; i >= n; i--)

using namespace std;

typedef vector<int> vi; typedef pair<int,int> pii;
typedef long long ll; typedef vector<long long> vl;
typedef vector<string> vs;

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

	int n;
	cin >> n;

	vi x(n), x2(n);
	REP(i, n) {
		cin >> x[i];
		x2[i] = x[i];
	}
	sort(x.begin(), x.end());

	int ans[2] = {x[n/2-1], x[n/2]};

	REP(i, n) {
		if (x2[i] < ans[1]) {
			cout << ans[1] << endl;
		} else if (x2[i] == ans[1]) {
			cout << ans[0] << endl;
		} else {
			cout << ans[0] << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int MAX = 310;

int A[MAX][MAX];
pair<int, int> X[MAX*MAX];
int M[MAX*MAX];

int main(){
    int H,W,D,Q;
    cin >> H >> W >> D;
    REP(i,H){
        REP(k,W){
            int a;
            cin >> a;
            a--;
            X[a] = make_pair(i, k);
            //A[i][k] = a;
        }
    }
    cin >> Q;

    REP(i,H*W){
        pair<int, int> loc = X[i];
        int x = loc.first;
        int y = loc.second;
        if(i >= D){
            pair<int, int> lloc = X[i-D];
            int lx = lloc.first;
            int ly = lloc.second;
            M[i] = M[i-D] + abs(x-lx) + abs(y-ly);
        }
        else{
            M[i] = 0;
        }
    }

    REP(i,Q){
        int l,r;
        cin >> l >> r;
        l--; r--;
        cout << M[r] - M[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[MAX];
int D[MAX],S[MAX],E[MAX],H[MAX];

void print(int u){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,calcSibling(u),E[u],D[u],H[u]);

  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r,p+1);
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}

void calcDegree(int u){
  if(T[u].l == NIL && T[u].r == NIL)E[u] = 0;
  else if(T[u].r == NIL || T[u].l == NIL)E[u] = 1;
  else E[u] = 2;
}

int  calcSibling(int u){
  if(T[u].p == NIL)return NIL;
  if(T[T[u].p].l != NIL && T[T[u].p].l != u)return T[T[u].p].l;
  if(T[T[u].p].r != NIL && T[T[u].p].r != u)return T[T[u].p].r;
  return NIL; 
}

int calcHeight(int u){
  int H1=0,H2=0;
  if(T[u].l != NIL){
    H1 = 1 + calcHeight(T[u].l);
  }
  if(T[u].r != NIL){
    H2 = 1 + calcHeight(T[u].r);
  }
  if(H1 < H2){
    H[u] = H2;
    return H[u];
  }
  else{
    H[u] = H1;
    return H[u];
  }
}

int main(){
  int n,id,root=0,l,r,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = T[i].r = T[i].l = NIL;
  }

  for(i=0;i<n;i++){
      scanf("%d %d %d",&id,&l,&r);
      T[id].l = l;
      T[id].r = r;
      if(l != NIL) T[l].p = id;
      if(r != NIL) T[r].p = id;
  }
  
  for(i=0;i<n;i++){//根
    if(T[i].p == NIL){
      root = i;
    }
  }

  calcDepth(root,0);//深さ

  
  for(i=0;i<n;i++){//出力
    calcDegree(i);
    calcHeight(i);
    print(i);
  }

  return 0;
}
  
      



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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int pln1 = n * a, pln2 = b;
  if (pln1 <= pln2) {
    cout << pln1 << endl;
  } else {
    cout << pln2 << endl;
  }
}

Measured memory_bytes: 256
a[11],j;main(N,i){for(;scanf("%d",&N),j=N;memset(a,0,sizeof(a))){
    for(getchar(),i=0;(j=getchar())!='\n';i++)if(j=='M')a[i%N]++;else if(j-'L')a[N]+=a[i%N]+1,a[i%N]=0;else a[i%N]+=a[N]+1,a[N]=0;
    for(i=0;i<N;printf("%d ",a[i++]))for(j=N-1;j>i;j--)if(a[j]<a[j-1])a[j-1]^=a[j],a[j]^=a[j-1],a[j-1]^=a[j];
    printf("%d\n",a[N]);
}}

Measured memory_bytes: 604
#include <iostream>
#include <complex>

using namespace std;

bool isPrime(int n) {
  if (n == 2) {
    return true;
  }
  // cout << "sqrt:" << sqrt(n) << endl;
  for (int i = 2; i <= sqrt(n); i++) {
    // cout << "n:" << n << ", i:" << i << endl;
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (isPrime(num)) {
      // cout << "num:" << num << ", prime" << endl;
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
  // cin >> TT;
  while (TT--) {
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> A(n);
    for (auto& aa : A) cin >> aa;
    ll na = 0, nb = 0, nm = 0;
    for (ll x : A) {
      if (x <= a) {
        ++na;
      } else if (x <= b) {
        ++nm;
      } else {
        ++nb;
      }
    }
    cout << min({na,nm,nb}) << endl;

    
  }
}


Measured memory_bytes: 3540
n, l = map(int, input().split())
data = [l] * n
ans = 0

for i in range(n):
    data[i] += i
    ans += data[i]

mini = abs(data[0])
temp = data[0]

for i in range(n):
    if mini > abs(data[i]):
        mini = abs(data[i])
        temp = data[i]

print(ans - temp)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  long long a,b,c,d;cin >> a >> b >> c >> d;
  long long p,q,r,s,m1,m2;
  long long ans;
  
  //compute
  p = a*c;
  q = a*d;
  r = b*c;
  s = b*d;
  m1 = max(p,q);
  m2 = max(r,s);
  ans = max(m1,m2);


  if(a * b < 0 || c * d < 0){
           if(ans < 0){
             ans = 0;
           }
         }
 
  //output
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int arr[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int left = 0, right = 0, ans = OO;
  for (int i = 0; i < n; ++i) {
    right = 0;
    left += arr[i];
    for (int j = i + 1; j < n; ++j) {
      right += arr[j];
    }
    ans = min(ans, abs(right - left));
  }
  cout << ans;
  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> d(n); rep(i,n) cin >> d[i];
    int ans = 0;
    rep(i,n){
        for(int j = i + 1; j < n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,k,*v=map(int,open(0).read().split())
m=0
r=range
for i in r(n+1):
 for j in r(min(k,n)-i+1):
  t=sorted(v[:i]+v[-j:]*(j>0))[::-1]
  while t and(k-i-j)*t[-1]<0:t.pop();j+=1
  m=max(m,sum(t))
print(m)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
    int sec, remain;
    int h, m, s;
    
    cin >> sec;
    
    h = sec / (60 * 60);
    remain = sec % (60 * 60);
    m = remain / 60;
    s = remain % 60;
    
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100100
const ll inf = (ll)1e10;
const ll MOD = (ll)1e9+7;
ll dp[22][1 << 22];
bool chk ( int pos, int mask ) {
	return mask & (1 << pos);
}
int on ( int pos, int mask ) {
	return mask | (1<<pos);
}
int n, done;
int adj[21][21];
ll solve(ll pos , ll mask){
    
    if (pos == n){
        if (mask == done - 1) {
            return 1;
        } else return 0;
    }
    if(dp[pos][mask] != -1) return dp[pos][mask];
    ll ret = 0;
    for(int j = 0 ; j < n; j++){
        if ( adj[pos][j] && !chk(j,mask) ) ret = (ret + solve ( pos+1, on(j,mask) ) ) %MOD;
    }
    return dp[pos][mask] = ret;
}
int main()
{
	#ifdef __APPLE__
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			cin >> adj[i][j];
		}
	}
	done = (1<<n);
	memset(dp,-1,sizeof(dp));
	cout << solve(0,0) << endl;
	return 0;
}


Measured memory_bytes: 721152
s = input()
count = 0
if s == "SSS":
  print(0)
elif s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR":
  print(1)
elif s== "SRR" or s == "RRS":
  print(2)
elif s == "RRR":
  print(3)

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

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;

  std::vector<int> xs(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> xs[i];
  }

  int h = xs[0];
  long sum = 0;
  for (int i = 1; i < n; ++i) {
    if (xs[i] < h) {
      sum += h - xs[i];
    } else {
      h = xs[i];
    }
  }

  std::cout << sum << std::endl;

  return 0;
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if (A + B >= K)
    if(A > K)
      cout << K << endl;
    else
      cout << A << endl;
  else
    cout << 2*A + B - K << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl


int main(){
  int N;
  string s, t;
  cin >> N >> s >> t;
  int cnt = 0;
  string ans;
  rep(i, N){
    if(s.substr(i,N-i) == t.substr(0,N-i)){
      ans = s+t.substr(N-i,i);
      cout << ans.size() << endl;
      return 0;
    }
  }
  ans = s+t;
  cout << ans.size() << 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++)

int main(int argc, char const *argv[])
{
	ll n; cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}


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

const int mxN = 2e5 + 5;
long long a[mxN], cnt[mxN];

int main() {
	int n;
	cin >> n;
	long long tot = 0;
	for(int i = 1; i <= n; ++i)
		cin >> a[i], ++cnt[a[i]];
	for(int i = 1; i <= n; ++i) {
		tot += (cnt[i] * (cnt[i] - 1) / 2);
	}
	for(int i = 1; i <= n; ++i) {
		long long temp = cnt[a[i]] - 1;
		cout << tot - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + temp * (temp - 1) / 2 << '\n';
	}
	// inclusion exclusion
}


Measured memory_bytes: 6728
#include <stdio.h>
int main()
{
	int K, S, counter;
	scanf("%d %d", &K, &S);
	counter = 0;

	for(int x = 0; x <= K; ++x){
		for(int y = 0; y <= K; ++y){
			int z = S - (x + y);
			if((z >= 0) && (z <= K))
				++counter;
		}
	}
	printf("%d\n", counter);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> pickdiv(ll n){
    vector<ll> res;
    for(ll i=1; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i);
        ll q = n/i;
        if(q != i){
            res.emplace_back(q);
        }
    }
    return res;
}

int main(){
    ll N;
    cin >> N;
    auto v = pickdiv(N);
    ll ans = 0;
    for(auto& q:v){
        ll a = N/q;
        if(a > q+1){
            ans += (a - 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>

using namespace std;

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

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); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,kum = INT_MAX,cnt = 0;
  cin >> n;
  vector<int> p(n),a(n);
  
  for (int i = 0; i < n; i++){
    cin >> p[i];
    if (p[i] <= kum){
      kum = p[i];
      cnt++;
    }
  }
  
  cout << cnt << '\n'; 
  return 0;
}

Measured memory_bytes: 4776
# イベントソートでもできると思う

import heapq

N, M = map(int, input().split())
event_list = [[m, 10**5] for m in range(1, M+1)]
for i in range(N):
  a, b = map(int, input().split())
  event_list.append([a, b])


event_list.sort()
jobs = []
ans = 0
for event in event_list:
  if event[1] < 10**5:
    heapq.heappush(jobs, -event[1])
  else:
    if jobs:
      ans -= heapq.heappop(jobs)

print(ans)

Measured memory_bytes: 36920
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        
        if (str.contains("7")){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}

Measured memory_bytes: 27020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  if(s[s.length()-1]-'0'==3) puts("bon");
  else if(s[s.length()-1]-'0'==0||s[s.length()-1]-'0'==1||s[s.length()-1]-'0'==6||s[s.length()-1]-'0'==8) puts("pon");
  else puts("hon");
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string S;
	cin>>S;
	if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
		cout<<"Bad";
	}else {
		cout<<"Good";
	}
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    rep(i, h) cin >> v[i];

    int ans = INF;
    using P = pair<int, int>;
    int dx[] = {0, 1};
    int dy[] = {1, 0};

    auto isIN = [&](int y, int x){
        return (0<=y && y<h && 0<=x && x<w);
    };

    queue<P> que;

    //if(v[0][0] == '#') que.push({0, 0, '#'});
    //else que.push({0, 0, '.'});
    que.push({0, 0});

    vector<vector<int>> dist(h, vector<int>(w, INF));

    if(v[0][0] == '#') dist[0][0] = 1;
    else dist[0][0] = 0;

    while(que.size() != 0){
        int y, x;
        P p = que.front();
        y = p.first, x = p.second;
        que.pop();

        rep(i, 2){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(isIN(ny, nx) && v[ny][nx] == '#' && v[y][x] == '.' && dist[ny][nx] > dist[y][x]+1){
                dist[ny][nx] = dist[y][x]+1;
                que.push({ny, nx});
            }
            else if(isIN(ny, nx) && !(v[ny][nx] == '#' && v[y][x] == '.') && dist[ny][nx] > dist[y][x]){
                dist[ny][nx] = dist[y][x];
                que.push({ny, nx});
            }
        }
    }

    cout << dist[h-1][w-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int N, C;
    cin >> N >> C;

    vector<vector<int>> D(C, vector<int>(C));
    for(auto& i : D) for(auto& j : i){
        cin >> j;
    }
    
    vector<vector<int>> c(N, vector<int>(N));
    for(auto& i : c) for(auto& j : i){
        cin >> j;
        --j;
    }

    vector<vector<int>> po(3, vector<int>(C));
    for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j){
        po[(i+j)%3][c[i][j]]++;
    }
    
    int64_t ans = 1e9;
    for(int i = 0; i < C; ++i){
        int64_t xx = 0;
        for(int j = 0; j < C; ++j){
            xx += D[j][i] * po[0][j];
        }
        for(int j = 0; j < C; ++j){
            if(i == j) continue;
            int64_t yy = xx;
            for(int k = 0; k < C; ++k){
                yy += D[k][j] * po[1][k];
            }
            for(int k = 0; k < C; ++k){
                if(i == k || j == k) continue;
                int64_t zz = yy;
                for(int l = 0; l < C; ++l){
                    zz += D[l][k] * po[2][l];
                }
                ans = min(ans, zz);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  string s;
  cin>>s;
  int j=0;
  for(char c:s){
    if(c=='C')
      j=1;
    else if(c=='F' && j==1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    constexpr int mod=1e9+7;
    ll ans=0;
    for(int i=k;i<=n+1;i++){
        ll mn=ll(i-1)*i/2;
        ll mx=ll(n+n-i+1)*i/2;
        (ans+=mx-mn+1)%=mod;
    }
    cout<<ans;
    return 0;
}



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

using namespace std;
  
const int INF = 1<<28;
  
int main() {
    int W; cin >> W;
    vector<int> a(W);
    for(int i = 0; i < W; ++i) cin >> a[i];
    vector<int> L(W+1), R(W+1);
    L[0] = -1;
    for(int i = 0; i < W; ++i) {
        L[i+1] = L[i] - 1;
        if(a[i] == 0){
            L[i+1] = INF;
        }else if(a[i] < 0){
            L[i+1] = min(L[i+1], -a[i]-1);
        }
    }
    R[W] = -1;
    for(int i = W-1; i >= 0; --i) {
        R[i] = R[i+1] - 1;
        if(a[i] == 0){
            R[i] = INF;
        }else if(a[i] < 0){
            R[i] = min(R[i], -a[i]-1);
        }
    }
    int res = 0;
    for(int i = 0; i < W; ++i) {
        if(a[i] > 0); else continue;
        int t = max(L[i+1], R[i]);
        if(t < 0) continue;
        res += min(a[i], t+1);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3876
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if s == "AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  else:
    re += 1
print("AC","x",ac)
print("WA","x",wa)
print("TLE","x",tle)
print("RE","x",re)

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

void insertSort(int*,int);
int main(){

int i,N,*array;
scanf("%d",&N);
array=(int *)malloc(N*sizeof(int));
for(i=0;i<N;i++){
scanf("%d",&array[i]);
}
insertSort(array,N);
return 0;
}

void insertSort(int* array,int N){
    int i,v,j,l;
    for(l=0;l<N-1;l++) printf("%d ",array[l]);
    printf("%d",array[N-1]);
    printf("\n");
     for(i=1;i<=N-1;i++){
        v=array[i];
        j=i-1;
        while(j>=0 && array[j]>v){
            array[j+1]=array[j];
            j--;
            array[j+1]=v;
        }
        for(l=0;l<N-1;l++){
        printf("%d ",array[l]);
        }
	printf("%d",array[N-1]);
        printf("\n");
    }
            
 }



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

using namespace std;

struct Node {
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

class BinarySearchTree {
private:
    Node *root = nullptr;
public:
    BinarySearchTree() {}

    BinarySearchTree(int key)
    {
        insert(key);
    }

    void insert(int key)
    {
        /* Nodeの準備 */
        Node *node = new Node;
        node->key = key;
        node->left = nullptr;
        node->right = nullptr;

        /* 根がNULL(木が空)の場合 */
        if (root == nullptr)
        {
            node->parent = nullptr;
            root = node;
            return;
        }

        Node *parent = root;
        while (true)
        {
            if (node->key <= parent->key)
            {
                if (parent->left == nullptr)
                {
                    parent->left = node;
                    node->parent = parent;
                    break;
                } else
                    parent = parent->left;
            } else
            {
                if (parent->right == nullptr)
                {
                    parent->right = node;
                    node->parent = parent;
                    break;
                } else
                    parent = parent->right;
            }
        }
    }

    Node *find(int key)
    {
        Node *current = root;
        while(current != nullptr && current->key != key)
        {
            if(key < current->key)
                current = current->left;
            else
                current = current->right;
        }
        return current;
    }

    void inParse(Node *node)
    {
        if (node != nullptr)
        {
            inParse(node->left);
            cout << " " << node->key;
            inParse(node->right);
        }
    }

    void preParse(Node *node)
    {
        if (node != nullptr)
        {
            cout << " " << node->key;
            preParse(node->left);
            preParse(node->right);
        }
    }

    void print()
    {
        inParse(root);
        cout << endl;
        preParse(root);
        cout << endl;
    }
};

int main()
{
    int m;
    cin >> m;
    BinarySearchTree tree;
    string command;
    int key;
    for(int i = 0; i < m; i++)
    {
        cin >> command;
        if(command == "insert")
        {
            cin >> key;
            tree.insert(key);
        }
        else if(command == "find")
        {
            cin >> key;
            if(tree.find(key) != nullptr)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        else if(command == "print")
            tree.print();
    }
}


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

int main(){
  
  string N;
  cin >> N;
  
  if(N[0]==N[1]){
    if(N[1]==N[2]){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    if(N[1]==N[2]){
      if(N[2]==N[3]){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }
}


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


int main(){
    string s;
    cin>>s;
    int len = s.size();
    for(int i = len-2; i >= 0; i -= 2){
        if(s.compare(0, i/2, s, i/2, i/2) == 0){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
using namespace std;
int n,a[N+5],s[N+5];
class FastIO
{
	private:
		#define FS 100000
		#define tc() (A==B&&(B=(A=FI)+fread(FI,1,FS,stdin),A==B)?EOF:*A++)
		#define tn (x<<3)+(x<<1)
		#define D isdigit(c=tc())
		char c,*A,*B,FI[FS];
	public:
		I FastIO() {A=B=FI;}
		Tp I void read(Ty& x) {x=0;W(!D);W(x=tn+(c&15),D);}
		Ts I void read(Ty& x,Ar&... y) {read(x),read(y...);}
}F;
int main()
{
	RI i,t=0;for(F.read(n),i=1;i<=n;++i) F.read(a[i]);
	for(sort(a+1,a+n+1),i=1;i<=n;++i) s[i]=a[i];t=unique(s+1,s+n+1)-s-1;
	if(!a[1]&&t<=2&&!(n%2)) {for(i=1;i<=n&&!a[i];++i);if(i==n/2+1||i==n+1) return puts("Yes"),0;}
	if(n%3) return puts("No"),0;
	for(i=1;i<n/3;++i) if(a[i]^a[i+1]) return puts("No"),0;
	for(i=n/3+1;i<n/3*2;++i) if(a[i]^a[i+1]) return puts("No"),0;
	for(i=n/3*2+1;i<n;++i) if(a[i]^a[i+1]) return puts("No"),0;
	return puts(t<=3&&(a[1]^a[n/3+1])==a[n]?"Yes":"No"),0;
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
)

func main() {
	var n, k, s int
	fmt.Scan(&n, &k, &s)
	d := int(1e9)
	if d == s {
		d = 1
	}
	for i := 0; i < n; i++ {
		if i < k {
			fmt.Printf("%d ", s)
		} else {
			fmt.Printf("%d ", d)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n, k; cin >> n >> k;
  double ans = 0;
  rep(i, n) {
    int x = i+1;
    double d = 1.0;
    while (x < k) {
      x *= 2;
      d /= 2;
    }
    ans += d;
  }
  printf("%.13lf\n", ans/n);
  return 0;
}


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

int main() {
  int n , m;
  cin >> n >> m;
  string s;
  cin >> s;
  int size = s.size();
  
  vector<int>a(size,0);
  for(int i=0; i<size-1; i++){
   if(s[i]=='A' && s[i+1]=='C'){
    for (int j=i+1; j<size; j++){
      a[j]++;
    }
   }
  }
  
  for(int i=0; i<m; i++){
    int g , h;
    cin >> g >> h;
    g--;
    h--;
    cout << a[h]-a[g] << endl;
  }
  
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
int n,k,arr[N],dp[N];    

int calc(int idx){
    if(idx==n-1)return 0;
    if(idx>n-1)return 1e5;
    
    if(dp[idx]!=-1)
    return dp[idx];
    
    int mn=1e9+10;
    for(int i=idx+1;i<=idx+k && i<n;++i)
        mn=min(mn,abs(arr[idx]-arr[i])+calc(i));

    return dp[idx]=mn;
}

int main(){
cin>>n>>k;
for(int i=0;i<n;++i)
cin>>arr[i];

memset(dp,-1,sizeof(dp));

cout<<calc(0);
return 0;    
}

Measured memory_bytes: 5760
import  numpy   as  np

S   =   input()
ANS =   [0]*len(S)

point   =   0

move_num    =   10**100

before_result = ["-",0]

for i in range(len(S)):
    point   =   0
    if(S[i] ==  "R"):
        if(before_result[0] != "R"):
            for j in range(i,len(S)):
                if(S[j] == "L"):
                    point = j-1
                    break
            before_result[1]    =   point
            before_result[0]    =   "R"
        else:
            point   =   before_result[1]
        if((move_num - (point - i)) % 2 == 0):
            ANS[point] += 1
        else:
            ANS[point + 1] += 1
    else:
        if(before_result[0] != "L"):
            for j in range(i,-1,-1):
                if(S[j] == "R"):
                    point = j+1
                    break
            before_result[1]    =   point
            before_result[0]    =   "L"
        else:
            point   =   before_result[1]
        if((move_num - (i - point)) % 2 == 0):
            ANS[point] += 1
        else:
            ANS[point - 1] += 1

for i in range(len(ANS)):
    print("{} ".format(ANS[i]),end = "")




Measured memory_bytes: 14304
import sys
input = sys.stdin.readline
def solve():
  n,k  =(int(i) for i in input().split())
  if n <= k:
    print(0)
    exit()
  else:

      ans = 0
      for b in range(k+1,n+1):
        if n%b == 0:
          ans += (n//b)*(b-k)
        else:
          if k == 0:
            ans += (n//b)*(b-k)+n%b
          else:
            ans += (n//b)*(b-k)+max(n%b-k+1,0)
  print(ans)
        
solve()
  

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

string dice[8];
string rotdice[8][24];
string sdice[8];
bool used[8];

bool val(int pos){
	int x=pos%2,y=pos/2%2,z=pos/4%2;
//if(x==1)cout<<pos<<" "<<sdice[pos]<<" "<<sdice[pos-1]<<" "<<abs(sdice[pos][3]-sdice[pos-1][2])<<endl;
//if(y==1)cout<<pos<<" "<<sdice[pos]<<" "<<sdice[pos-2]<<" "<<abs(sdice[pos][4]-sdice[pos-2][1])<<endl;
//if(z==1)cout<<pos<<" "<<sdice[pos]<<" "<<sdice[pos-4]<<" "<<abs(sdice[pos][5]-sdice[pos-4][0])<<endl;
	if(x==1&&abs(sdice[pos][3]-sdice[pos-1][2])!=32)return false;
	if(y==1&&abs(sdice[pos][4]-sdice[pos-2][1])!=32)return false;
	if(z==1&&abs(sdice[pos][5]-sdice[pos-4][0])!=32)return false;
	return true;
}

string h(string s,int n){
	if(n==0)return s;
	string ss;
	ss+=s[0];
	ss+=s[3];
	ss+=s[1];
	ss+=s[4];
	ss+=s[2];
	ss+=s[5];
	return h(ss,n-1);
}

string g(string s,int n){
	int pos[6][6]={
		{0,1,2,3,4,5},
		{1,5,2,3,0,4},
		{2,1,5,0,4,3},
		{3,1,0,5,4,2},
		{4,0,2,3,5,1},
		{5,4,2,3,1,0},
	};
	string res;
	rep(i,6)res+=s[pos[n][i]];
	return res;
}

bool f(int pos){
	if(pos==8){return true;}
	rep(k,8){
		if(pos==0&&k>0)break;
		if(used[k])continue;
		used[k]=true;
		rep(i,24){
			sdice[pos]=rotdice[k][i];
			if(!val(pos))continue;
			if(f(pos+1))return true;
		}
		used[k]=false;
	}
	return false;
}

int main() {
	IL{
		cin>>dice[0];
		if(dice[0]=="0")break;
		rep(i,7)cin>>dice[i+1];
		rep(i,8)used[i]=false;
		rep(k,8){
			rep(i,6){
				string d=g(dice[k],i);
				rep(j,4){
					rotdice[k][i*4+j]=h(d,j);
				}
			}
		}
		if(f(0)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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

import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd

l = [0, a[0]]
r = [0, a[-1]]
for i in range(1, n):
    l.append(gcd(a[i], l[i]))
    r.append(gcd(a[n-i-1], r[i]))
counter = 0
for i in range(n):
    num = gcd(l[i], r[n-i-1])
    if counter < num:
        counter = num

print(counter)

Measured memory_bytes: 14076