akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int musi = 100;
    vector<ll> A;

    void input() {

    }

    bool check(ll num) {
        //num文字であれできる?
        vector<ll> digit(musi);
        int n = A.size();
        for (int i = 1; i < n; ++i) {
            if (A[i - 1] >= A[i]) {
                //A[i]より小さな桁(vec的には大きな)を減らす
                for (int j = A[i] + 1; j < musi; ++j) {
                    digit[j] = 0ll;
                }
                digit[A[i]]++;
                for (int j = A[i]; j > 1; --j) {
                    if (digit[j] >= num) {
                        digit[j] -= num;
                        digit[j - 1]++;
                    }
                }
                if (digit[1] >= num) return false;
            }
        }
        return digit[1] < num;
    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<ll> v(N);
        rep(i, 0, N) cin >> v[i];
        bool flag = true;
        for (int i = 0; i < N - 1; ++i) {
            if (v[i] >= v[i + 1]) {
                flag = false;
                break;
            }
        }

        if (flag) {
            cout << 1 << endl;
            return;
        }


        rep(i, 0, N) {
            int tmp = v[i];
            if (tmp < musi) {
                A.push_back(tmp);
            }
        }

        ll ng = 1;
        ll ok = (ll) 1e6;
        while (ok - ng > 1) {
            ll mid = (ok + ng) / 2;
            if (check(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        check(2);

        cout << ok << endl;


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int n,k,a[1<<17],cnt;vector<int>x[1<<17];
int D(int p) {int M=0;for(int i=0;i<x[p].size();i++){M=max(M,D(x[p][i])+1);}if(M==k-1&&p!=1&&a[p]!=1){M=-1;cnt++;}return M;}
main(){cin>>n>>k;for(int i=1;i<=n;i++){cin>>a[i];if(i>=2){x[a[i]].push_back(i);}}if(a[1]!=1){a[1]=1;cnt++;}D(1);cout<<cnt<<endl;}

Measured memory_bytes: 13056
def submit():
    n = int(input())
    dp = [[0] * 3 for _ in range(n)]
    
    for i in range(n):
        a, b, c = map(int, input().split())
        
        if i == 0:
            dp[0] = [a, b, c]
        else:
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

    print(max(dp[n - 1]))


submit()

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


int main() {
     int n;  cin>>n;
    vector<int> h(n);
    int dp[100100];

    rep(i,n)cin>>h[i];

    for(int i=2;i<=n;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		if(i>2)dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
    }

    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val A = readLine.split(" ").map(_.toInt)
  val q = readInt
  val M = readLine.split(" ").map(_.toInt)

  for (i <- 0 until q) {
    if (solve(0, M(i))) println("yes") else println("no")
  }

  def solve(i: Int, m: Int): Boolean = {
    if (m == 0) return true
    if (i >= n) return false
    val res = solve(i + 1, m) || solve(i + 1, m - A(i))
    res
  }
}


Measured memory_bytes: 43964
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
if D[0] > 0:
    print(0)
    exit(0)
cs = Counter(D)
if cs[0] > 1:
    print(0)
    exit(0)
count = 0
ans = 1
prev = 1
for i in range(N + 1):
    n = cs[i]
    if n == 0:
        if count == N:
            print(ans)
        else:
            print(0)
        exit(0)
    else:
        count += n
        ans = (ans * (prev ** n)) % 998244353
        prev = n


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

int main(){

  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    v.push_back(k);
  }
  sort(v.begin(), v.end());

  int prev = 0;
  int co = 0;
  int ans = 0;
  for (int i = 0; i < n; i++){
    int j = v[i];
    if (j != prev) {
      ans += co % 2;
      prev = j;
      co = 1;
    } else {
      co++;
    }
  }
  ans += co % 2;
  cout << ans << endl;
  return 0;
}

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

int main(){//挿入ソート

    int v,n,A[1000];
    cin >> n;

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

    for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << A[i] << " ";
            } else {
                cout << A[i];
            }
        }

        cout << endl;
    
    for (int i = 1; i <= n-1; i++){

        v = A[i];
        int j = i - 1;

        while (j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }

        A[j + 1] = v;

        for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << A[i] << " ";
            } else {
                cout << A[i];
            }
        }

        cout << endl;
    }

    return 0;
    
}


Measured memory_bytes: 3088
program main
  implicit none
  integer :: n, i, nout, mi
  character(300000) :: s

  read(*, *) n
  read(*, *) s

  nout = 0
  do i = 2, n
    if (s(i:i) == "E") then
      nout = nout + 1
    end if
  end do

  mi = nout
  do i = 2, n
    if (s(i:i) == "E") then
      nout = nout - 1
    end if
    if (s(i - 1:i - 1) == "W") then
      nout = nout + 1
    end if
    mi = min(mi, nout)
  end do
  write(*, "(i0)") mi
end program main


Measured memory_bytes: 1212
a,b,c,d = map(int, input().split())
t_hp = a
a_hp = c
while True:
    a_hp = a_hp - b
    if a_hp <= 0:
        print('Yes')
        break
    t_hp = t_hp - d
    if t_hp <= 0:
        print('No')
        break

Measured memory_bytes: 9176
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string s;
	cin>>s;
	s[5]=' ';s[13]=' ';
	cout<<s;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

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

void solve()
{
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(i, q)
    {
        int t, u, v;
        cin >> t >> u >> v;
        if (t)
        {
            if (d.same(u, v))
                cout << 1 << endl;
            else
                cout << 0 << endl;
        }
        else
        {
            d.merge(u, v);
        }
    }
}

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

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 4040
/*****************Bismillahir Rahmanir Rahim***********************/

#include<bits/stdc++.h>
using namespace std;

/************************Start Of Template*************************/

/******** Mahin Shefat - GhOstMan *************/


#define     pb              push_back
#define     popb            pop_back
#define     ll              long long int
#define     ull             unsigned long long int
#define     max3(a,b,c)     max(a,max(b,c))
#define     max4(a,b,c,d)   max(max3(a,b,c),d)
#define     min3(a,b,c)     min(a,min(b,c))
#define     min4(a,b,c,d)   min(a,min3(b,c,d))
#define     MOD             1000000007
#define     f               first
#define     s               second
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     mp              make_pair
#define     check           printf("check")
#define     sqr(x)          (x)*(x)
#define     all(v)          v.begin(),v.end()
#define     fast            ios_base::sync_with_stdio(0);cin.tie(0)
#define     pii             pair<int,int>
#define     Pair            pair<ll,ll>
#define     MAX             1000000000000014
#define     MIN             -1000000000000014
#define     endl            '\n'
#define     Fread           freopen("inputdur.txt","r",stdin)
#define     Fwrite          freopen("output.txt","w",stdout)

/************************End Of Template*************************/
std::vector< int > g[200005];
bool mark[200005];
ll arr[200005];
void dfs(int u , ll val){
	mark[u] = true;
	arr[u] += val;
	for(int i = 0; i < g[u].size(); i++){
		int v = g[u][i];
		if(mark[v] == true) continue;
		dfs(v , arr[u]);
	}
}
int main(){
	
	int n , q;
	cin >> n >> q;
	for(int i = 1; i < n; i++){
		int u , v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}		
	for(int i = 1; i <= q; i++){
		ll id , val;
		cin >> id >> val;
		arr[id] += val;
	}
	dfs(1 , 0);
	for(int i = 1; i <= n; i++){
		cout << arr[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 24448
package main

import (
	"fmt"
	"strings"
	"unicode/utf8"
)

func main() {
	var n int
	var s string

	fmt.Scan(&n, &s)

	r := strings.Count(s, "R")
	g := strings.Count(s, "G")
	b := strings.Count(s, "B")
	lenS := utf8.RuneCountInString(s)

	var exclude int
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			k := j + j - i
			if k >= lenS {
				continue
			}
			if s[i] != s[j] && s[i] != s[k] && s[j] != s[k] {
				exclude++
			}
		}
	}

	fmt.Println(r*g*b - exclude)
}


Measured memory_bytes: 1884
n = int(input())
ary = [list(map(int,input().split())) for _ in range(n)]
ans = sum([sum(i) for i in ary])
for i in range(n):
    for j in range(n):
        for k in range(n):
            if j == k or i == k:continue
            if ary[i][j] > ary[i][k] + ary[k][j]:print(-1);exit()
            if ary[i][j] == ary[i][k] + ary[k][j]:
                ans -= ary[i][j]
                break
print(ans//2)

Measured memory_bytes: 43740
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const ll mod=1000000007;
void add(ll& a, ll b)
{
	a+=b;
	if(a>=mod)
		a-=mod;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	char k[10110];
	cin>>k;
	ll d;
	cin>>d;
	ll len=strlen(k);
	vector<vector<ll>> dp(d,vector<ll>(2));
	dp[0][0]=1;
	for(ll i=0;i<len;i++)
	{
		vector<vector<ll>> newdp(d,vector<ll>(2));
		for(ll sum=0;sum<d;sum++)
		{
			for(bool small_already : {false,true})
			{
				for(ll digit=0;digit<10;digit++)
				{
					if(digit>k[i]-'0'&&!small_already)
						break;
					add(newdp[(sum+digit)%d][small_already||(digit<k[i]-'0')],dp[sum][small_already]);
				}
			}
		}
		dp=newdp;
	}
	ll ans=0;
	ans=(dp[0][0]+dp[0][1])%mod;
	ans-=1;
	if(ans==-1)
		cout<<mod-1<<endl;
	else
		cout<<ans<<endl;


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ret = 0;
            int tmp = 0;

            for (int i = 0; i < N - 1; i++)
            {
                if (l[i] >= l[i + 1])
                {
                    tmp++;
                }
                else
                {
                    tmp = 0;
                }

                if (tmp > ret)
                {
                    ret = tmp;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 28252
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld n,i,j,p,k;cin>>n>>k;
    lld a[k];
    rep(i,0,k)
    cin>>a[i];
    while(1)
    {
    	j=n;p=0;
    	while(j>0)
    	{
    		i=j%10;
    		if(binary_search(a,a+k,i))
    		{
    			p=1;
    			break;
    		}
    		j=j/10;
    	}
    	if(p==1)
    	{
          n++;
    	}
    	else
    	{
    		cout<<n;return 0;
    	}
    }
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slow
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, M;
  cin >> N >>M;

  vi accepted(N);
  vi penalty(N);

  REP(i, M) {
    int P;
    string S;

    cin >> P >> S;
    P--;

    if (S == "AC") {
      accepted[P] = 1;
    } else {
      if (!accepted[P]) {
        penalty[P]++;
      }
    }
  }

  int a = 0;
  int p = 0;
  REP(i, N) {
    if (accepted[i]) {
      a++;
      p += penalty[i];
    }
  }

  cout << a << " " << p << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 1024
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        a : [i32; 5]
    }
    for i in 0..5 {
        if (a[i] == 0) {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2132
import sys
sys.setrecursionlimit(10**7)

def modinv(a,m=10**9+7):
    if a==0: return 1
    b=m
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % m

def cur(p):
    for x in neighbor[p]:
        if x==par[p]: continue
        par[x]=p
        descend[p]+=cur(x)
    return descend[p]

def cur2(p):
    for x in neighbor[p]:
        if x==par[p]: continue
        ans[x]=ans[p]*descend[x]*modinv(n-descend[x])%mod
        cur2(x)

mod=10**9+7
n=int(input())
neighbor=[[]  for _ in range(n+1)]
descend=[1]*(n+1)
par=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)
cur(1)

ans=[1]*(n+1)
ans1=1
for i in range(1,n+1):
    ans1=ans1*i*modinv(descend[i])%mod
ans[1]=ans1
cur2(1)
for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 139612
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  int N,K;cin>>N>>K;
  vector<int> A(N),F(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>F[i];
  sort(A.begin(),A.end());
  sort(F.begin(),F.end(),std::greater<int>());
  
  int l=0,r=A[N-1]*F[0]; //l,rは探索範囲の端点(含む)
  
  while(r-l>0){
    int X=(r+l)/2;//中点をとる
    int sum=0;
    for(int i=0;i<N;i++)sum+=(0>A[i]-X/F[i]?0:A[i]-X/F[i]);
    
    if(sum<=K)r=X;//条件を満たすなら, 
    else l=X+1;
  }
  cout<<l;
}












Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
using namespace std;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif // Mfc_Tanzim

    ll k, n;
    cin >> k >> n;
    vector<ll>v(n);
    map<ll, ll>mp;

    for(auto &i: v)
        cin >> i, mp[i]++;
    if(!mp[k])
    {
        cout << k << endl;
        return 0;
    }
    for(ll i=k-1,j=k+1; ;i--,j++)
    {
        if(mp[i]<1&& i>=0)
        {
            cout << i << endl;
            return 0;
        }
        else if(mp[j]<1)
        {
            cout << j << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int n = 1, x = 1, i, j, k, count = 0;
	while (n != 0 || x != 0)
	{
		scanf("%d %d", &n, &x);
		for (i = 1; i < n; i++)
		{
			for (j = i + 1; j < n; j++)
			{
				for (k = j + 1; k <= n; k++)
				{
					if (i + j + k == x)
					{
						count += 1;
					}
				}
			}
		}
		if ((n != 0) || (x != 0))
		{
			printf("%d\n", count);
		}
		count = 0;
	}
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (char i = '0'; i <= '9'; i++)
    {
        for (char j = '0'; j <= '9'; j++)
        {
            for (char k = '0'; k <= '9'; k++)
            {
                string number = "000";
                number[0] = i;
                number[1] = j;
                number[2] = k;
                int idx = 0;
                for (int m = 0; m < n; m++)
                {
                    if (number[idx] == s[m])
                    {
                        idx++;
                        if (idx == 3)
                        {
                            ans++;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;
const ll INF = 1e11;

ll R[101000];
typedef pair<ll, ll> P;

class SegmentTree{
    ll n;
    vector<P> node;

public:
    SegmentTree(vector<P> v){
        ll size = v.size();
        n = 1;
        while(n < size) n *= 2;
        node.resize(2*n-1, make_pair(INF, INF));

        for(ll i = 0; i < size; i++){
            node[n-1+i] = v[i];
        }
        for(ll i = n-2; i >= 0; i--){
            node[i] = min(node[2*i+1], node[2*i+2]);
        }
    }

    ll update(ll idx, ll val){
        idx += n-1;
        node[idx] = make_pair(val, idx-(n-1));
        while(idx > 0){
            idx = (idx-1)/2;
            node[idx] = min(node[2*idx+1], node[2*idx+2]);
        }
    }

    //return min value within [a,b)
    //call get_min(a, b);
    P get_min(ll a, ll b, ll k=0, ll l=0, ll r=-1){
        if(r < 0) r = n;

        if(b <= l || r <= a) return make_pair(INF, INF);

        if(a <= l && r <= b) return node[k];

        P vl = get_min(a, b, 2*k+1, l, (l+r)/2);
        P vr = get_min(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};


int main(){
    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    vector<P> DP(N+1);
    REP(i,N+1){
        DP[i] = make_pair(INF, i);
    }
    DP[N] = make_pair(0, N);
    SegmentTree tree(DP);

    for(int i = N-1; i >= 0; i--){
        if(S[i] == '1') continue;
        P get = tree.get_min(i+1, i+M+1);
        //cout << get.second << endl;
        //cout << get.first << endl;
        ll idx = get.second;
        ll val = get.first;
        //tree.update(i, val+1);
        tree.update(i, val+1);
        R[i] = idx;
    }

    ll num = tree.get_min(0,1).first;
    if(num >= INF){
        cout << -1 << endl;
        return 0;
    }

    ll next = 0;
    while(next != N){
        ll x = R[next];
        ll ans = x - next;
        printf("%lld ", ans);
        next = x;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long  num  = scan.nextLong();
		boolean flg = true;
		for(long i  = (long)Math.sqrt(num); i > 0 && flg; i--)
				if(num% i == 0) {
					System.out.println(i + num / i - 2);
					flg =  false;
				}
	}
}

Measured memory_bytes: 23892
#pragma GCC optimize("O2,unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
const int maxn = 1<<20;
map<int, int> dd;
int n, mx = 0, mn;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int d, i = 1; i <= n; i++) {
		cin >> d;
		dd[d]++;
		mx = max(mx, d);
	}
	for(int i = mx; i >= mx-i; i--) {
		int m = 1 + (i != mx-i);
		if(dd[i] < m) return cout << "Impossible", 0;
		dd[i] -= m;
	}
	
	for(auto i : dd) {
		int t = i.first - 1;
		if(mx-t <= t) i.second = 0;
		if(i.second) return cout << "Impossible", 0;
	}
	cout << "Possible";
}


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 110;
int n, m, a[maxn], sum;
bool bad;

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	for (int i = n - 1; i >= n - m; i--)
	{
		if (m * 4 * a[i] < sum)
		{
			bad = 1;
			break;
		}
	}
	if (bad)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define swap(type,x,y) do{type t=x;x=y;y=t;}while(0)

using namespace std;

void quick(int a[], int left, int right) {
	int pl = left;
	int pr = right;
	int x = a[(pl + pr) / 2];
	
	do {
		while (a[pl] < x)pl++;
		while (a[pr] > x)pr--;
		if (pl <= pr) {
			swap(int, a[pl], a[pr]);
			pl++;
			pr--;
		}
	} while (pl <= pr);
	if(left < pr) quick(a, left, pr);
	if (pl < right) quick(a, pl, right);
}

int main() {
	int i, n, *x, d, count = 0;
	
	cin >> n;
	x = new int[n];
	for (i = 0; i < n; i++) {
		cin >> d;
		x[i] = d;
	}

	quick(x, 0, n - 1);
	
	count++;
	for (i = 1; i < n; i++) 
		x[i] > x[i - 1] ? ++count : 0;
	
	cout << count;

	return 0;
}

Measured memory_bytes: 256
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    ll n;
    cin>>n;
    ll s=0;
    rep(i,1,n+1){
        if(i%3==0 || i%5==0)continue;
        s+=i;
    }
    cout<<s<<endl;

 
 
 
    
 
    return 0;
}


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

int main() {
	int n,m,c;
	cin >> n >> m >> c;
	vector<int> b(m,0);
	for(int i = 0;i < m;i++)
	{
		cin >> b.at(i);
	}
	int cn = 0;
	for(int i = 0;i < n;i++)
	{
		int sm = 0;
		for(int j = 0;j<m;j++)
		{
			int a;
			cin >> a;
			sm += a * b.at(j);
		}
		if(sm + c > 0)
		{
			cn++;
		}
	}
	cout << cn << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
using namespace std;

struct point{
	int x;
	int y;
};

struct point addPoint(point p1,point p2){
	point p;
	p.x = p1.x + p2.x;
	p.y = p1.y + p2.y;
	return p;
}

struct point substractPoint(point p1,point p2){
	point p;
	p.x = p2.x - p1.x;
	p.y = p2.y - p1.y;
	return p;
}

struct point turn90(point vect){
	point p;
	p.x = 0 * vect.x - vect.y;
	p.y = 1 * vect.x - 0 * vect.y;
	return p;
}


int main()
{
	point p1,p2,p3,p4;
	cin>>p1.x>>p1.y>>p2.x>>p2.y;
	point vec1,vec2,vec3;
	vec1 = substractPoint(p1,p2);		//p2 - -1
	vec2 = turn90(vec1);
	vec3 = turn90(vec2);
	p3 = addPoint(p2,vec2);
	p4 = addPoint(p3,vec3);
	cout<<p3.x<<" "<<p3.y<<" "<<p4.x<<" "<<p4.y<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m;
    char s[101][101];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int i,j;
        for(i=0;i<n;i++)
            scanf("%s",&s[i]);
            getchar();
        for(i=0;i<n;i++)
            printf("%s\n%s\n",s[i],s[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll r,d,x[11];
    cin>>r>>d>>x[0];
    rep(1,i,11){
        x[i]=r*x[i-1]-d;
        cout<<x[i]<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL A, B, C, X, Y;

void MAIN() {
    scanf("%lld%lld%lld%lld%lld", &A, &B, &C, &X, &Y);

    LL ans = 1LL<<60;
    REP (x, X+1) {
	LL tmp = 0;
	tmp += (LL) x * A;
	LL hX = (X - x) * 2;
	tmp += (LL) hX * C;
	LL hY = 2 * Y - hX;

	if (hY >= 0) {
	    LL guess = tmp + (hY+1) / 2 * B;
	    amin(ans, guess);

	    guess = tmp + hY * C;
	    amin(ans, guess);
	    if (hY >= 1) {
		guess = tmp + C + hY / 2 * B;
		amin(ans, guess);
	    }
	}
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(void){
    // Here your code !
    string s;
    int k;
    cin >> s;
    cin >> k;
    int i = 0;
    while(k > 0){
        if(0 < s[i]-'a' && 26 - (s[i]-'a') <= k){
            k -= 26 - (s[i]-'a');
            s[i] = 'a';
        }
        i++;
        if(i > s.length()){
            k %= 26;
            s[s.length()-1] += k;
            if(s[s.length()-1] > 'z'){
                s[s.length()-1] - 26;
            }
            break;
        }
    }
    cout << s;
}

Measured memory_bytes: 512
import math

A, B, H, M = map(int, input().split())

M_range = 6 * M
H_range = 30 * H + 0.5 * M

angle = abs(M_range - H_range)
if angle > 180:
    angle = 360 - angle

ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(angle))

print(math.sqrt(ans))


Measured memory_bytes: 9300
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  while (S.size()>1) {
    S.pop_back();
    if (S.size()%2==0) {
      string sub1 = S.substr(0, S.size()/2);
      string sub2 = S.substr(S.size()/2, S.size()/2);
      if (sub1==sub2) {
        cout << S.size() << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long W = sc.nextLong();
    int N = sc.nextInt();
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    for(int i = 0; i < N; i++) {
      long a = sc.nextLong() - 1;
      long b = sc.nextLong() - 1;
      long n = a * W + b;
      for(int k = 0; k < 3; k++) {
        for(int l = 0; l < 3; l++) {
          long s = n - k * W - l;
          if(a - k >= 0 && b - l >= 0 && a - k < H - 2 && b - l < W - 2 && s >= 0) {
            if(map.containsKey(s)) {
              map.put(s, map.get(s) + 1);
            } else {
              map.put(s, 1);
            }
          }
        }
      }
    }
    long[] num = new long[10];
    for(long s : map.keySet()) {
      num[map.get(s)]++;
    }
    long sum = 0;
    for(int i = 1; i < 10; i++) {
      sum += num[i];
    }
    num[0] = (H - 2) * (W - 2) - sum;
    for(int i = 0; i < 10; i++) {
      System.out.println(num[i]);
    } 
  }
}

Measured memory_bytes: 169772
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

int main(void){

    int count=0;
    char a[3];

    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    for(int i=0;i<3;i++){
        if(a[i]=='o')count++;
    }
    cout<<(700+100*count)<<endl;


}

Measured memory_bytes: 256
#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<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//16:35~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	//saで殴った方が早い
	int n,i;cin>>n;
	llint sai=0;
	vector<llint>a(n);
	for(i=0;i<n;i++){cin>>a[i];sai^=a[i];}
	for(i=0;i<n;i++){a[i]-=(a[i]&sai);}
	//最大化 吐き出し法
	int bas=0;
	while(-1){
		for(i=bas+1;i<n;i++){if(a[bas]<a[i]){swap(a[bas],a[i]);}}
		if(a[bas]==0){break;}
		for(i=bas+1;i<n;i++){mineq(a[i],a[i]^a[bas]);}
		bas++;
		if(bas>=n){break;}
	}
	llint ans=0;
	for(i=0;i<n;i++){maxeq(ans,ans^a[i]);}
	cout<<sai+ans*2<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	char S[11];
	scanf("%s", S);
	
	int i, j, k, l, ans = 0;
	for (l = 0; S[l] != 0; l++);
	for (i = 0; i < l; i++) {
		for (j = i + ans; j < l; j++) {
			for (k = i; k <= j; k++) {
				if (S[k] != 'A' && S[k] != 'G' && S[k] != 'T' && S[k] != 'C') break;
			}
			if (k > j && ans < j - i + 1) ans = j - i + 1;
			else if (k <= j) j = l;
		}
	}

	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

bool isABC(string s) {
  bool isA = false;
  bool isB = false;
  bool isC = false;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') {
      isA = true;
    }
    else if (s[i] == 'b') {
      isB = true;
    }
    else if (s[i] == 'c') {
      isC = true;
    }
  }

  return isA && isB && isC;
}

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

  int n = 3;
  string s;
  cin >> s;

  if (isABC(s)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(void){
	int n, s, p, q, r, P, Q, R, C;
	
	while(1){
		cin >> n;
		int S[n][4];
		if(n == 0)break;
		for(int i = 0; i < n; i++){
			cin >> s >> p >> q >> r;
			S[i][0] = s;
			S[i][1] = p;
			S[i][2] = q;
			S[i][3] = r;
		}
		cin >> P >> Q >> R >> C;
		int j = 0;
		for(int i = 0; i < n; i++){
			if(S[i][1] <= P && S[i][2] <= Q && S[i][3] <= R && (S[i][1]*4 + S[i][2]*9 + S[i][3]*4) <= C){
				cout << S[i][0] << endl;
				j = 1;
			}
		}
		if(j == 0)cout << "NA" << endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	int k, s;
	cin >> k >> s;
	int count = 0;
	FOR(x, 0, k+1) {
		FOR(y, 0, k + 1) {
			int z = s - x - y;
			if (0 <= z and z <= k) {
				if (x + y + z == s) {
					count++;
				}
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int c = 0, w = 0;
  map<int, int> mp;
  vector<int> a(n+1, 0);
  for (int i = 0; i < m; i++){
    int p;
    string s;
    cin >> p >> s;
    if (s == "WA"){
      if (mp[p] == 0){
        a[p]++;
      }
    }
    else{
      if (mp[p] == 0){
        mp[p] = 1;
        c++;
      }
    }
  }
  for (int i = 1; i <= n; i++){
    if (mp[i] == 1)
      w += a[i];
  }
  cout << c << ' ' << w << '\n';
  return 0;
}


Measured memory_bytes: 5376
n = int(input())
L = list(map(int,input().split()))
print(' '.join(map(str, L)))

for i in range(1, n):
    v = L[i]
    j = i - 1
    while j >= 0 and L[j] > v:
        L[j + 1] = L[j]
        j -= 1
    L[j + 1] = v
    print(' '.join(map(str,L)))



Measured memory_bytes: 5592
#include <iostream>

 

using namespace std;

 

int main()
{
   int x ,y, temp, i;
   
   for(i = 1; i <= 3000; i++)
   {
       
        cin >> x >> y;
        if(x > y)
       {
           temp = x;
           x = y;
           y = temp;
       }
       
       
       if(x == 0 && y == 0)
          break;
   
       cout << x << " " << y << endl;\
   }
}


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

int main()
{
	int m, k;
	cin >> m >> k;
	int n = 1 << m;
	if(m == 0){
		if(k == 0){
			cout << "0 0" << endl;
		}else{
			cout << -1 << endl;
		}
	}else if(m == 1){
		if(k == 0){
			cout << "0 0 1 1" << endl;
		}else{
			cout << -1 << endl;
		}
	}else if(k < n){
		bool first = true;
		for(auto i = 0; i < n; ++i){
			if(i == k) continue;
			if(first) first = false;
			else cout << " ";
			cout << i;
		}
		cout << " " << k;
		for(auto i = n - 1; i >= 0; --i){
			if(i == k) continue;
			cout << " " << i;
		}
		cout << " " << k << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	for(long long int i=0;i<s.size();i++){
		if(s[i]==','){
			cout<<" ";
		}
		else{
			cout<<s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <set>
#include <map>
#include <list>
#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;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
  int n;
  cin >> n;
  cout << n*n*n << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long t,j,p,r,i;
    cin>>j>>t;
    p=t-j+1;
    if(p<-1000000)
    p=-1000000;
    r=t+j-1;
    if(r>1000000)
    r=1000000;
    for(i=p;i<=r;i++)
    cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    lenS = len(S)
    for i in range(lenS):
        for j in range(i, lenS):
            ss = S[0:i+1] + S[j+1:lenS]
            if ss == "keyence":
                return "YES"
    return "NO"

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 2940
def main():
    from math import gcd

    def soinsuu(a):
        yy, j = set(), 2
        y = yy.add
        while(a > 1):
            for i in range(j, int(a**0.5)+1):
                if a % i == 0:
                    y(i)
                    a, j = a//i, i
                    break
            else:
                y(a)
                break
        return yy
    n = int(input())
    a = list(map(int, input().split()))

    s = set()
    flag = False
    for i in a:
        so = soinsuu(i)
        for j in so:
            if j in s:
                flag = True
                break
            else:
                s.add(j)
        if flag:
            break
    if flag == False:
        print("pairwise coprime")
        return

    temp1 = a[0]
    for i in a[1:]:
        temp1 = gcd(temp1, i)
    if temp1 > 1:
        print("not coprime")
    else:
        print("setwise coprime")


main()


Measured memory_bytes: 205492
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[100001];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum+=a[i]*a[j];
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner= new Scanner(System.in);
		int R= scanner.nextInt();

		if((0 <= R)&&(R < 1200)) {
			System.out.println("ABC");
		}else if((1200 <= R)&&(R <2800)){
			System.out.println("ARC");
		}else {
			System.out.println("AGC");

	}
}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b<<endl;
    else if(a>=6 && a<=12)
        cout<<b/2<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

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

void Main()
{
	int n; cin>>n;
	VI p(n);
	REP(i, n) cin >> p[i];

	int r=0;
	FOR(i,1,n-1){
		if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])){
			r++;
		}
	}
	cout << r << endl;
	

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

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

  vector<int> X(N);
  rep(i, N) cin >> X[i];

  vector<int> Y;
  Y = X;
  sort(Y.begin(), Y.end());

  int mid = N - (N + 1) / 2;
  rep(i, N) {
    if (X[i] < Y[mid])
      cout << Y[mid] << endl;
    else
      cout << Y[mid - 1] << endl;
  }
}

Measured memory_bytes: 3840
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

const ll N_MAX=210;
vector<vector<ll>> d(N_MAX,vector<ll>(N_MAX,INF));
vector<int> color(N_MAX);

bool dfs(int v, int c) {
if (color[v] == 0) {
    color[v] = c;
    for (int i = 0; i < d[v].size(); i++) {
        if(d[v][i]==1){
            if (!dfs(i, -c)) return false;
        }
        
    }
    return true;
}
return color[v] == c;
}

int main(){
    int N;
    cin>>N;
    
    REP(i,N){
        string S;
        cin>>S;
        REP(j,S.size()){
            if(S[j]=='1') d[i][j]=1;
        }
    }

    bool ng=!dfs(0,1);

    REP(i,N) d[i][i]=0;
    REP(i,N){
        REP(j,N){
            REP(k,N){
                d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }

    ll ans=0;
    REP(i,N){
        REP2(j,i+1,N){
            if(d[i][j]==INF) continue;
            ans=max(ans,d[i][j]);
        }
    }

    

    if(ng){
        cout<<-1<<endl;
    }else{
        cout<<ans+1<<endl;
    }
    
    

    

}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; 
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { 
                can2 = true;
                i += d.size(); 
            }
        }
        if (!can2) { 
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
    int N,H,*a,*b,i,cnt=0;
    cin >> N >> H;
    a = new int[N];
    b = new int[N];
    for(i=0;i<N;i++){
        cin >> a[i] >> b[i];
    }
    qsort(a,N,sizeof(int),compare_int);
    qsort(b,N,sizeof(int),compare_int);
    for(i=N-1;i>=0;i--){
        if(b[i]<=a[N-1]){
            break;
        }else{
            H -= b[i];
            cnt++;
            if(H<=0){
                cout << cnt << endl;
                return 0;
            }
        }
    }
    cnt += H / a[N-1];
    if(H%a[N-1]!=0){
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1464