akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let k: usize = sc.read();
    let n: usize = sc.read();

    if k % 2 == 0 {
        print!("{}", k / 2);
        for _ in 1..n {
            print!(" {}", k);
        }
        println!();
    } else {
        let x = (k + 1) / 2;
        let mut ans = vec![x; n];
        let mut cur = n - 1;
        for _ in 0..(n / 2) {
            ans[cur] -= 1;
            if ans[cur] == 0 {
                cur -= 1;
            } else {
                for i in (cur + 1)..n {
                    ans[i] = k;
                }
                cur = n - 1;
            }
        }

        for i in 0..n {
            if ans[i] == 0 {
                break;
            }
            if i > 0 {
                print!(" ");
            }
            print!("{}", ans[i]);
        }
        println!();
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    string s, t;
    cin >> s >> t;
    int rez = 0;
    for (int ctr1 = 0; ctr1 < s.length(); ++ctr1)
        rez += s[ctr1] == t[ctr1];
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    s = [input() for _ in range(N)]
    ans = 0
    chk = {}
    for tmp in s:
        d1 = "".join(sorted(list(tmp)))
        if d1 in chk.keys():
            ans += chk[d1]
            chk[d1] += 1
        else:
            chk[d1] = 1
    print(ans)


resolve()


Measured memory_bytes: 24976
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int mod=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll gcd(ll x,ll y){
	if(y)return gcd(y,x%y);
	else return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}


int main() {
	int x,y;
	bool f=false;
	cin>>x>>y;
	rep(i,0,x+1)
		if(2*i+4*(x-i)==y)f=true;
	if(f)print("Yes");
	else print("No");

}


Measured memory_bytes: 3616
N = int(input())
A = [int(input()) for i in range(N)]
B = 0
C = 1
for j in range(N):
  if A[B] == 2:
    print(C)
    break
  elif j == N-1:
    print('-1')
  else:
    B = A[B]-1
    C += 1

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

int main(){
    int N;
    cin >> N;
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h,h+N);
    int sum =0;
    for(int i =0;i<N;i++){
        if(i == N-1){
            sum += h[N-1]/2;
            continue;
        }
        sum += h[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
char cm[200][200];
int im[200][200];
 int W,H;
bool visited[200][200];
int sy,sx;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
typedef pair<int,int> P;

int bfs();

int main(){
 

  while(1)
    {
      cin >> W >> H;
      if(W == 0 && H == 0)break;
      memset(im,0,sizeof(im));
      memset(visited,false,sizeof(visited));
      for(int i=0;i<H;i++)
	{
	  for(int j=0;j<W;j++)
	    {
	      cin >> cm[i][j];
	      if(cm[i][j] == '#'){
		im[i][j] = 8;
	      }
	      else if(cm[i][j] == '@')
		{
		  sy = i;
		  sx = j;
		  im[i][j] = 1;
		}
	    }
	}

      cout << bfs() << endl;
      /*     
 for(int i=0;i<H;i++){
	for(int j=0;j<W;j++)cout << im[i][j];
	cout << endl;
      }
      */

    }
}

int bfs()
{
  int maxx = 0;
  queue<P> que;
  que.push(P(sx,sy)); 
  im[sy][sx] = 1;
  int cou=1;
  visited[sy][sx] = true;

  while(que.size())
    {
      P p = que.front();
      que.pop();

      for(int i=0;i<4;i++)
	{
	  int nx = p.first + dx[i],ny = p.second + dy[i];

	  if(0 <= nx && nx < W && 0 <= ny && ny < H && cm[ny][nx] != '#' && !visited[ny][nx])
	    {
	      visited[ny][nx] = true;
	      cou++;
	      im[ny][nx]=cou;
	      maxx = max(maxx,im[ny][nx]);
	      que.push(P(nx,ny));
	    }
	}
      
    }
return cou;
}

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

int main() {
  int n, q; cin >> n >> q;
  string s; cin >> s;
  
  vector<int> ac(n, 0);
  vector<int> a(n, 0);
  
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      a[i] = 1;
      ac[i + 1] = 1;
    }
  }
  
  vector<int> a_ac(n, 0);
  partial_sum(ac.begin(), ac.end(), a_ac.begin());
  
  for (int i = 0; i < q; i++) {
    int l, r; cin >> l >> r;
    int ans = a_ac[r - 1] - a_ac[l - 1];
    cout << ans << endl;
  }
}

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

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void solve(){
    ll n,k,ans;
    cin>>n>>k;
    if(n>=k)ans=min(abs(k-n%k),n%k);
    else{
        ans=min(n,abs(n-k));
    }
    cout<<ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int main(void)
{
	ll N, A, B;
	cin >> N >> A >> B;
	if(N == 1){
		if(A == B){
			PrintLn(1);
		}else{
			PrintLn(0);
		}
	}else if(N == 2){
		if(A <= B){
			PrintLn(1);
		}else{
			PrintLn(0);
		}
	}else{
		if(A <= B){
			PrintLn(B * (N - 1) + A - (A * (N - 1) + B) + 1);
		}else{
			PrintLn(0);
		}
	}
	return 0;
}


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

int main(){
    int N,T;
    cin >> N >> T;
    vector<int> A(N),B(N),id(N);
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
        id[i] = i;
    }
    sort(id.begin(),id.end(),[&](int i,int j){
        return A[i]<A[j];
    });
    vector<vector<int>> dp(N+2,vector<int>(T+2,0));
    for(int t=0;t<T;t++) for(int i=0;i<N;i++){
        dp[i+1][t] = max(dp[i+1][t],dp[i][t]);
        if(t+A[id[i]]<=T) dp[i+1][t+A[id[i]]] = max(dp[i+1][t+A[id[i]]],dp[i][t]+B[id[i]]);
        else dp[i+1][T] = max(dp[i+1][T],dp[i][t]+B[id[i]]);
    }
    int ans = 0;
    for(int t=0;t<=T;t++) for(int i=1;i<=N;i++) ans = max(ans,dp[i][t]);
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <cstdio>
#include <algorithm>

using namespace std;

int a, b, c, ans;

char thing[100000];

int main() {

	scanf("%s", &thing);
	for (int i = 0; a == 0; i++) {
		if (thing[i] == 'g') {
			b++;
		} else if (thing[i] == 'p') {
			c++;
		} else {
			a++;
		}
	}
	ans = floor((b - c)/2);

	printf("%d", ans);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c, tmp;
  
  scanf("%d %d %d", &a, &b, &c);
  
  tmp = a;
  a = b;
  b = tmp;
  
  tmp = a;
  a = c;
  c = tmp;
  
  printf("%d %d %d", a, b, c);
  
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {+0,+1,+0,-1};
const static int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-12;

int main(){
  int H,W;
  while(~scanf("%d %d",&H,&W)){
    int stage[51][51];
    bool patternB[51][51];
    bool patternC[51][51];
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	int point;
	scanf("%d",&point);
	stage[y][x] = point;
      }
    }
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	int pattern;
	scanf("%d",&pattern);
	patternB[y][x] = (bool)pattern;
      }
    }
    int H_C,W_C;
    scanf("%d %d",&H_C,&W_C);
    for(int y=0;y<H_C;y++){
      for(int x=0;x<W_C;x++){
	int pattern;
	scanf("%d",&pattern);
	patternC[y][x] = (bool)pattern;
      }
    }


    int res = -INF;
    for(int ly=0;ly<H;ly++){
      for(int lx=0;lx<W;lx++){
	for(int ry=ly;ry<H;ry++){
	  for(int rx=lx;rx<W;rx++){

	    //size check
	    if(ry - ly + 1 != H_C || rx - lx + 1 != W_C) continue;
	    
	    //pattern check
	    bool isok = true;
	    int sum = 0;
	    for(int by=ly,cy=0;by<=ry;by++,cy++){
	      for(int bx=lx,cx=0;bx<=rx;bx++,cx++){
		if(patternB[by][bx] != patternC[cy][cx]){
		  isok = false;
		}
		sum += stage[by][bx];
	      }
	    }

	    if(!isok) continue;

	    else{
	      res = max(res,sum);
	    }
	  }
	}
      }
    }
    if(res == -INF){
      printf("NA\n");
    }
    else{
      printf("%d\n",res);
    }
  }
}


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

const function<ll(ll, ll)> addQll = [](ll l, ll r) { return l + r; };

template <typename T>
class node {
public:
	T val, lazy;
	ll size;
	node<T> *l, *r;
	node() {}
	node(T val_, T lazy_, ll size_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : val(val_), lazy(lazy_), size(size_), l(l_), r(r_) {}
	void init(T val_, T lazy_, ll size_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		lazy = lazy_;
		size = size_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicLazySegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id1, id2;
	func_t merge1, merge2;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node(ll size) {
		pool[it].init(id1, id2, size);
		return &pool[it++];
	}
	node<T> *push(node<T> *t) {
		if (t == nullptr || t->lazy == id2) return t;
		if (t->size > 1) {
			if (t->l == nullptr) t->l = new_node(t->size / 2);
			if (t->r == nullptr) t->r = new_node(t->size / 2);
			t->l->lazy = merge2(t->l->lazy, t->lazy);
			t->r->lazy = merge2(t->r->lazy, t->lazy);
		}
		t->val = merge2(t->val, t->lazy * t->size);
		t->lazy = id2;
		return t;
	}
	node<T> *suc(ll l, ll r, node<T> *t, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return t;
		if (t == nullptr) t = new_node(ub - lb);
		if (l <= lb && ub <= r) {
			t->lazy = merge2(t->lazy, val);
			return t;
		}
		t = push(t);
		int c = (lb + ub) / 2;
		t->l = suc(l, r, t->l, lb, c, val);
		t->r = suc(l, r, t->r, c, ub, val);
		t->val = merge1(t->l == nullptr ? id1 : merge2(t->l->val, t->l->lazy * t->l->size), t->r == nullptr ? id1 : merge2(t->r->val, t->r->lazy * t->r->size));
		return t;
	}
	T sub(ll l, ll r, node<T> *t, ll lb, ll ub) {
		if (t == nullptr || ub <= l || r <= lb) return id1;
		t = push(t);
		if (l <= lb && ub <= r) return t->val;
		int c = (lb + ub) / 2;
		return merge1(sub(l, r, t->l, lb, c), sub(l, r, t->r, c, ub));
	}
public:
	DynamicLazySegmentTree(ll n_, T id1_, T id2_, func_t merge1_, func_t merge2_, int PMAX = 1e7)
		: n(size(n_)), id1(id1_), id2(id2_), merge1(merge1_), merge2(merge2_), root(nullptr), pool(PMAX), it(0) {}
	void update(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	DynamicLazySegmentTree<ll> lst(n, 0, 0, addQll, addQll, 3e5);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", lst.find(s, t));
		}
		else {
			cin >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}

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

int main() {
	int n;
	int balls[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) { cin >> balls[j]; }
		int b = 0, c = 0; int drop_balls = 0;
		for (int j = 0; j < 10; j++) {
			if (b < balls[j]) { b = balls[j]; drop_balls = j;}
			else if (c < balls[j]) { c = balls[j]; drop_balls = j;}
			else {cout << "NO" << endl;break;}
		}
		if (drop_balls == 9)cout << "YES" << endl;	
	}
}

Measured memory_bytes: 3080
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

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

// main function
int main()
{
	ll T = 0;
	ll X = 0;
	cin >> T >> X;
	cout << (double)T / X << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define rc(s) return cout<<s,0
using namespace std;

int n,a[50005],maxi,ans;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++){
        maxi=max(maxi,a[i-1]);
        if(a[i]>=maxi) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, functools, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ; count = 0; pro = 1

n=int(input())
count=0
# @functools.lru_cache(maxsize=None)
memo=[0]*(n+1)
memo[0]=0
def func(n):
    if memo[n] or n==0:return memo[n]
    # print(n)
    # global count
    # count+=1
    # if count%10==0:print(count)
    if n==0:
        return 0
    re=inf
    k=s=1
    while 6**k<=n:
      re=min(re,func(n-6**k)+1)
      k+=1
    while 9**s<=n:
      re=min(re,func(n-9**s)+1)
      s+=1

    re=min(re,func(n-1)+1)
    memo[n]=re
    return re
    
print(func(n))
# print(memo)



Measured memory_bytes: 66396
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e3+7, mod = 1e9 + 7;
int h, w, dp[N][N];
char sqr[N][N];

int solve(int i, int j)
{
	if(i == h && j == w)
		return 1;
	dp[i][j] = 0;
	if(sqr[i][j] == '#')
		return 0;
	if(i <= h - 1 && dp[i+1][j] == -1)
		dp[i+1][j] = solve(i+1, j);
	if(j <= w - 1 && dp[i][j+1] == -1)
		dp[i][j+1] = solve(i, j+1);
	if(i <= h - 1)
		dp[i][j] += dp[i+1][j], dp[i][j] %= mod;
	if(j <= w - 1)
		dp[i][j] += dp[i][j+1], dp[i][j] %= mod;
	return dp[i][j];
}


int32_t main()
{
	fast;

	cin >> h >> w;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			cin >> sqr[i][j], dp[i][j] = -1;
	solve(1, 1);
	cout << solve(1, 1);
	return 0;
}

Measured memory_bytes: 9216
var
 n,m,i,j,x:longint;
 a:array[0..101,0..101] of char;
begin
 readln(n,m);
 for i:=1 to n do
  begin
   for j:=1 to m do
    read(a[i,j]);
    readln;
    end;
    for i:=1 to n do
    begin
    for j:=1 to m do
    begin
    x:=0;
    if a[i,j]='#' then write('#')
                  else begin
                        if a[i-1,j-1]='#' then inc(x);
                        if a[i-1,j]='#' then inc(x);
                        if a[i-1,j+1]='#' then inc(x);
                        if a[i,j-1]='#' then inc(x);
                        if a[i,j+1]='#' then inc(x);
                        if a[i+1,j-1]='#' then inc(x);
                        if a[i+1,j]='#' then inc(x);
                        if a[i+1,j+1]='#' then inc(x);
                        write(x);
                       end;
   end;
   writeln;
   end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

vector<int> pos[26];

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

	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		pos[s[i] - 'a'].push_back(i);
	}

	for(int i = 0; i < 26; i++) {
		if(pos[i].size() <= 1) continue;
		int head = 0, tail = pos[i].size() - 1;
		while(abs(head - tail) > 1) {
			int num = tail - head + 1;
			int len = pos[i][tail] - pos[i][head] + 1;
			if(num * 2 > len) {
				cout << pos[i][head] + 1 << " " << pos[i][tail] + 1 << endl;
				return 0;
			}

			int d1 = pos[i][head + 1] - pos[i][head], d2 = pos[i][tail] - pos[i][tail - 1];
			if(d1 > d2) {
				head++;
			}
			else {
				tail--;
			}
		}
		if(pos[i][tail] - pos[i][head] <= 2) {
			cout << pos[i][head] + 1 << " " << pos[i][tail] + 1 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec A(N); readvec(A);

    vec s(N + 1);
    s[0] = 0;
    REP(i, N) s[i + 1] = s[i] + A[i];

    SORT(s);
    int ans = 0, tmp = 0, b = INF;
    REP(i, N + 1){
        if(s[i] != b){
            ans += tmp * (tmp - 1) / 2;
            b = s[i];
            tmp = 1;
        }else{
            tmp++;
        }
    }
    ans += tmp * (tmp - 1) / 2;

    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a;
    rep(i,5){
        cin >> a;
        if(a==0){
            cout << i+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define fi first
#define se second
#define pi pair<int, int>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define per(i, a, n) for(int i = a; i >= n; i--)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define Y "YES"
#define N "NO"
using namespace std;

bool n;

//void solve() {
//	cin >> n;
//}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);

	cin >> n;
	cout << !n;
}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F solver = new F();
        solver.solve(1, in, out);
        out.close();
    }

    static class F {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            final int n = in.nextInt();
            final int m = in.nextInt();
            if (n + m == 15) out.println("+");
            else if (n * m == 15) out.println("*");
            else out.println("x");
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#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 in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    char C; cin >> C;
    string vowel = "aiueo";
    cout << (vowel.find(C) == string::npos ? "consonant" : "vowel") << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int nn, mm, dd;
double ans;
double n, m, d;

int main(){
	std::cin >> n >> m >> d;
	if(d == 0.0){
		ans = (m-1)/n;
	}else{
		ans = 2*(m-1)*(n-d)/(n*n);
	}
	printf("%.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
constexpr ll MOD = 1000000007;
//---------------------------------//



int main() {
	string T, P;
	cin >> T >> P;
	
	bool ans = true;
	puts([&] {
		vector<int> v[2];
		REP(times, 2) {
			int pos = 0, idx = 0;
			while (pos < T.size() && idx < P.size()) {
				if (T[pos] == P[idx]) {
					v[times].emplace_back(pos);
					++pos; ++idx;
				}
				else ++pos;
			}
			if (idx < P.size()) return false;
			reverse(ALL(T));
			reverse(ALL(P));
		}
		
		for (int &u : v[1]) u = T.size() - 1 - u;
		reverse(ALL(v[1]));
		return v[0] == v[1];
		
		
	}() ? "yes": "no");
	
	return 0;
}



Measured memory_bytes: 8996
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL M = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int main(){
	int n;cin>>n;
	string s,t;
	cin>>s>>t;
	int x=0;
	REPP(l,1,SZ(s)+1){
		bool legit=1;
		REP(j,l){
			if(s[n-l+j]==t[j]){
			}
			else {legit=0;break;}
		}
		if(legit)x=l;
	}
	cout<<2*n-x;
}


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

using namespace std;

int main(){
   int n,m;
   cin>>n>>m;
   long long ans;
   if(n==m)ans=2;
   else if(abs(n-m)==1)ans=max(n,m);
   else ans=0;   
   for(long long i=2;i<=min(m,n);i++){
         ans*=i*i%1000000007;
         ans%=1000000007;
   }
   cout<<ans<<endl;
}

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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

int main() {
	int mrange = 101010;
	vector<bool> is_prime(mrange, true);
	is_prime[0] = false, is_prime[1] = false;
	for (int i = 2; i*i < mrange; i++) {
		if (!is_prime[i]) continue;
		for (int j = 2*i; j < mrange; j += i) is_prime[j] = false;
	}

	vector<bool> a(mrange, false);
	rep(i,mrange) {
		if (i % 2 == 0) continue;
		if (is_prime[i] and is_prime[(i + 1)/2]) a[i] = true; 
	}
	vector<int> psum(mrange + 1);
	psum[0] = 0;
	rep(i,mrange) {
		psum[i + 1] = psum[i] + (a[i]?1:0);
	}

	int q;
	cin >> q;
	rep(i,q) {
		int l, r;
		cin >> l >> r; r++;
		cout << psum[r] - psum[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int N;
	char S[128] = "";
	int i, x = 0, max = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (N < 1 || 100 < N) {
		puts("f*ck!!!!!");
		return 2;
	}
	if (scanf("%127s", S) != 1) return 1;
	if (S[N - 1] == '\0' || S[N] != '\0') {
		puts("OMG!!!!!");
		return 2;
	}
	for (i = 0; i < N; i++) {
		if (S[i] == 'I') x++;
		else if (S[i] == 'D') x--;
		if (x > max) max = x;
	}
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

// 90分取り組んでできなかったので解説を見て実装した。
fn main() {
    input! {
        N: String,
        K: usize,
    }

    // 左で0埋めすることにより、桁数はNの桁数(L)としてよい。
    let L: usize = N.len();

    // dp0[i][j] 上からi桁目まで決めて、0でない桁がj個あり、その後に何を選んでもNより小さいことが確定している数の個数
    let mut dp0: Vec<Vec<usize>> = vec![vec![0; K + 1]; L + 1];

    // dp1[i][j] 上からi桁目まで決めて、0でない桁がj個あり、その後に何を選んでもNより小さいことが確定しているというわけではない数の個数
    let mut dp1: Vec<Vec<usize>> = vec![vec![0; K + 1]; L + 1];

    // https://drken1215.hatenablog.com/entry/2020/02/09/225300
    // たとえば、S = 314159 のときは
    // 000000 〜 099999
    // 100000 〜 299999
    // 300000 〜 314159
    // に場合分けして考える

    // 000000-099999
    dp0[0][0] = 1;

    // 100000-299999
    let n0: usize = N[0..=0].parse().unwrap();
    dp0[0][1] = n0 - 1;

    // 300000-314159
    dp1[0][1] = 1;

    for i in 1..L {
        let n_i: usize = N[i..=i].parse().unwrap();

        // k == 0
        {
            let dp0_dp0 = dp0[i - 1][0];
            let dp1_dp0 = if n_i >= 1 { dp1[i - 1][0] } else { 0 };
            dp0[i][0] = dp0_dp0 + dp1_dp0;

            let dp0_dp1 = 0;
            let dp1_dp1 = if n_i == 0 { dp1[i - 1][0] } else { 0 };
            dp1[i][0] = dp0_dp1 + dp1_dp1;
        }

        for k in 1..=K {
            //// まずdp0 ////

            // dp0[i-1]に対して、0を選んだ場合 + 1~9を選んだ場合
            let dp0_dp0 = dp0[i - 1][k] + dp0[i - 1][k - 1] * 9;

            // dp1[i-1]に対して、0を選んだ場合 + 1~(n_i - 1)を選んだ場合
            let dp1_dp0 = match n_i {
                0 => 0,
                1 => dp1[i - 1][k],
                _ => dp1[i - 1][k] + dp1[i - 1][k - 1] * (n_i - 1),
            };

            dp0[i][k] = dp0_dp0 + dp1_dp0;
            //// ここまでdp0 ////

            //// ここからdp1 ////

            let dp0_dp1: usize = 0;
            let dp1_dp1: usize = if n_i == 0 {
                dp1[i - 1][k]
            } else {
                dp1[i - 1][k - 1] * 1
            };
            dp1[i][k] = dp0_dp1 + dp1_dp1;

            //// ここまでdp1 ////
        }
    }

    let ans = dp0[L - 1][K] + dp1[L - 1][K];
    println!("{}", ans);
}


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

int main(void){
    int N;
    cin>>N;
    int cnt=0;
    bool ok=false;
    int D1,D2;
    rep(i,N){
        cin>>D1>>D2;
        if(D1==D2){
            cnt++;
        }
        else{
            cnt=0;
        }
        if(cnt==3){
            ok=true;
            break;
        }
    }
    
    if(ok==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
   
}


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

using namespace std;

using ll = long long;

ll Solve() {
    ll n, k = 2;
    bool is_find = false;
    cin >> n;

    for ( ; k * (k - 1) <= 2 * n; ++k) {
        if (k * (k - 1) == 2 * n) {
            is_find = true;
            break;
        }
    }

    if (!is_find) return -1;

    cout << "Yes\n";
    cout << k << "\n";

    vector<vector<int>> s(k);
    int idx = 1;
    for (int i = 0; i < k; ++i) {
        for (int j = i + 1; j < k; ++j) {
            s[i].push_back(idx);
            s[j].push_back(idx);
            ++idx;
        }
    }

    for (int i = 0; i < k; ++i) {
        cout << s[i].size() << " ";
        const int size = s[i].size();
        for (int j = 0; j < size; ++j)
            cout << s[i][j] << " \n"[j == size - 1];
    }
    return 0;
}

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

    ll res = Solve();
    if (res == -1) cout << "No\n";

    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >=n; i--)    
#define iter(s) for(auto it:s)
 

#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)

#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse

#define tc ll q;cin>>q;while(q--)
#define pat ll n;cin>>n
#define pat1 vll a(n);forl(i,n)cin>>a[i]
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i]
#define pats string s;cin>>s
#define yesno if(flag)cout<<"YES\n";else cout<<"NO\n"
#define loop forl(i,n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a,b) cout << a << " " << b << endl
#define p3(a,b,c) cout << a << " " << b << " " << c << endl
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832
//**********************************
 
int main(){
    
    pats;
    ll cnt=0;
    vll a;
    forl(i,s.length()){
        if(s[i]=='R'){
            cnt++;
        }else{
            if(cnt!=0){
              a.pb(cnt);
              cnt=0;  
            }
            
        }
    }
    if(cnt!=0){
        a.pb(cnt);
    }
    if(a.size()==0){
        p1(0);
    }else{
        sort(all(a));
        p1(a[a.S-1]);
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;


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

  int ans = 0;
  char now = S[0];
  for(int i = 1; i < S.size(); i++) {
    if (now == S[i]) {
      ans++;
      now = (S[i] == '0') ? '1' : '0';
    }
    else {
      now = S[i];
    }
  }

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

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(void) {
    int num,i;
    char string[1002],*check;
    scanf("%d\n",&num);
    for (i=0; i<num; i++) {
        fgets(string,sizeof(string),stdin);
        while ((check=strstr(string,"Hoshino"))!=NULL) check[6]='a';
        printf("%s",string);
    }
    return 0;
}

Measured memory_bytes: 608
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b,c,x int
    fmt.Scan(&a,&b,&c,&x)
    ans := 0
    for i:=0; i<=a; i++{
        for j:=0; j<=b; j++{
            for k:=0; k<=c; k++{
                if i*500 + j*100+ k*50 == x{
                    ans++
                }
            }
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int k; cin >> k;

	if (k <= 10)
		cout << k << '\n';

	else
	{
		set<int> s;
		for (int i = 1; i < 10; ++i)
			s.insert(i);

		int ans;
		while (k--)
		{
			int num = (*s.begin());
			ans = num;
			s.erase(num);

			int d = num % 10;

			s.insert(num * 10 + d);

			if (d < 9)
				s.insert(num * 10 + d + 1);

			if (d > 0)
				s.insert(num * 10 + d - 1);
		}

		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 9216
N, M = [int(x) for x in input().split()]
p = []; S = []
for _ in range(M):
    p_tmp, S_tmp = input().split()
    p.append(int(p_tmp))
    S.append(str(S_tmp))

AC = [0] * N
WA = [0] * N
for i in range(M):
    if AC[p[i] - 1] == 1:
        continue
    if S[i] == 'AC':
        AC[p[i] - 1] = 1
    else:
        WA[p[i] - 1] += 1
for i in range(N):
    if AC[i] == 0:
        WA[i] = 0
AC_count = sum(AC)
WA_count = sum(WA)
print(AC_count, WA_count)

Measured memory_bytes: 15320
from fractions import gcd
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class SegmentTree:
    # セグ木は 1-indexed
    def __init__(self, n, initial=0):
        """
        n: 配列の大きさ
        initial: 単位元 (RMQでは大きな値)
        """
        self.offset = 2**(n-1).bit_length()  # 2進数表記の長さ
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)
        

    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = a
        for i in range(self.offset-1,0,-1):
            self.seg[i] = gcd(self.seg[i<<1] ,self.seg[(i<<1)+1])

            
    def update(self, k, a):
        """
        k番目の値をaに変更
        """
        k += self.offset
        self.seg[k] = a
        while k:
            k >>= 1
            self.seg[k] = gcd(self.seg[k<<1], self.seg[(k<<1)+1])

            
    def query(self, a, b):
        """
        区間[a, b)に対して最小公倍数を求める
        """
        a += self.offset
        b += self.offset - 1 
        res = self.initial
        while a < b:
            if a & 1:  # 兄弟の右なら
                res = gcd(res, self.seg[a])
                a += 1
            if not b & 1:  # 兄弟の左なら
                res = gcd(res, self.seg[b])
                b -= 1
            a >>= 1
            b >>= 1
        
        if a == b:
            res = gcd(res, self.seg[a])
        
        return res


if __name__ == "__main__":
    N = int(readline())
    A = [int(i) for i in readline().split()]
    seg = SegmentTree(N)
    seg.build(A)

    ans = seg.query(1, N)
    for i in range(N-2):
        tmp = gcd(seg.query(0, i+1), seg.query(i+2, N))
        ans = max(ans, tmp)
    ans = max(ans, seg.query(0, N-1))

    print(ans)

Measured memory_bytes: 16140
#include<stdio.h>
int main(){
	int H,W,m,n,i;
	for(;;){
		scanf("%d %d",&H,&W);
		if(H==W && H==0) break;
		for(m=1;m<=H;m++){
			if(m%2!=0){
				for(n=0;n<W/2;n++){
					printf("#");
					printf(".");
				}
				if(W%2!=0) printf("#");
				printf("\n");
			}
			else{
				for(n=0;n<W/2;n++){
					printf(".");
					printf("#");
				}
				if(W%2!=0) printf(".");
				printf("\n");
			}
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  ll one;
  vector<ll> a(n);
  rep(i, 0, n) {
    cin >> a[i];
    if(a[i] == 1) one = i;
  }
  
  cout << (n+k-3)/(k-1) << "\n";

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a <= 0 && b >= 0) puts("Zero");
	else if (a > 0 || (b - a + 1) % 2 == 0) puts("Positive");
	else puts("Negative");
	return 0;
}

Measured memory_bytes: 256
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<ll(n);++i)
#define repr(i,n) for(ll i=ll(n);i-->0;)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  bool ok = false;
  rep(i,n-2){
    if(a[i]==b[i] and a[i+1]==b[i+1] and a[i+2]==b[i+2])ok=true;
  }
  cout<<(ok?"Yes":"No")<<endl;

}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl


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

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

void solve() {

	string s, t;
	cin >> s >> t;
	vector<bool> sFlag(26, false);
	vector<bool> tFlag(26, false);

	const char a = 'a';

	int n = s.length();

	REP(i, n) {
		if (s[i] != t[i] && sFlag[s[i]-a] == false && tFlag[t[i]-a] == false) {
			char tmp = s[i], tmp2 = t[i];
			FOR(j, i, n - 1) {
				if (s[j] == tmp) {
					s[j] = tmp2;
					continue;
				}
				if (s[j] == tmp2) {
					s[j] = tmp;
					continue;
				}
			}
			tFlag[tmp2 - a] = true;
		}
		sFlag[s[i] - a] = true;
	}

	Yes(s == t);

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 916