akhauriyash/Code-Regression huggingface dataset:
fun main(arr:Array<String>) {
    val (x,y) = readLine()!!.split(" ").map { it.toLong() }
    var cur = x;
    var ans = 0
    for(i in (1..y)) {
        if(cur <= y) {
            ans++
            cur *= 2
        } else {
            break
        }
    }
    println(ans)
}



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

int main(void)
{
  double time1, time2;
  string result;
  while (cin >> time1 >> time2)
  {
    if (time1 < 35.50 and time2 < 71.00)
    {
      result = "AAA";
    }
    else if (time1 < 37.50 and time2 < 77.00)
    {
      result = "AA";
    }
    else if (time1 < 40.00 and time2 < 83.00)
    {
      result = "A";
    }
    else if (time1 < 43.00 and time2 < 89.00)
    {
      result = "B";
    }
    else if (time1 < 50.00 and time2 < 105.00)
    {
      result = "C";
    }
    else if (time1 < 55.00 and time2 < 116.00)
    {
      result = "D";
    }
    else if (time1 < 70.00 and time2 < 148.00)
    {
      result = "E";
    }
    else
    {
      result = "NA";
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
# https://atcoder.jp/contests/agc046/tasks/agc046_b
#
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def combination_mod(n, r, mod=998244353):
    # mod取りながらcombination
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


MOD = 998244353
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

A, B, C, D = read_ints()
i_max = C - A
j_max = D - B

'''
A+i,B+jまで広げたときを考える
このときの通りの総数は

更新則



これちがう↓
(1+(A+i-1,B+j)まで広げたの通りの総数)*(1+(A+i,B+j-1)の通りの総数)-1 となる
'''


dp = [[0] * (j_max + 1) for _ in ra(i_max + 1)]
# 初期値代入
for i in ra(i_max + 1):
    dp[i][0] = pow(B, i, MOD)

for j in ra(j_max + 1):
    dp[0][j] = pow(A, j, MOD)

# ループ
for i, j in product(range(1, i_max + 1), range(1, j_max + 1)):

    dp[i][j] = dp[i][j - 1] * (A + i) + dp[i - 1][j] * \
        (B + j) - (A + i - 1) * (B + j - 1)  # WA
    dp[i][j] = dp[i][j - 1] * (A + i) + dp[i - 1][j] * \
        (B + j) - (A + i - 1) * (B + j - 1) * dp[i - 1][j - 1]  # AC
    dp[i][j] %= MOD

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


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

const int N=1e5+10;
long long dp[N];

int main() {
    int n, k;
    cin >> n >> k;
    long long ans = (long long)n*n;
    if ( k>0 )
        for (int i=n; i>0; i--) {
            ans -= min(i,k)-1;
            int m=n/i;
            ans -= (m-1)*min(i,k);
            ans -= min(n-m*i+1, k);
        }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = new HashMap[Int,Array[Int]]
    val log = ListBuffer.empty[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map.remove(l(1)).get
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


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

int arr[10002];

int main(){
    int n;
    while(cin >> n, n){
        char x;
        // 4は番兵
        arr[0] = 4;
        for(int i = 1; i <= n; i++){
            cin >> arr[i];
        }
        arr[n+1] = 4;

        int delMax = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= 3; j++){
                int l = i-1, r = i+1, tmpdel = 0, tmpcnt = 1, color = j;
                while(1){
                    while(arr[l] == color)   l--, tmpcnt++;
                    while(arr[r] == color)   r++, tmpcnt++;
                    if(tmpcnt >= 4) tmpdel += tmpcnt;
                    else            break;
                    tmpcnt = 0;
                    if(arr[l] != arr[r])    break;
                    color = arr[l];
                }
                delMax = max(delMax, tmpdel);
            }
        }

        cout << n - delMax << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int h, w, ans[1005][1005];
char arr[1005][1005];
int solve(int i, int j)
{
    if ( i >= h || j >= w || arr[i][j] == '#' )
        return 0;
    if ( i == h - 1 && j == w - 1 )
        return 1;
    int ans1 = 0, ans2 = 0, ans3 = 0;
    if ( ans[i][j] == -1 )
    {
        ans1 = (solve(i + 1, j))% mod;
        ans2 = (solve(i, j + 1)) % mod;
        ans3 = (ans1 + ans2) % mod;
        ans[i][j] = ans3;
    }
    else
        ans3 = (ans[i][j]) % mod;
    return (ans3) % mod;
}
int main()
{
    Hello
    memset(ans, -1, sizeof ans);
    cin >> h >> w;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> arr[i][j];
    cout << solve(0, 0);
    return 0;
}



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

# define    ll            long long
# define    vi             std::vector<int>
# define    int            long long
# define    setbits(x)     __builtin_popcountll(x)
# define    zrobits(x)     __builtin_ctzll(x)
# define    fast           ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
# define    pb             push_back
# define    fn             for(int i=0;i<n;i++)
# define    rep(i,a,b)      for(ll i=a;i<b;i++)
# define    all(x)         x.begin(), x.end()
# define    allr(a)        a.rbegin(), a.rend()
# define    PI             3.14159265358979323846
# define    mod            1000000007
# define    endl           "\n"
# define    pii            pair<ll,ll>
# define    deb1(x)        cout<<#x<<" "<<x<<endl;
# define    deb2(x,y)      cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
# define    deb3(x,y,z)    cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

void Onigiri()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans1 = max(a, b) * max(c, d);
	int ans2 = max(a, b) * min(c, d);
	int ans3 = min(a, b) * max(c, d );
	int ans4 = min(a, b) * min(c, d);
	ans1 = max(ans1, ans2);
	ans3 = max(ans3, ans4);
	cout << max(ans1, ans3);

}
signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t=1;
// # 	cin >> t;
	while (t--)
	{
		Onigiri(); 
	}
}

Measured memory_bytes: 3640
import sys

input = sys.stdin.readline
MOD = 1000000007

A,B,N = map(int,input().split())


    

def f(x):
    return  int(A*x/B) - A*int(x/B)


x = min(B-1,N)

print(f(x))



#if A == B:
#    x = A - 1
#    print(x)
#
#else:
#    res = 0
#    left = 0
#    right = N
#
#    left_res = 0
#    right_res = 0
#
#    while (left+1) != right:
#        left_res = f(left)
#        right_res = f(right)
#        mid = (right+left)//2
#        if left_res > right_res:
#            right = mid
#        else:
#            left = mid
#
#    print(max(f(left),f(right)))

Measured memory_bytes: 61864
class Acc2D:
    def __init__(self, a, K):
        h, w = len(a), len(a[0])
        self.acc2D = self._build(h, w, a)
        self.K = K

    def _build(self, h, w, a):
        ret = [[0] * (w + 1) for _ in range(h + 1)]
        for r in range(h):
            for c in range(w):
                ret[r + 1][c + 1] = ret[r][c + 1] + ret[r + 1][c] - ret[r][c] + a[r][c]
                # 末項は必要に応じて改変すること
        return ret

    def get(self, r1, r2, c1, c2):
        # [r1,r2), [c1,c2) : 0-indexed
        if r1 < 0: r1 = 0
        if r2 >= self.K * 2: r2 = self.K * 2
        if c1 < 0: c1 = 0
        if c2 >= self.K * 2: c2 = self.K * 2
        acc2D = self.acc2D
        return acc2D[r2][c2] - acc2D[r1][c2] - acc2D[r2][c1] + acc2D[r1][c1]


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())

    g = [[0] * (K * 2) for _ in range(K * 2)]
    for _ in range(N):
        x, y, c = input().split()
        x = int(x) % (K * 2)
        y = (int(y) - (K if c == 'B' else 0)) % (K * 2)
        g[x][y] += 1  # White

    acc2d = Acc2D(g, K)
    ans = -1
    for r in range(K):
        for c in range(K):
            t = acc2d.get(0, r, 0, c)
            t += acc2d.get(0, r, c + K, c + K * 2)
            t += acc2d.get(r, r + K, c, c + K)
            t += acc2d.get(r + K, r + K * 2, 0, c)
            t += acc2d.get(r + K, r + K * 2, c + K, c + K * 2)
            ans = max(ans, t, N - t)
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


Measured memory_bytes: 107356
import java.util.Scanner;

// 7
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                a[i][j] = sc.nextInt();
        int N = sc.nextInt();
        int[] b = new int[N];
        for(int i = 0; i < N; i++)
            b[i] = sc.nextInt();

        int count = 0;
        //if count >= 6 then break
        int i, j, k = 0;
        for(i = 0; i < 3; i++)
            for(j = 0; j < 3; j++) {
                for(k = 0; k < N; k++) {
                    if(b[k] == a[i][j]) {
                        a[i][j] = -1;
                        ++count;
                        if(count == 7) {
                            i = j = k = 10;
                            System.out.println("Yes");
                        }
                    }
                }
            }

        String ans = "No";
        if(count <= 6) {
            for(int ii = 0; ii < 3; ii++)
                if(a[ii][0] == -1 && a[ii][1] == -1 && a[ii][2] == -1) {
                    ans = "Yes";
                    break;
                }
            for(int jj = 0; jj < 3; jj++)
                if(a[0][jj] == -1 && a[1][jj] == -1 && a[2][jj] == -1) {
                    ans = "Yes";
                    break;
                }

            if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) {
                ans = "Yes";
            }
            if(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1) {
                ans = "Yes";
            }
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 35840
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

ll pow2(long long n) {
	ll ret = 1;
	ll x = 2;
    while (n > 0) {
        if (n & 1) ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x *= x;
        n >>= 1;  // n を1bit 右にずらす
    }
    return ret;
}

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> k;
	long double p = 0.0;
	vector<ll> cc;
	for(i=n;i>=1;i--) {
		c = 0;
		a = i;
		while(a<k) {
			c++;
			a *= 2;
		}
		//cc.push_back(c);
		p += (long double)1/n/pow2(c);
	}
	/*
	x = 0;
	for(i=0;i<cc.size();i++) {
		x += pow2(c-cc[i]);
	}
	//cout << x << ' ' << c << ' ' << pow2(c) << endl;
	p = (long double)x / pow2(c) / n;
	*/
	cout << fixed << setprecision(10);
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 3692
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_ = sorted(a)
b_ = sorted(b)
f = sum(b_[i]<a_[i] for i in range(n))
if f:
    print("No")
    exit(0)
g = sum(b_[i-1]>=a_[i] for i in range(1,n))
if g:
    print("Yes")
    exit(0)
da = dict()
for i in range(n):
    da[a_[i]] = i
ca = list(map(lambda x:da[x],a))
db = dict()
for i in range(n):
    db[b_[i]] = i
cb = list(map(lambda x:db[x],b))
cb2 = [None]*n
for i in range(n):
    cb2[ca[i]] = cb[i]
cnt = 1
c = cb2[0]
while c:
    c = cb2[c]
    cnt += 1
if cnt ==  n:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 38252
import numpy as np
from functools import lru_cache

N, K = map(int, input().split())
A = np.array(input().split(), dtype = np.int64)

bit_cnt = [((A >> k) & 1).sum() for k in range(40)]

@lru_cache(maxsize = 10 ** 6)

def F(K, k = 39):
    #K以下、k-bit目まで見た(inclusive)の和、最大値
    if k == -1: #最後まで見た時
        return 0
    bit = 1 << k
    #k-bitを使う
    x = 0
    if K >= bit:
        x = ((N - bit_cnt[k]) << k) + F(K - bit, k - 1)
    #k-bitを使わない
    y = (bit_cnt[k] << k) + F(min(K, bit - 1), k - 1)
    return max(x, y)

ans = F(K)
print (ans)

Measured memory_bytes: 28936
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
using namespace std;

void dfs(int s)
{
	
}
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if(n>1&&a>b)
	{
		puts("0");
		return 0;
	}
	if(n==1)
	{
		if(a==b)
		{
			puts("1");
		}
		else
		{
			puts("0");
		}
		return 0;
	}

	else
	{
		long long ans = 0;
		ans+=(n-2)*(b-a)+1;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//region Template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = max(lhs, rhs.val); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = min(lhs, rhs.val); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion


vl factorize(ll x, bool uniqueOnly) {
    assert(x>1);
    vl res;
    int sq = sqrt(x);
    RNG(d, 2, sq+1) {
        while(x%d==0) {
            x /= d;
            res.push_back(d);
        }
    }
    if(x>1) res.push_back(x);
    if(uniqueOnly)
        res.resize(unique(ALL(res)) - res.begin());
    return res;
}

signed main() {
    FASTIO

    ll n; cin>>n;

    vl upf = factorize(2*n, true);
    vl pf;
    for(ll p : upf) {
        ll exp=p;
        while(1.*exp*p < 1e18 && 2*n % (exp*p) == 0)
            exp *= p;
        pf.push_back(exp);
    }

    ll best=1e18;

    FOR(bm, 1<<pf.size()) {
        ll x=1, y=1;
        FOR(i,pf.size()) {
            if(bm & (1<<i))
                x *= pf[i];
            else
                y *= pf[i];
        }
//
        auto res = crt({0,y-1}, {x,y});
        debug(res);
        if(res.first > 0)
            best |= MIN(res.first);
    }

    cout<<best<<endl;

}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cmath>
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
typedef long long lli;
typedef long li;
typedef pair<int,int> PI;
typedef pair<long,int> PLI;
typedef pair<int,long> PIL;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<long long> VLL;
typedef priority_queue<int> PQ;
typedef priority_queue<long> PQL;
typedef priority_queue<long long> PQLL;
#define FAST ios::sync_with_stdio(0)
#define forz(n) for (long i = 0; i < n; i++)
#define forv(i,x,y) for (long i=x; i<y; i++)
#define rforz(a,n) for (long i = a; i < n; i++)
#define forlz(n) for (long int i = 0; i < n; i++)
#define TRAV(it, v) for(auto it = v.begin(); it != v.end(); it++) 
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define SQ(a) (a)*(a)
#define UM unordered_map
#define US unordered_set
#define LB(v,x) lower_bound(v.begin(),v.end(),x);
#define UB(v,x) upper_bound(v.begin(),v.end(),x);
#define CUBE(a) (a)*(a)*(a)
#define SORT(v) sort(v.begin(),v.end());
#define SORTC(v,c) sort(v.begin(),v.end(),c);
#define Pi 3.14159265358979323846
 
 
#define module 1000000007
 
 
lli gcd(lli x,lli y){
    if(x==0) return y;
    return gcd(y%x,x);
}
 
PL Egcd(lli x,lli y){
    if(x==0) return MP(0,1);
    PL t=Egcd(y%x,x);
    return MP(t.S-t.F*(y/x),t.F);
}
 

bool comp(PLL a,PLL b){
    return a.S > b.S;
}
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
void solve2(){
   lli n,a,b;
   cin>>n>>a>>b;
   lli sum = (n/(a+b))*a;
   lli t = n%(a+b);
   sum += min(t,a);
   cout<<sum<<'\n';
   return;
}   
 
int main(){
    FAST;
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //=====================================code starts here
    // lli n;
    // cin>>n;
    // while(n--){
        solve2();
    // }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s;
  cin >> t;
  int dp[s.size()+1][t.size()+1];
  for (int i = 0; i <= s.size(); i++) {
      dp[i][0] = 0;
  }
  for (int i = 0; i <= t.size(); i++) {
      dp[0][i] = 0;
  }
  for (int i = 1; i <= s.size(); i++) {
      for (int j = 1; j <= t.size(); j++) {
          if (s[i-1] == t[j-1]) {
              dp[i][j] = 1 + dp[i-1][j-1];
          } else {
              dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
          }
      }
  }
  string ans;
  int p1 = s.size();
  int p2 = t.size();
  while(p1 != 0 && p2 != 0) {
      if (dp[p1-1][p2] == dp[p1][p2]) {
          p1--;
          continue;
      }
      if (dp[p1][p2-1] == dp[p1][p2]) {
          p2--;
          continue;
      }
      ans.pb(s[p1-1]);
      p1--; p2--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 38752
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N,T; cin >> N >> T;
    long long ans = 0;
    long long end = 0;
    for(int i=0;i<N;i++){
        int t; cin >> t;
        if(end < t){ans += T; end = t+T;}
        else if(end<t+T){ans += t+T-end; end = t+T;}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    char ch;
    cin >> ch;
    if (islower(ch)){
      cout << 'a' << endl;
    }
    else if (isupper(ch)){
      cout << 'A' << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
i = 1
while i<=1000000:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for j in range(H):
        if j%2 == 1:
            for k in range(1,W+1):
                if k%2 ==1:
                    print('.',end='')
                else:
                    print('#',end='')
        else:
            for m in range(1,W+1):
                if m%2 ==1:
                    print('#',end='')
                else:
                    print('.',end='')
        print()
    print()


Measured memory_bytes: 7000
#listに[a,b,c]形式で入力取得
box = list(map(int, input().split()))

#listの5と7の数をサーチする
#5が2個、7が2個ならYESを出力。違うならNO
if box.count(5) == 2 and box.count(7) == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int curMaxLength = 0;
        var hash = new RollingHash(s);
        for (int i = 0; i < s.Length; i++)
            for (int j = i; j < s.Length; j++)
                while (curMaxLength < j - i && j + curMaxLength < n && hash.Slice(i, curMaxLength + 1) == hash.Slice(j, curMaxLength + 1)) curMaxLength++;
        Console.WriteLine(curMaxLength);
    }
}

class RollingHash
{
    const ulong MASK30 = (1UL << 30) - 1;
    const ulong MASK31 = (1UL << 31) - 1;
    const ulong MOD = (1UL << 61) - 1;
    const ulong POSITIVIZER = MOD * ((1UL << 3) - 1);
    static ulong Base;
    static ulong[] powMemo = new ulong[5000 + 1];
    static RollingHash()
    {
        Base = (ulong)new Random().Next(129, int.MaxValue);
        powMemo[0] = 1;
        for (int i = 1; i < powMemo.Length; i++)
            powMemo[i] = CalcMod(Mul(powMemo[i - 1], Base));
    }

    ulong[] hash;

    public RollingHash(string s)
    {
        hash = new ulong[s.Length + 1];
        for (int i = 0; i < s.Length; i++)
            hash[i + 1] = CalcMod(Mul(hash[i], Base) + s[i]);
    }

    public ulong Slice(int begin, int length)
    {
        return CalcMod(hash[begin + length] + POSITIVIZER - Mul(hash[begin], powMemo[length]));
    }

    private static ulong Mul(ulong l, ulong r)
    {
        var lu = l >> 31;
        var ld = l & MASK31;
        var ru = r >> 31;
        var rd = r & MASK31;
        var middleBit = ld * ru + lu * rd;
        return ((lu * ru) << 1) +
            ld * rd +
            ((middleBit & MASK30) << 31) +
            (middleBit >> 30);
    }

    private static ulong CalcMod(ulong val)
    {
        val = (val & MOD) + (val >> 61);
        if (val > MOD) val -= MOD;
        return val;
    }
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> h(n),v(n,0);
  for(int i=0;i<n;i++)
    cin>>h[i];
  
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(h[a]>h[b])
      v[b]-=1;
    else if(h[a]<h[b])
      v[a]-=1;
    else
    {
      v[a]=-1;v[b]=-1;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if(!v[i])
      ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4052
#include<stdio.h>
int main()
{
	int i, n, v, j, c;
	int a[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i < n; i++) {
		for (c = 0; c < n; c++) {
			if (c == n - 1) {
				printf("%d\n", a[c]);
				break;
			}
			printf("%d ", a[c]);
		}
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j]>v ) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		
		
	}
	for (c = 0; c < n; c++) {
		if (c == n - 1) {
			printf("%d\n", a[c]);
			break;
		}
		printf("%d ", a[c]);
	}

}

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

ll mod = 7 + pow(10,9);

int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k;i <= n+1;i++){
        ll a = (n-i)*i + i + 1;
        ans += a;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int M;
int H[100000];
int A[100000];
int B[100000];
int mx[100000];
int main(){
  int i;
  int res = 0;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY=(0);e98WHCEY<(M);e98WHCEY++){
      rd(A[e98WHCEY]);A[e98WHCEY] += (-1);
      rd(B[e98WHCEY]);B[e98WHCEY] += (-1);
    }
  }
  for(i=(0);i<(M);i++){
    chmax(mx[A[i]], H[B[i]]);
    chmax(mx[B[i]], H[A[i]]);
  }
  for(i=(0);i<(N);i++){
    if(mx[i] < H[i]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// int N, M, H[1d5], A[1d5], B[1d5];
// int mx[1d5];
// {
//   int res = 0;
//   rd(N,M,H(N),(A--,B--)(M));
//   rep(i,M){
//     mx[A[i]] >?= H[B[i]];
//     mx[B[i]] >?= H[A[i]];
//   }
//   rep(i,N) if(mx[i] < H[i]) res++;
//   wt(res);
// }


Measured memory_bytes: 6224
n = int(input())
a_list = [int(i) for i in input().split()]
d_list =[]

for i in range(n):
	for j in range(n-i):
		# print(i,n-j-1)
		d_list.append(abs(a_list[i]-a_list[n-j-1]))
		
print(max(d_list))

Measured memory_bytes: 3188
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int X[MAXN];
int W[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), L = readInt(), T = readInt();
    for (int i = 0; i < n; i++) {
		X[i] = readInt();
		W[i] = readInt() - 1;
    }
    ll diff = 0;
    vector <int> vec;
    for (int i = 0; i < n; i++) {
    	ll v;
    	if (!W[i]) {
			v = (X[i] + T) % L;
			diff += (X[i] + T) / L;
    	} else {
			v = ((X[i] - T) % L + L) % L;
			diff -= (T - X[i] + L - 1) / L;    	
    	}
    	vec.pb(v);
    }
    sort(vec.begin(), vec.end());
    diff %= n;
    diff += n;
    diff %= n;
    rotate(vec.begin(),vec.begin()+diff,vec.end());
	for (int i = 0; i < n; i++) {
		cout << vec[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll INF = 2e9;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n)cin >> h[i];
	vector<int>dp(n,INF);
	rep(i, n)
	{
		if (i == 0)dp[i] = 0;
		else
		{
			rep1(j, k)
			{
				if (i - j < 0)break;	
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
	}
	co(dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse

    def div(self, x, y):
        """ MOD除算 """

        return x * pow(y, self.MOD-2, self.MOD) % self.MOD

N = INT()
A = LIST()
B = [0] + [A[i+1] - A[i] for i in range(N-1)]

mt = ModTools(N, MOD)
add = mt.fact[N-1]
cnt = [0] * N
for i in range(1, N):
    cnt[i] = round(cnt[i-1] + add)
    cnt[i] %= MOD
    add *= mt.div(i , (i+1))
    add %= MOD

ans = 0
for i in range(1, N):
    ans += B[i] * cnt[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 63472
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(2,vector<int>(n));
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      cin>>a.at(i).at(j);
  vector<vector<int>> c(2,vector<int>(n,0));
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      c[i][j]=(j==0?a.at(i).at(j):c[i][j-1]+a.at(i).at(j));
      if(i>0)
        c[i][j]=max(c[i][j],c[i-1][j]+a.at(i).at(j));
    }
  }
  cout<<c[1][n-1]<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = -INF; ll z = 0, o = 1;
vl flag, color, D; vector<vector<tuple<ll, ll, ll>>> path;
//***********//
class UnionFind {
public:
	vl rank, par, siz;
	UnionFind() {}
	UnionFind(ll N) {
		rank.resize(N, 0);
		par.resize(N, 0);
		siz.resize(N, 1);
		init(N);
	}
	void init(ll N) {
		for (ll i = 0; i < N; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	ll find(ll x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}
	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x != y) {
			if (rank[x] < rank[y]) {
				par[x] = y;
				siz[y] += siz[x];
			}
			else {
				par[y] = x;
				siz[x] += siz[y];
				if (rank[x] == rank[y]) rank[x]++;
			}
		}
	}
	bool issame(ll x, ll y) {
		return find(x) == find(y);
	}
	ll size(ll x) {
		return siz[find(x)];
	}
};
int main() {
	cin >> N >> M;
	UnionFind UF(N);
	vll L(M);
	for (i = 0; i < N; i++) {
		ll k;
		cin >> k;
		for (j = 0; j < k; j++) {
			ll l;
			cin >> l;
			L[l-1].push_back(i);
		}
	}
	for (i = 0; i < M; i++) {
		if (L[i].size() >= 2) {
			for (j = 0; j < L[i].size() - 1; j++) {
				UF.unite(L[i][j], L[i][j + 1]);
			}
		}
	}
	ll par = UF.find(0);
	for (i = 1; i < N; i++) {
		//debug(i,UF.find(i));
		if (UF.find(i) != par) {
			cout << "NO";
			exit(0);
		}
	}
	cout << "YES";
}


Measured memory_bytes: 6136
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<long long> ans;

void dfs(long long x) {
    if (x > 3234566667) return;
    ans.push_back(x);
    for (int i = -1; i <= 1; i++) {
        int add = x % 10 + i;
        if (0 <= add && add <= 9) {
            dfs(x * 10 + add);
        }
    }
}

int main() {
    int K; cin >> K;
    for (long long i = 1; i < 10; i++) dfs(i);
    sort(ans.begin(), ans.end());
    cout << ans[K-1] << endl;
}

Measured memory_bytes: 4292
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
int ADD(int a, int b) { return (a + b) % MOD; }
int SUB(int a, int b) { return (a - b + MOD) % MOD; }

int main() {
    int N, K; cin >> N >> K;
    vector<int> a(N + 1);
    for (int i = 1; i <= N; i++) cin >> a[i];

    vector<vector<int>> dp(N + 1, vector<int>(K + 1, 0));
    dp[0][K] = 1;
    for (int i = 1; i <= N; i++) {
        vector<int> acc(K + 2, 0);
        for (int j = 0; j <= K; j++) acc[j + 1] = ADD(acc[j], dp[i - 1][j]);
        for (int j = 0; j <= K; j++) {
            dp[i][j] = SUB(acc[min(K, j + a[i]) + 1], acc[j]);
        }
    }
    cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 40192
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>

#define INF 1050000000
#define MOD 1000000007

using namespace std;



int main() {
	int a, b, c; cin >> a >> b >> c;

	if (a == b&&b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}








}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007 
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
using namespace std;
int main()
{
	ll r,d,x;
	cin>>r>>d>>x;
	for(int i=1;i<=10;i++)
	{
		cout<<r*x-d<<endl;
		x = r*x-d;
	}
}

Measured memory_bytes: 256
fun main (args:Array<String>){
    val num = readLine()
    if (num != null) {
        when {
            num.endsWith("3") -> {
                print("bon")
            }
            num.endsWith("0") -> {
                print("pon")
            }
            num.endsWith("1") -> {
                print("pon")
            }
            num.endsWith("6") -> {
                print("pon")
            }
            num.endsWith("8") -> {
                print("pon")
            }
            else -> {
                print("hon")
            }
        }

    }
}

Measured memory_bytes: 35664
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
    //    random_device rnd;
    //    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(A+B,min(A+C,B+C)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    int tp=0;
    for(int i=0;i<n;i++){
        if(s[i]=='I')tp++;
        else tp--;
        ans=max(ans,tp);
    }
    cout<<ans<<endl;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int n, m;
	cin >> n >> m;
	bool red[n], white[n];
	rep(i, 0, n) {
		if(i == 0) {
			red[i] = true;
			white[i] = false;
		} else {
			red[i] = false;
			white[i] = true;
		}
	}

	int count[n];
	rep(i, 0, n) count[i] = 1;

	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if(red[x] and white[x]) {
			red[y] = true;
			white[y] = true;
		} else if(red[x] and white[x] == false) {
			red[x] = white[x] = false;
			red[y] = true;
		} else if(red[x] == false and white[x]) {
			red[x] = white[x] = false;
			white[y] = true;
		}
		count[x]--;
		count[y]++;

		if(count[x] == 0) {
			red[x] = false;
			white[x] = false;
		}
	}

	int rsl = 0;
	rep(i, 0, n) {
		if(count[i] > 0 and red[i]) rsl++;
	}

	cout << rsl << endl;

}


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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

using namespace __gnu_pbds;
typedef tree<
ii,
null_type,
less<ii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

signed main(){
	IOS
	int n,k;cin>>n>>k;
	vi v(n);
	forn(i,n){
		cin>>v[i];v[i]-=k;
		if(i) v[i]+=v[i-1];
	}
	map<int,int> mp;
	int ans = 0;
	ordered_set st;
	int unq=0;
	st.insert({0,++unq});
	forn(i,n){
		ans+=st.order_of_key({v[i],INT_MAX});
		st.insert({v[i],++unq});
	}
	cout<<ans;
}

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


int main(){
    int W,H;
    cin>>H>>W;
    int dp[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int tile;
            if(cin>>tile,tile==0){
                dp[i][j]=(j?dp[i][j-1]:0)+1;
            }else{
                dp[i][j]=0;
            }
        }
    }
    int ans=0;
    typedef pair<int,int> P;
    stack<P,vector<P>> S;
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(S.empty()){
                S.emplace(dp[i][j],i);
                continue;
            }
            P p = S.top();
            if(p.first==dp[i][j]){
                continue;
            }
            if(p.first<dp[i][j]){
                S.emplace(dp[i][j],i);
                continue;
            }
            while(!S.empty()){
                ans=max(ans,p.first*(i-p.second));
                S.pop();
                if(S.empty()){
                    S.emplace(dp[i][j],p.second);
                    break;
                }
                if(S.top().first>=dp[i][j]){
                    p=S.top();
                    continue;
                }else{
                    S.emplace(dp[i][j],p.second);
                    break;
                }
            }
        }
        while(!S.empty()){
            P p = S.top(); S.pop();
            ans=max(ans,p.first*(H-p.second));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10748
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


long long fac[1000000], finv[1000000], inv[1000000];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    u64 x, y;
    cin >> x >> y;

    u64 n;
    if ((x + y) % 3)
    {
        cout << "0\n";
        return 0;
    }
    n = (x + y) / 3;
    if (x < n || y < n)
    {
        cout << "0\n";
        return 0;
    }

    x = x - n;
    y = y - n;

    // init(x + y, MIN(x, y));

    COMinit();
    cout << COM(x + y, MIN(x, y)) << "\n";
    //cout << C[x + y][MIN(x, y)] << "\n";
    return 0;
}



Measured memory_bytes: 23680