akhauriyash/Code-Regression huggingface dataset:
/*
 * B.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 5;

/* typedef */

/* global variables */

int dp[2][N][N][N][N];

/* subroutines */

int rec(int k, int l0, int r0, int l1, int r1) {
  if (dp[k][l0][r0][l1][r1] >= 0) return dp[k][l0][r0][l1][r1];

  int ret;
  if (k == 0) {
    if ((l0 > 0 &&
	 ((l1 > 0 && rec(1, l0, r0, (l1 + l0) >= N ? 0 : l1 + l0, r1) == 0) ||
	  (r1 > 0 && rec(1, l0, r0, l1, (r1 + l0) >= N ? 0 : r1 + l0) == 0))) ||
	(r0 > 0 &&
	 ((l1 > 0 && rec(1, l0, r0, (l1 + r0) >= N ? 0 : l1 + r0, r1) == 0) ||
	  (r1 > 0 && rec(1, l0, r0, l1, (r1 + r0) >= N ? 0 : r1 + r0) == 0))))
      ret = 0;
    else
      ret = 1;
  }
  else {
    if ((l1 > 0 &&
	 ((l0 > 0 && rec(0, (l0 + l1) >= N ? 0 : l0 + l1, r0, l1, r1) == 1) ||
	  (r0 > 0 && rec(0, l0, (r0 + l1) >= N ? 0 : r0 + l1, l1, r1) == 1))) ||
	(r1 > 0 &&
	 ((l0 > 0 && rec(0, (l0 + r1) >= N ? 0 : l0 + r1, r0, l1, r1) == 1) ||
	  (r0 > 0 && rec(0, l0, (r0 + r1) >= N ? 0 : r0 + r1, l1, r1) == 1))))
      ret = 1;
    else
      ret = 0;
  }

  return (dp[k][l0][r0][l1][r1] = ret);
}

/* main */

int main() {
  int l0, r0, l1, r1;
  cin >> l0 >> r0 >> l1 >> r1;

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

  int ans = rec(0, l0, r0, l1, r1);
  cout << (ans == 0 ? "ISONO" : "NAKAJIMA") << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int D, E;
  while(cin>>D>>E) {
    if(D == 0) return 0;
    double ans = 1000;
    FOR(x,0,D+1) {
      int y = D - x;
      ans = min(ans, fabs(sqrt(x*x+y*y) - E));
    }
    printf("%0.6lf\n", ans);
  }
  return 0;
}

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

using namespace std;

int l1, l2;
string s1, s2, res;

string func(char cn, string str1, string str2, int p, int q, int l)
{
  if(p >= l1 && q >= l2){
    str2 += cn;
    return str2;
  }

  if(l < res.size() && cn == res[l]) return func(s1[p], (str1+cn), str2, p+1, q, l+1);
  return func(s2[q], str1, (str2+cn), p, q+1, l);
}

int main()
{
  while(cin>>s1 && s1 != "-"){
    cin >> s2 >> res;
    l1 = s1.size();
    l2 = s2.size();

    cout << func(s2[0], "", "", 0, 1, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 100
int main(){
  int n,i,j=0,A[N],b,minj,k,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj])minj = j;
    }
    k = A[i];
    A[i] = A[minj];
    A[minj] = k;
    if(i != minj) count++;
    
  }
    for(b=0;b<n-1;b++) printf("%d ",A[b]);
    printf("%d",A[n-1]);
    printf("\n");
    printf("%d",count);
    printf("\n");
    
  return 0; 
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, z;
	cin>>x>>y>>z;
	cout<<x*y/2<<'\n';
	return 0;
}


Measured memory_bytes: 256
# マージO(n)かかっちゃう
class union_find:
	def __init__(self, size):
		# 負の値はルート (集合の代表) で集合の個数
		# 正の値は次の要素を表す
		self.size=size
		self.table = [-1 for _ in range(size)]
		self.num=[0 for i in range(size)]

	# 集合の代表を求める
	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			# 経路の圧縮
			self.table[x] = self.find(self.table[x])
			return(self.table[x])

	# 併合
	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] <= self.table[s2]:
				# 小さいほうが個数が多い
				self.table[s1] += self.table[s2]
				self.table[s2] = s1
			else:
				self.table[s2] += self.table[s1]
				self.table[s1] = s2
			return(True)
		return(False)

	def definite(self):
		for i in range(self.size):
			self.num[i]=self.find(i)
		return(True)


N,K,L=list(map(int,input().split()))
road=union_find(N)
rail=union_find(N)

for i in range(K):
	a=list(map(int,input().split()))
	road.unite(a[0]-1,a[1]-1)

for i in range(L):
	a=list(map(int,input().split()))
	rail.unite(a[0]-1,a[1]-1)

road.definite()
rail.definite()

dic={}
# print(road.num,rail.num)

for i in range(N):
	key=str(road.num[i])+":"+str(rail.num[i])
	if key in dic:
		dic[key].append(i)
	else:
		dic[key]=[i]

# print(dic)
res=[0 for i in range(N)]
for i in dic.values():
	l=len(i)
	for j in i:
		res[j]=l

for i in res:
	print(i,end=" ")
print("")	

















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

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut sum_list = vec![0; 1 << n];

    for bit in 0..1 << n {
        for i in 0..n {
            if (bit & 1 << i) != 0 {
                sum_list[bit] += a[i];
            }
        }
    }

    let q: usize = read();
    for _ in 0..q {
        let m: u64 = read();
        if sum_list.iter().any(|&v| v == m) {
            println!("yes");
        } else {
            println!("no");
        }
    }
}



Measured memory_bytes: 13124
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def mileage(t, v, vl, vr):
    assert(0 <= vl <= v and 0 <= vr <= v)
    # 最高速度v, 左端での速度vl, 右端での速度vr, 秒数tの時の走行距離を求める
    l = v-vl
    r = t-(v-vr)
    if l > r:
        tmp = (l+r)/2
        l = tmp
        r = tmp
    ret = 0
    ret += l*l/2+vl*l
    ret += (r-l)*v
    ret += (t-r)*vr+(t-r)*(t-r)/2
    return ret

def main():
    n = ri()
    lt = rli()
    lv = rli()
    lt.append(0)
    lv.append(0)
    lefts = [0] # 各区間の左端での列車の速度
    for i in range(n):
        left = min(lefts[i]+lt[i], lv[i], lv[i+1])
        offset = 0
        for j in range(i+1, n+1):
            left = min(left, offset+lv[j])
            offset += lt[j]
        lefts.append(left)
    # print(lefts)
    ans = 0
    for i in range(n):
        ans += mileage(lt[i], lv[i], lefts[i], lefts[i+1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int n, k;
int arr[1005];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	REP(i, 0, n){
		cin >> arr[i];
		
	}
	sort(arr, arr + n);
	int ans = 0;
	REP(i,0,k){
		ans = ans + arr[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long res = 0;
            //     long[] kn = s2iarray(Console.ReadLine().Split(' '));
            //   long[] an = s2iarray(Console.ReadLine().Split(' '));
           int r =  s2i(Console.ReadLine());
            Console.WriteLine(r * 2* Math.PI);


        }
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 27464
n,m=map(int,input().split())
x=list(map(int,input().split()))
a=[]
for i in range(m):
  a.append([])
for i in range(n):
  a[x[i]%m].append(x[i])
for i in range(m):
  a[i].sort()
ans=0
for i in range(1,(m+1)//2):
  if len(a[i])<len(a[m-i]):
    t=m-i
  else:
    t=i
  pairs=0
  r=0
  count=1
  for j in range(len(a[t])):
    if a[t][j]==r:
      count+=1
    else:
      pairs+=count//2
      count=1
      r=a[t][j]
  pairs+=count//2
  ans+=len(a[m-t])
  ans+=min((len(a[t])-len(a[m-t]))//2,pairs)
if m%2==0:
  ans+=len(a[m//2])//2
ans+=len(a[0])//2
print(ans)


Measured memory_bytes: 99124
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  int i;
  for(i=0;i<n;i++) cin >> s[i];
  sort(s.begin(),s.end());
  int cnt = 0;
  for(i=0;i<n;i++){
    if(s[i] != s[i+1]) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;

int n,k,a[N],f[N<<2];
void pushup(int o){
	f[o]=max(f[o<<1],f[o<<1|1]);
}
int ask(int l,int r,int o,int ld,int rd){
	if(l==r)return f[o];
	if(ld<=l&&rd>=r)return f[o];
	int mid=l+r>>1,ans=0;
	if(rd>mid)ans=max(ans,ask(mid+1,r,o<<1|1,ld,rd));
	if(ld<=mid)ans=max(ans,ask(l,mid,o<<1,ld,rd));
	return ans;
}
void modify(int l,int r,int o,int x,int y){
	if(l==r){
		f[o]=y;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)modify(l,mid,o<<1,x,y);
	else modify(mid+1,r,o<<1|1,x,y);
	pushup(o);
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),a[i]++;
	for(int i=1;i<=n;i++){
		int x=ask(1,300001,1,max(1,a[i]-k),min(300001,a[i]+k))+1;
		modify(1,300001,1,a[i],x);
	}
	printf("%d\n",f[1]);
}

Measured memory_bytes: 9096
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main()
{
	map<char, int> hold;
	string a;
	cin >> a;
	for (int i = 0; i < a.size(); ++i)
		hold[a.at(i)]++;
	
	bool check = true;
	for (auto it = hold.begin(); it != hold.end(); ++it)
		if (it->second % 2 != 0)
			check = false;

	if (check)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> A(N+2);
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }
    A[0] = numeric_limits<int64_t>::max();
    A[N+1] = numeric_limits<int64_t>::min();

    // vector< vector<int64_t> > dp(N+1, vector<int64_t>());
    int64_t cash = 1000;
    int64_t kabu = 0;
    for(int i=1; i<=N; i++) {
        if(A[i-1] >= A[i] && A[i] <= A[i+1]) {
            kabu += cash / A[i];
            cash -= (cash / A[i]) * A[i];
        } else if(A[i-1] <= A[i] && A[i] >= A[i+1]) {
            cash += kabu * A[i];
            kabu = 0;
        }
        // cerr << i << ' ' << cash << ' ' << kabu << endl;
    }

    cout << cash << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = (m); i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b)
{
    ll t;
    while (b != 0)
    {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int gcd(int a, int b)
{
    int t;
    while (b != 0)
    {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
ll recfact(ll start, ll n)
{
    ll i;
    if (n <= 16)
    {
        ll r = start;
        for (i = start + 1; i < start + n; i++)
            r = r * i % mod;
        return r % mod;
    }
    i = n / 2;
    return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m)
{
    if (n < m)
        return 0;
    ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
    return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
    if (firstItr < 0 || secondItr > int(str.size() - 1))
        return str;
    while (firstItr < secondItr)
    {
        swap(str[firstItr], str[secondItr]);
        firstItr++;
        secondItr--;
    }
    return str;
}
std::string RunLengthEncoding(std::string str)
{
    int itr = 0;
    std::string res;
    while (itr < int(str.size()))
    {
        char tmp = str[itr++];
        int length = 1;
        while (itr < int(str.size()) && str[itr] == tmp)
        {
            ++itr;
            ++length;
        }
        res.push_back(tmp);
        res += to_string(length);
    }
    return res;
}
std::string split(std::string str, size_t first_itr, bool isFront)
{
    if (first_itr < 0 || first_itr > str.size())
    {
        return str;
    }
    else
    {
        if (isFront)
        {
            std::string tmp;
            for (size_t i = 0; i < first_itr; i++)
            {
                tmp.push_back(str.at(i));
            }
            return tmp;
        }
        else
        {
            std::string tmp;
            for (size_t i = first_itr; i < str.size(); i++)
            {
                tmp.push_back(str.at(i));
            }
            return tmp;
        }
    }
}

int main()
{
    str s,t,u;cin>>s>>t;
    int a,b;cin>>a>>b;
    cin>>u;
    if(u==s)--a;
    else --b;
    cout<<a<<" "<<b<<endl;
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

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

const int mod = 1e9 + 7;
const int N = 200005;

bool isPrime (ll n){
    if (n < 5 || n % 2 == 0 || n % 3 == 0)
        return (n == 2 || n == 3);
    ll maxP = sqrt (n) + 2;
    for (ll p = 5; p < maxP; p += 6)
        if (n % p == 0 || n % (p + 2) == 0)
            return false;
    return true;
}


void solve(){
	ll n;
	cin >> n;
	set<pair<ll, ll>>p;
	for(ll i = 2; i <= sqrt(n); i++){
		if(n % i == 0){
			if(i == n/i and i != 1 and isPrime(i)) p.insert({i,i});
			else{
				if(i != 1 and isPrime(i))p.insert({i,i});
				if(n/i != 1 and isPrime(n/i))p.insert({n/i,n/i});
			}
		}
	}
	if(p.empty()){
		cout << (n > 1 ? 1:0) << endl;
		return ;
	}
	ll cnt = 0;
	while(true){
		while(!p.empty() and n % (*(p.begin())).fst != 0)
			p.erase(p.begin());
		if(p.empty()){
			cout << cnt << endl;
			return ;
		}
		ll temp = (*(p.begin())).fst, v = (*(p.begin())).snd;
		n /= temp;
		p.erase(p.begin());
		p.insert({temp*v, v});
		cnt++;
		if(n == 1){
			cout << cnt << endl;
			return ;
		}
	}
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3732
def main():
    n = int(input())
    a = list(map(int, input().split()))
    MAX = 10**18
    if 0 in a:
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > MAX:
            print(-1)
            return
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21472
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll poc(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
bool cmp(ppll a,ppll b){
    return a.first.first+a.first.second<b.first.first+b.first.second;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    vector<ppll> v;
    rep(i,0,n){
        ll w,s,vv;cin>>w>>s>>vv;
        v.push_back({{s,w},vv});
    }
    sort(v.begin(),v.end(),cmp);
    ll dp[20001];
    fill(dp,dp+20001,-inf);
    ll ans=0;
    dp[0]=0;
    rep(i,0,n){
        ll s=v[i].first.first,w=v[i].first.second,co=v[i].second;
        rrep(j,s,0){
            ll ne=j+w;
            Max(dp[ne],dp[j]+co);
            Max(ans,dp[ne]);
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,k=MAP()
if a<=k:
    k-=a
    print(0,max(0,b-k))
else:
    print(a-k,b)

Measured memory_bytes: 38256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>


#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	IOS

		ll n; 
	cin >> n;
	string s;
	set<string> ss;
	for (int i = 0; i < n; i++){
		cin >> s;
		ss.insert(s);
	}
	cout << ss.size();
	getchar();
	getchar();
	return 0;
}

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

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string x;
    cin>>x;
    for(int i=2;i<=x.length();i+=2)
    {
        string y=x.substr(0,(x.length()-i)/2);
        string z=y+y;
        string temp=x.substr(0,x.length()-i);
        if(temp==z)
        {
            cout <<x.length()- i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
void solve(){
	int n, k;
	cin >> n >> k;
	int count = 0;
	while(n > 0){
		n/=k;
		count++;
	}
	cout << count << endl;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] h = new int[n];
    for(int i=0; i<n; i++){
      h[i] = sc.nextInt();
    }
    
    int ans = 0;
    int j=1;
    while(j<n){
      int m=0;
      while(j<n && h[j-1]>=h[j]){
        m++;
        j++;
      }
      j++;
      if(ans<m){
        ans=m;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50796
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

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

  vector<int16_t> X;

  for (int n=0; n<N; ++n) {
    int x;
    cin >> x;
    X.push_back(x);
  }

  uint64_t min_cost = UINT64_MAX;
  
  for (int place=1; place<=100; ++place) {
    uint64_t cost = 0;
    for (auto x : X)
      cost += (x-place)*(x-place);

    min_cost = min(min_cost, cost);
  }

  cout << min_cost << endl;

  return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;
using Graph=vector<vector<int>>;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>h(n);
    Graph g(n);
    rep(i,0,n){
        cin>>h.at(i);
    }
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }
    int c=0;
    rep(i,0,n){
        bool x=true;
        for(auto j:g.at(i)){
            if(h.at(i)<=h.at(j)) x=false;
        }
        if(x)c++;
    }
    cout<<c<<endl;
return 0;
}

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

int main() {
	int N, M, K;
	cin >> N >> M;
	vector<int> vec(N * (M + 1));
	vector<int> vecK(N);
	int sum = 0;
	int count1 = 0;
	int count2 = 0;

	for (int i = 0; i < vec.size(); i++)
		cin >> vec.at(i);

	for (int i = 0; i < N; i++) {
		vecK.at(i) = vec.at(sum);
		vec.at(sum) = 0;
		sum = sum + 1 + vecK.at(i);
	}

	for (int i = 0; i < M; i++) {
		for (int j = 0; j < vec.size(); j++) {
			if (vec.at(j) == i + 1)
				count1++;
		}
		if (count1 == N)
			count2++;
		count1 = 0;
	}
	cout << count2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

int h, w, k;

void paint_row(vector<vector<char>>& g, int r) {
  for (int i = 0; i < h; i++) {
    if (i == r) {
      for (int j = 0; j < w; j++) {
        g[i][j] = '.';
      }
      return;
    }
  }
}

void paint_column(vector<vector<char>>& g, int c) {
  for (int j = 0; j < w; j++) {
    if (j == c) {
      for (int i = 0; i < h; i++) {
        g[i][j] = '.';
      }
      return;
    }
  }
}

int black(vector<vector<char>>& g) {
  int res = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (g[i][j] == '#') res++;
    }
  }
  
  return res;
}

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  cin >> h >> w >> k;
  vector<vector<char>> G(h, vector<char>(w));

  rep (i, h) {
    rep (j, w) {
      cin >> G[i][j];
    }
  }

  ll ans = 0; //combination pattern;
  for (int row = 0; row < (1 << h); row++) {
    vector<vector<char>> g1 = G;
    for (int i = 0; i < h; i++) {
      if (row & (1 << i)) {
        paint_row(g1, i);
      }
    }

    for (int col = 0; col < (1 << w); col++) {
    vector<vector<char>> g2 = g1;
      for (int j = 0; j < w; j++) {
        if (col & (1 << j)) {
          paint_column(g2, j);
        }
      }

      if (black(g2) == k) ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3568
d='URLD'
*y,s,t=open(0).read().split()
h,w,n,r,c=map(int,y)
b=[h,w,w,h]
o=[h-r+1,c,w-c+1,r]
a=0
for i,j in enumerate(d):
  x=o[i]
  for k in range(n):
    x+=(s[k]==j)
    if x>b[i]:a=1
    x-=(dict(zip(d,d[::-1]))[t[k]]==j)*x>1
print('YNEOS'[a::2])

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

int main() {
  ll l,r,res=2018;
  cin>>l>>r;
  if(r-l>=2019) r=l+2018;
  for(ll i=l; i<=r-1; i++){
    for(ll j=i+1; j<=r; j++){
      ll p=(i*j)%2019;
      res=min(p,res);
    }
  }
  cout<<res;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    cnt = {}
    for i in range(N):
        result = input()
        cnt[result] = cnt.get(result, 0) + 1
    for result in ("AC", "WA", "TLE", "RE"):
        print("{} x {}".format(result, cnt.get(result, 0)))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
long n,m;
vector<long[2]> var(28);
long f(vector<long> c,long t){
    c[t-1]=1;
    bool jud=true;
    for(long i = 0; i < n; i++){
        if(c[i]==0)
            jud=false;
    }
    if(jud)
        return 1;
    long count=0;
    for(auto x:var){
        if(x[0]==t&&c[x[1]-1]!=1)
            count+=f(c,x[1]);
        else if(x[1]==t&&c[x[0]-1]!=1)
            count+=f(c,x[0]);
    }
    return count;
}
int main(){
    cin>>n>>m;
    for(int i = 0; i < m; i++)
        cin>>var[i][0]>>var[i][1];
    long count=0;
    for(auto x:var){
        if(x[0]==1){
            vector<long> c(n,0);
            c[0]=1;
            count+=f(c,x[1]);
        }
        
    }
    cout<<count;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

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

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t; cin >> s >> t;
	int f[26] = {0};
	For(i,0,s.size()) f[s[i]-'a'] = 1;
	For(i,0,t.size()) {
		if (f[t[i]-'a'] == 0) {
			cout << -1;
			return 0;
		}
	}

	int ans, last;
	vector < vector <int> > arr(26);
	For(i,0,s.size()) arr[s[i]-'a'].pb(i);
	For(i,0,t.size()) {
		int letter = t[i]-'a';
		if (i == 0) {
			int index = *lower_bound(all(arr[letter]),0);
			last = index;
			ans = index;
			continue;
		}

		auto it = upper_bound(all(arr[letter]), last);
		if (it != arr[letter].end()) {
			ans += (*it-last);
			last = *it;
			continue;
		}

		int index = *lower_bound(all(arr[letter]),0);
		ans += (s.size()+index-last);
		last = index;
	}
	cout << ans+1;
	return 0;
}

Measured memory_bytes: 1736
n = int(input())
ans = ''
for i in range(10000):
    # 偶奇で最下位桁を決定
    if n % 2 == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n -= 1
    # 1ビット右シフト(-2進数)
    n //= -2
print(int(ans))

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var N,M int

	fmt.Scan(&N,&M)

	var rin []int
	for i := 0;i < N;i++{
		rin = append(rin,0)
	}

	for i:= 0;i < M;i++{
		var a,b int
		fmt.Scan(&a,&b)
		rin[a-1]++
		rin[b-1]++
	}

	for i := 0;i < N;i++{
		fmt.Println(rin[i])
	}
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    #2n-1Cn

    fac1=1
    fac2=1
    facs=[1,1]
    for i in range(2,2*N):
        facs.append(facs[-1]*i%mod)

    # fac1=pow(facs[N],mod-2,mod)
    # fac2=pow(facs[N-1],mod-2,mod)
    # tot=facs[2*N-1]*fac1%mod
    # tot*=fac2
    # tot%=mod
    def comb(N,r):
        fac1=pow(facs[r],mod-2,mod)
        fac2=pow(facs[N-r],mod-2,mod)
        tot=(facs[N]*fac1%mod)*fac2%mod
        return tot
    tot=comb(2*N-1,N)
    if N-1<=K:
        print(tot)
    
    
    else:#0のへやがk+1より多くあるとボツ
        r=0
        for i in range(1,N-(K+1)+1):
            n=N-i
            r+=comb(N,i)*comb(n+i-1,i-1)%mod
            r%=mod
        print((tot-r)%mod)





if __name__ == "__main__":
    main()

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 1005;

int n, m, K;
char s[N][N];
int a[N][N];

int main() {
	read(n), read(m), read(K);
	for (int i = 1; i <= n; ++i) {
		readStr(s[i] + 1);
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		int lst = 0;
		for (int j = 1; j <= m; ++j) {
			if (s[i][j] == '#') {
				++cnt;
				for (int k = lst + 1; k <= j; ++k) {
					a[i][k] = cnt;
				}
				lst = j;
			}
		}
		if (lst) {
			for (int k = lst + 1; k <= m; ++k) {
				a[i][k] = cnt;
			}
		}
	}
	for (int j = 1; j <= m; ++j) {
		int lst = 0;
		for (int i = 1; i <= n; ++i) {
			if (a[i][j]) {
				for (int k = lst + 1; k < i; ++k) {
					a[k][j] = a[i][j];
				}
				lst = i;
			}
		}
		for (int k = lst + 1; k <= n; ++k) {
			a[k][j] = a[lst][j];
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			print(a[i][j], " \n"[j == m]);
		}
	}
}


Measured memory_bytes: 5668
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e9;

vector<int> n;

void gen(int cur, int l){
  if (cur > (ll)1e11) return;
  n.eb(cur);
  for (int i = max(0LL, (ll)l-1LL); i < min(10LL, (ll)l+2LL); i++){
    gen(cur * 10LL + i, i);
  }
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    for (int i = 1; i < 10; i++){
      gen(i, i);
    }

    int k;
    cin >> k;

    //cout << n.size() << '\n';

    sort(n.begin(), n.end());

    //cout << (int)(lower_bound(n.begin(), n.end(), 3234566667LL) - n.begin()) << '\n';

    cout << n[k-1] << '\n';

//    for (int i =0 ; i < 20; i++) cout << n[i] << ' ';

    return 0;
}


Measured memory_bytes: 10604
s = input()
i = 0
c = 0
while i != len(s):
  if i == 0:
    b = s[i]
    c += 1
    i += 1
  else:
    if s[i] == b:
      if i+1 == len(s):
        break
      else:
        b = s[i] + s[i+1]
        c += 1
        i += 2
    else:
      b = s[i]
      c += 1
      i += 1
      
print(c)

Measured memory_bytes: 3500
#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

struct chtime{
	chrono::system_clock::time_point stm;
	auto nget() { return chrono::system_clock::now();}
	chtime() { stm = nget();}
	uint64_t gtm(){
		return chrono::duration_cast<chrono::milliseconds>(nget()-stm).count();
	}
	void disp(){ cerr << gtm() <<"\n";}
};
chtime tmq;

ll CTM;
const ll TLMT = 2 *1000;
const ll ZGZ = 1000000;
mt19937 mran(202005282);
int D;
VI C(26);
vector<VI> S(366, VI(26));

inline int xran(int su){ return mran() % su;}
inline int xran2(int su){ return mran() & su ;} //su = (2^n)-1
inline ll xran9(ll su){ return mran() & su ;}

vector<double> mkfq(int n = 100){
	vector<double> zzx(n+1);
	rep(i, n+1)  zzx[i] = 1 -(1 - i /(1.0*n)) * (1 - i/(1.0*n));
	return zzx;
}

inline ll clpt(const VI& t){
	VI usd(27, -1);
	//VL rtn(D);
	ll ans = 0;
	rep(i, D){
		ans += S[i][t[i]];
		usd[t[i]] = i;
		rep(j, 26){
			ans -= (ll)C[j] * (i - usd[j]);
		}
		//dbg(i, ans);
	}
	return ans;
}

inline ll clpt2(const VI& t){
	VI usd(27, -1);
	//VL rtn(D);
	ll ans = 0;
	rep(i, D){
		ans += S[i][t[i]];
		usd[t[i]] = i;
		rep(j, 26){
			ans -= (ll)C[j] * (i - usd[j]);
		}
		//dbg(i, ans);
	}
	return ans;
}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >>D;
	rep(i, 26) cin >> C[i];
	rep(i, D) rep(j, 26) cin >>S[i][j];
	auto fqd = mkfq(100);
	for(auto& z: fqd) z /=100;
	ll BST = 0, ALBST =0;
	int tct =0, chcnt =0;
	rep(i, 99) xran2(1023);
	
	VI idt(D);
	rep(i, D) idt[i] = i%26;
	auto rc = clpt(idt);
	BST = ALBST = rc;
	//dbg(rc);
	for(; (tct &511 != 501) || (CTM = tmq.gtm()) < TLMT - 50; tct++){
	
		int p1 = xran(26), p2 = xran(26);
		while(idt[p1]==p2) p2 = xran(26);
		int op1 = idt[p1];
		idt[p1] = p2;
		ll cur = clpt(idt);
		if(BST < cur){
			BST = cur;
		}else{
			double zan = 1.0 - 1.0 * CTM / TLMT; 
			int qw= zan*100;
			
			if(xran2(1023) < fqd[qw] * 1023){
				//BST = cur; chcnt++;
			}
			//if(tct%ZGZ==0) dbg(zan, qw, BST);
			idt[p1] = op1;
		}
		ALBST =max(ALBST, BST);
		
	}
	
	//dbg(ALBST, BST, tmq.gtm(), tct, chcnt);
	rep(i, D) cout <<idt[i]+1 <<"\n";
	return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
#include <string.h>

int main(void)
{
    int q,a,b,i,x;
    char str[1010],str2[1010],p[20];
    
    scanf("%s",str);
    scanf("%d",&q);
    
    for(i=0;i<q;i++){
        scanf("%s%d%d",p,&a,&b);
        strcpy(str2,str);
        
        if(strcmp(p,"reverse")==0){
            x=b;
            for(;a<=b;a++){
                str[a]=str2[x];
                x--;
            }
        }else if(strcmp(p,"replace")==0){
            x=0;
            scanf("%s",str2);
            for(;a<=b;a++){
                str[a]=str2[x];
                x++;
            }
        }else{
            for(;a<=b;a++){
            printf("%c",str[a]);
            }
        printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int a = sc.nextInt();
    static int b = sc.nextInt();

    public static void main(String[] args) {
        int d = a / b;
        int r = a % b;
        double f = (double)a / (double) b;
        System.out.print(d + " " + r + " ");
        System.out.printf("%f\n", f);

    }
}



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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

typedef struct Fenwick{
  int n;
  int *bit;
} Fenwick;
Fenwick *new_Fenwick(int n){
  Fenwick *ret = (Fenwick*)malloc(sizeof(Fenwick));
  ret->n = n;
  ret->bit = (int*)malloc(sizeof(int)*(n+1));
  memset(ret->bit,0,sizeof(int)*(n+1));
  return ret;
}
void free_Fenwick(Fenwick *f){
  free(f->bit);
  free(f);
}
void add_FW(Fenwick *f,int a,int w){
  int x;
  for(x=a;x<=f->n;x+=x&-x)f->bit[x]+=w;
}
int sum_FW(Fenwick *f,int a){
  int ret = 0;
  int x;
  for(x=a;x>0;x-=x&-x)ret+=f->bit[x];
  return ret;
}
int lower_bound_FW(Fenwick *f,int w){
  int x=0;
  int k=1;
  if(w<=0)return 0;
  while((k<<1)<=f->n)k<<=1;
  for(;k>0;k>>=1){
    if(x+k<=f->n && f->bit[x+k]<w){
      w-=f->bit[x+k];
      x+=k;
    }
  }
  return x+1;
}

int cnt[26];
int tmp[26];
int po[525252];
vi ord[26];
int tail[26];

int main(){
  string s;
  cin>>s;
  int n = s.size();
  // ?????§??????
  REP(i,n)cnt[s[i]-'a']++;
  REP(i,26)if(cnt[i]%2==1){
    puts("-1");
    return 0;
  }
  // ?????????
  ll yose = 0;
  int c1 = 0;
  string t;
  REP(i,n){
    int c = s[i]-'a';
    tmp[c]++;
    if(tmp[c]>cnt[c]/2){
      po[i]=1;
      c1 += 1;
    }else{
      po[i]=0;
      t += s[i];
      yose += c1;
    }
  }
  REP(i,n)if(po[i])t+=s[i];
  n = n/2;
  string a = t.substr(0,n);
  string b = t.substr(n);
  reverse(ALL(b));
  REP(i,n){
    int c = a[i]-'a';
    ord[c].push_back(i+1);
  }
  Fenwick *f = new_Fenwick(n+30);
  ll ans = 0;
  REP(i,n){
    int c = b[i]-'a';
    int x = ord[c][tail[c]++];
    ans += sum_FW(f,n+30) - sum_FW(f,x);
    add_FW(f,x,1);
  }
  printf("%lld\n",ans+yose);
  return 0;
}

Measured memory_bytes: 5860