akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  
//
//  Created by yataka on 2018/10/11.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define MAX_N 100
int main(){
    int N, L;
    cin >> N >> L;
    string S[MAX_N];
    for( int i = 0; i < N; i++){
        cin >> S[i];
    }
    string ans = "";
    sort( S, S + N);
    for(int i = 0; i < N; i++){
        ans = ans + S[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
 
        long X = sc.nextLong();
        long a = 100;

        for(int i=1; i<=10000; i++){
            a = (long)(a * 1.01);
            if(a>=X){
                System.out.println(i);
                return;
            }
        }
    }
}

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

int main() {
long long int N,M,L=3000;
  cin >>N>>M;
  for(long long int i=N;i<M;i++){
     if(L==0)break;
    for(long long int j=N+1;j<M+1;j++){
      L=min(L,(i*j)%2019);
      if(L==0)break;
    }
  }
  cout <<L;
}

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

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

Measured memory_bytes: 256
// Making chalk mark on generator: $1
// Knowing where to make mark: $9,999
#include <bits/stdc++.h>
#define when(...) fprintf(stderr,__VA_ARGS__)
typedef long long ll;
ll read() {
	static char c;
	static ll x;
	int flag = 1;
	while (c = getchar(), !isdigit(c))
		if (c == '-') flag = 0;
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = x * 10 + c - '0';
	return flag ? x : -x;
}

int n, m;
struct line {
	ll l, r, a;
	bool operator<(const line &rhs) const {return r < rhs.r;}
} ns[200200];

struct segmenttree {
#define lc x<<1
#define rc x<<1|1
#define mid ((l+r)>>1)
	ll ns[800800], tag[800800];
	inline void pushdown(int x, int l, int r) {
		if (!tag[x]) return ;
		if (l != r) {
			tag[lc] += tag[x];
			tag[rc] += tag[x];
		}
		ns[x] += tag[x];
		tag[x] = 0;
	}
	ll query(int ql, int qr, int x = 1, int l = 0, int r = n) {
		pushdown(x, l, r);
		if (l >= ql && r <= qr) return ns[x];
		ll ans = -1e18;
		if (ql <= mid) ans = std::max(ans, query(ql, qr, lc, l, mid));
		if (qr > mid) ans = std::max(ans, query(ql, qr, rc, mid + 1, r));
		return ans;
	}
	void update(int ql, int qr, ll delta, int x = 1, int l = 0, int r = n) {
		pushdown(x, l, r);
		if (l >= ql && r <= qr) return tag[x] += delta, void();
		if (ql <= mid) update(ql, qr, delta, lc, l, mid);
		if (qr > mid) update(ql, qr, delta, rc, mid + 1, r);
		pushdown(lc, l, mid);
		pushdown(rc, mid + 1, r);
		ns[x] = std::max(ns[lc], ns[rc]);
	}
} seg;

signed main() {
	n = read(), m = read();
	for (int i = 1; i <= m; ++i) ns[i].l = read(), ns[i].r = read(), ns[i].a = read();
	std::sort(ns + 1, ns + 1 + m);

	for (int i = 1, cur = 1; i <= n; ++i) {
		seg.update(i, i, seg.query(0, i));
		for (; ns[cur].r == i; ++cur) seg.update(ns[cur].l, ns[cur].r, ns[cur].a);
	}
	printf("%lld\n", seg.query(0, n));
}

Measured memory_bytes: 17408
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<string> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,x ;
	cin >> n >> x ;
	vector<ll> b(n+1,1) ;
	vector<ll> p(n+1,1) ;
	for(int i=1;i<=n;i++){
		b.at(i) = b.at(i-1)*2+3 ;
		p.at(i) = p.at(i-1)*2+1 ;
	}
	ll ans = 0 ;
	ll level = n ;
	while(1){
		if(level==1){
			if(x<=4) ans += x-1 ;
			else ans += 3 ;
			break ;
		}
		if(x==1) break ;
		if(x==b.at(level)){
			ans += p.at(level) ;
			break ;
		}
		if(x==(b.at(level)+1)/2){
			ans += p.at(level-1)+1 ;
			break ;
		}
		if(x>(b.at(level)+1)/2){
			ans += p.at(level-1)+1 ;
			x -= b.at(level-1)+2 ;
			level-- ;
		}else{
			x -= 1 ;
			level-- ;
		}
	}
	cout << ans << endl ;
}


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

int main()
{
  int n;
  cin >> n;
  int a[n][3];
  for(int i = 0; i < n; i++)
    for(int j = 0; j < 3; j++)
      cin >> a[i][j];
  for(int i = 1; i < n; i++)
    for(int j = 0; j < 3; j++)
    {
      if(j == 0)
        a[i][j] = max(a[i-1][1], a[i-1][2]) + a[i][j];
      else if(j == 1)
        a[i][j] = max(a[i-1][0], a[i-1][2]) + a[i][j];
      else
        a[i][j] = max(a[i-1][1], a[i-1][0]) + a[i][j];
    }
  int mx = a[n-1][0];
  mx = max(mx, max(a[n-1][1], a[n-1][2]));
  cout << mx << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m;
char c[15][15];
bool ok[15][15];
vector<PII> vv;
queue<int> qq;
void col(queue<int> q)
{
	if (q.size()<2)
	{
		cout <<"YES";
		exit(0);
	}
	int t=q.front();
	q.pop();
	for (int i=0;i<q.size();i++)
	{
		int tt=q.front();
		q.pop();
		if (ok[t][tt]) col(q);
		q.push(tt);
	}
	if (q.size()%2==0) col(q);
	q.push(t);
}
void row(vector<PII> v,queue<int> q)
{
	if (q.size()>=1)
	{
		int t=q.front();
	    q.pop();
	    for (int i=0;i<q.size();i++)
	    {
		    int tt=q.front();
		    q.pop();
		    v.push_back(MP(t,tt));
		    //cout <<t<<" "<<tt<<" ##\n";
			row(v,q);
			v.pop_back();
			q.push(tt);
		}
		if (q.size()%2==0)
		{
			v.push_back(MP(t,t));
		    //cout <<t<<" "<<t<<" ##\n";
			row(v,q);
			v.pop_back();
		}
		q.push(t);
	}
	else
	{
		for (int i=0;i<m;i++)
		{
			for (int j=0;j<=i;j++)
			{
				ok[i][j]=ok[j][i]=1;
				for (int k=0;k<v.size();k++)
				{
					int x=v[k].F,y=v[k].S;
					if (c[x][i]!=c[y][j] || c[x][j]!=c[y][i]) ok[i][j]=ok[j][i]=0;
				}
			}
		}
		for (int i=0;i<m;i++) q.push(i);
		col(q);
	}
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		    cin >>c[i][j];
	}
	for (int i=0;i<n;i++) qq.push(i);
	row(vv,qq);
	cout <<"NO";
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int f(int u, vector<vector<int>>& G, vector<int>& memo) {
    if (memo[u] != -1) return memo[u];
    int ma = 0;
    for (int v: G[u]) ma = max(ma, f(v, G, memo) + 1);
    return memo[u] = ma;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, N + M - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[v].pb(u);
    }
    vector<int> memo(N, -1);
    rep(u, N) f(u, G, memo);
    vector<int> par(N, -1);
    rep(u, N) for (int v: G[u]) if (memo[v] == memo[u] - 1) par[u] = v;
    rep(u, N) cout << par[u] + 1 << endl;
}


Measured memory_bytes: 12692
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k, D[10] = {};
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        int x;
        cin >> x;
        D[x] = 1;
    }
    for (int i = n; ; ++i) {
        int ans = 1;
        int x = i;
        while (x) {
            if (D[x % 10]) ans = 0;
            x /= 10;
        }
        if (ans) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  ll K,A,B,bis=0,m=0,n;
  std::cin >> K >> A >> B;

  if(B-A<=2 || K<=A){
    std::cout << K+1 << '\n';
    return 0;
  }

  bis=B+(K-(A+1))/2*(B-A)+(K-(A+1))%2;

  std::cout << bis << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
    ll w;
    cin>>w;
    vector<ll>weight(n);
    vector<ll>values(n);
    for(ll i =0 ; i< n;i++){
        cin>>weight[i]>>values[i];
    }
    vector<vector<ll>>dp(n+1, vector<ll>(w+1, 0));
    for(ll i = 1; i <= n ; i++){
        for(ll j = 1 ; j<=w ;j++){
            if(j>=weight[i-1]){
                dp[i][j] =max(dp[i-1][j] , dp[i-1][j-weight[i-1]]+values[i-1]);
            }
            else{
                dp[i][j]= max(dp[i][j], dp[i-1][j]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 81012
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s; cin>>s;
  vector<string> t;
  t.PB("AKIHABARA");
  t.PB("KIHABARA");
  t.PB("AKIHBRA");
  t.PB("AKIHABRA");
  t.PB("AKIHABAR");
  t.PB("KIHBARA");
  t.PB("KIHABRA");
  t.PB("KIHABAR");
  t.PB("AKIHBRA");
  t.PB("AKIHBAR");
  t.PB("AKIHABR");
  t.PB("KIHBRA");
  t.PB("KIHBAR");
  t.PB("KIHABR");
  t.PB("AKIHBR");
  t.PB("KIHBR");
  REP(i,t.size()){
    if(s==t[i]) return cout<<"YES"<<endl,0;
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn gcd(n: usize, m:usize) -> usize {
    if m == 0 {
        return n;
    }
    return gcd(m, n % m);
}

fn main() {
    input! {
        K: usize,
    }

    let mut ans = 0;
    for a in 1..K+1 {
        for b in 1..K+1 {
            for c in 1..K+1 {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    println!("{}", ans);
}


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


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


int main()
{
  security();
}

Measured memory_bytes: 256
import Data.Bits
f a = if mod a 2 == 1 then if mod (a+1) 4 == 2 then 1 else 0 else if mod (div a 2) 2 == 1 then xor a 1 else a
main=do
 [a,b]<-map read.words<$>getLine ::IO[Int]
 print$xor (f b) (f (a-1))

Measured memory_bytes: 508
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    r = int(readline())
    print(3 * r * r)
    
    return


if __name__ == '__main__':
    main()


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


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

    int x = 1;
    int count = 0;

    for(int j=0; j<N; j++){
        if(a[j] == x){
            x++;
        }
        else{
            count++;
        }
    }

    if(count < N){
        cout << count;
    }
    else{
        cout << -1;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
                            
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

int n,m,cl;
int a[N];

int X;
int b[N];

int res[200][200];

int main(){
		
	NFS
	
	cin >> n >> m;	
	
	cin >> cl;
	
	for(int i=1;i<=cl;i++)cin >> a[i];
	
	for(int i=1;i<=cl;i++){
		for(int j=1;j<=a[i];j++){
			X++;
			b[X]=i;
		}
	}
	
	int cur=0;
	
	for(int i=1;i<=n;i++){
		if(i%2){
			for(int j=1;j<=m;j++){
				cur++;
				res[i][j]=b[cur];
			}
		}
		else{
			for(int j=m;j>=1;j--){
				cur++;
				res[i][j]=b[cur];
			}
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)cout << res[i][j] << ' ';
		cout << endl;
	}

	ioi
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n,lo=100005,hi=0;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		lo=min(lo,v[i]);
		hi=max(hi,v[i]);
	}
	if(hi-lo>1)
	cout<<"No";
	else if(lo==hi){
		if(v[0]==n-1)
		cout<<"Yes";
		else if(2*v[0]<=n)
		cout<<"Yes";
		else
		cout<<"No";
	}
	else{
		ll cnt=0;
		for(ll i=0;i<n;i++)
		if(v[i]==lo)
		cnt++;
		ll tr=(n-cnt)/2;
		if(!tr||hi<=cnt||hi>cnt+tr)
		cout<<"No";
		else
		cout<<"Yes";
	}
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 1024
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//edge cases when n=1 , m=1. wrong variable in loop. if<->while;merge resize;LLONG_MAX
signed main()
{ 
	speed
	//global var
	int x,a;cin>>x>>a;
	if(x<a){
		cout<<0<<"\n";
	}
	else{
		cout<<10<<"\n";
	}
}

Measured memory_bytes: 256
#include <cstdio>

using LL = long long;
const int MAXN = (int)1e5;

LL a[MAXN];

struct LinearBasis {
  static const int MAXL = 64;
  LL a[MAXL];

  LinearBasis() {
    for (int i = 0; i < MAXL; ++i) a[i] = 0;
  }

  void Add(LL vec) {
    for (int j = MAXL - 1; j >= 0 && vec > 0; --j) {
      if (((vec >> j) & 1) == 0) continue;
      if (a[j] > 0) {
        vec ^= a[j];  // a[j]!=0,就用a[j]消去t的第j位的1
        continue;
      }
      for (int k = 0; k < j; ++k) {
        if ((vec >> k) & 1) vec ^= a[k];
      }
      for (int k = j + 1; k < MAXL; ++k) {
        if ((a[k] >> j) & 1) a[k] ^= vec;
      }
      a[j] = vec;
      break;
    }    
  }

  void Build(LL *vec_array, int len) {
    for (int i = 0; i < len; ++i) Add(vec_array[i]);
  }

  LL GetMax() {
    LL res = 0;
    for (int i = MAXL - 1; i >= 0; --i) {
      res ^= a[i];
    }
    return res;
  }
};

LL solve(int n) {
  LL xor_sum = 0;
  for (int i = 0; i < n; ++i) xor_sum ^= a[i];

  for (int i = 0; i < LinearBasis::MAXL; ++i) {
    if (((xor_sum >> i) & 1) == 0) continue;
    for (int j = 0; j < n; ++j) {
      if ((a[j] >> i) & 1) a[j] ^= (1LL << i);
    }
  }

  LinearBasis lb;
  lb.Build(a, n);
  LL lb_max = lb.GetMax();
  // printf("xor_sum = %lld\n", xor_sum);
  // printf("lb_max = %lld\n", lb_max);

  return lb_max * 2 + xor_sum;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%lld", a + i);
  printf("%lld\n", solve(n));

  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    public class Program {
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(' ');
            int[] Ns = new int[Keys.Length];
            for (int i = 0; i < Keys.Length; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }

        static void Main() {
            var s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            int[] Hs = new int[N];
            for (int i = 0; i < N; i++) {
                Hs[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(Hs);
            int Min = Hs[N - 1] - Hs[0];
            for (int offset = 0; offset < N - K + 1; offset++) {
                Min = Math.Min(Min, Hs[offset + K - 1] - Hs[offset]);
            }
            Console.WriteLine(Min);
        }
    }
}


Measured memory_bytes: 15452
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int n,k,sum=0,ans=0,count=1;
    string s;
    cin>>n>>k>>s;
    queue<int> Q;
    FOR(i,1,n){
        if(s[i]-s[i-1]!=0 && s[i]-'0'==0){
            if(ans<sum+count) ans=sum+count;
            if(Q.size()>=k){
                sum-=Q.front();
                Q.pop();
            }
            count++;
        }
        else if(s[i]-s[i-1]!=0 && s[i]-'1'==0){
            sum+=count;
            Q.push(count);
            count=1;
        }
        else count++;
    }

    if(ans<sum+count) ans=sum+count;
    cout<<ans<<endl;

}

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


int main() { //A
  int N, M;
  cin >> N >> M;
 
  if (N == 0 && M != 0){
  cout << M * (M - 1) / 2 << endl; 
  }
  else if (N != 0 && M == 0){
  cout << N * (N - 1) / 2 << endl; 
  }
  else if (N == 0 && M == 0){
  cout << 0 << endl; 
  }
  else{
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl; 
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    string[] pic = new string[input[0] + 2];
    for(int i = 1; i <= input[0]; i++){
      pic[i] = "#" + Console.ReadLine() + "#";
    }
    
    for(int i = 0; i < input[1] + 2; i++){
      pic[0] += "#";
      pic[input[0] + 1] += "#";
    }
    
    for(int i = 0; i < input[0] + 2; i++){
      Console.WriteLine(pic[i]);
    }
  }
}

Measured memory_bytes: 13268
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Str s;
	AtCoder::input(&s);

	if ("Sunny" == s[0]) {
		printf("Cloudy\n");
	}else if("Cloudy" == s[0]) {
		printf("Rainy\n");
	} else {
		printf("Sunny\n");
	}
	
	return 0;
}


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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A;
ll X,Y;
int main(){
  cin >> N;
  A.assign(N+10,0);
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }

  X=-1;Y=-1;
  for (ll i=1;i<=N;i++){
    if (A[i]>Y){X=i;Y=A[i];}
  }
  sort(A.begin()+1,A.begin()+N+1);
  //cout << X << endl;
  for (ll i=1;i<=N;i++){
    if (i==X) cout << A[N-1] << endl;
    else cout << A[N] << endl;
  }
}


Measured memory_bytes: 3200
program probC
    implicit none
    integer::n, i, maxv, smax
    integer, allocatable::a(:), c(:)
    read(*,*) n
    allocate(a(n),c(n))
    do i = 1, n
        read(*,*) a(i)
    end do
    c = a
    maxv = maxval(a)
    do i = 1, n
        if(a(i) == maxv) then
            c(i) = 0
            exit
        end if
    end do
    smax = maxval(c)
    do i = 1, n
        if(a(i) == maxv) then
            write(*,*) smax
        else    
            write(*,*) maxv
        end if
    end do
    deallocate(a,c)
    stop
end program

Measured memory_bytes: 4576
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N,M = list(map(int, input().split()))
        KS = np.zeros((M,N+1),dtype=int)
        for i in range(M):
            tmp = list(map(int, input().split()))
            tmp = tmp + [0]*(N-tmp[0])
            KS[i] = tmp
        P = list(map(int, input().split()))
    else:
        pass
    count = 0
    for i in range(2**N):
        b = "0"*N + bin(i)[2:] 
        tcount = 0
        for j in range(M):
            p = P[j]
            ks = KS[j][1:]
            n = 0
            for tks in ks:
                n += int(b[-tks])
            if n % 2 == p:
                tcount += 1
            else:
                break
        else:
            count += 1
            #print(i,b)

    print(count)
if __name__ =='__main__':
    main()

Measured memory_bytes: 12476
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int lim=100005;

bool t[lim];
int t2[101];

int n,k;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	
	for(int i=0;i<n;i++) cin>>t2[i];
	
	t[0]=true;
	
	for(int i=1;i<=k;i++){
		for(int j=0;t2[j]<=i && j<n;j++) t[i]|=t[i-t2[j]];
		t[i]^=1;
	}
	if(t[k]) cout<<"Second"; else cout<<"First";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    vll a(n);
    vll ss(60);
    REP(i, n) {
        cin >> a[i];
        REP(j, 50) {
            if ((a[i] >> j) & 1) ss[j]++;
        }
    }
    ll res = 0;
    // 最大桁数 i 桁で　feasibke な mask := X(i) <= K を構築
    REP(i, 50) {
        ll mask = 0;
        REPR(j, i + 1) {
            if (mask + (1LL << j) <= k && n - ss[j] > ss[j]) mask += (1LL << j);
        }
        ll cur = 0;
        REP(j, n) cur += (a[j] ^ mask);
        res = max(res, cur);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = map(int, input().split())
B = list(map(int, input().split()))
C = list(map(int, input().split()))

point = sum(B)
prev_a = -1
for a in A:
    if a - prev_a == 1:
        point += C[a-2]
    prev_a = a
print(point)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, K;
    cin >> N >> K;

    vec<ll> P(N);
    rep(i, N) cin >> P[i], --P[i];

    vec<ll> C(N);
    rep(i, N) cin >> C[i];

    ll ans = -1e18;
    rep(i, N) {
        vec<ll> cycle;

        ll now = i;
        ll sm  = 0;

        while (true) {
            sm += C[now];
            cycle.push_back(sm);
            now = P[now];
            if (now == i) break;
        }

        ll tmp = -1e18;
        ll sz  = cycle.size();
        rep(j, sz) {
            if(K<j+1) break;
            ll roop = (K - j - 1) / sz;
            if (sm > 0) {
                tmp = sm * roop + cycle[j];
            } else {
                tmp = cycle[j];
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3804
#include <iostream>
using namespace std;
int main(){
    int num;
    cin>> num;
    int ary[num];
    for(int i=0;i<num;i++){
        cin>>ary[i];
    }

    for(int i=0;i<num;i++){
        cout<<ary[num-i-1];
        if(i!=(num-1)){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}

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

#define int long long

#define PB push_back
#define PPB pop_back
#define MK make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;

static const int INF = 1LL << 61;
//static const int MOD = 1000000007;
static const int MAX_N = 100005;

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

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

    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    if (n == 2) {
        for (int i = 1; i <= 3; ++i) cout << i << endl;
        return 0;
    }
    const int len = 2 * n - 1;
    int cur = 1;
    for (int i = 1; i <= len; ++i) {
        const int j = x == 2;
        if (i == len / 2 - 1) {
            for (int k = 0; k < 4; ++k) {
                cout << x + dx[j][k] << endl;
            }
            i += 3;
            continue;
        }
        

        do {
            bool flg = true;
            for (int k = 0; k < 4; ++k) {
                if (cur == x + dx[j][k]) {
                    flg = false;
                    break;
                }
            }
            if (flg) break;
            cur++;
        } while (1);
        cout << cur << endl;
        cur++;
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100012
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

int s, w;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> s >> w;
    if(w >= s) cout << "unsafe\n";
    else cout << "safe\n";
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int tmp_count = 0;
  int min = 1000;
  for (int i = 0; i < (int)s.size() - (int)t.size() + 1; i++) {
    for (int j = 0; j < (int)t.size(); j++) {
      if (s.at(i + j) != t.at(j)) {
        tmp_count++;
      }
    }
    if (min >= tmp_count) {
      min = tmp_count;
    }
    tmp_count = 0;
  }
  
  cout << min << endl;
}


Measured memory_bytes: 3596
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val MOD = 1e9.toInt + 7

  val N = in.next().toInt
  val A = new Array[Long](N+1)
  for (i <- 1 to N)
    A(i) = in.next().toLong

  //
  val dp = new Array[Long](65)

  // 準備 桁ごとの1の数を用意
  for (e <- A.drop(1)) {
    var now = e
    var ind = 0
    while (now > 0) {
      if (now % 2 == 1) {
        dp(ind) += 1
      }
      now /= 2
      ind += 1
    }
  }

  def comb2(n: Long): Long = {
    val res =
      if (n % 2 == 0) {
        (n / 2) * (n-1)
      }
      else {
        n * ((n-1) / 2)
      }

    res % MOD
  }

  var ans = 0L
  var base = 1L
  for (i <- 0 until 65) {
    val cnt = dp(i)
    if (i > 0) {
      base *= 2
      base %= MOD
    }
    

    val one = cnt
    val zero = N - cnt
    val hoge = (one * zero) % MOD
    ans += base * hoge
    ans %= MOD
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 85588
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=(l),i##end=(r);i<=i##end;i++)
#define Fordown(i,r,l) for(int i=(r),i##end=(l);i>=i##end;i--)
using namespace std;
typedef long long ll;
const int INF=1e9;
const int N=6e2+10;
char a[N][N];
int vis[N][N];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int n=read();
	For(i,1,n)For(j,1,n){
		char ch=getchar();
		while(!isalpha(ch))ch=getchar();
		a[i][j]=ch;
	}
	For(i,1,(n<<1)-1)For(j,1,(n<<1)-1)a[i][j]=a[(i-1)%n+1][(j-1)%n+1];
	int ans=0;
	For(i,0,n-1)For(j,0,n-1){
		if(i==0 || j==0){
			int Flag=0;
			For(k,1,n)For(l,1,n)
				if(a[k+i][l+j] ^ a[l+i][k+j])Flag=1;
			if(!Flag)ans++,vis[i][j]=1;
		}
		else if(vis[i-1][j-1])ans++,vis[i][j]=1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1280
def bubbleSort(A, N):
    c = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                c += 1
                flag = 1
    print " ".join(map(str, A))
    print c


N = int(raw_input())
L = map(int, raw_input().split())

bubbleSort(L, N)

Measured memory_bytes: 6464
highway_kyori = [0,6,13,18,23,43,58]
highway_price1 = [300,500,600,700,1350,1650]
highway_price2 = [350,450,600,1150,1500]
highway_price3 = [250,400,1000,1350]
highway_price4 = [250,850,1300]
highway_price5 = [600,1150]
highway_price6 = [500]
highway_price = [highway_price1,highway_price2,highway_price3,highway_price4,highway_price5,highway_price6]

id1 = gets.to_i
until id1 == 0
    discount = 0
    time1 = gets.split(" ").map{|k| k.to_i }
    time1[0] *= 60
    all_time1 = time1[0] + time1[1]
    id2 = gets.to_i
    time2 = gets.split(" ").map{|k| k.to_i }
    time2[0] *= 60
    all_time2 = time2[0] + time2[1]
    if all_time1 >= 1050 && all_time1 <= 1170 &&  (highway_kyori[id2-1] - highway_kyori[id1-1]) <= 40
        discount = 1
    elsif all_time2 >= 1050 && all_time2 <= 1170 &&  (highway_kyori[id2-1] - highway_kyori[id1-1]) <= 40
        discount = 1
    end

    if discount == 0
        aa = highway_price[id1-1]
        ans = aa[id2-id1-1]
        puts ans
    elsif discount == 1
        aa = highway_price[id1-1]
        ans1 = aa[id2-id1-1] / 2
        ans2 = ans1.to_s.split("")
        if ans2[-1] == "5"
            ans1 += 25
        end
        ans = ans1
        puts ans
    end
    id1 = gets.to_i
end




Measured memory_bytes: 6860
N=int(input())
A = [int(input()) for i in range(N)]

target = {}
 
for i in A:
    if i in target:
        target[i] += 1
    else:
        target[i] = 1

ans = 0
for i in target:
    if target[i] % 2 == 0:
        continue
    else:
        ans += 1
print(ans)

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

int main() {
  int n; cin >> n;
  for(int i=0;i<n;i++) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[2]*a[2] == (a[0]*a[0] + a[1]*a[1])) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1168
import sys
from heapq import heappop, heappush,heapify
input = sys.stdin.readline
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = list(map(int,input().split()))
    if a <= M:
        AB[a].append(-b)
work = 0
AB2 = []
heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heappush(AB2,j)
    if len(AB2) > 0:
        b = heappop(AB2)
        work += -b
print(work)

Measured memory_bytes: 23752
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [, W] = input[0].map(Number);
  const image = input.slice(1, -1).map((line) => line[0]);

  return [
    "#".repeat(W + 2),
    ...image.map((line) => `#${line}#`),
    "#".repeat(W + 2),
  ].join("\n");
};

console.log(main(read()));


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    cin >> n;
    cout << (n/500)*1000 + ((n%500)/5)*5;   
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
    int n,m;
    int ansn,ansm;
    while(cin>>n>>m,n)
    {
        bool b=false;
        vector<int> nn;
        vector<int> mm;
        for(int i=0;i<n;i++)
        {
            int num;
            cin>>num;
            nn.push_back(num);
        }
        for(int i=0;i<m;i++)
        {
            int num;
            cin>>num;
            mm.push_back(num);
        }
        sort(nn.begin(),nn.end());
        sort(mm.begin(),mm.end());
        int numn=0;
        int numm=0;
        for(int i=0;i<n;i++)
        {
            numn+=nn[i];
        }
        for(int i=0;i<m;i++)
        {
            numm+=mm[i];
        }
        int minmn=1000;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                int a,b;
                a=numn;
                b=numm;
                numn-=nn[i];
                numm-=mm[j];
                numn+=mm[j];
                numm+=nn[i];
                if((minmn>=nn[i]+mm[j])&&numm==numn)
                {
                    ansn=nn[i];
                    ansm=mm[j];
                    minmn=(nn[i]+mm[j]);
                }
                numn=a;
                numm=b;
            }
        }
        if(minmn!=1000)cout<<ansn<<" "<<ansm<<endl;
        else cout<<"-1"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>

using namespace std;

int main(){
	int num[10];

	for (int i = 0; i < 10; i++){
		cin >> num[i];
	}
	for (int i = 1; i < 10; i++){
		num[0] += num[i];
	}
	cout << num[0] << endl;
}

Measured memory_bytes: 3076
using System;
using System.Text;
using System.Linq;

class A {
    string[] Rs(){
		return Console.ReadLine().Split(' ');
	}
    public void run(){
        int N = int.Parse(Console.ReadLine());
        int[] p = Rs().Select( x => int.Parse(x)-1 ).ToArray();
        int[] rp = new int[N];
        for(int i=0;i<N;i++) rp[p[i]] = i;
        int d = 30000;
        StringBuilder sb = new StringBuilder("", 10*N);
        
        for(int i=0;i<N-1;i++){
            sb.Append(10+d*i+rp[i]);
            sb.Append(' ');
        }
        sb.Append(10+d*(N-1)+rp[N-1]);
        sb.Append('\n');
        for(int i=0;i<N-1;i++){
            sb.Append(d*(N-i));
            sb.Append(' ');
        }
        sb.Append(d);
        sb.Append('\n');
        
        Console.WriteLine(sb.ToString());
    }
    
}

class Program {
    static void Main(string[] args){
        A a = new A();
        a.run();
    }
}

Measured memory_bytes: 9176
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int m, k;
    cin >> m >> k;
    if (pow(2, m) <= k) {
        cout << -1 << endl;
    } else if (k == 0) {
        for (int i = 0; i < pow(2, m); i++) {
            cout << i << " " << i << " ";
        }
        cout << endl;
    } else if (m == 1 && k == 1) {
        cout << -1 << endl;
    } else {
        cout << k << " ";
        for (int i = 0; i < pow(2, m); i++) {
            if (i != k) {
                cout << i << " ";
            }
        }
        cout << k << " ";
        for (int i = pow(2, m) - 1; i >= 0; i--) {
            if (i != k) {
                cout << i << " ";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int n, m;
//char maze[101][101];
//typedef pair < int, int> P;
//int sx, sy, gx, gy;
//int d[101][101];
//int dx[4] = { 1,0,-1,0 };
//int dy[4] = { 1,0,-1,0 };

//const ll mod = 1000000007;

int main()
{
	cin >> n >> m;
	cout << n + (m / 2) << endl;
}

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a.at(i);
    sort(a.begin(), a.end(), greater<int>());
    int sum=0;
    for(int i=1;i<n;i++) sum+=a.at(i);
  	//cout<<a.at(0)<<' '<<sum<<endl;
    a.at(0)<sum? cout<<"Yes"<<endl: cout<<"No"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
if n == 1:
    print(0)
else:
    x_list = factorization(n)
    ans = 0
    for x in x_list:
        n = 2
        while True:
            if x[1] < (n * n + n) // 2:
                ans += n - 1
                break 
            n += 1

    print(ans)


Measured memory_bytes: 9484
package main

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

func main() {
	var a, b, c int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		strs := strings.Split(line, " ")
		a, _ = strconv.Atoi(strs[0])
		b, _ = strconv.Atoi(strs[1])
		c, _ = strconv.Atoi(strs[2])
	}

	var output string
	if a < b && b < c {
		output = "Yes"
	} else {
		output = "No"
	}

	fmt.Printf("%v\n", output)
}



Measured memory_bytes: 1096
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s,res;

int main()
{
	cin>>s;
	if(s=="keyence") puts("YES"),exit(0);
	rep(i,s.size())
	{
		for(int j=i;j<s.size();j++)
		{
			res=s.substr(0,i)+s.substr(j+1,s.size()-j-1);
			if(res=="keyence") puts("YES"),exit(0);	
		}
	}
	puts("NO");
	rt0;
}

Measured memory_bytes: 256
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            lst.append(m)
            if m <= 1:
                break
        if m <= 1:
            break
    print(min(lst))
    return


main()


Measured memory_bytes: 3060
N = gets.to_i

sum = Array.new(10010, 0)

1.upto(105) do |x|
  1.upto(105) do |y|
    1.upto(105) do |z|
      n = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)
      sum[n] += 1 if n < 10010
    end
  end
end

N.times do |i|
  puts sum[i+1]
end


Measured memory_bytes: 14200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> button(N);
  
  for (int i = 0; i < N; i++) {
    cin >> button.at(i); 
  }
  
  int num = 0;
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (button.at(num) == 2) {
       count += i + 1;
       break;
    }
    
    num = button.at(num) - 1;
  }
  if (count == 0) {
    cout << -1 << endl; 
  } else {
    cout << count << endl; 
  }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c,x; cin>>a>>b>>c>>x;
    int cnt =0;
  REP(i, a+1){
      REP(j,b+1){
        REP(k,c+1){
          if(500*i+100*j+k*50==x) cnt++;
        }
      }
  }
        print(cnt);
    return 0;
}


Measured memory_bytes: 256