akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N], B[MAX_N], C[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> A[i];
		A[i]--;
	}
	int res = 0;
	rep(i, 0, N) {
		int b; cin >> b; res += b;
	}
	rep(i, 0, N - 1) cin >> C[i];

	rep(i, 0, N - 1) {
		if(A[i] == A[i + 1] - 1) res += C[A[i]];
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

const int INF = 1001001001;

int main(){
  ll n;
  cin >> n;
  ll maxl = 0,minr = 10e9,distmax = 0,case1 = 0,case2 = 0;
  vector<pair<ll,ll>> lr;
  for(int i=0;i<n;i++){
    ll l; cin >> l;
    ll r; cin >> r;
    maxl = max(l,maxl);
    minr = min(r,minr);
    lr.push_back(make_pair(l,r));
    distmax = max(distmax,r-l);
  }

  //右端が一番左側にあるpairと左端が一番右がわにあるpairを同じ集合に含む
  case1 = max(minr - maxl + 1 + distmax + 1,distmax+1);

  //別々の集合に含まれる
  {
    for(int i=0;i<n;i++){
      lr.at(i).first = max(minr-lr.at(i).first + 1,0ll);
      lr.at(i).second = max(lr.at(i).second-maxl + 1,0ll);
    }
    sort(lr.begin(),lr.end(),[](const pair<ll,ll> a, const pair<ll,ll> b) {
      if(a.first != b.first) return a.first < b.first;
      else return a.second > b.second;
    });
    ll mina = INF,minb = INF;
    for(int i=0;i<n-1;i++){
      mina = lr.at(i+1).first;
      minb = min(minb,lr.at(i).second);
      case2 = max(case2,mina + minb);
    }
  }
  cout << max(case1,case2) << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
 
using graph = vector<vector<ll>>;

int main(){
    ll d,t,s;
    cin >> d >> t >> s;
    if(d <= t * s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int comp(const void * a , const void * b){
  if(*( int * )a < *( int * )b) return 1;
  else return -1;
}

int main(void){
  int i, data[10];
  for(i=0;i<10;i++){
    scanf("%d", &data[i]);
  }
  qsort(data, 10, sizeof(int), comp);
  printf("%d\n%d\n%d\n", data[0], data[1], data[2]);
  return 0;
}

Measured memory_bytes: 604
import java.util.*;
import java.util.stream.*;

public class Main {
	Scanner sc;
	int N;
	int[] H;
	
//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	/**
	 * アルゴリズム本体
	 */
	private void calc() {
		N = sc.nextInt();
		H = new int[N];
		
		int lastVal = -1;
		boolean solvable = true;
		
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
			if (H[i] - 1 >= lastVal) {
				lastVal = H[i] - 1;
				continue;
			} else if (H[i] >= lastVal) {
				lastVal = H[i];
				continue;
			}
			solvable = false;
			break;
		}
		out(solvable?"Yes":"No");
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
//======
// main
//
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

}

Measured memory_bytes: 49996
//Bismillahir Rahmanir-Rahim
/**@MSR**/
#include<bits/stdc++.h>
using namespace std;

#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define lli long long int
#define el '\n'
#define inf 2000000000
#define mem(a,b) memset(a, b, sizeof(a) )

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define F1(i,n)  for(lli i=1;i<=n;i++)
#define F0(i,n)  for(lli i=0;i<n;i++)
#define FRev(i,n)  for(lli i=n-1;i>=0;i--)
#define ever (;;)

ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

const int mx = 1e5+123;
int dp[mx][4], n;
int h[mx][4];

int magic( int i, int f1 )
{
    if ( i > n )
        return 0;
    if ( dp[i][f1] != -1 )
        return dp[i][f1];

    int ret = 0;
    for ( int j = 1; j <= 3; j++ )
    {
        if ( j != f1 )
        {
            ret = max ( ret, h[i][j] + magic ( i+1, j ) );
        }
    }

    return dp[i][f1] = ret;

}


int main()
{
    optimize();
    ll t,x,y,k,z,m,a,b;
    /**/
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>h[i][1]>>h[i][2]>>h[i][3];



    mem(dp,-1);

    cout<<magic(1,0)<<el;

    return 0;
}
/**/




Measured memory_bytes: 14584
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N, P;
    cin >> N >> P;
    LL dp[2] = {};
    dp[0] = 1;
    REP(i, N) {
        int A;
        cin >> A;
        LL ndp[2] = {};
        ndp[0] += dp[0];
        ndp[1] += dp[1];
        ndp[(0 + A) % 2] += dp[0];
        ndp[(1 + A) % 2] += dp[1];
        dp[0] = ndp[0];
        dp[1] = ndp[1];
    }
    cout << dp[P] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    ll ax = abs(x);

    ll i = ax / d;
    if (k <= i) {
        cout << ax - d * k << endl;
    } else if ((k - i) % 2 == 0) {
        cout << ax - d * i << endl;
    } else {
        cout << abs(ax - d * i - d) << endl;
    }
}


Measured memory_bytes: 3588
S = input()
K = int(input())

ans = ""
for s in S:
    if s == "a":
        ans += s
    elif 123-ord(s) <= K:
        ans += "a"
        K -= 123-ord(s)
    else:
        ans += s
if K > 0:
    ans = ans[:-1] + chr((ord(ans[-1])-97+K)%26+97)
print(ans)


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

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

    int n, m;
    cin >> n >> m;
    vector<bool> a(n + 1, true);
    REP(i, m) {
        int tmp;
        cin >> tmp;
        a[tmp] = false;
    }

    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    REP(now, n) {
        for (int next = now + 1; next <= min(n, now + 2); next++) {
            if (a[next]) {
                dp[next] += dp[now];
                dp[next] %= int(1e9 + 7);
            }
        }
    }

    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    long double a, b; cin >> a >> b;
    long double ans = floor(a * b);
    cout << fixed << setprecision(0) << ans << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

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

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

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

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t A, B, C;

    scanf("%zu %zu %zu", &A, &B, &C);

    if (A == B && B == C) {
        puts(A % 2 == 0 ? "-1" : "0");
    }
    else {
        size_t cnt = 0;

        do {
            if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
                break;
            }

            const size_t newA = (B + C) / 2;
            const size_t newB = (A + C) / 2;
            const size_t newC = (A + B) / 2;

            A = newA;
            B = newB;
            C = newC;

            cnt++;
        } while (true);

        printf("%zu\n", cnt);
    }

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL n, m, xsum, left, ysum, right;

int main()
{
	in >> n >> m;
	std::vector<LL>x(n), y(m);
	rep(i, n) in >> x[i];
	rep(i, m) in >> y[i];
	xsum = x[0];
	for (int i = 1; i < n; ++i)
	{
		left += x[i] * i - xsum;
		xsum += x[i];
		left %= mod;
	}
	ysum = y[0];
	for (int i = 1; i < m; ++i)
	{
		right += y[i] * i - ysum;
		ysum += y[i];
		right %= mod;
	}
	out << (left*right) % mod << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define endl	'\n'
#define MOD 1000000

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = { 0,1,0,-1 };
int dy[] = { -1,0,1,0 };
int dz[] = { 0,0,0,0,1,-1 };
const int INF = 1000000000;

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

	int n;
	cin >> n; 
	vector<int> v(n);

	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	for (int i = n - 2; i >= 0; i--) {
		if (v[i] <= v[i + 1]) continue;
		if (v[i] - v[i + 1] != 1) {
			cout << "No";
			return 0;
		}
		v[i] -= 1;
	}

	cout << "Yes";
}


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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, a, b, c);
  int ans = 0;
  while (true) {
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    if (a > 0) c -= a, b -= a, a = 0;
    if (c == 0) break;
    if (a == b) {
      ++a, ++b;
    } else {
      a += 2;
    }
    ++ans;
  };
  wt(ans);
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll ans = 0,a;
  rep(i,10){
    cin >> a;
    ans += a;
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 3124
## 一時間もTLEのために時間を無駄にした　学びもないつまんない問題...

R, C, K = map(int, input().split())
dp = [[[0]*(C+1) for _ in range(R+1)]for __ in range(4)]
# dp[r][c][j] :=r index c columns already j cnt
dp[0][0][0] = 0
D = [[0 for i in range(C+1)] for j in range(R+1)]

for i in range(K):
    r, c, v = map(int, input().split())
    D[r][c] = v

for i in range(R+1):
    for j in range(C+1):
        if D[i][j] > 0:
            v = D[i][j]
            M = max(dp[k][i-1][j] for k in range(4))
            dp[0][i][j] = max(dp[0][i][j-1], M)
            dp[1][i][j] = max(dp[0][i][j-1]+v, dp[1][i][j-1], M+v)
            dp[2][i][j] = max(dp[1][i][j-1]+v, dp[2][i][j-1])
            dp[3][i][j] = max(dp[2][i][j-1]+v, dp[3][i][j-1])

        else:
            M = max(dp[k][i-1][j] for k in range(4))
            dp[0][i][j] = max(dp[0][i][j-1], M)
            dp[1][i][j] = dp[1][i][j-1]
            dp[2][i][j] = dp[2][i][j-1]
            dp[3][i][j] = dp[3][i][j-1]

ans = 0
for i in range(4):
    ans = max(ans, dp[i][-1][-1])
print(ans)


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

int n,m,k;
int fa[100005];
vector<int> bk[100005];
set<int> fri[100005];

int find(int x){
    if(fa[x]==x)return x;
    else return fa[x]=find(fa[x]);
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    fa[x]=y;
}

int main(){

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

    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)fa[i]=i;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        unite(a,b);
        bk[a].push_back(b);
        bk[b].push_back(a);
    }
    for(int i=0;i<k;i++){
        int a,b;
        cin>>a>>b;
        bk[a].push_back(b);
        bk[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        int anc=find(i);
        fri[anc].insert(i);
    }
    for(int i=1;i<=n;i++){
        int anc=find(i);
        int ans=fri[anc].size()-1;
        for(int j=0;j<bk[i].size();j++){
            if(fri[anc].find(bk[i][j])!=fri[anc].end())ans--;
        }
        cout<<ans<<' ';
    }
    cout<<endl;

    return 0;
}

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

using namespace std;

void solve()
{
	string str;
	while(getline(cin, str))
	{
		for(int i = 1; i <= 26; ++i)
		{
			string permutated = str;
			for(int j = 0; j < permutated.size(); ++j)
			{
				if('a' <= permutated[j] && permutated[j] <= 'z')
				{
					if(permutated[j] + i > 'z')
					{
						permutated[j] = permutated[j] + i - 26;
					}
					else
					{
						permutated[j] += i;
					}
				}
			}
			if(permutated.find("the") != permutated.npos || permutated.find("this") != permutated.npos || permutated.find("that") != permutated.npos)
			{
				cout << permutated << endl;
			}
		}
	}
}

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

Measured memory_bytes: 1184
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-07-29 16:51:04 +0900
# LastModified: 2020-07-29 16:59:15 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, a, b = map(int, input().split())
    down = (n-1)*a + b
    up = (n-1)*b + a
    if up-down+1 > 0:
        print(up-down+1)
    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I=int(A);I<int(B);I++)
#define SORT(x) (sort(x.begin(),x.end()))
#define REV(x) (reverse(x.begin(),x.end()))


int main(){
  ll n,ans=0;
  
  cin >> n;
  vector<ll> a(n);
  FOR(i,0,n)cin >> a[i];
  SORT(a);
  FOR(i,0,n)FOR(j,i+1,n)FOR(k,j+1,n){
    if(a[i]+ a[j]>a[k])ans++;
    else break;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    string s1, s2;
    cin >> s1;
    cin >> s2;
    n = s1.length();
    m = s2.length();
    int f[n + 1][m + 1];
    for (int i = 0; i <= n; i++)
    {
        f[i][0] = 0;
    }
    for (int j = 0; j <= m; j++)
    {
        f[0][j] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (s1[i - 1] == s2[j - 1])
            {
                f[i][j] = f[i - 1][j - 1] + 1;
            }
            else
            {
                f[i][j] = max(f[i - 1][j], f[i][j - 1]);
            }
        }
    }
    string xau;
    while (n > 0 && m > 0)
    {
        if (s1[n - 1] == s2[m - 1])
        {
            xau = char(s1[n - 1]) + xau;
            n--;
            m--;
        }
        else
        {
            if (f[n - 1][m] == f[n][m])
            {
                n--;
            }
            else
            {
                m--;
            }
        }
    }
    cout << xau;
}

Measured memory_bytes: 35456
def main():
    from collections import Counter as CNT
    from itertools import combinations as COM

    n, *s = open(0).read().split()
    i = [x[0] for x in s]
    d = CNT(i)
    c = [d.get(i) if d.get(i) != None else 0 for i in 'MARCH']
    ans = sum(a * b * c for a, b, c in COM(c, 3))
    print(ans)

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 10832
Y, N = map(int, input().split())

hantei = False
for i in range((N//10000), -1, -1):
    if i <= Y:
        for j in range( ((N - (10000*i)) // 5000), -1, -1):
            if i+j <= Y:
                if (1000 * (Y-i-j) + 5000 * j + 10000 * i) == N:
                     hantei = True
                     break
        else:
            continue
        break

if hantei:
    print("{} {} {}".format(i,j,(Y-i-j)))
else:
    print("-1 -1 -1")


Measured memory_bytes: 3064
n,w=map(int, input().split())
weight=[0]*n
value=[0]*n
for i in range(n):
    weight[i],value[i]=map(int,input().split())

dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for sum_w in range(w+1):
        # i番目の品物を選ぶ場合
        if sum_w -  weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+value[i])
        # i番目の品物を選ばない場合
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[n][w])

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

using namespace std;

int main(){
  string S;cin>>S;
  int count = 0;
  for(int i=0;i<3;i++){
    if(S[i]=='R') count++; 
  }
  if(count==1) cout << 1 << endl;
  else if(count==3) cout << 3 << endl;
  else if(count==0) cout << 0 << endl;
  else{
    if(S[0]==S[2]) cout << 1 << endl;
    else cout << 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#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

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 };


int main() {
	ll n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << n * 2 << endl;
	}
}

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

int main()
{
    int k,j;
    cin>>k;
    string s;
    cin>>s;
    int l=s.length();
    if(l<=k)
        cout<<s;
    if(l>k)
    {
        for(int i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"...";
    }
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int a,b;
  
  cin >> a >> b;
  if(a*b == 15)
    cout << "*" << "\n";
  else if((a+b) == 15)
    cout << "+" << "\n";
  else
    cout << "x" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,k;
  cin>>a>>b>>k;
  int cnt=0;
  repn(i,101){
    if(a%i==0 && b%i==0){
      cnt++;
    }
    if(cnt==k){cout<<i<<endl;return 0;}
  }


  return 0;
}

Measured memory_bytes: 256
/*** ?????°?????? ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; ++i)
int dx[4]={1, 0, -1, 0};
int dy[4]={0, -1, 0, 1};

void check(int x, int y, int w, int h, char lattice[][50], bool lat[][50]){
	REP(i, 4){
		int xx=x+dx[i], yy=y+dy[i];
		if(xx>=0 && xx<w && yy>=0 && yy<h && lattice[yy][xx]=='.' && !lat[yy][xx]){
			lat[yy][xx]=true;
			check(xx, yy, w, h, lattice, lat);
		}
	}
}

int main(){
	int w, h;
	int i, j;
	
	cin >> w >> h;
	while(w || h){
		char lattice[50][50]={};
		bool lat_b[50][50]={};
		bool lat_w[50][50]={};
		
		REP(j, h){
			REP(i, w){
				cin >> lattice[j][i];
			}
		}
		
		REP(j, h){
			REP(i, w){
				if(lattice[j][i]=='B') check(i, j, w, h, lattice, lat_b);
				else if (lattice[j][i]=='W') check(i, j, w, h, lattice, lat_w);
			}
		}
		
		int black=0, white=0;
		REP(j, h){
			REP(i, w){
				if(lat_b[j][i] && !lat_w[j][i]) ++black;
				else if(!lat_b[j][i] && lat_w[j][i]) ++white;
			}
		}
		
		cout << black << " " << white << endl;
		
		cin >> w >> h;
	}
	return 0;
}

Measured memory_bytes: 3156
#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

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

  if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" ||
      s == "hihihihihi") {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


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

#define ll long long
#define mod 1000000007

ll n;
double prob, dp[3003];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	double ans = 0;
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> prob;

		for (int heads = i; heads >= 0; heads--) {
			dp[heads] = (heads == 0 ? 0 : prob * dp[heads - 1]) + (1 - prob) * dp[heads];
		}
	}

	for (int i = n / 2 + 1; i <= n; i++ ) {
		ans += dp[i];
	}

	cout << setprecision(10) << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int n, m, q;
vector <int> a, b, c, d;
int ans;

template <typename T>
void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

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

  int a_count, b_count, c_count;
  if (k >= a) {
    a_count = a;
    if ((k - a) >= b) {
      b_count = b;
      c_count = (k - a_count - b_count);
      cout << a_count - c_count << endl;
    } else {
      cout << a_count << endl;
    }
  } else {
    a_count = k;
    cout << a_count <<endl;
  }
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;
 
int main(int argc, char* argv[])
{    
    int n;
    scanf("%d", &n);
    vector<ll> z(n);
    int i;
    ll sum=0;
    for(i=0; i<n; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        z[i]=a+b;
        sum-=b;
    }
    sort(z.rbegin(), z.rend());

    for(i=0; i<n; i++) {
        if(i%2==0) {
            sum+=z[i];
        }
    }
    printf("%lld\n", sum);

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main() {
  int n,cnt;
  cin >> n;
  for(int i=0; i<=n/7; i++) {
    cnt=n;
    cnt-=i*7;
    if(cnt%4==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

int main() {
    int sx, sy, tx, ty;
    std::cin >> sx;
    std::cin >> sy;
    std::cin >> tx;
    std::cin >> ty;

    std::map<int, std::map<int, bool>> r;

    int x = sx, y = sy;
    std::string out;

    for (int i = 0; i < 2; i++) {
        while (x != tx || y != ty) {
            if (x < tx) {
                if (!r[x+1][y]) {
                    r[++x][y] = true;
                    out += "R";
                    continue;
                }
            }
            if (y <= ty) {
                if (!r[x][y+1]) {
                    r[x][++y] = true;
                    out += "U";
                    continue;
                }
            }
            if (x != tx) {
                if (!r[x-1][y]) {
                    r[--x][y] = true;
                    out += "L";
                    continue;
                }
            }
            if (!r[x][y-1] || (x == tx && (y-1) == ty)) {
                r[x][--y] = true;
                out += "D";
                continue;
            }
        }
        while (x != sx || y != sy) {
            if (x > sx) {
                if (!r[x-1][y]) {
                    r[--x][y] = true;
                    out += "L";
                    continue;
                }
            }
            if (y >= sy) {
                if (!r[x][y-1]) {
                    r[x][--y] = true;
                    out += "D";
                    continue;
                }
            }
            
            if (x != sx) {
                if (!r[x+1][y]) {
                    r[++x][y] = true;
                    out += "R";
                    continue;
                }
            }
            if (!r[x][y+1] || (x == sx && (y+1) == sy)) {
                r[x][++y] = true;
                out += "U";
                continue;
            }
        }
    }
    
    std::cout << out.c_str() << std::endl;
    
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = (N % 1000) / 100;
  c = (N % 100) / 10;
  d = (N % 10);
  if ((a == b) && (b == c) || (b == c) && (c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int R,G;
    cin >> R >> G;
    cout << 2*G-R;
    return 0;
}


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

int main() {
 vector<int> vec(5);
  cin >> vec.at(0) >> vec.at(1) >>vec.at(2) >> vec.at(3) >>vec.at(4);
  vector<int> ans(5);
  for (int i=0; i<5; i++){
    if ( vec.at(i)%10 == 0){
    ans.at(i) = vec.at(i);
    }
    else{
      ans.at(i) = vec.at(i) - ( vec.at(i) % 10 ) + 10;
    }
  }
  vector<int> amari(5);
    for (int i=0; i<5; i++){
      if ( vec.at(i)%10 == 0){
      amari.at(i) = 10;
      }
      else{
        amari.at(i) = vec.at(i) % 10;
      }
    }
  sort(amari.begin(), amari.end());
  if (amari.at(0) == 10){
    int answer;
    answer = (ans.at(0) + ans.at(1) + ans.at(2) + ans.at(3) + ans.at(4));
              cout << answer << endl;
  }
  else{
    int answer;
    answer = (ans.at(0) + ans.at(1) + ans.at(2) + ans.at(3) + ans.at(4) + amari.at(0) - 10);
    cout << answer << endl;
}
              }

Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def ceil(a, b): return (a + b - 1) // b


def main():
    X, Y = map(int, input().split())
    ans = 0
    while X <= Y:
        X *= 2
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
def _integral(A):
    result = []
    sum_value = 0
    result.append(sum_value)
    for i in range(len(A)):
        sum_value += A[i]
        result.append(sum_value)
    return result


def _main(N, M, K, A, B):
    integral_a = _integral(A)
    integral_b = _integral(B)
    top_count = 0
    b_max = len(B)
    for a_index in range(len(A) + 1):
        a_value = integral_a[a_index]
        if K < a_value:
            break
        for b_index in range(0, min(len(B) + 1, b_max + 1))[::-1]:
            if a_value + integral_b[b_index] <= K:
                if top_count < a_index + b_index:
                    top_count = a_index + b_index
                b_max = b_index
                break
    print(top_count)


if __name__ == "__main__":
    Na, Ma, Ka = map(int, input().split())
    Aa = list(map(float, input().split()))
    Ba = list(map(float, input().split()))
    _main(Na, Ma, Ka, Aa, Ba)


Measured memory_bytes: 41596
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int n;
    int sum,num;
    while(cin>>n)
    {
        sum=0;
        num=1;
        for(int i=1; i<=n; i++)
        {
            int ans=0;
            int m=i;
            while(m%2==0)
            {
                m/=2;
                ans++;
            }
            if(sum<ans)
            {
                sum=ans;
                num=i;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}


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

string rev(string S){
  string res = S;
  int N = S.size();
  for(int i=0; i<N; i++){
    res.at(i) = S.at(N-i-1);
  }
  return res;
}

int add(string &front, string &back, int F, string C, int j){
  if(j==0){
    if(F==1) front = C+front;
    else back = back+C;
  }
  else{
    if(F==1) back = back+C;
    else front = C+front;
  }
  return 0;
}

int main(){
  string S;
  int Q;
  cin >> S >> Q;
  vector<int> T(Q), F(Q);
  vector<string> C(Q);
  for(int i=0; i<Q; i++){
    cin >>T.at(i);
    if(T.at(i)==2){
      cin >> F.at(i) >> C.at(i);
    }
  }
  string front;
  string back;
  int j = 0;
  for(int i=0; i<Q; i++){
    if(T.at(i)==1) j = 1-j;
    else add(front,back,F.at(i),C.at(i),j);
  }
  if(j==1){
    S=rev(S);
    front=rev(front);
    back=rev(back);
    S=back+S+front;
  }
  else{
    S=front+S+back;
  }
  cout << S << endl;
}

Measured memory_bytes: 14372
import re

s = input()
even_list = []
odd_list = []

for i in range(len(s)):
    if (i+1) % 2 == 0:
        even_list.append(s[i])
    else:
        odd_list.append(s[i])

for i in range(len(even_list)):
    if not re.match(r'[L,U,D]',even_list[i]):
        print("No")
        exit()

for i in range(len(odd_list)):
    if not re.match(r'[R,U,D]', odd_list[i]):
        print("No")
        exit()

print("Yes")



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const double EPS = 1e-9;

int main(){
    int n;
    double k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;

    double c[205];
    rep(i,n) cin >> c[i];
    c[n] = l;

    double m, h, s; //?????¨???????????????????????°????????????????????????
    double time = 0;
    int i = 0;
    while(m < l){
        double next = c[i] - m;
        if((h > 0 && s < EPS) || h > k){
            h--;
            s = t;
        }else if(h == 0 && s < EPS){
            time += next / u;
            m += next;
            i++;
            h++;
        }else if(s > EPS){
            if(next / v <= s){
                s -= next / v;
                time += next / v;
                m += next;
                i++;
                h++;
            }else{
                m += s * v;
                time += s;
                s = 0;
            }
        }
    }
    cout <<fixed << setprecision(8) <<  time << endl;
}

Measured memory_bytes: 3260
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
ans=[None]*(N-K)
for i in range(N-K):
  if A[K+i]>A[i]:
    ans[i]='Yes'
  else:
    ans[i]='No'
print(*ans, sep='\n')

Measured memory_bytes: 94996
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i){
	return 2*i+1;
}

void maxHeapify(int *A, int i, int n){
	int l_idx, r_idx, temp;
	l_idx = left(i+1)-1;
	r_idx = right(i+1)-1;
	temp = i;

	if(r_idx < n){
		if(A[r_idx] > A[i]){
			temp = r_idx;
		}
	}
	if (l_idx < n){
		if (A[l_idx] > A[temp]){
			temp = l_idx;
		}
	}
	if (temp != i){
		std::swap(A[i], A[temp]);
		maxHeapify(A, temp, n);
	}
}

void compareParent(int *A, int i, int n){
	int p;
	if (i!=0){
		p = parent(i+1)-1;
		if (A[i] > A[p]){
			std::swap(A[i], A[p]);
			compareParent(A, p, n);
		}
	}
}

int main(void){
	int n;
	int A[2000000];
	n = 0;
	char op[10];
	while(1){
		scanf("%s", op);
		if(op[2] == 'd'){
			break;
		}
		else if(op[2] == 's'){
			scanf("%d", &A[n]);
			n++;
			compareParent(A, n-1, n);
		}
		else{
			printf("%d\n", A[0]);
			std::swap(A[n-1], A[0]);
			n--;
			maxHeapify(A, 0, n);
		}
	}
	return 0;
}

Measured memory_bytes: 6488
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <complex>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1000000007;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans=0;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> b(n+1,0);
    for(int i = 0; i < n; i++){
        b[a[i]] = b[a[i]-1] + 1;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans,b[i]);
    }

    cout << n - ans << endl;

    // map<int,int> m;
    // for(int i = 0; i < n; i++){
    //     if(!m.count(a[i]-1)){
    //         m[a[i]] = 1;
    //     }else{
    //         m[a[i]] = m[a[i]-1] + 1;
    //     }
    // }
    // //int ans = 0;
    // for(auto itr = m.begin(); itr != m.end(); itr++){
    //     ans = max(ans,itr->second);
    // }

    // cout << n - ans << endl;

    return 0;
}

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

struct edge {
    int to, dist, cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr int INF = 1e9;

int main() {
    int N, M;
    while(cin >> N >> M, N) {
        vector<int> d(N, INF);
        vector<int> cost(N, INF);
        graph g(N);
        for(int i=0; i<M; ++i) {
            int a, b, d, c;
            cin >> a >> b >> d >> c;
            a--; b--;
            g[a].push_back((edge){b, d, c});
            g[b].push_back((edge){a, d, c});
        }
        using state = tuple<int, int, int>;
        priority_queue<state, vector<state>, greater<state>> que;
        que.push(make_tuple(0, 0, 0));
        d[0] = 0;
        cost[0] = 0;
        while(!que.empty()) {
            int dis, cos, v;
            tie(dis, cos, v) = que.top();
            que.pop();
            if(d[v] < dis || cost[v] < cos) {
                continue;
            }
            for(auto& e : g[v]) {
                if(d[e.to] > d[v] + e.dist || d[e.to] == d[v] + e.dist && cost[e.to] > e.cost) {
                    d[e.to] = d[v] + e.dist;
                    cost[e.to] = e.cost;
                    que.push(make_tuple(d[e.to], cost[e.to], e.to));
                }
            }
        }
        cout << accumulate(cost.begin()+1, cost.end(), 0) << endl;
    }
}


Measured memory_bytes: 3896
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N >> K;
	vector<vector<long long int>>dp(2, vector<long long int>(K + 5));
	dp[1][0] = 1;
	for (int i = 0; i < N; i++) {
		cin >> M;
		for (auto &j : dp[i & 1])j = 0;
		for (int j = 0; j <= K; j++) {
			dp[i & 1][j] += dp[(i ^ 1) & 1][j];
			dp[i & 1][min(j + M, K) + 1] -= dp[(i ^ 1) & 1][j]-MOD;
		}
		for (int j = 1; j <= K + 1; j++) {
			dp[i & 1][j] += dp[i & 1][j - 1];
			dp[i & 1][j] %= MOD;
		}
	}
	cout << dp[(N ^ 1) & 1][K] << endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a= s.nextInt(),b=s.nextInt(),c=s.nextInt();
        System.out.println(Math.min(b/a,c));

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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



int main() {
	int n;
	cin >> n;
	int *h;
	h = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int count = 0;

	for (int i = 0; i < 100; i++) {
		int flag = 0;
		for (int i = 0; i < n; i++) {
			if (h[i] != 0) {
				h[i]--;
				if (flag == 0) {
					count++;
					flag = 1;
				}
			}
			else if (h[i] == 0) {
				flag = 0;
			}
		}

	}

	cout << count;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

long N;

int dfs(long x, int y) {
  if (x > N) return 0;
  
  int ret = 0;
  if ( y == 0x7 ) ret++;
  
  ret += dfs(x * 10 + 3, y | 0x1 );
  ret += dfs(x * 10 + 5, y | 0x2 );
  ret += dfs(x * 10 + 7, y | 0x4 );
  
  return ret;
}

int main(void) {
    scanf("%ld", &N);
   
    
    printf("%d\n", dfs(0, 0x0));

	return 0;
}


Measured memory_bytes: 256
n=int(input())
for k in range(1,3501):
    for j in range(1,k+2):
        a=(4*j*k - n*k- n*j)
        if a<=0 : continue
        i = n*j*k / a
        i2= n*j*k // a
        if i==i2 :
            print(i2,j,k)
            break
    else:
        continue
    break

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int D = int.Parse(input[0]);
		int[] c = new int[26];
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<26; i++) c[i] = int.Parse(input[i]);
		int[][] s = new int[D][];
		for(int i=0; i<D; i++)
		{
			input = Console.ReadLine().Split(' ');
			s[i] = new int[26];
			for(int j=0; j<26; j++) s[i][j] = int.Parse(input[j]);
		}
		int[] t = new int[D];
		int[][] last = new int[D][];	
		for(int i=0; i<D; i++)
		{
			last[i] = new int[26];
			for(int j=0; j<26; j++) last[i][j] = -1;
		}
		int satisfy = 0;
		for(int i=0; i<D; i++)
		{
			int maxS = s[i][0];
			int idx = 0;
			for(int j=1; j<26; j++)
			if(maxS < s[i][j])
			{
				maxS = s[i][j];
				idx = j;
			} 
			t[i] = idx;
			satisfy += s[i][t[i]];
			last[i][t[i]] = i;
			for(int j=0; j<26; j++)
			{
				if(j!=t[i] && i>0) last[i][j] = last[i-1][j];
				satisfy -= c[j] * (i - last[i][j]);
			}
		}
		Random rd = new Random();
		for(int i=0; i<1000; i++)
		{
			int dTmp = rd.Next() % D;
			int qTmp = rd.Next() % 26;
			int qPre = t[dTmp];
			int iSatisfy = satisfy;
			iSatisfy += (s[dTmp][qTmp] - s[dTmp][qPre]);
			int lastTemp = last[dTmp][qPre];
			int nextD = dTmp;
			for(; nextD < D && dTmp == last[nextD][qPre]; nextD++) { }
			iSatisfy -= c[qPre] * (lastTemp - dTmp) * (nextD - dTmp);
			nextD = dTmp;
			for(; nextD < D && dTmp == last[nextD][qTmp]; nextD++) { }
			iSatisfy -= c[qTmp] * ((dTmp == 0 ? -1 : last[dTmp-1][qTmp]) - dTmp) * (nextD - dTmp);
			if(satisfy < iSatisfy) satisfy = iSatisfy;
			else t[dTmp] = qPre;
		}
		foreach(int ans in t) Console.WriteLine(ans + 1);
	}
}


Measured memory_bytes: 28124
fun main(args : Array<String>) {
    val (s, t) = readLine()!!.split(" ")
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val u = readLine()!!

    if (u == s) {
        println("${a-1} $b")
    } else {
        println("$a ${b-1}")
    }
}


Measured memory_bytes: 37944