akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	while(n--){
		int r, t; cin >> r >> t;
		auto solve = [](int r, int t){
			vi res = {t / 30 * 5 + r / 100};
			if(t % 30 == 0){
				if(r % 100 == 0);
				else res.pb(res[0] + 1);
			}
			else{
				if(r % 100 == 0) res.pb(res[0] + 5);
				else res.pb(res[0] + 1), res.pb(res[0] + 5), res.pb(res[0] + 6);
			}
			return res;
		};
		vi ans = solve(r, t);
		sort(all(ans));
		rep(i, ans.size()) cout << ans[i] << (i==ans.size()-1?"\n":" ");
	}
	return 0;
}


Measured memory_bytes: 3152
import math

K, A, B = map(int, input().split())
A2B = B - A

# 最初は1枚
ans = 1

# 1枚からはじめって1円に考案できるかどうか
if K >= A - 1:
    K -= (A - 1)  # A枚になるように叩く
    ans += (A - 1) # A枚持っている
else:
    ans += K # 1円にならないので全部叩く
    K = 0 # 残りは0

# 交換する価値がある (増える)
if A2B > 2:
    times = K // 2  # 残り回数のうち，A->円，円->Bの回数だけ交換できる
    ans += A2B * times  # 交換で増える分
    ans += K % 2  # 残りの枚数
else: # 増えない場合，残っている回数は叩いて増やせばいい
    ans += K

print(ans)

Measured memory_bytes: 38384
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	// remove odd strings
	answer := make([]string, len(s)/2+1)
	for i := 0; i < len(s); i = i + 2 {
		answer = append(answer, string(s[i]))
	}
	fmt.Println(strings.Join(answer, ""))
}


Measured memory_bytes: 6272
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int r;
    cin >> r;
    output(r * r);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using ll = long long;
using ld = long double;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

int mod = 1e9 + 7;

int binpow(int a, int b) {
    if (b == 1) {
        return a % mod;
    }
    if (b & 1)
        return binpow(a, b - 1) * a % mod;
    int x = binpow(a, b / 2) % mod;
    return x * x % mod;
}
int fact[1300200];

int C(int n, int k) {
    return fact[n] % mod * binpow(fact[k], mod - 2) % mod * binpow(fact[n - k], mod - 2) % mod;
}



signed main() {
    accell();
    int x, y;
    cin >> x >> y;
    int ab = x + y;
    if (ab % 3 != 0) {
        cout << 0;
        return 0;
    }
    ab /= 3;
    int cur = x - ab;
    if (x < ab || y < ab) {
        cout << 0;
        return 0;
    }
    fact[0] = 1;
    for(int i = 1; i <= 1200000; ++i)
        fact[i] = fact[i - 1] * i % mod;
    cout << C(ab, cur) % mod << '\n';
    return 0;
}


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

int main()
{
  string S;
  long long K;
  cin >> S >> K;
  if(K <= 100)
  {
    int vcount = 0;
    for(int i=0;i<K;i++)
    {
      if('1' != S[i]) break;
      vcount++;
    }
    if(vcount == K)
    {
      cout << "1" << endl;
      return 0;
    }
  }
  for(int i=0;i<S.size();i++)
  {
    if(S[i] != '1')
    {
      cout << S[i] << endl;
      break;
    }
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int A[2][n];
  for ( int i = 0; i < 2; i++){
    for ( int j = 0; j < n; j++){
      cin >> A[i][j];
    }
  }

  int a[n], b[n];
  a[0] = A[0][0];
  b[n-1] = A[1][n-1];
  for ( int i = 1; i < n; i++){
    a[i] = a[i-1] + A[0][i];
  }
  for ( int i = n-2; i >= 0; i--){
    b[i] = b[i+1] + A[1][i];
  }

  int ans = 0;
  for ( int i = 0; i < n; i++){
    ans = max(ans, a[i] + b[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Pattern;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Boolean b = false;
    int n = Integer.parseInt(sc.next());
    String pattern = "^\\d{1}$";
    Pattern p = Pattern.compile(pattern);
    for(int i = 1; i < 10; i++) {
	  if(n % i == 0) {
        if(p.matcher(String.valueOf(n/i)).find()){
    		System.out.println("Yes");
            b = true;
		}
        if(b)
        break;
      }
    }
    if(!b){
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

char S[SIZE];
ll dp[SIZE][4];

int main(){

	scanf("%s",S);

	int len;
	for(len = 0; S[len] != '\0'; len++);

	for(int i = 0; i <= len; i++){
		for(int k = 0; k < 4; k++){

			dp[i][k] = 0;
		}
	}

	dp[0][0] = 1;

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

		//状態を進めない
		for(int k = 0; k < 4; k++){
			if(S[i] != '?'){

				dp[i+1][k] += dp[i][k];

			}else{

				dp[i+1][k] += 3*dp[i][k];
			}
			dp[i+1][k] %= MOD;
		}

		//状態を進める
		if(S[i] == 'A' || S[i] == '?'){

			dp[i+1][1] += dp[i][0];
			dp[i+1][1] %= MOD;
		}
		if(S[i] == 'B' || S[i] == '?'){

			dp[i+1][2] += dp[i][1];
			dp[i+1][2] %= MOD;
		}
		if(S[i] == 'C' || S[i] == '?'){

			dp[i+1][3] += dp[i][2];
			dp[i+1][3] %= MOD;
		}
	}

	printf("%lld\n",dp[len][3]);

	return 0;
}


Measured memory_bytes: 7048
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let a = parse_line::<usize>();
    let s = parse_line::<String>();
  
    if a < 3200 {
        println("red");
    } else {
        println(s);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<math.h>

using namespace std;
int main() {

	int X,A,B;
	char str[3][3];
	
	
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> str[i][j];
			
		}
	}

	cout << str[0][0] << str[1][1] << str[2][2] << endl;
	
	

	//cin >> X >> A >> B;

	
	
	
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int num_ball=scan.nextInt();
        int color=scan.nextInt();
        int answer=color;
        int i;
        for(i=1;i<num_ball;i++){
            answer*=(color-1);
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
/* attention to typo and overflow */
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;
const int INF=1<<25;
//void io(){ cin.tie(0);ios::sync_with_stdio(false);} //attention to use of endl
/*printf("%.9Lf\n",cf);*/
char output(bool i,bool j){
	if(i==1 && j==0){
		return 'M';
	}
	if(i==0 && j==1){
		return 'L';
	}
	if(i==0 && j==0){
		return 'I';
	}
	if(i==1 && j==1){
		return 'U';
	}
	return 'N';
}

int main(){
	//io();
	string s;
	getline(cin,s);
	//cin.ignore();
	int ans;
	cin>>ans;

	vector <int> plus;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(i!=0 && s[i-1]=='*'){
				plus[plus.size()-1]*=s[i]-'0';
			}else{
				plus.push_back(s[i]-'0');
			}
		}
	}

	int one=0;
	for(int i=0;i<plus.size();i++){
		//cerr<<plus[i]<<endl;
		one+=plus[i];
	}

	int two=s[0]-'0';
	for(int i=1;i<s.size();i++){
		if(i%2==0){
			if(s[i-1]=='+'){
				two+=s[i]-'0';
			}else{
				two*=s[i]-'0';
			}
		}
	}

	//cerr<<ans<<' '<<one<<' '<<two<<endl;

	cout<<output(ans==one,ans==two)<<endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    ll ans = 0;
    if(a==0) ans = 1;
    if(b==0) ans = 2;
    if(c==0) ans = 3;
    if(d==0) ans = 4;
    if(e==0) ans = 5;
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;



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

  int F[n][10];
  rep(i,n)rep(j,10)cin>>F[i][j];

  int P[n][10];
  rep(i,n)rep(j,11)cin>>P[i][j];

  int ans=-INF;

  for(int i=1;i<(1<<10);i++){
    int  tmp=0;
    rep(j,n){
      int cnt=0;
      rep(k,10){
        if((i>>k&1)&&F[j][k])cnt++;
      }
      tmp+=P[j][cnt];
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;

  return 0;
}


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

int main() {
  int H, W, i, j, k;
  cin >> H >> W;
  vector<char> frame(H*(W+3));
  k = 0;
  
  for(i=0; i<H; i++){
    vector<char> px(W);
    for(j=0; j<W; j++){
      cin >> px.at(j);
    }
    px.push_back('#');
    frame.at(k) = '#';
    k++;
    for(j=0; j<px.size(); j++){
      frame.at(k) = px.at(j);
      k++;
    }
    frame.at(k) = '\n';
    k++;
  }
  
  for(i=0; i<2; i++){
    for(j=0; j<W+2; j++){
      cout << "#";
    }
    cout << endl;
    if(i==1) break;
    for(j=0; j<frame.size(); j++){
      cout << frame.at(j);
    }
  }
}

Measured memory_bytes: 256
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}

int32_t  main(){
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++)
        cout<<"x";
    cout<<endl;
}

Measured memory_bytes: 3588
import bisect
n = int(input())
s = input()
elist = []
wlist = []
for i in range(n):
	if s[i] == "E":
		elist.append(i)
	elif s[i] == "W":
		wlist.append(i)
ans = 10**18
lenelist = len(elist)
"""
西にいるWを数える
東にいるEを数える
"""
for i in range(n):
	tmp = lenelist-bisect.bisect_right(elist, i)+bisect.bisect_left(wlist, i)
	ans = min(tmp, ans)
print(ans)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

bool match(char c, char d){
    if(c=='?' || d=='?') return true;
    else if(c == d) return true;
    else return false;
}
bool check(string s, string t){
    REP(i,s.size()){
        if(match(s[i],t[i]) == false) return false;
    }
    return true;
}

int main(void){
    string S_, T; cin >> S_ >> T;

    string ans = "UNRESTORABLE";
    REP(i,S_.size()-T.size()+1){
        if(check(S_.substr(S_.size()-T.size()-i, T.size()), T)){
            REP(j,T.size()){
                S_[S_.size()-T.size()-i+j] = T[j];
            }
            REP(j,S_.size()){
                if(S_[j] == '?') S_[j] = 'a';
            }
            ans = S_;
            break;
        }
    }
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 256
import bisect

S = input()
N = len(S)

# 反対方向を示すマスにたどり着くまで子供は同じ方向に進み続ける
turn_spot_R, turn_spot_L = [], []
for i in range(1, N):
    if S[i-1] == "R" and S[i] == "L":
        turn_spot_R.append(i-1)
        turn_spot_L.append(i)

ans = [0]*N
for i in range(N):
    if S[i] == "R":
        turning_idx = turn_spot_L[bisect.bisect_left(turn_spot_L, i)]
        if abs(turning_idx - i) % 2 == 0:
            ans[turning_idx] += 1
        else:
            ans[turning_idx-1] += 1
    else:
        turning_idx = turn_spot_R[bisect.bisect_left(turn_spot_R, i)-1]
        if abs(turning_idx - i) % 2 == 0:
            ans[turning_idx] += 1
        else:
            ans[turning_idx+1] += 1
            
print(*ans)

Measured memory_bytes: 10288
n = int(input())
v = list(map(int, input().split(' ')))
v = sorted(v)

s = 0
for i in range (0,n-2):
  i = 0
  v = sorted(v)
  s = (v[i]+v[i+1])/2
  v.append(s)
  del v[0:2]

ans = (v[0] + v[1]) / 2
print(ans)


Measured memory_bytes: 3064
#import time
#start = time.time()

n = int(input())
ls = [1]
t = 6
while t < 100000:
    ls.append(t)
    t *= 6
t = 9
while t < 100000:
    ls.append(t)
    t *= 9

ls.sort()
#print(ls)
"""
cnt = 0
while n >= 6:
    print(n,ls)
    ls = [i for i in ls if i <= n]
    n -= ls[len(ls)-1]
    cnt += 1
print(cnt+n)
"""
#dp[n] n円を引き出すために必要な回数
dp = [10**9 for i in range(n+1)]
dp[0] = 0

for i in range(1,n+1):
    ls1 = [j for j in ls if j <= i]
    #print(ls1)
    for j in range(len(ls1)):
        #print(i,i-ls1[j])
        dp[i] = min(dp[i],dp[i - ls1[j]] + 1)

print(dp[n])

#process_time = time.time() - start

#print(process_time)


Measured memory_bytes: 44784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,pair<int,char>>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";

int dfs(vector<int>adj[], int parent, vector<int>&visit, vector<int>&dp){
	visit[parent]=1;
	for(auto child : adj[parent]){
		if(!visit[child]){
			dp[parent] = max(dp[parent],1 + dfs(adj,child,visit,dp));
		}
		else{
			dp[parent] = max(dp[parent], 1 + dp[child]);
		}
	}
	return dp[parent];
}
void solve(){
    int n,m;
    cin>>n>>m;
    std::vector<int>adj[n];
    for(int i=0;i<m;i++){
    	int x,y;
    	cin>>x>>y;
    	x--; y--;
    	adj[x].pb(y);
    }
    vector<int>dp(n,0),visit(n,0);
    int ans = 0;
    for(int i=0;i<n;i++)
    if(!visit[i])
    ans = max(ans,dfs(adj,i,visit,dp));
	cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }

return 0;
}

Measured memory_bytes: 12964
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  string s; cin >> s;
  rep(i, 2) rep(j, 2) {
    vi32 brd(N);
    // 0 : S, 1 : W
    brd[0] = i, brd[1] = j;
    reps(k, N - 2) {
      if (brd[k] == 0) {
        if (s[k] == 'o') brd[k + 1] = brd[k - 1];
        if (s[k] == 'x') brd[k + 1] = 1 - brd[k - 1];
      } else {
        if (s[k] == 'o') brd[k + 1] = 1 - brd[k - 1];
        if (s[k] == 'x') brd[k + 1] = brd[k - 1];
      }
    }
    if (brd[N - 1] == 0) {
      if ((s[N - 1] == 'o') ^ (brd[0] == brd[N - 2])) continue;
    } else {
      if ((s[N - 1] == 'x') ^ (brd[0] == brd[N - 2])) continue;
    }
    if (brd[0] == 0) {
      if ((s[0] == 'o') ^ (brd[1] == brd[N - 1])) continue;
    } else {
      if ((s[0] == 'x') ^ (brd[1] == brd[N - 1])) continue;
    }
    rep(i, N) if (brd[i] == 0) cout << 'S'; else cout << 'W';
    cout << '\n';
    return;
  }
  cout << -1 << '\n';
}


Measured memory_bytes: 924
//#pragma GCC optimize(\"Ofast,no-stack-protector\")
//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")
//#pragma GCC target(\"avx,tune=native\")
// Neil

#include<bits/stdc++.h>

using namespace std;

typedef complex<double> base;
typedef long double ld;
typedef long long ll;

#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair< ll , ll >
#define vi vector<int>
#define vvi vector< vi >
const int MAXN=(int)(2e5+5);
const ll MOD=(ll)(1e9+7);
int t;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    string str;
    cin>>str;
    //reverse(str.begin(), str.end());
    int n = str.size();
    ll ans = 0;
    for(int i = 0;i<1<<(n-1);i++){
        ll tmp = 0;
        ll s = 0;
        //cout<<i<<endl;
        for(int j=0;j<n;j++){
            if((i & (1<<j))!=0){
                tmp+=s*10+(str[j] - '0');
                //cout<<s<<endl;
                s =0 ;
            }
            else{
               s = s*10 + (str[j] - '0');
            }
        }
        //cout<<s<<endl;
        tmp+=s;
        ans += tmp;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,a[200100],sa;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],sa^=a[i];
	for(int i=1;i<=n;i++) cout<<(sa^a[i])<<' ';
	cout<<endl;
	return 0;
}


Measured memory_bytes: 4368
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;
int f(int x) {
	int cnt = 0;
	lp(5) {
		cnt += x % 10;
		x = x / 10;
	}
	return cnt;
}
int main() {
	int n, a, b, cnt = 0;
	cin >> n >> a >> b;
	lp(n + 1) {
		if (a <= f(i) && f(i) <= b)
			cnt += i;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
A = list(map(int, input().split()))
K = 0
K = K+A[1]
if A[0]%2==0 and A[3]%2==0 and A[4]%2==0:
	K = K+A[0]+A[3]+A[4]
elif A[0]%2!=0 and A[3]%2!=0 and A[4]%2!=0:
	K = K+A[0]+A[3]+A[4]
elif A[0]+A[3]+A[4]<=2:
	pass
else:
	K = K+A[0]+A[3]+A[4]-1
print(K)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<list>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    while(1){
cin>> n;
if(n==0)break;
vector<int> a(n);
for(int i=0;i<n;i++)
cin>>a[i];
sort(a.begin(),a.end());
int min=a[1]-a[0];
for(int i=1;i<n;i++){
if(a[i]-a[i-1]<min)
min=a[i]-a[i-1];
}
cout<<min<<endl;
    }
    return 0;
}

Measured memory_bytes: 3140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static double max = 0.0;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();

			double[] array = new double[N];
			for (int i = 0; i < N; i++) {
				array[i] = scanner.nextDouble();
			}
			Arrays.sort(array);

			double result = array[0];
			for (int i = 0; i < N; i++) {
				result = (result + array[i]) / 2;
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 24148
using System;
using System.Collections.Generic; 

class Untitled
{
  static void Main(string[] args)
  {
	// ???????????´??°?????????????????????????????????????°??????????????????????????????????????????°?????????????????????????????????
    bool parsed = false;
    List <int> list = new List <int> ();
	string[] strs = null;
    string s = Console.ReadLine();
    if (!String.IsNullOrEmpty (s)) {
		strs = s.Split (' ');
		if (strs.Length == 3) {
		  	int val;
		  	int i = 0;
		  	parsed = Int32.TryParse (strs[i], out val);
			while (parsed) {
				list.Add (val);
				i++;
				if (i >= strs.Length)
				  break;
				parsed = Int32.TryParse (strs[i], out val);
			}
		}
    }
	list.Sort ();
	string strOutput = "";
	for (int i = 0; i < list.Count; i++) {
		if (i == list.Count - 1) {
			strOutput += list [i]; 
		} else {
			strOutput += list [i] + " ";
		}
	}
	System.Console.WriteLine (strOutput);
  }
}

Measured memory_bytes: 9148
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define N  100005
ll n,k;
ll a[N],dp[N];
int main()
{
	ios
	cin>>n>>k;
	ll i,j;
	for(i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	for(i=1;i<=k;i++){
		for(j=0;j<n;j++){
			if(a[j]<=i)
				dp[i]|=(!dp[i-a[j]]);
		}
	}
	if(dp[k]==1)cout<<"First";else cout<<"Second";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
map<ll, ll> prime_factor(ll m){
    map<ll, ll> res;
    for(int i = 2; i * i <= m; i++){
        while(m % i == 0){
            res[i]++;
            m /= i;
        }
    }
    if(m != 1) res[m] = 1;
    return res;
}

int main(){
    using mint = ModInt<1000000007>;

    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> max_num(1000010, 0);
    rep(i, n){
        cin >> a[i];
        auto P = prime_factor(a[i]);
        for(auto p : P){
            max_num[p.first] = max(max_num[p.first], p.second);
        }
    }
    mint lcm = 1;
    for(int i = 2; i < 1000010; i++){
        lcm *= pow(i, max_num[i]); 
    }
    mint ans = 0;
    rep(i, n) ans += lcm / a[i];
    cout << ans << endl;
}

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

const int INF = 0x7fffffff;

const int MAX_N = 200000;

int main(){
    int N;
    int r[MAX_N];
    int dp[MAX_N];
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", r + i);
    }
    fill(dp, dp + N, INF);
    int ans = -INF;
    dp[0] = r[0];
    for(int i = 1; i < N; i++){
        ans = max(ans, r[i] - dp[i-1]);
        dp[i] = min(r[i], dp[i-1]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2752
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String).chars().collect::<Vec<_>>();

    // 末尾文字から順に13で割った余りについてDPで解を求める
    let M = 13;
    let MOD = 1000000007;
    let (dp, _) = S.iter()
        .rev()
        .map(|c| c.to_digit(10))
        .fold(
            (
                (0..M).map(
                    |i| match i {
                        0 => 1,
                        _ => 0
                    }
                ).collect::<Vec<_>>(),
                1
            ),
            |(dp, acc), c| {
                (
                    match c {
                        None => (0..M)
                            .map(
                                |i|
                                (0..10).map(|j| dp[(M * M + i - j * acc) % M])
                                    .sum::<usize>() % MOD
                            )
                            .collect::<Vec<_>>(),
                        Some(k) => (0..M)
                            .map(|i| dp[(M * M + i - (k as usize) * acc) % M])
                            .collect::<Vec<_>>()
                    },
                    (10 * acc) % M
                )
            }
        );
    let ans = dp[5];

    println!("{}", ans);
}


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

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


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

#define int ll
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5, M = 1e2 + 2;

int A[N], DP[N][M];
bool P[N];

int Sign(int i) { return i & 1 ? -1 : 1; }

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) DP[i][j] = -INF;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		if (i) {
			char c; cin >> c;
			P[i] = (c == '+');
		}
		cin >> A[i];
	}
	DP[0][0] = A[0];
	for (int i = 1; i < n; i++) for (int j = M - 1; j >= 0; j--) {
		if (P[i]) DP[i][j] = DP[i - 1][j] + A[i] * Sign(j);
		else if (j) DP[i][j] = DP[i - 1][j - 1] + A[i] * Sign(j);
		if (j + 1 < M) DP[i][j] = max(DP[i][j], DP[i][j + 1]);
	}
	cout << DP[n - 1][0] << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  
  for(int i = 0; i < N; i++) {
    cin >> num.at(i);
  }
  sort(num.begin(), num.end());
  cout << num.at(num.size() - 1) - num.at(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m, d;
    cin >> m >> d;
    int count = 0;
    Rep(i, 1, d + 1) {
        int d_1 = i % 10;
        int d_2 = (i - d_1) / 10; //10けたの数
        if(d_1 >= 2 && d_2 >= 2){
            if(d_1 * d_2 <= m) count ++;
        }
    }
    cout << count << endl;


}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

using namespace std;

char G[50][50];
int dst[50][50];

int main() {
    int H, W;
    cin >> H >> W;
    int num_white = 0;
    rep(i, H) {
        rep(j, W) {
            cin >> G[i][j];
            dst[i][j] = -1;
            if(G[i][j] == '.')
                num_white++;
        }
    }
    if(G[0][0] == '.')
        num_white--;

    vector<pair<int, int>> move = {{1, 0}, {0, 1} ,{-1, 0}, {0, -1}};

    queue<pair<int, int>> q;
    q.push({0, 0});
    dst[0][0] = 0;
    while(!q.empty()) {
        auto i = q.front().first;
        auto j = q.front().second;
        q.pop();
        for(auto m: move) {
            auto next_i = i + m.first;
            auto next_j = j + m.second;
            if(next_i < 0 || next_i >= H || next_j < 0 || next_j >= W) {
                continue;
            }
            if(G[next_i][next_j] != '.') {
                continue;
            }
            if(dst[next_i][next_j] >= 0)
                continue;
            dst[next_i][next_j] = dst[i][j]+1;
            if(next_i == H-1 && next_j == W-1)
                break;
            q.push({next_i, next_j});
        }
    }
#if 0
    rep(i, H) {
        rep(j, W) {
            printf("%02d ", dst[i][j]);
        }
        printf("\n");
    }
#endif

    if(dst[H-1][W-1] >= 0) {
//        cout << dst[H-1][W-1] << " " << num_white << " " << num_white - dst[H-1][W-1] << endl;
        cout << num_white - dst[H-1][W-1] << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int ans = 0;
        for (int i = 1; i <= n - 2; i++) {
            for (int j = i + 1; j <= n - 1; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) ans ++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;

}



Measured memory_bytes: 3124
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define INF 1LL<<61
int main(){
    int n;
    int a[100100] = {};
    cin >> n;
    REP(i,1,n+1){
        int t;
        cin >> t;
        a[t] = i;
    }
    REP(i,1,n){
        cout << a[i] << " ";
    }
    cout << a[n] << endl;

   
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long K, string S) {
  vector<pair<char, int>> tmp = {make_pair('1', 0)};
  for (int i = 0; i < N; i++) {
    auto elem = S[i];
    if (tmp.empty() || tmp.back().first != elem)
      tmp.emplace_back(make_pair(elem, i));
  }
  for (int i = 0; i < 2 * K + 5; i++) tmp.push_back(make_pair('1', N));
  int maxim = 0;
  for (int i = 0; i < tmp.size() - 2 * K - 1; i++) {
    if (tmp[i].first == '0') continue;
    chmax(maxim, tmp[i + 2 * K + 1].second - tmp[i].second);
  }
  cout << maxim << endl;
}

int main() {
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);

  string S;
  cin >> S;
  solve(N, K, S);
  return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
	string s;cin>>s;
	int ans=0;
	for(int i=0;i<s.length();i++) {
		if(i%2&&s[i]=='g') ans++;
		if(i%2==0&&s[i]=='p') ans--;	
	}    
	cout<<ans<<endl;
    return 0;
}

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


using namespace std;
typedef long long ll;

int main(){
    int a,b,k;

    cin >> k >> a >> b;

    string res = "NG";

    for(int i=a;i<=b;i++){
        if(i % k == 0) res = "OK";
    }

    cout << res << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int MN = 105;
const int INF = 1e9;
int N,M,A[MN],B[MN],dist[MN],D[MN][MN],L[MN][MN];
bool used[MN],ch[MN][MN];
vector<int> G[MN],V[MN];

bool cmp(int A, int B)
{
    return (A-1)/M<(B-1)/M;
}

void bfs(){
    queue<int> Q;
    for(int i=0; i<N; i++){
        if(!used[i]){
            dist[i] = 0;
            Q.push(i);
        }
        else dist[i] = INF;
    }
    while(!Q.empty()){
        int a = Q.front();
        Q.pop();
        for(int b: G[a]){
            if(B[b] != -1 && dist[B[b]] == INF){
                dist[B[b]] = dist[a] + 1;
                Q.push(B[b]);
            }
        }
    }
}

bool dfs(int a){
    for(int b: G[a]){
        if(B[b]==-1||dist[B[b]]==dist[a]+1&&dfs(B[b])){
            used[a] = 1;
            A[a] = b;
            B[b] = a;
            return 1;
        }
    }
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> N >> M;
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cin >> D[i][j];
        }
    }
    for(int t=0; t<M; t++){
        for(int i=0; i<N; i++){
            G[i].clear();
            for(int j=0; j<M; j++){
                if(ch[i][j]) continue;
                G[i].push_back((D[i][j]-1)/M);
            }
        }
        int match = 0;
        fill(A,A+MN,-1);
        fill(B,B+MN,-1);
        while(1){
            bfs();
            int flow = 0;
            for(int i=0; i<N; i++)
                if(!used[i] && dfs(i)) flow++;
            if(flow == 0) break;
            match += flow;
        }
        fill(used,used+MN,0);
        for(int i=0; i<N; i++){
            for(int j=0; j<M; j++){
                if(ch[i][j]) continue;
                if(A[i]==(D[i][j]-1)/M){
                    ch[i][j] = 1;
                    L[i][t] = D[i][j];
                    break;
                }
            }
        }
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cout << L[i][j] << ' ';
            V[j].push_back(L[i][j]);
        }
        cout << '\n';
    }
    for(int j=0; j<M; j++) sort(V[j].begin(),V[j].end(),cmp);
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cout << V[j][i] << ' ';
        }
        cout << '\n';
    }
}



Measured memory_bytes: 640
S = input()


dict_string = {}
dict_depth = {}

for s in S:
    if s in dict_string:
        dict_string[s] += 1
    else:
        dict_string[s] = 1
        dict_depth[s] = 0


dict_string_calc = dict_string.copy()


while len(dict_string_calc) != 1:
    x = None
    y = None

    for k, v in sorted(dict_string_calc.items(), key=lambda x: x[1]):
        if x == None:
            x = k
            x_cnt = v
            continue

        if y == None:
            y = k
            y_cnt = v
            break

    for s in (x + y):
        if s in dict_depth:
            dict_depth[s] += 1
        else:
            raise

    del dict_string_calc[x]
    del dict_string_calc[y]

    dict_string_calc[x + y] = x_cnt + y_cnt


ans = 0

for k, v in dict_depth.items():
    ans += dict_string[k] * v


if len(dict_string) == 1:
    ans = len(S)

print(ans)


Measured memory_bytes: 5744
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
ll r=1;
a=a%m;
while(b>0)
{
if(b&1)
r=(r*a)%m;
b=b/2;
a=(a*a)%m;
}
return r%m;
}

vi bit;//1-based indexing

void bit_update(ll x,ll n,ll val)
{
    while(x<n)
    {
        bit[x]+=val;
        x+=(x&(~x+1));
    }
}

ll bit_sum(ll x)
{
    ll sum=0;
    while(x>0)
    {
        sum+=bit[x];
        x-=(x&(~x+1));
    }
    return sum;
}



int main(){
    IOS
    ll n;
    cin>>n;
    cout<<((n*1LL*(n-1))/2);



    return 0;
}


Measured memory_bytes: 256
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//math
template <class T>
inline T sqr(T x) { return x * x; }

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

//repetition
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    int R;
    cin >> R;
    cout << 2 * R * PI << endl;
}

Measured memory_bytes: 3224