akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn=2005;
const int maxs=20;
struct Circle
{
	double x,y,z,r;
	Circle(double X=0,double Y=0,double Z=0,double R=0)
	{
		x=X;y=Y;z=Z;r=R;
	}
	Circle operator -(const Circle &p)
	{
		return Circle(x-p.x,y-p.y,z-p.z,0);
	}
}cir[maxn],sor[maxs],o;
bitset<maxn> sp[maxs],now;
#define sqr(v) ((v)*(v))
const double eps=1e-8;
bool cross(int i,int j)
{
	Circle vec=o-sor[i];
	double a=sqr(vec.x)+sqr(vec.y)+sqr(vec.z);
	double b=2*vec.x*(sor[i].x-cir[j].x)+2*vec.y*(sor[i].y-cir[j].y)+2*vec.z*(sor[i].z-cir[j].z);
	double c=sqr(sor[i].x-cir[j].x)+sqr(sor[i].y-cir[j].y)+sqr(sor[i].z-cir[j].z)-sqr(cir[j].r);
	double delta=b*b-4*a*c;
	if(delta>eps)
	{
		double t1=(-b+sqrt(delta))/(2*a);
		if(-eps<t1&&t1<1+eps)return true;
		double t2=(-b-sqrt(delta))/(2*a);
		if(-eps<t2&&t2<1+eps)return true;
	}
	return false;
}
int main()
{
	int n,m,r,i,j;
	double tmp,res;
	while(scanf("%d%d%d",&n,&m,&r)!=EOF)
	{
		if(!n&&!m&&!r)break;
		for(i=0;i<n;++i)
			scanf("%lf %lf %lf %lf",&cir[i].x,&cir[i].y,&cir[i].z,&cir[i].r);
		for(i=0;i<m;++i)
			scanf("%lf %lf %lf %lf",&sor[i].x,&sor[i].y,&sor[i].z,&sor[i].r);
		scanf("%lf%lf%lf",&o.x,&o.y,&o.z);
		for(i=0;i<m;++i)
		{
			sp[i].reset();
			for(j=0;j<n;++j)
				if(cross(i,j))sp[i][j]=1;
			//cout <<sor[i].r<<endl;
			//cout <<sor[i].r/(sqr(sor[i].x-o.x)+sqr(sor[i].y-o.y)+sqr(sor[i].z-o.z))<<endl;
			//cout <<sor[i].x<<" "<<sor[i].y<<" "<<sor[i].z<<endl;
			//cout <<sqr(sor[i].x-o.x)<<" "<<sqr(sor[i].y-o.y)<<" "<<sqr(sor[i].z-o.z)<<endl;
		}
		//cout <<o.x<<" "<<o.y<<" "<<o.z<<endl;
		res=0;
		for(i=0;i<(1<<m);++i)
		{
			tmp=0;
			now.reset();
			for(j=0;(1<<j)<=i;++j)
				if(i&(1<<j))
				{
					now|=sp[j];
					tmp+=sor[j].r/(sqr(sor[j].x-o.x)+sqr(sor[j].y-o.y)+sqr(sor[j].z-o.z));
				}
			if(now.count()<=r&&tmp>res)res=tmp;
		}
		printf("%.9f\n",res);
	}
	return 0;
}

Measured memory_bytes: 1320
//file_name:ABC86_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    rep(i,2){
        int a;
        cin >> a;
        if(a%2==0){
            puts("Even");
            return 0;
        }
    }


    ll ans = 0;

    cout << "Odd" << endl;
    return 0;
}



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

int dp[3][1<<8];

int main(){
    int n;
    int d[3];
    cin>>n;
    cin>>d[0]>>d[1]>>d[2];
    vector<int> arr(8);
    
    for(int i = 0; i < 8; i++) cin>>arr[i];

    for(int i = 1; i < (1<<n); i++){
        int ko = 0;
        int sm = 0;
        for(int j = 0; j < n; j++){
            if(i&(1<<j)){
                sm+=arr[j];
                ko++;
            }
        }
        for(int j = 0; j < 3; j++){
            dp[j][i] = (ko-1)*10+abs(sm-d[j]);
        }
    }
    int ans = 1e8;
    for(int i = 1; i < (1<<n); i++){
        for(int j = 1; j < (1<<n); j++){
            if((i&j)==0){
                for(int k = 1; k < (1<<n); k++){
                    if((k&i)==0 && (j&k)==0){
                        ans = min(ans,dp[0][i]+dp[1][j]+dp[2][k]);
                    }
                }
            }
        }
    }

    cout<<ans;
}


Measured memory_bytes: 256
card=[]
for i in range(3):
  card.append(list(map(int,input().split())))
n = int(input())
for i in range(n):
  k = int(input())
  for i in range(3):
    for j in range(3):
      if k == card[i][j]:
        card[i][j] = -1

bingo=False
for i in range(3):
  if card[0][i] == -1 and card[1][i] == -1 and card[2][i] == -1:
    bingo=True
  if card[i][0] == -1 and card[i][1] == -1 and card[i][2] == -1:
    bingo=True
if card[0][0] == -1 and card[1][1] == -1 and card[2][2] == -1:
  bingo=True
if card[2][0] == -1 and card[1][1] == -1 and card[0][2] == -1:
  bingo=True
if bingo:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, K = lr()
    MOD = pow(10, 9)+7
    lst = [0]*K
    klst = [0]*K
    for k in range(K, 0, -1):
        lst[k-1] = pow(K//k, N, MOD)
        for i in range(2, K//k+1):
            lst[k-1] -= lst[i*k-1]
        klst[k-1] = k*lst[k-1]
    print(sum(klst)%MOD)
resolve()

Measured memory_bytes: 69496
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
#define ld long double

int main()
{
    ll x,n;
    cin >> x >> n;
    ll p;
    ll ct[10001]={0};
    for(ll i=0;i<n;i++)
    {
      cin >> p;
      ct[p]=1;
    }
    ll min=1000000;
    ll ans=0;
    for(ll i=-10000;i<=10000;i++)
    {
      if(ct[i]==0 || i<=0)
      {
        //cout << i;
        if(abs(x-i)<min)
        {
          ans=i;
          min=abs(x-i);
        }
      }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3708
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    ll a[100005];
    ll maxsum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] > 0) maxsum += a[i];
    }
    ll psum = 0;
    ll nsum = 0;
    for(int i = 0; i < k; i++){
        if(a[i] > 0) psum += a[i];
        else nsum -= a[i];
    }
    ll ans = 0;
    for(int i = k; i <= n; i++){
        ans = max(ans, maxsum - min(psum, nsum));
        if(a[i] > 0) psum += a[i];
        else nsum -= a[i];
        if(a[i - k] > 0) psum -= a[i - k];
        else nsum += a[i - k];
    }
    cout << ans << endl;
}

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

bool isPrime(int x) {
    if (x == 2) {
        return true;
    }

    if (x <= 1 || x % 2 == 0) {
        return false;
    }

    for (int i = 3; i <= sqrt(x); i+=2) {
        if (x % i == 0) {
            return false;
        }
    }

    return true;
}

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

    int a, count = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (isPrime(a)) {
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3092
#include <iostream>
 #include <bitset>
 #include <algorithm>
 
 using namespace std;
 
 bitset<10000> cookie[10];
 
 int main() {
    int r;
     int c;
     while (cin >> r >> c && r > 0) {
         int i, j;
         
         for (i = 0; i < r; i++) {
             for (j = 0; j < c; j++) {
                 bool upwards;
                 cin >> upwards;
                 cookie[i][j] = upwards;
             }
         }
         
         int result = 0;
         int permute = 1 << r;
         for (i = 0; i < permute; i++) {
            for (j = 0; j < r; j++) {
             if (i & 1 << j) {
                 cookie[j].flip();
             }
            }
            
            int possibleResult = 0;
            for (int p = 0; p < c; p++) {
             int upCount = 0;
             for (int q = 0; q < r; q++) {
                 if (cookie[q][p]) {
                     upCount++;
                 }
             }
             possibleResult += max(upCount, r - upCount);
            }
            result = max(result, possibleResult);   
             
            for (j = 0; j < r; j++) {
                if (i & 1 << j) {
                    cookie[j].flip();
                }
            }                                
        }
        cout << result << endl;
     }   
     return 0;
 }

Measured memory_bytes: 3004
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one == N:
    print("Yes")
    exit()
print("Yes" if two+int(two>0) >= zero+int(one>0) else "No")

Measured memory_bytes: 20104
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=200000;

int main(){
   int n;
   cin>>n;
   int r[MAX];
   for(int i=0;i<n;i++){
       cin>>r[i];
   }
  int minv = r[0];
  int maxv = -10000000000;
  for(int j=1;j<n;j++){
      maxv=max(maxv,r[j] - minv);
      minv=min(minv,r[j]);
  }
  cout<< maxv <<endl;
  return 0;
    
}


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

int solve() {
    string N;
    cin >> N;
    reverse(N.begin(), N.end());
    N.push_back('0');
    ll m = N.size();
    vector<int> dp0(m+1), dp1(m+1);
    for ( int i = 1; i <= m; i++ ) {
        int a = N[i-1] - '0';
        if ( i <= 1 ) {
            dp0[i] = a;
            dp1[i] = 10 - a;
        } else {
            dp0[i] = min(dp0[i-1] + a, dp1[i-1] + a + 1);
            dp1[i] = min(dp0[i-1] + 10 - a, dp1[i-1] + 10 - (a + 1));
        }
    }
    int ans = min(dp0[m], dp1[m]);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int n, a[1005];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(abs(a[i]-a[j])%(n-1)==0){
                cout << a[i] << " " << a[j] << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
    string N;
    cin >> N;

    int64_t sum = 0;
    for (char c : N) {
        sum += c - '0';
    }

    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3720
s=input()
a=[0]*13
a[0]=1
for i in s:
  b=[0]*13
  for j,k in enumerate(a):
    b[(j*10)%13]+=k
  a=b[:]
  b=[0]*13
  if i=="?":
    for l in range(10):
      for j,k in enumerate(a):
        b[(j+l)%13]+=k
  else:
    for j,k in enumerate(a):
      b[(j+int(i))%13]+=k
  a=[j%(10**9+7) for j in b]
print(a[5]%(10**9+7))

Measured memory_bytes: 45348
shapes = {
    'A': '1100000011',
    'B': '1000000010000000100000001',
    'C': '1111',
    'D': '01000000110000001',
    'E': '11000000011',
    'F': '100000001100000001',
    'G': '0110000011'
}

while True:
    try:
        plane = ''
        for i in range(8):
            plane += input()

        for name in shapes:
            try:
                plane.index(shapes[name])
                print(name)
                break
            except:
                pass

        input()
    except:
        break


Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  int baka;
  for (int i = 0; i < N; i++) {
    if (A.at(i) > A.at(baka)) {
      baka = i;
    }
  }
  cout << A.at(baka) + B.at(baka) << endl;
  return 0;
}


Measured memory_bytes: 1148
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        Map<Character, Integer> mapS = new HashMap<>();
        Map<Character, Integer> mapT = new HashMap<>();

        for (int i=0; i<s.length; i++) {
            if (mapS.containsKey(s[i])) {
                mapS.put(s[i], mapS.get(s[i]) + 1);
            } else {
                mapS.put(s[i], 1);
            }
        }
        for (int i=0; i<t.length; i++) {
            if (mapT.containsKey(t[i])) {
                mapT.put(t[i], mapT.get(t[i]) + 1);
            } else {
                mapT.put(t[i], 1);
            }
        }

//        System.out.print(mapS);
//        System.out.print(mapT);

        List<Integer> listS = new ArrayList<>();
        for (int v: mapS.values()) {
            listS.add(v);
        }
        Collections.sort(listS);
        List<Integer> listT = new ArrayList<>();
        for (int v: mapT.values()) {
            listT.add(v);
        }
        Collections.sort(listT);

//        System.out.print(listS);
//        System.out.print(listT);

        if (listS.size() != listT.size()) {
            System.out.print("No");
            return;
        }

        for (int i=0; i<listS.size(); i++) {
            int ss = listS.get(i);
            int tt = listT.get(i);
            if (ss != tt) {
                System.out.print("No");
                return;
            }
        }

        System.out.print("Yes");

    }


}



Measured memory_bytes: 49780
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    int ans=1;
    while(ans<=n){
        ans*=2;
    }
    cout << ans/2 <<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;


int main() {

	// 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	string S;
	cin >> S;

	int flag = 0;
	if (S.find("A") == string::npos) {
		flag = 1;
	}
	if (S.find("B") == string::npos) {
		flag = 1;
	}

	if (flag == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;

typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

	int a, b, c;
	cin >> a >> b >> c;
	if(c > a + b) cout << "NA";
	else cout << c - min(a, c);
	cout << "\n";
	return 0;
}



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

int mod = 1e9 + 7;

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< std::vector< int > > AB(N);
    for(int i=0; i<N-1; i++){
        int a, b;
        std::cin >> a >> b;
        AB[a - 1].push_back(b - 1);
        AB[b - 1].push_back(a - 1);
    }
    
    int st = 0;
    for(int i=0; i<N; i++){
        if(AB[i].size() == 1){
            st = i;
            break;
        }
    }
    
    std::deque< int > deq_No;
    std::deque< int > deq_preNo;
    std::deque< int > deq_color;
    std::deque< int > deq_d;
    deq_No.push_back(st);
    deq_preNo.push_back(-1);
    deq_color.push_back(0);
    deq_d.push_back(0);
    
    long long ans = 1;
    
    while(!deq_No.empty()){
        int No = deq_No[0];
        int preNo = deq_preNo[0];
        int color = deq_color[0];
        int d = deq_d[0];
        deq_No.pop_front();
        deq_preNo.pop_front();
        deq_color.pop_front();
        deq_d.pop_front();
        
        ans = (ans * (K - color - (d >= 2))) % mod;
        
        int cnt = 1;
        for(int i=0; i<AB[No].size(); i++){
            if(AB[No][i] == preNo){
                continue;
            }
            deq_No.push_back(AB[No][i]);
            deq_preNo.push_back(No);
            deq_color.push_back(cnt);
            deq_d.push_back(d + 1);
            cnt++;
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}



Measured memory_bytes: 7800
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  long double res = 0;
  long double btc = 0;
  F0R(i, N) {
    long double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") res += x;
    else btc += x;
  }
  res += btc * 380000;
  cout << res;
}
#endif


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

int gcd(int a, int b) {
  if (a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

int my_gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }

int main() {
  int K;
  cin >> K;

  ll ans = 0;

  rep_s(i, 1, K + 1) {
    rep_s(j, 1, K + 1) {
      rep_s(l, 1, K + 1) { ans += my_gcd(i, j, l); }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>num(N + 10);
	num[1] = 1;
	vector<int>p;
	p.push_back(2);
	num[2] = 2;
	for (int i = 3; i <= N; i++) {
		int m = i;
		for(auto j:p){
			if (j*j > i)break;
			if (i%j == 0) {
				m = j;
				break;
			}
		}
		if (m == i) {
			num[i] = 2;
		}
		else {
			int box = i;
			int add = 0;
			while (box%m == 0) {
				box /= m;
				add++;
			}
			num[i] = num[i / m] / add * (add + 1);
		}
		if (num[i] == 2)p.push_back(i);
	}
	long long int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += 1LL * num[i] * i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 46464
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define mx 100005
int32_t main()
{
    cin.tie(0);cout.tie(0);
    ios_base::sync_with_stdio(0);
    string s;cin>>s;
    int ss=0,k=0;
    for(int i=s.size();i>=0;i--)
    {
        if(s[i]=='W')
        k++;
        else
        ss+=k;
    }
    cout<<ss;
    
    
}

Measured memory_bytes: 720
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 5e5 + 10; 
const int block_size = 800;

int cnt[N];
int A[N];
int cur = 0;

void remove(int idx){
   cnt[A[idx]]--;
   if(cnt[A[idx]] == 0) --cur;
}

void add(int idx){
   if(cnt[A[idx]] == 0) ++cur;
   cnt[A[idx]]++;
}

int get_answer(){
   return cur;
}

struct Query {
    int l, r, idx;
    bool operator<(Query other) const
    {
        return make_pair(l / block_size, r) <
               make_pair(other.l / block_size, other.r);
    }
};

vector<int> mo_s_algorithm(vector<Query> queries) {
    vector<int> answers(queries.size());
    sort(queries.begin(), queries.end());

    // TODO: initialize data structure

    int cur_l = 0;
    int cur_r = -1;
    // invariant: data structure will always reflect the range [cur_l, cur_r]
    for (Query q : queries) {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        answers[q.idx] = get_answer();
    }
    return answers;
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,q;
   cin >> n >> q;
   vector<Query> Q(q);
   f(i,0,n){
      cin >> A[i];
   }
   f(i,0,q){
      int l,r;
      cin >> l >> r;
      --l,--r;
      Q[i].l = l, Q[i].r = r;
      Q[i].idx = i;
   }
   vector<int> R = mo_s_algorithm(Q);
   f(i,0,q){
      cout << R[i] << '\n';
   }
   return 0;
} 

Measured memory_bytes: 38228
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ff first
#define mp make_pair
#define dd second
#define pp pair<int,int>
#define N 100005
using namespace std;


main() {
    ios_base::sync_with_stdio(false);
    //freopen("test2", "r", stdin);
    int a,b,c; cin >> a >> b >> c;
    for(int i = 0; i < 100; ++i) {
        if(a > i) continue;
        if(b > i) continue;
        if(c > i) continue;
        int sum = i-a+i-b+i-c;
        if(sum % 2 == 0) {
            cout << sum/2 << endl; exit(0);
        }
    }
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,a,ans=0;
	cin>>n;
	forn(i,n){
		cin>>a;
		while(a>0 && a%2==0){
			a = a/2;
			ans++;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

	int N;
	cin >> N;
	long long int ans = ((long long int)N - 1) * ((long long int)N) / 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n, k = [int(i) for i in input().strip().split(' ')]
As = [int(i) for i in input().strip().split(' ')]
for i, a in enumerate(As):
    if a == 1:
        x = i+1

lm = (x-1) % (k-1)
rm = (n - x) % (k-1)
if lm == 0 and rm == 0:
    print(int((x - 1) / (k-1))+int((n - x) / (k-1)))
elif lm == 0 or rm == 0:
    print(int((x - 1) / (k-1))+int((n - x) / (k-1)) + 1)
else:
    if lm + rm <= k-1:
        print(int((x - 1) / (k-1))+int((n - x) / (k-1)) + 1)
    else:
        print(int((x - 1) / (k-1))+int((n - x) / (k-1)) + 2)



Measured memory_bytes: 13812
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <tuple>
using namespace std;

int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for(int i=0; i<X; i++) cin >> A[i];
    for(int i=0; i<Y; i++) cin >> B[i];
    for(int i=0; i<Z; i++) cin >> C[i];
    sort(A.begin(), A.end(), greater<long long>());
    sort(B.begin(), B.end(), greater<long long>());
    sort(C.begin(), C.end(), greater<long long>());

    set<tuple<int, int, int>> st;
    int cnt = 0;
    priority_queue<tuple<long long, int, int, int>> pq;
    pq.push(make_tuple(A[0]+B[0]+C[0], 0, 0, 0));
    st.insert(make_tuple(0, 0, 0));
    while(!pq.empty()){
        auto tp = pq.top();
        pq.pop();
        long long sm, i, j, k;
        tie(sm, i, j, k) = tp;
        cout << sm << endl;
        cnt++;
        if(cnt == K) break;
        if(i+1 < X){
            auto t = make_tuple(i+1, j, k);
            if(st.find(t) == st.end()){
                st.insert(make_tuple(i+1, j, k));
                long long sm = A[i+1]+B[j]+C[k];
                pq.push(make_tuple(sm, i+1, j, k));
            }
        }
        if(j+1 < Y){
            auto t = make_tuple(i, j+1, k);
            if(st.find(t) == st.end()){
                st.insert(make_tuple(i, j+1, k));
                long long sm = A[i]+B[j+1]+C[k];
                pq.push(make_tuple(sm, i, j+1, k));
            }
        }
        if(k+1 < Z){
            auto t = make_tuple(i, j, k+1);
            if(st.find(t) == st.end()){
                st.insert(make_tuple(i, j, k+1));
                long long sm = A[i]+B[j]+C[k+1];
                pq.push(make_tuple(sm, i, j, k+1));
            }
        }
    }
    return 0;
}

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

int main(){
vector<int> a(1000000);
vector<string> b(1000000);
vector<int> c(1000000);
vector<int> d(1000000);

int n;
string m;
cin>>n>>m;
int ans =n;
for(int i=0;i<n;i++){
    if(m[i]=='x'&&m[i+1]=='x'){
    	ans=i+1;
        break;
    }
}
cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 22760
#include <bits/stdc++.h>
using namespace std;
int dp[1001][1001];
int ans=0;
int  countP(int i, int j, vector<vector<int>> &path, int h, int w){
    if(i==h || j ==w)
    return 0;
    if(!path[i][j])
    return 0;
    if(dp[i][j] != -1)
    return dp[i][j] ;
    if(i==h-1 && j==w-1)
    return 1;
    long long  temp=0;
    
        temp = countP(i+1,j,path,h,w)  + countP(i,j+1,path,h,w);
        
    // }
    // else{
    //      temp = countP(i+1,j,path,h,w)  + countP(i,j+1,path,h,w) ;
    // }
    dp[i][j] = (int)temp %1000000007;
    return dp[i][j];
}
int main() {
	int h,w;
	cin>>h>>w;
	memset(dp, -1, sizeof(dp));
	vector<vector<int>>path(h+1,vector<int>(w+1, 0));
	for(int i=0;i<h;i++){
	    for(int j=0;j<w;j++){
	        char ch;
	        cin>>ch;
	        if(ch == '.'){
	            path[i][j]=1;
	        }
	    }
	}
	cout<<countP(0,0, path,h,w);
	
	return 0;
}

Measured memory_bytes: 11656
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n,m,p,a,b;
  while(scanf("%d %d %d %d %d", &n, &m, &p, &a, &b), n){
    a--;b--;
    vector<vector<pair<int,int> > > vec(m, vector<pair<int, int> >()); // ????????°?????? vec[from] -> (to, cost)
    vector<int> ticket(n);
    rep(i,n) scanf("%d", &ticket[i]);
    rep(i,p){
      int x,y,z;
      scanf("%d %d %d", &x, &y, &z);
      x--;y--;
      vec[x].pb(mp(y,z));
      vec[y].pb(mp(x,z));
    }

    vector<vector<double> > dp(1<<n, vector<double>(m, INF));
    dp[0][a]=0;
    rep(mask, 1<<n){
      rep(i,m) if(dp[mask][i]!=INF && i!=b){
        rep(j,n) if((mask&(1<<j))==0){
          // ticket[j]????????¨??????
          int nmask = mask | (1<<j);
          for(auto nxt : vec[i]) if(nxt.fi != a){
            dp[nmask][nxt.fi] = min(dp[nmask][nxt.fi], dp[mask][i] + (double)nxt.se/ticket[j]);
          }
        }
      }
    }
    double ans = INF;
    rep(mask, 1<<n) ans = min(ans, dp[mask][b]);
    if(ans == INF) printf("Impossible\n");
    else printf("%.5f\n", ans);
  }
  return 0;
}

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

using namespace std;

int main()
{
    string st;cin>>st;
    int i,j,k,l=0;

    for(i=0;i<3;i++)
    {
        if(st[i]==st[i+1])
        {
            l++;
        }

      if(st[i]!=st[i+1])
      {
          if(i!=0)break;
      }
    }

    if(l>=2)puts("Yes");else puts("No");
    return 0;
}


Measured memory_bytes: 256
typedef char Bool;
#define true 39
#define false 0 
typedef long long int64;
typedef unsigned long long uint64;
typedef int int32;
typedef unsigned int uint32;
typedef unsigned char byte;
#pragma warning (disable:4996)
#include <stdio.h>
#include <malloc.h>

int main()
{
	int x, n;
	int* p;
	scanf("%d %d", &x, &n);

	p = (int*)malloc(sizeof(int) * n);

	for (int i = 0; i != n; i++)
	{
		scanf("%d", &p[i]);
	}

	Bool pc = false, mc = false;

	if (n == 0) 
	{
		printf("%d", x);
		return 0;
	}

	for (int i = 0; 1; i++)
	{
		for (int j = 0; j != n; j++)
		{
			if ((x - i) == p[j])
			{
				mc = true;
			}
			if ((x + i) == p[j])
			{
				pc = true;
			}
		}
		if (!mc) 
		{
			printf("%d", x - i);
			return 0;
		}
		if (!pc)
		{
			printf("%d", x + i);
			return 0;
		}
		pc = false;
		mc = false;

	}

	return 0;
}

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


int heap[500005];
int H;

int parent(int i) {
    return i/2;
}

int left(int i) {
    return 2*i;
}

int right(int i) {
    return 2*i+1;
}

void maxHeapify(int A[], int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if(l <= H && A[l] > A[i]) {
        largest = l;
    } else { 
        largest = i;
    }
    if(r <= H && A[r] > A[largest]) {
        largest = r;
    }
    if(largest != i) {
        int t = A[i];
        A[i] = A[largest];
        A[largest] = t;
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int A[]) {
	int i;
    for(i=H/2;i>0;i--) {
        maxHeapify(A, i);
    }
}

int main(){
	int i,n,t;
	scanf("%d\n", &n);
	H = n;
	
	for(i=1;i<=n;i++) {
		scanf("%d", &heap[i]);
	}

	buildMaxHeap(heap);

	for(i=1;i<=n;i++) {
		printf(" %d", heap[i]);
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 3672
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define MAX 362880 //9の階乗
#define N 3
#define N2 9

/*
螺旋本の解答例`似せてc言語で書いてみた
*/

typedef struct puzzle{
	int f[N2];
	int space;
	int path;
}Puzzle;

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

int V[MAX];

// QUEUE --------

Puzzle Q[MAX];
int head, tail;

int empty(){
	return head == tail;
}

void push(Puzzle x){
	Q[tail] = x;
	tail = (tail+1)%MAX;
}

Puzzle front(){
	Puzzle x;
	x = Q[head];
	head = (head+1)%MAX;
	return x;
	
}

// QUEUE --------


/* 
int cheak(Puzzle p)
1から9までの数を並び替えた数列をすべて列挙して辞書順に並び替えたとき以下の数列
p.f[8],p.f[7],p.f[6].......p.[0]
が前から何番目にあるかを返す関数
*/
int cheak(Puzzle p){
	int i, j, fac, count, res = 0;
	for(i = 0, fac = 1; i < N2; fac*= ++i){
		for(j = 0, count = 0; j < i; j++){
			if(p.f[j] < p.f[i]) count++;
		
		}
		res += count*fac;
	}
	
	return res;	
}

int isTarget(Puzzle p){
	int i;
	for(i = 0; i < N2; i++ )
		if(p.f[i] != (i + 1) ) return 0;
	return 1;
}

int bfs(Puzzle s){
	int sx, sy, tx, ty, r, temp;
	Puzzle u, v;
	
	s.path = 0;
	
	push(s);
	
	V[cheak(s)] = 1;
	
	while(!empty()){
		u = front();
		if( isTarget(u)) return u.path;
		sx = u.space / N;
		sy = u.space % N;
		
		for ( r = 0; r < 4; r++ ) {
			tx = sx + dx[r];
			ty = sy + dy[r];
			if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
			v = u;
			
			temp = v.f[u.space];
			v.f[u.space] = v.f[tx * N + ty];
			v.f[tx * N + ty] = temp;
			
			v.space = tx * N + ty;
			
			if( !V[cheak(v)] ){
				V[cheak(v)] = 1;
				v.path++;
				push(v);
			}
		}
	}
	
	return -1;
}

int main(){
	int i, ans;
	Puzzle in;
	
	for( i = 0; i < N2; i++ ) {
		scanf("%d", &in.f[i]);
		if( in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	
	ans = bfs(in);
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 10948
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    ll n,m;
    cin>>n>>m;
    
    int h = m/n;
    
    while(1){
        if(m%h==0){
            cout<<h<<endl;
            break;
        }
        h--;
    }
}

Measured memory_bytes: 3628
N = int(input())

ans = 0

c = input()
redNum = c.count("R")
leftWhite = c.count("W", 0,redNum)
rightRed = c.count("R", redNum,N)

ans += min(leftWhite, rightRed)
if leftWhite > rightRed:
    ans += (leftWhite - rightRed)

print(ans)

Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
int n,A,B,a[300005],t,k;
int main(){
	scanf("%d%d%d",&n,&A,&B);
	if (1ll*A*B<n||A+B>n+1){
		puts("-1"); return 0;
	}
	if (B==1){
		for (int i=1;i<=n;++i) printf("%d ",i); return 0;
	}
	for (int i=1;i<=(n-A)/(B-1);++i){
		for (int j=k+B;j>k;--j) a[++t]=j;
		k+=B;
	}
	for (int j=k+(n-A)%(B-1)+1;j>k;--j) a[++t]=j;
	k+=(n-A)%(B-1)+1;
	for (++t;t<=n;++t) a[t]=t;
	for (int i=1;i<=n;++i) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 3328
import collections
N = int(input())
num = []
mod = 10**9+7
for i in range(2,N+1):
    for j in range(2,i+1):
        #print(j)
        while i%j==0:
            i //= j
            num.append(j)
#print(num)
A = collections.Counter(num)
#print(A)
ans = 1
for v in A.values():
    ans *= (v+1)%mod
print(ans%mod)

Measured memory_bytes: 39664
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > g(n);
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		g[a].emplace_back(b);
	}
	// find cycle
	std::vector<int> cycle;
	{
		std::vector<int> went(n,-1);
		auto dfs = [&] (auto f, int i) -> int {
			for(auto to:g[i]) {
				// cycle
				if(went[to]==went[i]) {
					cycle.emplace_back(i);
					return to;
				}
				if(went[to]!=-1) continue;
				went[to]=went[i];
				int x = f(f,to);
				if(x==-2) return -2;
				if(x!=-1) {
					cycle.emplace_back(i);
					if(x==i) return -2;
					return x;
				}
			}
			went[i]=-2;
			return -1;
		};
		rep(i,n) {
			went[i]=i;
			if(dfs(dfs,i)==-2) break;
		}
	}
	if(cycle.size()==0) {
		print(-1);
		return 0;
	}
	while(true) {
		debug(cycle);
		std::set<int> cs(all(cycle));
		std::set<std::pair<int,int> > set;
		rep(i,n) if(cs.count(i)) for(auto to:g[i]) if(cs.count(to)) set.emplace(i,to);
		debug(set.size());
		int o=set.size();
		rep(i,cycle.size()) set.erase(std::make_pair(cycle[(i+1)%cycle.size()],cycle[i]));
		assert(o-cycle.size()==set.size());
		debug(set.size());
		if(set.empty()) break;
		auto e=set.begin();
		int s=e->first,t=e->second;
		std::vector<int> went(n,1);
		for(auto x:cycle) went[x]=-1;
		cycle.clear();
		auto dfs = [&] (auto f, int i) -> int {
			if(i==s) {
				cycle.emplace_back(i);
				return 0;
			}
			for(auto to:g[i]) {
				if(went[to]!=-1) continue;
				went[to]=went[i];
				int x = f(f,to);
				if(x!=-1) {
					cycle.emplace_back(i);
					return x;
				}
			}
			return -1;
		};
		went[t]=0;
		dfs(dfs,t);
	}
	if(cycle.size()==0) {
		print(-1);
		return 0;
	}
	print(cycle.size());
	for(auto x:cycle) print(x+1);

	return 0;
}


Measured memory_bytes: 512
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

// 参考: https://atcoder.jp/contests/abc124/submissions/4962823

fn main() {
    let (N, K) = read!(usize, usize);
    let S = rl().chars().collect::<Vec<_>>();

    let mut nums = vec![];
    let mut now = '1';
    let mut cnt = 0;
    for i in 0..N {
        if S[i] == now {
            cnt += 1;
        } else {
            nums.push(cnt);
            now = if now == '0' { '1' } else { '0' };
            cnt = 1;
        }
    }
    if cnt != 0 {
        nums.push(cnt);
    }
    if nums.len() % 2 == 0 {
        nums.push(0);
    }

    let add = 2 * K + 1;
    let mut answer = 0;

    let mut i = 0;
    while i < nums.len() {
        let mut sum = 0;
        let r = min(i + add, nums.len());
        for j in i..r {
            sum += nums[j];
        }
        answer = max(answer, sum);
        i += 2;
    }

    println!("{}", answer)
}


Measured memory_bytes: 4352
//112
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include <vector>
using namespace std;

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

    vector<int> vc(N);
    vector<int> vt(N);

    int minT = 1010;
    bool flag = false;
    for(int i = 0; i < N; i++)
    {
        /* code */
        cin >> vc[i];
        cin >> vt[i];
        if(T >= vt[i]){
            if(minT > vc[i]){
                flag = true;
                minT = vc[i];
            }
        }
    }
    if(flag){
        cout << minT << endl;
    }else{
        cout << "TLE" << endl;
    }

}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  lint n, m;

  cin >> n >> m;
  lint res;
  if(n * 2 <= m){
    res = n;
    m -= n * 2;
    res += m / 4;
  }
  else res = m / 2;
  cout << res << endl;
}

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

int main() {
    int n;
    cin>>n;
    vector<char> s(n);
    vector<char> t(n);
    rep(i,n){
        cin>>s[i];
    }
    rep(i,n){
        cin>>t[i];
    }
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll ans[202]={0};
    ans[1]=1;
    for(int i=2;i<=200;i++)
    { 
        ans[i]=ans[i-1];
        for(int j=1;j<=i;j++)
        {
            for(int k=j;k<=i;k++)
            {
                int y=__gcd(j,k);
                y=__gcd(i,y);
                if(i==j&&i==k)
                {
                    ans[i]+=y;
                }
                else if(i==k||j==k)
                {
                    ans[i]+=3*y;
                }
                else
                {
                    ans[i]+=6*y;
                }
            }
        }
    }
    int k;
    cin>>k;
    cout<<ans[k];
    return 0;
}
//make all values ll


Measured memory_bytes: 3616
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

void io(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (sz(s)) {
    	setIn(s+".in");
    	setOut(s+".out");
    }
}

template<class T> using pqg = priority_queue<T,vector<T>,greater<T>> ;

ll N, negshift, posshift;
multiset<ll> neg, pos;
pl fst, lst = {-1,-1};

void ad(int ind, int l, int r) {
    if (lst.f == -1) {
        fst = {l,0};  
    } else {
        // cout << "HA " << *neg.begin()+negshift << "\n";
        fst.f -= r-l;
        negshift -= r-l;
        posshift += lst.s-lst.f;
        if (l < *neg.begin()+negshift) {
            fst.s += (ll)ind*(*neg.begin()+negshift-l);
            // cout << "OOPS " << fst.f << " " << fst.s << "\n";
            fst.f = l;
        }
        fst.s += l-fst.f;
    }
    if (sz(neg) == 0 || *neg.rbegin()+negshift > l) {
        neg.insert(l-negshift); neg.insert(l-negshift);
        auto a = *neg.rbegin(); neg.erase(prev(neg.end())); pos.insert(a+negshift-posshift);
    } else {
        pos.insert(l-posshift), pos.insert(l-posshift);
        auto a = *pos.begin(); pos.erase(pos.begin()); neg.insert(a+posshift-negshift);
    }
    // cout << fst.f << " " << fst.s << "\n";
    assert(sz(neg) == sz(pos));
    lst = {l,r};
}

int main() {
    io();
    cin >> N;
    F0R(i,N) {
        int l,r; cin >> l >> r;
        ad(i,l,r);
    }
    vl v;
    for (auto a: neg) v.pb(a+negshift);
    for (auto a: pos) v.pb(a+posshift);
    /*cout << fst.f << " " << fst.s << "\n";
    for (auto a: v) cout << a << " ";
    cout << "\n";*/
    
    ll ans = fst.s;
    FOR(i,1,sz(v)) {
        fst.s -= (N-i)*(v[i]-v[i-1]);
        ans = min(ans,fst.s);
    }
    cout << ans;
}

/* 
* (Actually read this pls)
    * Rlly bad errors: int overflow, array bounds
    * Less bad errors: special cases (n=1?), set tle
    * Common sense: do smth instead of nothing
*/

Measured memory_bytes: 11764