akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n,a,b;
	cin >> n >> a >> b;

	int ans = 0;
	for(int i=1 ; i<=n ; i++)
	{
		int sum = 0;
		int temp = i;
		while(temp > 0)
		{
			sum += temp%10;
			temp = temp / 10;
		}

		if(sum >= a && sum <= b)
			ans += i;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    String s = sc.next();
    int ans = 1;

    for(int i = 0; i < n - 1; i++){
      if(s.charAt(i) != s.charAt(i + 1)){
        ans += 1;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

//幅優先探索(グリッド)
//{i, j}:始点
//visit:1:訪問済み
//task:未訪問のマス
//depth:深さ
//操作後のマスは訪問済みにすること
ll bfs(ll h, ll w, vector<string> &grid, ll i, ll j) {
  vector<vector<ll>> visit(h, vector<ll>(w, 0));
  queue<vector<ll>> task;
  task.push({i, j});
  visit.at(i).at(j) = 1;
  ll depth = 0;
  while (task.size() > 0) {
    ll sz = task.size();
    for (ll i = 0; i < sz; i++) {
      ll y = task.front().at(0), x = task.front().at(1);
      if (y + 1 == h - 1 && x == w - 1) return depth + 1;
      if (y - 1 == h - 1 && x == w - 1) return depth + 1;
      if (y == h - 1 && x + 1 == w - 1) return depth + 1;
      if (y == h - 1 && x - 1 == w - 1) return depth + 1;
      if (y + 1 < h && grid.at(y + 1).at(x) == '.' && visit.at(y + 1).at(x) == 0) {
        task.push({y + 1, x});
        visit.at(y + 1).at(x) = 1;
      }
      if (y - 1 >= 0 && grid.at(y - 1).at(x) == '.' && visit.at(y - 1).at(x) == 0) {
        task.push({y - 1, x});
        visit.at(y - 1).at(x) = 1;
      }
      if (x + 1 < w && grid.at(y).at(x + 1) == '.' && visit.at(y).at(x + 1) == 0) {
        task.push({y, x + 1});
        visit.at(y).at(x + 1) = 1;
      }
      if (x - 1 >= 0 && grid.at(y).at(x - 1) == '.' && visit.at(y).at(x - 1) == 0) {
        task.push({y, x - 1});
        visit.at(y).at(x - 1) = 1;
      }
      task.pop();
    }
    depth++;
  }
  return - 1;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) cin >> grid.at(i);
  int cnt = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (grid.at(i).at(j) == '.') cnt++;
  int memo = bfs(h, w, grid, 0, 0);
  if (memo == - 1) neg();
  else cout << cnt - memo - 1 << endl;
}

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

int main() {
  

int x,a,b;
cin>>x>>a>>b;
int p=b-a;
if(p<=0){
    cout<<"delicious"<<endl;
}
else if(p<=x){
    cout<<"safe"<<endl;
}
else{
    cout<<"dangerous"<<endl;
}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)


Measured memory_bytes: 283372
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main (){
  
  double a,b,c;
  double pi;
  pi =3.14159265358979;
  cin >> a>>b>>c;
  
  if(2*c >= a*a*b){
    
    printf("%.10lf\n", 180*atan2(((2*a*a*b-2*c)/(a*a)),a)/pi);
    
          }
                      
    else{
      printf("%.10lf\n",180*atan2(b,((2*c)/(a*b)))/pi);
    }
                      }
  


Measured memory_bytes: 256
S=input()
S=S.replace('/','')
S=list(S)
year=int(S[0]+S[1]+S[2]+S[3])
month=int(S[4]+S[5])
day=int(S[6]+S[7])
if year <= 2018:
  print('Heisei')
elif year >= 2020:
  print('TBD')
elif month <= 3:
  print('Heisei')
elif month >= 5:
  print('TBD')
else:
  print('Heisei')

Measured memory_bytes: 3064
#!/usr/bin/env python3
#ABC57 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,a,b = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse = True)
fact = [1]
for i in range(1,n+1):
    fact.append(fact[i-1]*(i))
def comb(n,r):
    return fact[n]// fact[r] //fact[n-r]
ans = sum(v[:a])/a
print(ans)
M,m = max(v[:a]),min(v[:a])
if M != m:
    c1,c2 = v[:a].count(m),v.count(m)
    print(comb(c2,c1))
else:
    ans = 0
    c = v.count(m)
    for i in range(a,b+1):
        if c >= i:
            ans += comb(c,i)
    print(ans)


Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int f(int x){
    int ans = 0;
    for(int i = 1; i <= x; i++) if(x % i == 0) ans++;
    return ans;
}
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i+=2) if(f(i) == 8) ans++;
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();

		int n = Integer.parseInt(str.split(" ")[0]);
		int l = Integer.parseInt(str.split(" ")[1]);

		int min = l;
		int sum = 0;
		int w = 0;
		for(int i = 0; i<n; i++) {
			w = l + i;
			sum += w;

			if(Math.abs(l + min) > Math.abs(w)) {
				min = i;
			}
		}

		System.out.println(sum - l - min);


	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <set>
using namespace std;


int N;


int main(){
    while(cin >> N && N>0){
        int k,f;
        vector<vector<int>> v(31);
        set<int> s[N+1][31];
        for(int i=1;i<=N;i++){
            cin >> k;
            s[i][0].insert(i);
            for(int j=1;j<=k;j++){
                cin >> f;
                v[f].push_back(i);
            }
        }
        int ans = -1;
        for(int d=1;d<=30;d++){
            for(int i=1;i<=N;i++) s[i][d] = s[i][d-1];
            for(auto x:v[d]){
                for(auto y:v[d]){
                    if(x==y) continue;
                    for(auto a:s[y][d-1]) s[x][d].insert(a);
                }
            }
            for(auto x:v[d]){
                if(s[x][d].size()==N){
                    ans = d;
                    break;
                }
            }
            if(ans!=-1) break;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 6516
def main():
    n = int(input())
    t= list(map(int,input().split()))
    a= list(map(int,input().split()))


    maxh = t[:]
    minflag = [0 for _ in range(n)]

    if t[-1] != a[0]:
        return 0
    else:
        maxflag = t[-1]
    maxh[0] = t[0]
    minflag[0] = 1

    for i in range(1,n):
        if t[i] > t[i-1]:
            minflag[i] = 1

    maxh[-1] = a[-1]
    minflag[-1] = 1
    if a[-1] != t[-1]:
        for i in range(n-2,-1,-1):
            if a[i] > t[i]:
                return 0
            elif a[i] == t[i]:
                if a[i] != maxflag:
                    return 0
                else:
                    minflag[i] = 1
                    break
            maxh[i] = a[i]
            if a[i] > a[i+1]:
                minflag[i] = 1

    res = 1
    for i in range(n):
        if not minflag[i]:
            res *= maxh[i]
            res %= (10**9+7)
    return res % (10**9+7)

print(main())

Measured memory_bytes: 19012
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    H, W = map(int, input().split())

    print("#" * (W+2))
    for _ in range(H):
        s = input()
        print("#", end="")
        print(s, end="")
        print("#")
    print("#" * (W+2))

if __name__ == "__main__": main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin>>n>>m;
  int h=0;
  int g=1000000000;
  for(int i=0;i<m;i++){
    int a,s;
    cin>>a>>s;
    h=max(h,a);
    g=min(g,s);
  }
  if(h>g){
    cout<<0<<endl;
  }
  else{
    cout<<g-h+1<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long int a,b;
    while(cin>>a>>b){
        if(b>a)swap(a,b);
        long long int lcm=(long long int)a*b;
        while(a%b){
            long int c=a%b;
            a=b;
            b=c;
        }
        cout<<b<<" "<<lcm/b<<endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d = 0, f = 0, e;
	cin >> a >> b >> c;
	for (int h = 1; h <= b; h++) {
		cin >> e;
		if (c < e) {
			d++;
		}
		else {
			f++;
		}
	}
	cout << min(d,f) << "\n";
	cin >> e;
}

Measured memory_bytes: 256
r,c =  map(int,input().split())
A = [[0] for i in range(r)]
for i in range(r):
	l = list(map(int,input().split()))
	l.append(sum(l))
	A[i] = l
B = []
for i in range(c+1):
	a = 0
	for j in range(r):
		a += A[j][i]
	B.append(a)
A.append(B)
for k in A:
	print(*k)


Measured memory_bytes: 6236
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

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

int main(void){
	int n, i;
	int a[100001];
	scanf("%d", &n);
	for(i=0; i<=n; i++){
		scanf("%d", a+i);
	}
	long ans=0;
	for(i=0; i<n; i++){
		int b;
		scanf("%d", &b);
		if(b<=a[i]){
			a[i]-=b;
			ans+=b;
		}else{
			ans+=a[i];
			b-=a[i];
			a[i]=0;
			if(b<a[i+1]){
				a[i+1]-=b;
				ans+=b;
			}else{
				ans+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

int main(void) {
  ll N, M;
  cin >> N >> M;
  ll i;
  ll a[MAX];
  P p[MAX];
  
  for(i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a, a+N);
  
  for(i=0; i<M; i++) {
    cin >> p[i].sc >> p[i].ft;
  }
  sort(p, p+M);
  reverse(p, p+M);
  
  ll ans=0;
  ll pos=0;
  for(i=0; i<M; i++) {
    ll t=lb(a+pos, a+N, p[i].ft)-a;
    if(t==pos) break;
    
    ll c=min(t-pos, p[i].sc);
    
    //pt(t<<" "<<c<<" "<<pos);
    ans+=p[i].ft*c;
    pos+=c;
    
  }
  
  for(i=pos; i<N; i++) {
    ans+=a[i];
  }
  pt(ans);
  
}


Measured memory_bytes: 2560
////////////////////////////////////////////////////////////////////
// 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	INF		UINT64_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;

int main()
{
	ll N = 0;
	ll X = 0;
	ll ans = 0;
	ll min_total = 0;

	cin >> N >> X;
	vector<ll> M(N);

	Rep(i, N) {
		cin >> M[i];
		min_total += M[i];
	}
	sort(M.begin(), M.end());

	if (X >= min_total) {
		ans += N;
		// remain
		X -= min_total;
		ans += X / M[0];
	}

	cout << ans << endl;

	return 0;
}


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


void solve(long long A, long long B){
  cout << (A * B) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3652
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N, W = map(int, input().split())
    w, v = [0] * N, [0] * N
    for i in range(N):
        w[i], v[i] = map(int, input().split())
    # https://qiita.com/drken/items/dc53c683d6de8aeacf5a#dp-%E5%AE%9F%E8%A3%85%E3%81%AE%E9%A0%86%E5%BA%8F

    INF = 10**10  # INF+INFを計算してもオーバーフローしない範囲で大きく
    # dpテーブル dp[i][j]:= i番目までの荷物の中から重さj以下で選ぶ通り数
    dp = [[0]*(W+1) for _ in range(N+1)]
    """
    初期化の値は，
        最小化問題：INF, 
        最大化問題：-INF（0以上の値しか取らないなら-1, あるいは0でもいいかも)
        数え上げ問題：0
        確率問題：0
        Yes/No判定問題:False
    """

    # 初期条件
    # dp[0][0] = 0

    # ループ
    for typ in range(1, N+1):
        for weight in range(W+1):

            """
            dp[from] の値の更新が完了していればノード from からノード to への緩和を行っていい．貰うdpであれ配るdpであれ．
            両者の違いを意識すべきケースはcf. 
            https://qiita.com/drken/items/ace3142967c4f01d42e9#%E8%B2%B0%E3%81%86-dp-%E3%81%A8%E9%85%8D%E3%82%8B-dp-%E3%81%AE%E6%AF%94%E8%BC%83

            # 遷移式がたくさんある場合この中でさらにforループを回したりする cf. https://atcoder.jp/contests/dp/tasks/dp_b
            """
            # i番目選ぶ
            if weight-w[typ-1] >= 0:
                dp[typ][weight] = max(max(dp[typ][weight], dp[typ-1][weight-w[typ-1]]+v[typ-1]),dp[typ-1][weight])
            # 選ばない
            else:
                dp[typ][weight] = max(dp[typ][weight], dp[typ-1][weight])

    # 出力
    print(dp[N][W])


resolve()

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int		N;
	std::cin >> N;

	int	curx = 0, cury = 0;
	int	prev_t = 0;	

	while (N--)
	{
		int	t, x, y;
		std::cin >> t >> x >> y;

		int	min_time = fabs((x - curx)) + fabs(y - cury);
		if (min_time > t - prev_t or ((t - prev_t) - min_time ) % 2 == 1)
		{
			pnl("No");
			return 0;
		}
		prev_t = t;
		curx = x;
		cury = y;
	}
	pnl("Yes");
}



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

namespace Test
{
    class ForStudy
    {
        public static void Main(string[] args)
        {
            var list = new List<string>();
            while (true)
            {
                string str= Console.ReadLine();
                if (str == "-")
                {
                    break;
                }
                int n = int.Parse(Console.ReadLine());
                
                for(int i = 0; i < n; i++)
                {
                    str=Shuffle(str, int.Parse(Console.ReadLine()));
                }

                list.Add(str);

            }
            foreach(string str in list)
            {
                Console.WriteLine(str);
            }
            
        }
        public static string Shuffle(string str, int num)
        {
            int length = str.Length;
            string result = str.Substring(num)+str.Substring(0,num);
           
            return result;
        }
    }
}


Measured memory_bytes: 15988
from heapq import heappop, heappush

X, Y, Z, K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

h = []
heappush(h, (-A[0]-B[0]-C[0], 0, 0, 0))
used = set()
result = []

for _ in range(K):
    sum, i, j, k = heappop(h)
    result.append(-sum)
    if i < X-1 and (i+1, j, k) not in used:
        heappush(h, (-A[i+1]-B[j]-C[k], i+1, j, k))
        used.add((i+1, j, k))
    if j < Y-1 and (i, j+1, k) not in used:
        heappush(h, (-A[i]-B[j+1]-C[k], i, j+1, k))
        used.add((i, j+1, k))
    if k < Z-1 and (i, j, k+1) not in used:
        heappush(h, (-A[i]-B[j]-C[k+1], i, j, k+1))
        used.add((i, j, k+1))

for v in result:
    print(v)


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in(), b = in(), c = in();

  cout << min(c, b / a) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  map<char,bool> a;
  a['q']=a['w']=a['e']=a['r']=a['t']=a['a']=a['s']=a['d']=a['f']=a['g']=a['z']=a['x']=a['c']=a['v']=a['b']=true;
  a['y']=a['u']=a['i']=a['o']=a['p']=a['h']=a['j']=a['k']=a['l']=a['n']=a['m']=false;
  char str[35];
  while(1){
    scanf("%s",str);
    if(strcmp(str,"#")==0) break;
    int l=strlen(str),cnt=0;
    bool dotti=a[str[0]];
    for(int i=1;i<l;i++){
      if(dotti!=a[str[i]]){
	dotti=a[str[i]];
	cnt++;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1192
#include<stdio.h>
int main()
{
int a,b,c,d;
long int a1,a2;
scanf("%d %d %d %d",&a,&b,&c,&d);
a1=a*b;
a2=c*d;
if(a1>a2)
printf("%ld",a1);
else
printf("%ld",a2);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(int a, int n) {//aのn乗を計算します。
	int x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;



int yaku[26];
int sosuu[25] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 };
void bunkai(int n) {
	while (n > 1) {
		REP(i, 25) {
			if (n%sosuu[i] == 0) {
				yaku[i]++;
				n /= sosuu[i];
			}
		}
	}
}
int main() {
	m0(yaku);
	int N; cin >> N;
	FOR(i, 1, N + 1)bunkai(i);
	int c2 = 0, c4 = 0, c14=0, c24=0, c74=0;
	REP(i, 26) {
		if (yaku[i] >= 2)c2++;
		if (yaku[i] >= 4)c4++;
		if (yaku[i] >= 14)c14++;
		if (yaku[i] >= 24)c24++;
		if (yaku[i] >= 74)c74++;
	}
	if (c4 < 2) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = c4 * (c4 - 1) / 2 * (c2 - 2);
	ans += c14 * (c4 - 1);
	ans += c24 * (c2 - 1);
	ans += c74;
	/*
	REP(i, 25) {
		cout << yaku[i] << " ";
	}
	cout << endl;
	*/
	cout << ans << endl;
}




Measured memory_bytes: 256
A,B,C = map(int , input().split())
K = int(input())

if A<B:
    if B<C:
        print("Yes")
    else:
        if B<(C*(2 ** K)):
            print("Yes")
        else:
            print("No")
else:
    while A>=B:
        B *= 2
        K -= 1
    if B<(C*(2 ** K)):
        print("Yes")
    else:
        print("No")
    


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll n;
    cin>>n;
    ll a[n],b[n],c[n],i,dp1[n],dp2[n],dp3[n];
    for(i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    dp1[0]=a[0];
    dp2[0]=b[0];
    dp3[0]=c[0];
    for(i=1;i<n;i++){
        dp1[i]= a[i]+max(dp2[i-1],dp3[i-1]);
        dp2[i]= b[i]+max(dp1[i-1],dp3[i-1]);
        dp3[i]= c[i]+max(dp1[i-1],dp2[i-1]);
    }
    cout<<max(max(dp1[n-1],dp2[n-1]),dp3[n-1])<<endl;
    
    return 0;
}

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

const int maxn = 3000, mod = 1e9 + 7, inv2 = (mod + 1) >> 1;
int n, q, a[maxn + 3], f[maxn + 3][maxn + 3], g[maxn + 3][maxn + 3];

int main() {
	scanf("%d %d", &n, &q);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			f[i][j] = a[i] > a[j];
			f[j][i] = a[j] > a[i];
		}
	}
	int tot = 1;
	for (int x, y; q --> 0; ) {
		tot = 2ll * tot % mod;
		scanf("%d %d", &x, &y);
		for (int i = 1; i <= n; i++) {
			if (i != x) g[i][x] = f[i][x], g[x][i] = f[x][i];
			if (i != y) g[i][y] = f[i][y], g[y][i] = f[y][i];
		}
		f[x][y] = 1ll * (g[x][y] + g[y][x]) * inv2 % mod;
		f[y][x] = 1ll * (g[x][y] + g[y][x]) * inv2 % mod;
		for (int i = 1; i <= n; i++) if (i != x && i != y) {
			f[i][x] = 1ll * (g[i][x] + g[i][y]) * inv2 % mod;
			f[i][y] = 1ll * (g[i][x] + g[i][y]) * inv2 % mod;
			f[x][i] = 1ll * (g[x][i] + g[y][i]) * inv2 % mod;
			f[y][i] = 1ll * (g[x][i] + g[y][i]) * inv2 % mod;
		}
	}
	int sum = 0;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			sum = (sum + f[i][j]) % mod;
		}
	}
	printf("%lld\n", 1ll * sum * tot % mod);
	return 0;
}

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

int main(){

    ll n,k;
    cin >> n >> k;

    vector<pair<int,int> > p(n);

    rep(i,n){
        cin >> p[i].first >> p[i].second;
    }

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

    ll cnt=0;

    for(int i=0;i<n;i++){
        cnt+=p[i].second;
        if(k<=cnt){
            cout << p[i].first << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PRECISION(x) cout << fixed << setprecision(x); 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#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 DO(X) while(X--)
#define DRI(X) int (X); cin >> X
#define DRII(X, Y) int X, Y; cin >> X >> Y
#define DRIII(X, Y, Z) int X, Y, Z; cin >> X >> Y >> Z
#define read(X) for(int &ele : (X)) cin >> ele
#define readI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define debug(x) cerr << '>' << #x << ':' << x << endl
#define MP make_pair
#define PB push_back
#define F first
#define S second

using namespace std;
typedef long long LL;
const int INF = 1<<29;
inline int in() { int x; cin >> x; return x; }
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }

int main(){
	FAST_IO 
	long long N; cin >> N;
	long long curDivisor = 10, fiveCount = 0;
	while(N % 2 == 0 && N / curDivisor){
		fiveCount += (N / curDivisor);
		curDivisor *= 5;
	}
	cout << fiveCount << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

if h[0] > 1:
  h[0] -= 1

ans = "Yes"
for i in range(1, n):
  if h[i] > h[i-1]:
    h[i] -= 1
  if h[i] < h[i-1]:
    ans = "No"
    break

print(ans)


Measured memory_bytes: 63984
using System;

namespace AGC019_B___Reverse_and_Compare
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine();
            var alphabets = new long[26];
            for (int i = 0; i < A.Length; i++) alphabets[A[i] - 'a']++;
            long result = (long)A.Length * (long)(A.Length - 1) / 2 + 1;
            for (int i = 0; i < 26; i++) result -= alphabets[i] * (alphabets[i] - 1) / 2;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int n,m,x[55];
vector<pair<int,int>> v[55];
long long dp[1<<20];
bool dfs1(int a,int b,int c,int d){
	if (a==c)
		return 1;
	for (auto& i : v[a])
		if (i.first!=b && dfs1(i.first,a,c,d)){
			x[i.second]^=1<<d;
			return 1;
		}
	return 0;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int ta,tb;
		scanf("%d%d",&ta,&tb);
		v[ta].emplace_back(tb,i);
		v[tb].emplace_back(ta,i);
	}
	scanf("%d",&m);
	for (int i=0;i<m;i++){
		int ta,tb;
		scanf("%d%d",&ta,&tb);
		dfs1(ta,0,tb,i);
	}
	dp[0]=1;
	for (int i=1;i<n;i++)
		for (int j=(1<<m)-1;j>=0;j--)
			dp[j|x[i]]+=dp[j];
	printf("%lld\n",dp[(1<<m)-1]);
}

Measured memory_bytes: 8448
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
S = input()

for i in range(A):
	if S[i] == "-":
		print("No")
		exit()
for i in range(A+1, A+B+1):
	if S[i] == "-":
		print("No")
		exit()

if S[A] == "-":
	print("Yes")
else:
	print("No")

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        //bytesのiterを生成
        .bytes()
        //それをas charでchar型に変換したiterを生成
        .map(|c| c.expect("failed to read char") as char)
        //c.is_whitespace()がfalseになるまで（つまり普通の文字が出るまで）iterを進めたiterを生成
        .skip_while(|c| c.is_whitespace())
        // !c.is_whitespace()がtrue, 即ち（普通の文字の間）iterを進め, 進んだところまでのiterを生成
        .take_while(|c| !c.is_whitespace())
        // それをcollect()してiterからStringを作る
        .collect();
    // parse()で任意の型に変換して返す。
    token.parse().ok().expect("failed to parse token")
}


fn read_one_line_to_vec<T: FromStr>() -> Vec<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let v: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c == &'\x0d' || c == &'\x0a')
        .take_while(|c| !(c == &'\x0d' || c == &'\x0a'))
        .collect();
    v.split_whitespace()
        .map(|c| { let string = c.to_string();
            string.parse::<T>().ok().expect("failed to parse token")})
        .collect()
}

fn main() {
    // ALDS1_4_A_Linear_Search

    let _s_len: i32 = read();
    let s: Vec<i32> = read_one_line_to_vec();
    let _q_len :i32= read();
    let t :Vec<i32> = read_one_line_to_vec();


    let mut c = 0;
    for t_v in t.iter() {
        for s_v in s.iter() {
            if s_v == t_v {
                c+=1;
                break
            }
        }
    }
    println!("{}", c);
}

fn print_vec(v: Vec<i32>) {
    let mut v_iter = v.iter();
    print!("{}", v_iter.next().as_ref().unwrap());
    for v in v_iter {
        print!(" {}", v)
    }
    println!();
}



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

const int N = 55556;

int n, np[N];

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

	vector <int> can;
	np[0] = np[1] = 1;
	for (int i = 2; i < N; ++i) if (!np[i]) {
		for (int j = i + i; j < N; j += i) np[j] = 1;
		if (i % 5 == 1) can.push_back(i);
	}

	cin >> n;
	assert(can.size() >= n);
	for (int i = 0; i < n; ++i) {
		cout << can[i] << ' ';
	}
	cout << endl;
}

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

using namespace std;
typedef long long ll;


ll N;


int main(){
	cin >> N;
	string S;
	cin >> S;
	S += " ";
	S[N] = ' ';
	
	int max_match_len = 0;
	for ( int dist = 1; dist <= N-1; dist++ ){
		int match_len = 0;
		for ( int i = 0; i < N-dist+1; i++ ){ // 最後に必ずelse側を実行するよう+1する
			if ( S[i] == S[i+dist] ){
				match_len++;
			}
			else {
				int valid_match_len = min( dist, match_len );
				max_match_len = max( max_match_len, valid_match_len );
				if ( valid_match_len == dist )
					break;
				match_len = 0;
			}
		}
		
	}
	
	cout << max_match_len << endl;


	return 0;
}


Measured memory_bytes: 256
def main():
    a, b = input().split()
    na, nb = int(a), int(b)

    s = a * nb
    t = b * na

    ret = min(s, t)

    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main(){
  int n;
  cin >> n;
  int a = n % 10;
  
  if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon" << endl;
  if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
  if(a == 3) cout << "bon" << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int n;
	cin >> n;
	int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout << x[n-1] << endl;
//	cout << fixed << setprecision(15);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INt_MAX
#define inf llONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 10;

pair < ll, ll > a[N], tmp;
ll c[N];
ll dp[100];

bool cmp(pair < ll, ll > A, pair < ll, ll > B) {
    return A.fir * (B.sec + 1) > B.fir * (A.sec + 1);
}

void solve() {

    int n; ll t;
    scanf("%d %lld", &n, &t);
    int cnt1 = 0, cnt2 = 0;
    rep(i, 1, n) {
        scanf("%lld %lld", &tmp.fir, &tmp.sec);
        if(tmp.fir == 0) c[++ cnt2] = tmp.sec + 1;
        else a[++ cnt1] = tmp;
    }
    sort(c + 1 , c + cnt2 + 1) ;
    sort(a + 1 , a + cnt1 + 1 , cmp) ;
    for(int i = 1; i <= 30 ;i ++) dp[i] = t + 1 ;
    dp[0] = 0 ;
    int cnt = 0 ;
    for(int i = 1; i <= cnt2 ;i ++) c[i] += c[i - 1] ;

    for(int i = 1; i <= cnt1 ;i ++)
    {
      for(int j = 30 ;j >= 1 ;j --)
       dp[j] = min(dp[j] , (dp[j - 1] + 1) * (a[i].first + 1)+ a[i].second) ;
    }
    int ans = 0 ;
    for(int i = 0 ;i <= 30 ;i ++)
     {
       if(dp[i] > t) continue ;
       int j = 0 ;
       if(cnt2)
        j = upper_bound(c + 1 , c + cnt2 + 1 , t - dp[i]) - c - 1;
       ans = max(ans , i + j) ;
     }
    printf("%d\n", ans);
    return ;
}
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n, k;
    string str;
    cin >> n >> k >> str;
    vector<ll> ary;
#if 1
    int now = 1; //今見ている数
    int cnt = 0; //nowがいくつ並んでいるか
    for (int i = 0; i < n; i++)
    {
        if (str[i] == (char)('0' + now)) cnt++;
        else {
            ary.push_back(cnt);
            now = 1 - now; //0と1を切り替える時の計算 now ^= 1;
            cnt = 1; //新しいのをカウントし始める
        }
    }
    if (cnt != 0) ary.push_back(cnt);

    //1-0-1-0-1-0-1って感じの配列が欲しい
    //1-0-1-0みたいに0で終わってたら、適当に１つ足す
    if (ary.size() % 2 == 0) ary.push_back(0);
    if (str[0] == '0') {
        ary.push_back(0);
    }
#else
    char prev = 0;
    for (ll i = 0; (i < n); i++) {
        char curr = str[i];
        if (prev != curr) {
            prev = curr;
            ary.push_back(1);
        } else {
            ary[ary.size()-1]++;
        }
    }
    if (str[n-1] == '0') ary.push_back(0);
#endif

#if 0
        vector<ll> sum(ary.size() + 1);
        for (int i = 0; i < ary.size(); i++)
        {
                sum[i + 1] = sum[i] + ary[i];
        }
#else
    vector<ll> sum(ary.size()+1, 0);
    for (ll i = 0; (i < ary.size()); ++i) {
        sum[i+1] = sum[i] + ary[i];
    }
#endif

#if 0
        int Add = 2 * k + 1;
        int maxv = 0;
        //1-0-1...の1から始めるので、偶数番目だけ見る
        for (int i = 0; i < ary.size(); i += 2)
        {
                //次のleft, rightを計算する [left, right)
                int left = i;
                int right = min(i + Add, (int)ary.size());
                int tmp = sum[right] - sum[left];

                maxv = max(tmp, maxv);
        }
#else
    // ここもだめ
    ll maxv = 0;
    for(ll i = 0; (i < ary.size()); i+=2) {
        ll left = i;
        ll right = min((ll)(sum.size()-1), i+(k-1)*2+3);
        maxv = max(maxv, sum[right] - sum[left]);
    }
#endif
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>  // ios_base::sync_with_stdio(false);
#define MAXN 501          // cin.tie(NULL);
#define di pair<int, int>
#define tri pair<int, di>
#define bi pair<bool, int>
using namespace std;
void swap(int ar[],int  i,int j)
    {int aux = ar[j]; ar[j] = ar[i]; ar[i] = ar[j];}

int upperbound(long long ar[],int k, int length){
    int best = k;
    int l = k;
    int r = length;
    int m;
    while(r > l){
        m = (r + l) / 2;
        if(ar[m]/2  +  ar[m] % 2 <= ar[k]){
            best = m;
            l = m + 1;
        }
        else
            r = m;
    }
    return best;
}

int main(){
    int n;
    int k;
    cin >> k;
    int a, b;
    a = k /100;
    b = k % 100;

    if(a >= 1 && a <=12){
        if(b <= 12 && b >= 1 ){
            cout << "AMBIGUOUS" ;
        }
        else{
            cout << "MMYY";
        }
    }

    else if(b >= 1 && b <=12){
        if(  a <= 12 && a >= 1 ){
            cout << "AMBIGUOUS";
        }
        else{
            cout << "YYMM";
        }
    }
    else{
        cout << "NA";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;
int n,m;
string s,t;
int dp[3004][3004];

int solve(int i,int j){
	if(i>=n || j>=m) return 0;
	if(dp[i][j]!=-1 )return dp[i][j];
	if(s[i]==t[j]){
		return dp[i][j]=1+ solve(i+1,j+1);
	}
	else
		return dp[i][j]= max(solve(i+1, j), solve(i,j+1));
}

int32_t main()
{
   
   
    crap;
    memset(dp,-1,sizeof(dp));
    
    cin>>s>>t;
    n = s.length();
    m = t.length();

    int idx = solve(0,0);
    
    int i=0,j=0;
    string sp="";
    while(i<n && j<m && idx){
    	if(s[i]==t[j]){
    		sp+= s[i];
    		idx--;
    		i++;
    		j++;
    	}
    	else{
    		if(dp[i+1][j]>dp[i][j+1])
    			i++;
    		else
    			j++;
    	}
    }
    
   // reverse(sp.begin(),sp.end());
   cout<<sp<<endl;
   
   
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200002;
const int MOD =1000000007;
   
     signed main(){
 string s,t;int ans=MOD;
 cin>>s>>t;
 int s0=s.size(),t0=t.size();
 for(int i=0;i<=s0-t0;i++){
     int k=0;
     for(int j=0;j<t0;j++)if(t[j]!=s[i+j])k++;
     ans=min(ans,k);
 }
 cout<<ans<<endl;
 
   }
     


 


 






    





      

        


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(unsigned int i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define sum(a) accumulate(begin(a), end(a), 0)


template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int gcd(ll a, ll b, ll c) {
	return gcd(a, gcd(b, c));
}


int main() {
	ll N;
	vector<ll> X;
	cin >> N;
	rep(i, 0, N) {
		ll temp;
		cin >> temp;
		X.push_back(temp);
	}
	so(X);

	ll ans = MAX;
	rep(i, X[0], X[N - 1] + 1) {
		ll tempAns = 0;
		rep(ii, 0, N) {
			tempAns += (X[ii] - i) * (X[ii] - i);
		}
		if (ans > tempAns) ans = tempAns;
	}

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

Measured memory_bytes: 256
import math
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
n=nCast(input())
ab=nCast(input().split())
p=nCast(input().split())
x,y,z=0,0,0
for number in p:
    if number<=ab[0]:
        x+=1
    elif number>ab[1]:
        z+=1
    else:
        y+=1
print(min(x,y,z))


Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define mp make_pair
#define mpp(AA, BB, CC) mp( mp(BB, CC) , AA )
#define F first
#define S second

using namespace std;

int main()
{
    int n, m, k, a;
    vector < vector < int > > g;
    vector < bool > p;
    vector < bool > act;
    cin >> n >> m;
    g.assign(n, vector < int > (0) );
    for(int i = 0 ; i < m ; i++){
        cin >> k;
        while(k--){
            cin >> a;
            g[a - 1].push_back(i);
        }
    }
    for(int i = 0 ; i < m ; i++){
        cin >> a;
        p.push_back( (bool)a );
    }
    int res = 0;
    for(int mask = 0 ; mask < (1<<n) ; mask++){

        act.assign(m, false);
        for(int i = 0 ; i < n ; i++){
            if( (mask&(1<<i)) != 0 ){
                //if(mask == 1)cout << i << endl;
                for(int j = 0 ; j < g[i].size() ; j++){
                    act[ g[i][j] ] = !act[ g[i][j] ];
                }
            }
        }//cout << endl;
        bool sw = true;
        for(int i = 0 ; i < act.size() && sw ; i++){
            if(act[i] != p[i]) sw = false;
        }
        if(sw){
            res++;

        }

    }
    cout << res;
    return 0;
}










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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << min(n, k)*x + max(0, n-k)*y << endl;
    return 0;
}


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

int main(){
  int a,b,c;
  int cnt;
  int f;
  
  scanf(" %d %d %d",&a,&b,&c);
  
  cnt = 1;
  f = 0;
  while(a * b >= b * cnt){
    if(((b * cnt) + c) % a == 0){
      f = 1;
      break;
    }
    cnt++;
  }
  
  if(f){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define mk make_pair
# define fr first
# define sc second
# define test1(x) cout<<"x is "<<x<<"!"<<endl
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII; 
bool test=true;

void solve();
int main(){int t=1;if(t==0)cin>>t;while(t--)solve();}

int n;

string s;

void solve(){
	cin>>n>>s;
	
	if(n<3200)cout<<"red";
	else cout<<s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n+1);
    for(int i=0;i<=n;i++){
        cin >> a[i];
        if(i<=60){
            if((1LL<<i)<a[i]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if(n==0){
        if(a[0]==1){
            cout << 1 << endl;
        }
        else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(a[0]){
        cout << -1 << endl;
        return 0;
    }
    ll ans=0;
    vector<ll> v(n+1);
    v[n]=a[n];
    vector<ll> l(n+1,INF);
    l[0]=1;
    for(int i=1;i<=n;i++){
        chmin(l[i],(l[i-1]-a[i-1])*2);
        if(l[i]<=0){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i=n-1;i>=0;i--){
        v[i]=min(l[i],v[i+1]+a[i]);
    }
    for(int i=0;i<=n;i++){
        ans+=v[i];
        if(v[i]>l[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5536
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005&lang=jp*/

#include <iostream>

using namespace std;

int gcd(int x,int y){
    if(x<y){
        swap(x,y);
    }
    if(y==0){
        return x;
    }else {
        return gcd(y, x % y);
    }
}

int main(){
    int x,y;
    while(cin>>x>>y){
        long long g=gcd(x,y);
        cout<<g<<" "<<y/g*x<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156