akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <set>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T>
int size(T const& container) {
  return static_cast<int>(container.size());
}

template <typename T>
bool maxs(T& a, T const& b) {
  return a < b ? a = b, true : false;
}

template <typename T>
bool mins(T& a, T const& b) {
  return a > b ? a = b, true : false;
}

signed main() {
  const int N = rint();
  multiset<int> s;
  dotimes(i, N) {
    int A = rint();
    auto it = s.lower_bound(A);
    if (it != s.begin())
      s.erase(--it);
    s.insert(A);
  }
  wint(::size(s));
  return 0;
}


Measured memory_bytes: 7968
IN = list(map(int, input().split()))
K = IN[0]
N = IN[1]
IN = list(map(int, input().split()))

interval_max = K - IN[N-1] + IN[0]

i = 0
while i < N-1:
    interval = IN[i+1] - IN[i]

    if interval_max < interval:
        interval_max = interval

    i += 1

print(K - interval_max)

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

// 

public class Program_ABC113_B // ←Class名変更！！
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());


        var xy = ReadLine().Split(' ');
        var t = int.Parse(xy[0]);  //x,y なのか y,xなのか注意
        var a = int.Parse(xy[1]);

        var ha = Array.ConvertAll(ReadLine().Split(' '), int.Parse);

        var tempI = 0 + 1;
        var tempV = t - (ha[0] * 0.006D);
        tempV = Abs(a - tempV);
        for (int i = 1; i < ha.Length; i++)
        {
            var r = t - (ha[i] * 0.006D);
            System.Diagnostics.Debug.WriteLine($"★★{r}");
            r = Abs(a - r);
            if (r < tempV)
            {
                tempI = i + 1;
                tempV = r;
            }

        }

        var result = tempI;
        WriteLine($"{result}");
        return;

    } // Main

}     // Class


Measured memory_bytes: 13212
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println((A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) ? "Possible" : "Impossible");
        }
    }
}


Measured memory_bytes: 27056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

void solve() {
	i64 a, b, k;
	cin >> a >> b >> k;
	if (a > k) {
      	a -= k;
	} else {
		k -= a;
		a = 0;
      	if (b > k) {
          b -= k;
        } else {
          k -= b;
          b = 0;
        }
	}
	cout << a << ' ' << b << endl;
}

int main() {
	solve();
	return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> d;
    d.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    vector<int> d_sum;
    d_sum.resize(N - 1);
    d_sum[0] = d[N - 1];
    for (int i = 1; i < N - 1; ++i) {
        d_sum[i] = d_sum[i - 1] + d[N - i - 1];
    }
    uint64_t ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += d[i] * d_sum[N - i - 2];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
class max{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    int add = a+b;
    int sub = a-b;
    int mul = a*b;
    if(add > sub){
      if(add > mul){
        Console.WriteLine(add);
      }
      else if(mul > sub){
        Console.WriteLine(mul);
      }
    }
    else{
      if(mul > sub){
        Console.WriteLine(mul);
      }
      else{
        Console.WriteLine(sub);
      }
    }
  }
}

Measured memory_bytes: 13140
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    r = ii()
    print(6.28318530717958623200*r)


main()




Measured memory_bytes: 9812
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
using namespace std;
template <typename T> inline T __lcm(T a,T b)
{
    return (a*b)/__gcd(a,b);
}

ll n;
ll a[1000000][4];
ll dp[1000000][4];

ll fun(ll i,ll pos)
{
    if(i==n)
    {
        return 0;
    }
    if(dp[i][pos]!=-1)
    {
        return dp[i][pos];
    }
    ll profit1;
    ll profit2;
    if(pos==0)
    {
        profit1=a[i][pos]+fun(i+1,1);
        profit2=a[i][pos]+fun(i+1,2);
    }
    else if(pos==1)
    {
        profit1=a[i][pos]+fun(i+1,0);
        profit2=a[i][pos]+fun(i+1,2);
    }
    else
    {
        profit1=a[i][pos]+fun(i+1,0);
        profit2=a[i][pos]+fun(i+1,1);
    }
    return dp[i][pos]=max(profit1,profit2);

}

int main()
{
    memset(dp,-1,sizeof(dp[0][0])*1000000*4);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll ans=max(fun(0,2),max(fun(0,0),fun(0,1)));
    printf("%lld\n",ans);
}

Measured memory_bytes: 39808
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int sumOfDigits(ll n) {
  int ret = 0;
  while (n > 0) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

void solve() {
  ll n; cin >> n;
  string sn = to_string(n);
  string tn = ctos(sn[0]);
  rep(i, sn.size() - 1) tn += '9';
  ll m = stoll(tn);
  // debug3(sn, tn, m);
  if (n == m) outl(sumOfDigits(m));
  else outl(sumOfDigits(m) - 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((b + 10*g) % 4 == 0) {
	cout << "YES" << endl;
  }
  else {
	cout << "NO" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005],t[500005];
bool flag,dame;

int main(){
	cin >> a >> b >> c;
	for(i=0;i<10;i++){
		c = a * c - b;
		p(c);
	}
	return 0;
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll ok[101];
signed main() {
    ll k; cin >> k;
    ll a = k / 50; k %= 50;
    for (int h = 0; h < 50; h++) {
        ok[h] = a + h;
    }
    for (int h = 0; h < k; h++) {
        for (int i = 0; i < 50; i++) {
            if (h == i) { ok[i] += 50; }
            else { ok[i]--; }
        }
    }
    cout << 50 << endl; cout << ok[0];
    for (int i = 1; i < 50; i++) {
        cout << ' ' << ok[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 2e5 + 10;
int n, T, a[N], b[N], p[N];
bool cmp(const int &i, const int &j)
{
	return 1LL * (b[i] + 1) * a[j] < 1LL * (b[j] + 1) * a[i];
}
bool cmp2(const int &i, const int &j)
{
	return b[i] < b[j];
}
ll calc(int t, int i)
{
	return 1LL * a[i] * t + b[i];
}
map<int, int> dp, tmp;
int main()
{
	n = read(), T = read();
	for (int i = 1; i <= n; ++i)
	{
		p[i] = i;
		a[i] = read(), b[i] = read();
	}
	dp[0] = 0;
	sort(p + 1, p + 1 + n, cmp);
	int ans = 0, k = n + 1;
	for (int i = 1; i <= n; ++i)
	{
		if (a[p[i]] == 0)
		{
			k = i;
			break;
		}
		tmp = dp;
		for (auto pr : dp)
		{
			int cnt = pr.first, t = pr.second;
			if (calc(t + 1, p[i]) + t + 1 <= T)
			{
				t = calc(t + 1, p[i]) + t + 1;
				if (!tmp.count(cnt + 1))
					tmp[cnt + 1] = t;
				else
					tmp[cnt + 1] = min(tmp[cnt + 1], t);
			}
		}
		dp = tmp;
	}
	sort(p + k, p + 1 + n, cmp2);
	for (auto pr : dp)
	{
		int cnt = pr.first, t = pr.second;
		assert(cnt < 50);
		for (int i = k; i <= n; ++i)
		{
			if (calc(t + 1, p[i]) + t + 1 <= T)
				t = t + 1 + calc(t + 1, p[i]), ++cnt;
		}
		ans = max(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define REV(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ--------------------*/
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
/*---------------------臨時関数----------------------*/
/*----------------------end-------------------------*/
signed main(){
  int X,Y;cin>>X>>Y;
  int cnt=0;
  for(int i=X;i<=Y;i*=2){
    cnt++;
  }
  cout<<cnt<<endl;
}


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

namespace AtCoder.Abc
{
    class QuestionI
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long num_N = long.Parse(Console.ReadLine());

            int num_500Joy = 1000;
            int num_5Joy = 5;

            long num_500Coin = num_N / 500;
            long num_5Coin = (num_N % 500) / 5;

            long result = num_500Coin * num_500Joy + num_5Coin * num_5Joy;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
int A[MAX_N], B[MAX_N];


int main() {
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    vector<Pii> vp;
    for (int i = 0; i < N; ++i) {
        vp.emplace_back(B[i], A[i]);
    }
    sort(all(vp));
    for (int i = 0; i < N; ++i) {
        A[i] = vp[i].sc;
        B[i] = vp[i].fi;
    }

    vector<Pii> vp2;
    for (int i = 0; i < N; ++i) {
        vp2.emplace_back(A[i], i);
    }
    sort(all(vp2));

    for (int i = 0; i < N; ++i) {
        int a = vp2[i].fi;
        int b = B[i];
        if (a > b) {
            cout << "No" << endl;
            return 0;
        }
    }

    int cycle_size = 0;
    set<int> st;
    int next_id = vp2[0].sc;
    for (int i = 0; i < N; ++i) {
        if (st.count(vp2[next_id].sc) > 0) break;
        ++cycle_size;
        st.insert(vp2[next_id].sc);
        next_id = vp2[next_id].sc;
    }

    if (cycle_size < N) {
        cout << "Yes" << endl;
        return 0;
    }

    bool can_swap = false;
    for (int i = 1; i < N; ++i) {
        int a = vp2[i].fi;
        int b = B[i-1];
        if (b >= a) {
            can_swap = true;
            break;
        }
    }

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

    return 0;
}


Measured memory_bytes: 7284
#include<stdio.h>
int main()
{ 
  int i,n,flag;
  char s[100001];
  scanf("%s",s);
  int count=0;
  n=0;
  while(s[n]!='\0') n++;
  if(s[0]=='1') flag=1;
  else          flag=0;
  int count1=0;
  
  for(i=0;i<n;i++)
  {
    if(n%2==0)
    {
      
      if((i%2==0&&s[i]!='1')||(i%2==1&&s[i]!='0')) count++;
      if((i%2==0&&s[i]!='0')||(i%2==1&&s[i]!='1')) count1++;
      
    }else
    {
        if((i%2==0&&s[i]!='1')||(i%2==1&&s[i]!='0')) count++;
        if((i%2==0&&s[i]!='0')||(i%2==1&&s[i]!='1')) count1++;
    }
  }
  if(count1<count) count=count1;
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dy = {{1, 0, -1, -1, -1, 0, 0}, {1, 1, 0, -1, 0, 1, 0}};
vector<int> dx = {0, 1, 1, 0, -1, -1, 0};
int main(){
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  int n;
  cin >> n;
  set<pair<int, int>> st;
  for (int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    st.insert(make_pair(y, x));
  }
  int lx, ly;
  cin >> lx >> ly;
  set<tuple<int, int, int>> used;
  deque<pair<int, tuple<int, int, int>>> dq;
  dq.push_back(make_pair(0, make_tuple(sy, sx, 0)));
  int ans = -1;
  while (!dq.empty()){
    int c = dq.front().first;
    int y = get<0>(dq.front().second);
    int x = get<1>(dq.front().second);
    int t = get<2>(dq.front().second);
    dq.pop_front();
    if (y == gy && x == gx){
      ans = c;
      break;
    }
    if (!used.count(make_tuple(y, x, t))){
      used.insert(make_tuple(y, x, t));
      int d = abs(y) * abs(x) * t % 6;
      for (int i = 0; i < 7; i++){
        int y2 = y + dy[abs(x) % 2][i];
        int x2 = x + dx[i];
        int t2 = (t + 1) % 6;
        if (abs(y2) <= ly && abs(x2) <= lx && !st.count(make_pair(y2, x2))){
          tuple<int, int, int> T = make_tuple(y2, x2, t2);
          if (!used.count(T)){
            if (i == d){
              dq.push_front(make_pair(c, T));
            } else {
              dq.push_back(make_pair(c + 1, T));
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 18268
#import<iostream>
#import<algorithm>
long long i,j,n,x,m=1000000007,s[200],d[100001];
main(){std::cin>>n>>x;for(i=0;i!=n;++i)std::cin>>s[i];std::sort(s,s+n);for(i=0;i<=x;++i)d[i]=i;for(i=0;i!=n;++i){for(j=x;j;--j)d[j]=(d[j]*i+d[j%s[i]])%m;}std::cout<<d[x];}

Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt(), K = sc.nextInt();
        BigInteger[][] nCr = new BigInteger[N+1][K+1];
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= K; j++) {
                nCr[i][j] = BigInteger.ZERO;
            }
        }
        nCr[0][0] = BigInteger.valueOf(1);
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= Math.min(i, K); j++) {
                if (j - 1 >= 0)
                    nCr[i][j] = nCr[i-1][j-1].add(nCr[i-1][j]);
                else
                    nCr[i][j] = nCr[i-1][j];
            }
        }

        BigInteger MAX = BigInteger.valueOf((long)(Math.pow(10, 9) + 7));
        for (int i = 1; i <= K; i++) {
            System.out.println((nCr[N-K+1][i].multiply(nCr[K-1][i-1]).mod(MAX)));
        }
    }
}


Measured memory_bytes: 542496
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long st = in.nextLong();
    long en = in.nextLong();
    long mod1 = in.nextLong();
    long mod2 = in.nextLong();
    in.close();
    long mod1and2 = lcmul(mod1, mod2);
    long countand = en / mod1and2;
    countand -= (st - 1) / mod1and2;
        long countor = en / mod1 - (st - 1) / mod1 + en / mod2 - (st - 1) / mod2;
    long ans = en - st - countor + countand  + 1;
    System.out.println(ans);
  }
  public static long gcdiv(long a, long b) {
    while (a != b) {
      if (a > b) {
        a -= b * (a / b);
        if (a == 0) {
          a = b;
        }
      } else if (b > a) {
        b -= a * (b / a);
        if (b == 0) {
          b = a;
        }
      }
    }
    return a;
  }
  public static long lcmul(long a, long b) {
    long gcdiv = gcdiv(a, b);
    a /= gcdiv;
    b /= gcdiv;
    return a * b * gcdiv;
  }
  public static long lcmul(long a, long b, long gcdiv) {
    a /= gcdiv;
    b /= gcdiv;
    return a * b * gcdiv;
  }
}

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


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

    int num = N % 500;
    if (num <= A) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3608
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n=sc.nextInt();
int[] a=new int[n];
int c=0,d=0;
for (int i = 0; i < n; i++) {
    a[i]=sc.nextInt()%4;
    if(a[i]==0)c++;
    if(a[i]==2)d++;
}
String ans;
if(d==0){
    if(n-c<=c+1){
        ans="Yes";
    }else{
        ans="No";
    }
}else if(n-d+1-c<=c+1){
    ans="Yes";
}else{
    ans="No";
}
out.println(ans);
}}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,k;
graph t;

ll factorial(ll n,ll mod = mod){
  static ll dp[100000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

ll powl(ll x,ll r,ll mod = mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod = mod){
  return powl(x,mod-2,mod);
}

ll combination(ll n,ll m,ll mod = mod){
  if(n < m) return 0;
  return (((factorial(n)*inverse(factorial(m)))%mod)*inverse(factorial(n-m)))%mod;
}

ll dfs(ll x, ll prev, ll d){
  // cerr << x << " " << d << endl;
  if(k-d < 0 || 1+t[x].size()-d < 0) return 0;
  ll ret = combination(k-d, 1+t[x].size()-d)*factorial(1+t[x].size()-d);
  ret %= mod;
  for(auto y : t[x]){
    if(y.first == prev) continue;
    ret *= dfs(y.first, x, 2);
    ret %= mod;
  }
  return ret;
}

int main(){
  cin >> n >> k;
  for(ll i = 0;i < n-1;i++){
    ll a,b;
    cin >> a >> b;
    t[a][b] = t[b][a] = 1;
  }
  cout << dfs(1,0,0) << endl;

}


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

using namespace std;

int main()
{
    string S,T;
    char B;
    int flag = 0;
    cin >> S >> T;

    for (int i = 0; i < S.length(); i++)
    {
        B = S[S.length() -1];
        S.pop_back();
        S = B + S;

        if (S == T)
        {
            cout << "Yes";
            flag = 2;
            break;
        }

        if (S != T)
        {
            flag = 1;
        }

    }

    if (flag == 1)
    {
        cout << "No";
    }


}

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

int main() {
  int dig_x,dig_y;
  cin >> dig_x >> dig_y;
  vector<vector<string>>dig_area(dig_x+2,vector<string>(dig_y+2,"#"));

  for (int cx = 0; cx < dig_x;cx++){
    string dig_pic;
    cin >> dig_pic;
    for (int cy = 0; cy < dig_y;cy++){   
      dig_area.at(cx+1).at(cy+1) = dig_pic.at(cy);
    }
  }
  
  for (int cx = 0; cx < dig_x + 2;cx++){
	  for (int cy = 0; cy < dig_y + 2;cy++){
      cout << dig_area.at(cx).at(cy);
    }
    cout << endl;
  }
  
}


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

#define n 3
#define n1 9


struct puzz{
  int m[n1];
  int space;
  string path;
  int operator < (const puzz &p)const{
    for(int i=0;i<n1;i++){
      if(m[i]==p.m[i])continue;
      return m[i] > p.m[i];
    }
    return false;
  }
};


static const int x[4]={-1,0,1,0};
static const int y[4]={0,-1,0,1};
static const char c[4]={'u','l','d','r'};

int target(puzz p){
  for(int i=0;i<n1;i++){
    if(p.m[i]!=(i+1))return false;
  }
  return true;
}

string am(puzz p){
  queue<puzz> Q;
  map<puzz, int> V;
  puzz a,b;
  int tmp;
  p.path="";
  Q.push(p);
  V[p]=true;

  while(!Q.empty()){
    a=Q.front();
    Q.pop();
    if(target(a))return a.path;
    int xx=a.space/n;
    int yy=a.space%n;
    for(int k=0;k<4;k++){
      int xc=xx+x[k];
      int yc=yy+y[k];
      if(xc<0||yc<0||xc>=n||yc>=n)continue;
      b=a;
      tmp=b.m[a.space];
      b.m[a.space]=b.m[xc*n+yc];
      b.m[xc*n+yc]=tmp;
      b.space=xc*n+yc;
      if(!V[b]){
	V[b]=true;
	b.path+=c[k];
	Q.push(b);
	
      }
    }
  }
  return "unsolvable";
}

int main(){
  puzz input;
  for(int i=0;i<n1;i++){
    cin>>input.m[i];
    if(input.m[i]==0){
      input.m[i]=n1;
      input.space=i;
    }
  }
  string ans =am(input);
  cout<<ans.size()<<endl;
  return 0;
}



Measured memory_bytes: 30576
#include <stdio.h>
#include <stdlib.h>

const int map[7][2]={
    {0,0}, /* 0:砂漠 */
    {2,3}, /* 1:A XorY*/
    {0,4}, /* 2:X 砂漠orZ*/
    {2,0}, /* 3:Y Aor砂漠*/
    {5,6}, /* 4:Z WorB*/
    {6,3}, /* 5:W BorY*/
    {3,2}, /* 6:B YorX*/
};
 
int main(void) {
    char route[200];
    int i,P;
    while(0==0) {
        scanf("%s",route);
        if(route[0]=='#')break;
        P=1;//初期位置はA
        for(i=0;route[i];i++)
			P=map[P][route[i]-'0'];
        
		if(P==6)printf("Yes\n");
		else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 944
import sys
readline = sys.stdin.readline
from math import log2
from itertools import accumulate
N, M = map(int, readline().split())
A = [list(map(int, readline().split())) for i in range(N)]
B = max(max(Ai) for Ai in A)
if M == 1:
    if N == 1 or all(A[i][0] < A[i+1][0] for i in range(N-1)):
        print("0")
    else:
        print("-1")
    exit(0)
logB = log2(B)
logBi = int(logB)
INF = 10**18
INFL = [INF]*(M - logBi-2)
def gen(P, t, L = min(logBi+2, M)):
    if t <= logB:
        for k in range(t):
            P[:] = accumulate(P)
    else:
        V = [1]*L
        for k in range(1, L):
            V[k] = V[k-1] * (t + k - 1)//k

        for i in range(L-1, 0, -1):
            P[i] += sum(P[j] * V[i-j] for j in range(i))
        if logBi+2 < M:
            P[logBi+2:] = INFL
T = [0]*N
ans = 0
P = [0]*M
for i in range(N-1):
    a0, a1 = A[i][:2]
    b0, b1 = A[i+1][:2]
    if a0 < b0:
        continue
    if a0 > b0:
        ans = -1
        break
    t0 = T[i]
    v = max(t0*a0 + a1 - b1, 0)
    if v % b0 > 0:
        T[i+1] = t1 = (v + b0-1) // b0
        ans += t1
        continue

    t1 = v // b0
    if t0 <= t1:
        P[:] = A[i+1]
        gen(P, t1 - t0)
        if P <= A[i]:
            t1 += 1
    else:
        P[:] = A[i]
        gen(P, t0 - t1)
        if A[i+1] <= P:
            t1 += 1
    T[i+1] = t1
    ans += t1
print(ans)

Measured memory_bytes: 43380
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A

def main():
    n = int(input())
    S = set(list(map(int, input().split((' ')))))
    q = int(input())
    T = set(list(map(int, input().split((' ')))))

    ans = 0
    for t in T:
        for s in S:
            if t == s:
                ans += 1
    
    print(ans)


main()


Measured memory_bytes: 6548
#include <stdio.h>

int main(void) {
	int a, b, a1, b1, tmp, i;
	char instr[80];
	
	while (fgets(instr, sizeof(instr), stdin) != NULL) {
		sscanf(instr, "%d %d", &a, &b);
		
		if (a<b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		a1=a;
		b1=b;
		
		while (1) {
			if ((a%b) == 0)  break;
			tmp = b;
			b = a%b;
			a = tmp;
		}
		
		printf("%d %d\n", b, a1/b*b1);
	}
	
	return 0;
}

Measured memory_bytes: 604
/*
正整数 X が与えられます。 X 以下の最大のべき乗数を求めてください。 ただし、べき乗数とは、ある 1 以上の整数 b と 2 以上の整数 p を使って bp とかける整数のことを指すこととします。

制約
1 ≤ X ≤ 1000
X は整数
入力
入力は以下の形式で標準入力から与えられる。

X
出力
X 以下の最大のべき乗数を出力せよ。
*/
#include <stdio.h>
#include <math.h>
int main()
{
	int x;
	int numb=1;
	scanf("%d",&x);
	int max=1;
	int i;
	for(numb=2;numb<=sqrt(x);numb++)
	{
		i=2;
		while(pow(numb, i)<=x)
		i++;
		
		if(pow(numb, i-1)>max)
		max=pow(numb, i-1);
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(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 repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
const int d = 86400;
const int r = 10800;
int t[d*2];
int s[d*2];

int main(){
	scanf("%d" , &N);
	int x = 0;
	repp(i,0,N){
		int a,b;
		scanf("%d%d" , &a , &b);
		++t[(x+a)%d];
		x = (x + a + b) % d;
	}
	repp(i,0,d){
		t[i+d] = t[i];
	}
	s[0] = t[0];
	repp(i,1,2*d){
		s[i] = s[i-1] + t[i];
	}
	int m = 0;
	repp(i,0,d+1){
		m = max(m , s[i+r+1] - s[i]);
	}
	printf("%d\n" , m);
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,m,l[SZ],r[SZ],qzh[SZ];
char s[SZ];
ll dp[3003][3003],MOD=1e9+7;
ll tmp[3003];
int sum(int l,int r)
{
	if(l<=r)
	return qzh[r]-qzh[l-1];
	return 0;
}
ll fac[SZ],rfac[SZ];
ll qp(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD; b>>=1;
    }
    return ans;
}
ll C(int a,int b)
{
	if(b>a) return 0;
	return fac[a]*rfac[b]%MOD*rfac[a-b]%MOD;
}
int main()
{
	fac[0]=rfac[0]=1;
	for(int i=1;i<=200000;i++)
	fac[i]=fac[i-1]*i%MOD, rfac[i]=rfac[i-1]*qp(i,MOD-2)%MOD;
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) qzh[i]=qzh[i-1]+s[i]-48;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",l+i,r+i);
		if(r[i]<r[i-1]) {--i; --m; continue;}
	}
	l[m+1]=n+1; r[m+1]=n+1;
	dp[0][0]=1;
	for(int i=1;i<=m;i++)
	{
		for(int j=0;j<=n;j++) tmp[j]=0;
		int s=sum(max(r[i-1]+1,l[i]),r[i]);
		for(int j=0;j<=n;j++) tmp[j+s]+=dp[i-1][j];
		int ol=max(r[i]-l[i+1]+1,0),p=r[i]-l[i]+1-ol;
		for(int j=0;j<=ol;j++)
		for(int k=j;k<=n&&k-j<=p;k++)
			dp[i][j]=(dp[i][j]+C(p,k-j)*tmp[k]%MOD)%MOD;
	}
	ll ans=dp[m][0];
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}

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

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

using namespace std;

using graph=vector<vector<int>>;

void add_undirected_edge(graph& G,int u,int v){
	G[u].emplace_back(v);
	G[v].emplace_back(u);
}

graph T;
priority_queue<int> Q;
vector<int> ans;

void dfs(int u,int p){
	ans[u]=Q.top(); Q.pop();
	for(int v:T[u]) if(v!=p) dfs(v,u);
}

int main(){
	int n; scanf("%d",&n);
	T.resize(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		add_undirected_edge(T,u,v);
	}

	vector<int> wt(n);
	rep(u,n){
		scanf("%d",&wt[u]);
		Q.emplace(wt[u]);
	}

	ans.resize(n);
	dfs(0,-1);

	printf("%d\n",accumulate(wt.begin(),wt.end(),0)-*max_element(wt.begin(),wt.end()));
	rep(u,n) printf("%d%c",ans[u],u<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
	int flag=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<=a.size();j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=2e5+5;
const int M=524288+5;
const int mod=924844033; 
int n,nn,cnt,u,v,ans,first[N],fac[N],inv[N];
int num[N],sz[N],a[M],b[M];
struct edge{int to,next;}e[N*2];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void ins(int u,int v){e[++cnt]=(edge){v,first[u]};first[u]=cnt;}
void dfs(int x,int fa)
{
	sz[x]=1;
	for(int i=first[x];i;i=e[i].next)
	{
		int to=e[i].to;
		if(to==fa)continue;
		dfs(to,x);
		sz[x]+=sz[to];
	}
	if(fa!=-1)a[sz[x]]++,a[n-sz[x]]++;
}
int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;b>>=1;
	}
	return ans;
}
void ntt(int *a,int n,int f)
{
	int k=0;while((1<<k)<n)k++;
	for(int i=0;i<n;i++)
	{
		int t=0;
		for(int j=0;j<k;j++)
			if(i&(1<<j))t|=(1<<(k-j-1));
		if(i<t)swap(a[i],a[t]);
	}
	for(int l=2;l<=n;l<<=1)
	{
		int m=l>>1,nw=power(5,(mod-1)/l);
		if(f==-1)nw=power(nw,mod-2);
		for(int *p=a;p!=a+n;p+=l)
		{
			int w=1;
			for(int i=0;i<m;i++)
			{
				int t=1ll*p[m+i]*w%mod;
				p[m+i]=(p[i]-t+mod)%mod;
				p[i]=(p[i]+t)%mod;
				w=1ll*w*nw%mod;
			}
		}
	}
	if(f==-1)
	{
		int inv=power(n,mod-2);
		for(int i=0;i<n;i++)a[i]=1ll*a[i]*inv%mod;
	}
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		u=read();v=read();
		ins(u,v);ins(v,u);
	}
	dfs(1,-1);
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=power(fac[n],mod-2);
	for(int i=n;i>=1;i--)inv[i-1]=1ll*inv[i]*i%mod;
	for(int i=1;i<=n;i++)a[i]=1ll*a[i]*fac[i]%mod;
	for(int i=0;i<=n;i++)b[n-i]=inv[i];
	nn=1;while(nn<n+n+1)nn<<=1;
	ntt(a,nn,1);ntt(b,nn,1);
	for(int i=0;i<nn;i++)a[i]=1ll*a[i]*b[i]%mod;
	ntt(a,nn,-1);
	for(int i=1;i<=n;i++)
	{
		ans=1ll*fac[n]*inv[i]%mod*inv[n-i]%mod*n%mod;
		printf("%lld\n",(ans-1ll*a[n+i]*inv[i]%mod+mod)%mod);
	}
	return 0;
}

Measured memory_bytes: 21120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
	char city[11];
	int score;
} S_Restaurant;

int cmp(const void * n1, const void * n2)
{
  char *n1_city = ((S_Restaurant *)n1)->city;
  char *n2_city = ((S_Restaurant *)n2)->city;
  int n1_score = ((S_Restaurant *)n1)->score;
  int n2_score = ((S_Restaurant *)n2)->score;
	if (strcmp(n1_city, n2_city) > 0)
	{
		return 1;
	}
	else if (strcmp(n1_city, n2_city) < 0)
	{
		return -1;
	}
	else
	{
		if (n1_score < n2_score) {
      return 1;
    } else if (n1_score > n2_score) {
      return -1;
    } else {
      return 0;
    }
	}
}


int main(void){

  int n;
  scanf("%d", &n);
  S_Restaurant restaurants[n];
  int score_list[n];
  for (int i = 0; i < n; i++) {
    scanf("%s %d", restaurants[i].city, &restaurants[i].score);
    score_list[i] = restaurants[i].score;
  }

  qsort(restaurants, n, sizeof(S_Restaurant), cmp);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 100; j++) {
      if (score_list[j] == restaurants[i].score) {
        printf("%d\n", j+1);
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 172_D
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		// Scannerクラスのインスタンスをクローズ
		sc.close();

		long ans = 0;

		for(int i=1; i<=N; i++){
			long kakeMax = N/i;

			ans += kakeMax*(kakeMax+1)*i / 2;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 35716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string t = Console.ReadLine();

			int[,] dp = new int[s.Length + 1, t.Length + 1];

			for (int i = 0; i < s.Length; i++) {
				for (int j = 0; j < t.Length; j++) {
					if (s[i] == t[j]) {
						dp[i + 1, j + 1] = Math.Max(dp[i + 1, j + 1], dp[i, j] + 1);
					}
					dp[i + 1, j + 1] = Math.Max(dp[i + 1, j + 1], dp[i + 1, j]);
					dp[i + 1, j + 1] = Math.Max(dp[i + 1, j + 1], dp[i, j + 1]);
				}
			}
			{
				string ans = "";
				int i = s.Length;
				int j = t.Length;
				while (i > 0 && j > 0) {
					if (dp[i - 1, j] == dp[i, j]) {
						i--;
					} else if (dp[i, j - 1] == dp[i, j]) {
						j--;
					} else {
						ans = s[i - 1] + ans;
						i--;
						j--;
					}
				}
				Console.WriteLine(ans);
			}
		}
	}
}

Measured memory_bytes: 50004
#include <bits/stdc++.h>
#define rep(i,n) for(long long i = 0; i < (long long)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	string s, ans = "Yes";
	cin >> s;
	if (s[2] != s[3] || s[4] != s[5]) ans = "No";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int s;
    cin>>s;
    int sf=s/100;
    int sr=s%100;
    if(0<sf&&0<sr&&sf<=12&&sr<=12)cout<<"AMBIGUOUS"<<endl;
    else if((sf>12||sf==0)&&(sr>12||sr==0))cout<<"NA"<<endl;
    else if(0<sf&&sf<=12&&(sr>12||sr==0))cout<<"MMYY"<<endl;
    else if((sf>12||sf==00)&&sr<=12&&0<sr)cout<<"YYMM"<<endl;
}

Measured memory_bytes: 256
//https://betrue12.hateblo.jp/entry/2019/04/21/150214
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 998244353;

void add(long long& a, const long long& b)
{
	a = (a + b) % mod;
}

void mul(long long& a, const long long& b)
{
	a = (a * b) % mod;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	int sum = 0;
	for(int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	vector<vector<long long>> dp(N + 1, vector<long long>(sum + 301, 0)); //dp[i][j]: first i nums has been painted, total value of red color is j, the number of ways to paint first i colors is dp[i][j].
	vector<vector<long long>> dp2(N + 1, vector<long long>(sum + 301, 0)); //dp[i][j]: first i nums has been painted into red or green(exclude blue), total value of red color is j, the number of ways to paint first i colors is dp[i][j].
	dp[0][0] = 1;
	dp2[0][0] = 1;
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j <= sum; j++)
		{
			add(dp[i + 1][j + A[i]], dp[i][j]); //paint i-th into red color
			add(dp[i + 1][j], 2 * dp[i][j]); //paint i-th into other color
			add(dp2[i + 1][j + A[i]], dp2[i][j]); //paint i-th into red color
			add(dp2[i + 1][j], dp2[i][j]); //paint i-th into green color
		}
	}
	long long neg = 0;
	for(int j = (sum + 1) / 2; j <= sum; j++)
	{
		add(neg, dp[N][j]);	
	}
	if(sum % 2 == 0)
	{
		add(neg, mod - dp2[N][sum / 2]);
	}
	mul(neg, 3);
	long long ans = 1;
	for(int i = 0; i < N; i++) mul(ans, 3);
	add(ans, mod - neg);

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


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

int main(){
    int n,a,ans=0,sm=1,bi=1;
    vector<int> co(9,0);
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a<400){
            co.at(0)++;
        }else if(a<800){
            co.at(1)++;
        }else if(a<1200){
            co.at(2)++;
        }else if(a<1600){
            co.at(3)++;
        }else if(a<2000){
            co.at(4)++;
        }else if(a<2400){
            co.at(5)++;
        }else if(a<2800){
            co.at(6)++;
        }else if(a<3200){
            co.at(7)++;
        }else{
            co.at(8)++;
        }
    }

    for(int i=0;i<8;i++){
        if(co.at(i)){
            ans++;
        }
    }
    if(ans>0){
        sm=ans;
    }
    bi=ans+co.at(8);
    cout << sm <<" "<< bi << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    ll a[n];
    ll sum = 0LL;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll c = (ll)(ceil((double)sum / (double)n));
    ll f = (ll)(floor((double)sum / (double)n));

    ll x = 0LL;
    ll y = 0LL;
    for(int i = 0; i < n; i++){
        x += (a[i] - c)*(a[i] - c);
        y += (a[i] - f)*(a[i] - f);
    }
    cout << min(x,y) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    long long int a,b;
    cin>>a;
    while(a){
       a--;
       s+=char('a'+a%26);
       a/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<'\n';
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	ini(n);
	vector<string> a;
	int ma = 0;
	map<string,int> map1;
	FOR(i,0,n){
		ins(x);
		a.push_back(x);
		map1[x]++;
		ma = max(ma,map1[x]);
	}
	vector<string> x1;
	FOR(i,0,n){
		if(map1[a[i]] == ma){
			x1.push_back(a[i]);
		}
	}
	sort(x1.begin(),x1.end());
	int size = x1.size();
	string at = x1[0];
	FOR(i,0,size){
		if(i != 0 and x1[i] == at){
			continue;
		}
		out(x1[i]);
		at = x1[i];
	}
	return 0;
}

Measured memory_bytes: 27120
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;

int a[15];
int y[15][15];
bool tf[15];

void set_tf(int n) {
	for (int i = 0; i < 15; i++) {
		if (n % 2 == 1)
			tf[i] = true;
		else
			tf[i] = false;
		n /= 2;
	}
}

int get_num() {
	int ans = 0;
	for (int i = 0; i < 15; i++) {
		if (tf[i]) ans++;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			y[i][j] = -1;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < a[i]; j++) {
			int x, y_; cin >> x >> y_;
			y[i][x-1] = y_;
		}
	}
	int ans = 0;
	int n_pow = pow(2, n);
	for (int i = 0; i < n_pow; i++) {
		bool flag = true;
		set_tf(i);
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (y[j][k] == -1) continue;
				if (tf[j] && y[j][k] == 1 && !tf[k]) {
					flag = false;
					break;
				}
				else if (tf[j] && y[j][k] == 0 && tf[k]) {
					flag = false;
					break;
				}
			}
			if (!flag) break;
		}
		if (flag) ans = max(ans, get_num());
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int main() {
	int i;
	int a, b;
	scanf("%d %d", &a, &b);
	if (a >= 13)printf("%d", b);
	else if (a >= 6)printf("%d", b / 2);
	else printf("0");
	printf("\n");











	return 0;
}

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

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

class Task:
    def __repr__(self):
        return str(self.__dict__)
    def time_toget_point(self, p):
        if p >= self.max_minus:
            return math.ceil(self.b + (p - self.max_minus)/self.u)
        else:
            return math.ceil(p/self.l)

def solve():
    n, x = map(int, input().split())
    t_list = []
    total_behind = 0 # これだけ点を取らなければならない

    for i in range(n):
        t = Task()
        t.b, t.l, t.u = map(int, input().split())

        t.max_minus = t.b * t.l # 重み最低で勉強しない場合のマイナス
        t.max_plus = (x-t.b) * t.u # 重み最高で満点まで勉強する時のプラス
        t.eff = t.max_plus + t.max_minus # 重み最高にした時の勉強効率
        t_list.append(t)

        total_behind += t.max_minus
    dprint(total_behind)

    # 重み最高での勉強効率の降順に並び変え
    import numpy as np
    t_list = sorted(t_list, key=lambda t: t.eff, reverse=True)
    cumsum = list(np.cumsum([t.eff for t in t_list]))
    dprint(t_list)
    dprint(cumsum)

    # 何要素目まで上から取ると必要点数を超えるか
    import bisect
    for max_i in range(len(t_list)):
        if cumsum[max_i] > total_behind:
            break
    dprint("max_i:", max_i)

    # 部分点を取るtaskをi番目と決めたときの、必要勉強時間を求める。その最小値が答えになる
    min_time = -1
    for i, t in enumerate(t_list):
        if i <= max_i:
            # このケースでは上から max_i 要素目までのうち i 以外を取り、iから最適な値をとる
            rest_p = total_behind - (cumsum[max_i] - t.eff)

        else:
            # このケースでは単に上から max_i-1 要素目までとり、iから最適な個数とる
            # 必要時間がXを超える場合は解にならないが、気にしなくていい
            if max_i == 0:
                rest_p = total_behind
            else:
                rest_p = total_behind - cumsum[max_i-1]

        time = x * (max_i) + t.time_toget_point(rest_p)
        dprint(i, rest_p, time, min_time, t)
        if min_time == -1 or min_time > time:
            min_time = time
    print(min_time)

solve()

Measured memory_bytes: 65304
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;

const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int a,b;

	cin>>a>>b;

	if(b>=a)cout<<"unsafe\n";
	else	cout<<"safe\n";
	
}


Measured memory_bytes: 3652