akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){

    int N;
    cin >>N;
    string s;
    cin >> s;
    char back;
    map<string,int>Q;
    Q.insert(make_pair(s,1)); 
    back=s[s.size()-1];
    int ans=0;
    for(int i=2;i<=N;i++){
        cin >> s;
        
        if(s[0]!=back || Q.count(s)>0){
        ans=-1;
        break;
        }
        else{
            back=s[s.size()-1];
            Q.insert(make_pair(s,i)); 
        }
    }


    if(ans<0){
        cout <<"No"<<endl;
    }
    else{
        cout <<"Yes"<<endl;
    }
 return 0;
}

Measured memory_bytes: 256
/*
    B - Resale
    https://atcoder.jp/contests/abc125/tasks/abc125_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    int Vi[20] = {};
    int Ci[20] = {};

    for (int i = 0; i < n; i++)
        cin >> Vi[i];

    for (int i = 0; i < n; i++)
        cin >> Ci[i];

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (Vi[i] - Ci[i] >= 0)
            sum += Vi[i] - Ci[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int power(int a, int b)
{
    int c=a;
    for(int i=1; i<b; i++)
    {
        a*=c;
    }
    return a;
}
int main()
{
    int x;
    cin>>x;
    int MAX=-1;
    //cout<<power(2,2)<<endl;
    for(int b=1; b<=100; b++)
    {
        for(int p=2; p<=100; p++)
        {
            if(power(b,p)<=x)
            {
                MAX=max(MAX,power(b,p));
            }
        }
    }
    cout<<MAX<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n;
	cin >> n;
	cout << n*(n+1)/2 << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;

    vl a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    sort(all(a)), sort(all(b));

    if (n % 2) {
        cout << max(0LL, b[n / 2] - a[n / 2] + 1) << '\n';
    } else {
        cout << max(0LL, (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1) << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

int main() {
	// your code goes here
    int n,a[10005],m,i;
    char s[10005];
    cin >> n >> s;
    m=strlen(s);
    for(i=0;i<m;i++) a[i]=s[i]-'A';
    for(i=0;i<m;i++) a[i]=(a[i]+n)%26;
    for(i=0;i<m;i++) printf("%c",'A'+a[i]);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=0
y=0
t=0
for i in range(n):
    T,X,Y=map(int,input().split())
    if (abs(X-x)+abs(Y-y))%2!=(T-t)%2 or abs(X-x)+abs(Y-y)>T-t:
        print("No")
        exit()
    t=T
    x=X
    y=Y
print("Yes")


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

ll solve() {
    ll N, C, c;
    cin >> N >> C;
    vector<vector<ll>> D(C, vector<ll>(C));
    vector<vector<ll>> num_ini(3, vector<ll>(C));
    for ( int i = 0; i < C; i++ ) {
        for ( int j = 0; j < C; j++ ) {
            cin >> D[i][j];
        }
    }
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            cin >> c;
            c--;
            num_ini[(i+j+2)%3][c]++;
        }
    }
    // (i+j)%3=kのマスをk1に塗り替える時の違和感
    vector<vector<ll>> d(3, vector<ll>(C));
    for ( int t = 0; t < 3; t++ ) {
        for ( int k1 = 0; k1 < C; k1++ ) {
            for ( int k0 = 0; k0 < C; k0++ ) {
                if ( k1 == k0 ) continue;
                d[t][k1] += num_ini[t][k0] * D[k0][k1];
            }
        }
    }
    ll ans = 1e9;
    for ( int k0 = 0; k0 < C; k0++ ) {
        for ( int k1 = 0; k1 < C; k1++ ) {
            if ( k1 == k0 ) continue;
            for ( int k2 = 0; k2 < C; k2++ ) {
                if ( k2 == k0 || k2 == k1 ) continue;
                ll s = d[0][k0] + d[1][k1] + d[2][k2];
                ans = min(ans, s);
            }
        }
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
pixel = [[] for i in range(h+2)]
for i in range(h+2):
    if i == 0:
        pixel[i].append('#'*(w+2))
    elif i == h+1:
        pixel[i].append('#'*(w+2))
    else :
        pixel[i].append('#')
        s = input()
        pixel[i].append(s)
        pixel[i].append('#')
for i in range(h+2):
    print("".join(pixel[i]))



Measured memory_bytes: 9056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int x = scanner.nextInt();
		int n = scanner.nextInt();
		int[] p = new int[n];
		int ans = x;
		int dif = 1;
		int flag = 1;
		
		for (int i = 0; i < n; i++) {
			p[i] = scanner.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			if (p[i] == x) {
				flag = 0;
				break;
			}
		}
		
		while (flag == 0) {
			flag = 1;
			
			for (int i = 0; i < n; i++) {
				if (p[i] == x - dif) {
					flag = 0;
					break;
				}
			}
			
			if (flag == 1) {
				ans = x - dif;
				break;
			}
			
			flag = 1;
			
			for (int i = 0; i < n; i++) {
				if (p[i] == x + dif) {
					flag = 0;
					break;
				}
			}
			
			if (flag == 1) {
				ans = x + dif;
				break;
			}
			
			dif++;
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 35880
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
using vpii=vector<pii>;


int max_u(ll&m, ll v)
{
	if(m<v)
	{
		m=v;
		return 1;
	}
	return 0;
}


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vpii dt(n);
		vi c(n+1);
		vi f(n);
		ll sum=0, tn=0, ans=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &dt[i].second, &dt[i].first);
		}
		sort(dt.rbegin(), dt.rend());

		for(int i=0;i<k;i++)
		{
			int&rc=c[dt[i].second];

			sum+=dt[i].first;
			if(!rc) tn++;
			rc++;
		}

		max_u(ans, sum+tn*tn);
		int t=k;
		for(int i=k-1;i>=0;i--)
		{
			int&rc=c[dt[i].second];
			if(rc<=1) continue;
			rc--;
			for(;t<n;t++)
			{
				if(!c[dt[t].second]) break;
			}
			if(t>=n) break;

			sum+=dt[t].first-dt[i].first;
			c[dt[t].second]++;
			tn++;
			max_u(ans, sum+tn*tn);
		}

		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#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 all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

vector<vector<ll>> dp(3001, vector<ll>(3001, 0));
//dp.at(i).at(j)はsの初めi文字とtの初めj文字のLCS長

int main(){
  string s, t;
  cin >> s >> t;
  rep(i, sz(s)){
    rep(j, sz(t)){
      if(s.at(i) == t.at(j)){
        dp.at(i+1).at(j+1) = dp.at(i).at(j)+1;
      }
      else{
        dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j), dp.at(i).at(j+1));
      }
    }
  }
  string ans = "";
  int i = sz(s);
  int j = sz(t);
  while(i != 0 && j != 0){
    if(dp.at(i).at(j) == dp.at(i).at(j-1)){
      j--;
    }
    else if(dp.at(i).at(j) == dp.at(i-1).at(j)){
      i--;
    }
    else{
      ans.push_back(s.at(i-1));
      i--;
      j--;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
}

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

#define LL long long
#define pii pair<int, int>
#define mp make_pair

const int maxN = 5005;
const LL inf = 1e18;

int n;
LL f[maxN + 1][maxN + 1];

pii num[maxN + 1];

inline bool comp(pii a, pii b)
{
	return a.first + a.second < b.first + b.second;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d %d", &num[i].first, &num[i].second);

	sort(num + 1, num + n + 1, comp);

	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n; j++) f[i][j] = inf;

	f[0][0] = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= i; j++)
		{
			f[i][j] = f[i - 1][j];
			if(!j) continue;
			if(num[i].first >= f[i - 1][j - 1]) f[i][j] = min(f[i][j], f[i - 1][j - 1] + num[i].second);
		}

	int ans = 0;
	for(int j = 0; j <= n; j++)
		if(f[n][j] != inf) ans = j;

	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 195968
from math import floor

def f(a,b,x):
    return floor(a*x/b) - a*floor(x/b)

a,b,n = map(int, input().split())
res = -10**9
for x in range(max(min(n,b)-100,0),min(n,b)+1):
    res = max(res, f(a,b,x))
print(res)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N,K;
  cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<bool> dp(6000,0);
  for(int i=0;i<5005;i++)dp[i]=0;
  dp[0]=1;
  sort(v.begin(),v.end());
  int l=0;
  int r=N-1;
  int m=l;
  int ans=-1;

  for(int i=0;i<5005;i++)dp[i]=0;
  dp[0]=1;
  for(int i=0;i<N;i++){
    if(i==m)continue;
    for(int j=5000;j-v[i]>=0;j--){
      dp[j]=(dp[j]||dp[j-v[i]]);
    }
  }
  int o=0;
  int ok=0;
  for(int i=max(K-v[m],o);i<K;i++)if(dp[i])ok++;
  if(ok)ans=0;

  m=r;

  for(int i=0;i<5005;i++)dp[i]=0;
  dp[0]=1;
  for(int i=0;i<N;i++){
    if(i==m)continue;
    for(int j=5000;j-v[i]>=0;j--){
      dp[j]=(dp[j]||dp[j-v[i]]);
    }
  }
  ok=0;
  for(int i=max(K-v[m],o);i<K;i++)if(dp[i])ok++;
  if(ok==0)ans=N;

  m=(l+r)/2;

  while(r-l>1&&ans==-1){
    for(int i=0;i<5005;i++)dp[i]=0;
    dp[0]=1;
    for(int i=0;i<N;i++){
      if(i==m)continue;
      for(int j=5000;j-v[i]>=0;j--){
        dp[j]=(dp[j]||dp[j-v[i]]);
      }
    }
    ok=0;
    for(int i=max(K-v[m],o);i<K;i++)if(dp[i])ok++;
    if(ok)r=m;
    else l=m;
    m=(r+l)/2;
  }
  if(ans==-1)cout<<l+1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;cin>>n>>x;
    vector<int> m;
    int sum = 0;
    rep(i,n){
        int t;cin>>t;
        sum += t;
        m.emplace_back(t);
    }
    sort(all(m));
    x-=sum;
    cout<<x/m[0] + n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using ldb = long double;
using pa = pair < int, int >;
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;
#define pb push_back
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;

int a, b, c, d,sum;
string s1,s2,s,s3,s4;
char ch1,ch2,ch;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s1;
    s2 = s1;
    int c = 0;
    for(int i = 0;i<(s1.size()-1)/2;i++){
    	s3 += s1[i];
    	c++;
    }
    f(i,c+1,s1.size()){
        s4 += s1[i];
    }
    // cout << s3 << " "<< s4 << endl;
    string s33 = s3;
    string s44 = s4;
    reverse(all(s33));
    reverse(all(s44));
    reverse(all(s2));
    if(s2 == s1 and s33 == s3 and s44 == s4){
    	cout << "Yes\n";
    }
    else
    	cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
using namespace std;
typedef long long ll;
const int N=20;
const int M=500;
const int P=1<<16;
int n,m,x,y,z,dp[N][P],G[N][N],tot,sum=0,g[P],ans;
inline 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<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
inline void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
//	freopen("data.in","r",stdin);
	mem(G,-1);
	n=read(),m=read();
	FOR(i,1,m)
	{
		x=read(),y=read(),z=read();
		sum+=z;
		G[x][y]=G[y][x]=z;
	}
	tot=(1<<n)-1;
	FOR(i,1,tot)
		FOR(j,0,n-1) if ((i>>j)&1)
			FOR(k,j,n-1) if ((i>>k)&1)
				if (G[j+1][k+1]!=-1) g[i]+=G[j+1][k+1];
	mem(dp,-1);
	dp[1][1]=0;
	FOR(S,1,tot)
	{
		FOR(i,0,n-1) if (((S>>i)&1)&&dp[i+1][S]!=-1)
		{
			int ss=(tot xor S)|(1<<i);
			for (register int s=ss;s;s=(s-1)&ss)
			{
				if (!((s>>i)&1)) continue;
				dp[i+1][S|s]=max(dp[i+1][S|s],dp[i+1][S]+g[s]);
			}
			FOR(j,0,n-1)
			{
				if ((S>>j)&1) continue;
				if (G[i+1][j+1]==-1) continue;
				dp[j+1][S|(1<<j)]=max(dp[j+1][S|(1<<j)],dp[i+1][S]+G[i+1][j+1]);
			}
		}
	}
	ans=sum-dp[n][tot];
	write(ans);
	return 0;
}

Measured memory_bytes: 5504
# standard library# {{{
import sys
import os
import time
import re
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
# }}}

# input


def solve():
    N, h = map(int, input().split())
    I = [list(map(int, input().split())) for _ in range(N)]
    A = [x[0] for x in I]
    B = [x[1] for x in I]
    A.sort()
    a = max(A)
    B.sort()
    C = B[bisect_left(B, a):]
    s = sum(C)

    count = 0
    for c in reversed(C):
        count += 1
        h -= c
        if h > 0:
            pass
        else:
            break

    if h > 0:
        count += math.ceil(h/a)

    print(count)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 95188
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int a[200005],b[200005],c[200005];
int main(){
    int t;
    while( scanf("%d",&t)!=EOF){
        int i;
        for(i=1;i<=t;i++){
            scanf("%d",&a[i]);
        }
        b[0]=1e9+1;
        for(i=1;i<=t;i++){
            if(a[i]<b[i-1]) b[i]=a[i];
            else b[i]=b[i-1];
        }
        c[t+1]=0;
        for(i=t;i>=1;i--){
            if(a[i]>c[i+1]) c[i]=a[i];
            else c[i]=c[i+1];
        }
        int max_num=-1e9-1;
        for(i=1;i<t;i++){
            if(c[i+1]-b[i]>max_num) max_num=c[i+1]-b[i];
        }
        printf("%d\n",max_num);
    }
    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  int rui[100010]={};
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    rui[a]++;
    rui[b+1]--;
  }
  int ma=1;
  int now=1;
  for(int i=2;i<100010;i++){
    now+=rui[i];
    //cout<<now<<endl;
    if(now>=i){
    ma=max(ma,i);
    }
  }
  
  cout<<ma-1<<endl;
  return 0;
}



Measured memory_bytes: 3488
def main():
    N = int(input())
    A = list(map(int, input().split()))
    h = A[0]
    ans = 0

    for i in range(N):
        if A[i] < h:
            ans += h - A[i]
        if A[i] > h:
            h = A[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define szz(x) (int) (x).size()
#define FOR(i,a,b) for (int i = (a), _for = (b); i < _for; i++)
#define REP(i,n) FOR(i,0,(n))
#define _ << " " <<
const ll MOD = 1000000007ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
inline ll SUB(ll a, ll b) { return a-b >= 0ll ? a-b : a-b+MOD; }
inline ll ADD(ll a, ll b) { return a+b >= MOD ? a+b-MOD : a+b; }
inline ll MUL(ll a, ll b) { return a*b % MOD; }

constexpr int MAX = 100000;
int dp[MAX + 3];
int a[301];
int n, K;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> K;
  REP(i,n) cin >> a[i];
  REP(i,K+1) REP(j,n) if (i >= a[j] && !dp[i - a[j]]) dp[i] = 1;
  if (dp[K]) cout << "First" << endl;
  else cout << "Second" << endl;
}






Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var n = Sarray()[0];
            var ls = new List<int>();
            var rs = new List<int>();
            for(var i=0;i<n;i++)
            {
                var tmp = Sarray();
                ls.Add(tmp[0]);
                rs.Add(tmp[1]);
            }
            ls.Sort();
            rs.Sort();
            var ans = 0;
            if(n%2==1)
            {
                var l = ls[n / 2];
                var r = rs[n / 2];
                ans = r - l + 1;
            }
            else
            {
                var l2 = ls[n / 2 - 1] + ls[n / 2];
                var r2 = rs[n / 2 - 1] + rs[n / 2];
                ans = r2 - l2 + 1;
            }
            WriteLine(ans);
        }

    }
}


Measured memory_bytes: 44744
X, Y, Z, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

tmpList = []
for i in range(X):
    for j in range(Y):
        tmpList.append(a[i] + b[j])

tmpList.sort(reverse=True)
ansLst = []
for i in range(min(K, len(tmpList))):
    for j in c:
        ansLst.append(tmpList[i] + j)

ansLst.sort(reverse=True)

for i in range(K):
    print(ansLst[i])

Measured memory_bytes: 147776
def main():
    N = int(input())
    a = list(map(int, input().split()))

    dp = [[10**13]*N for i in range(N)]
    s = [0] * (N+1)
    for i in range(N):
        s[i+1] = s[i] + a[i]
        dp[i][i] = 0
    for i in range(N-1, -1, -1):
        for j in range(i+1, N):
            tmp = s[j+1] - s[i]
            for k in range(i, j):
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j] + tmp)

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


main()


Measured memory_bytes: 41456
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
  string s,t ; cin>>s>>t ;
  ll a= s.size() ;
  ll b= t.size() ;
  ll c= a-b+1 ;
  ll ans= INF ;
  rep(i,c){
    ll cnt= 0;
    rep2(j,0,b-1){
    if(s[j+i]!=t[j]) cnt++ ;
    }
    chmin(ans,cnt) ;
  }
  cout<<ans<<endl ;

   return 0 ;
 }



Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        var input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int A = int.Parse(input[1]);
        int B = int.Parse(input[2]);
        int a = A * N;
        if(a > B)
        {
            Console.WriteLine(B);
        }
        else
        {
            Console.WriteLine(a);
        }
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }
    /*
    最小公倍数
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    */
    //a<=c, b<=d;
}

//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


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

typedef long long st_t;

const st_t INF = 0x7fffffff;

const int MAX_N = 100000;

st_t st[1 << 18];
// 1 << 18 = 262144

void init(int n, st_t* st){
    int nn = 1;
    while(nn < n) nn *= 2;
    fill(st, st + 2 * nn - 1, INF);
}

void update(int i, st_t a, int k, int l, int r, st_t* st){
    if(i < l || r <= i) return;
    if(r - l == 1) st[k] = a;
    else{
        int chl = 2 * k + 1;
        int chr = 2 * k + 2;
        update(i, a, chl, l, (l + r) / 2, st);
        update(i, a, chr, (l + r) / 2, r, st);
        st[k] = min(st[chl], st[chr]);
    }
}

st_t get_min(int a, int b, int k, int l, int r, st_t* st){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return st[k];
    st_t res_l = get_min(a, b, 2 * k + 1, l, (l + r) / 2, st);
    st_t res_r = get_min(a, b, 2 * k + 2, (l + r) / 2, r, st);
    return min(res_l, res_r);
}

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    init(n, st);
    for(int i = 0; i < q; i++){
        int c, x, y;
        scanf("%d%d%d", &c, &x, &y);
        if(c == 0){
            update(x, y, 0, 0, n, st);
        }else{
            long long ret = get_min(x, y + 1, 0, 0, n, st);
            printf("%lld\n", ret);
        }
    }
    return 0;
}

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

int main(void) {
	string O, E;

	cin >> O;
	cin >> E;
	int lo = O.length();
	int le = E.length();
	string ans = string(2 * le, ' ');
	for (int p = 0; p < le; ++p) {
		ans[2 * p] = O[p];
		ans[2 * p + 1] = E[p];
	}
	if (lo > le)
		ans += O[lo - 1];

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


Measured memory_bytes: 256
import numpy as np
N, M, X = map(int, input().split())

p = []
books = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    p.append(tmp[0])
    books.append(np.array(tmp[1:]))

saiyou = 0b00
ans = 10**7
for _ in range(2**N):
    mon = 0
    sat = np.zeros(M)
    for j, book in enumerate(books):
        if (saiyou >> j)&1 == 1:
            mon += p[j]
            sat += book
    if np.min(sat) >= X and ans > mon:
        ans = mon
    saiyou += 1

if ans == 10**7:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27216
#coding: utf-8

swap = 0
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    if minj > i:
	    temp = a[i]
	    a[i] = a[minj]
	    a[minj] = temp
	    swap += 1
print(' '.join([str(i) for i in a]))
print(swap)


Measured memory_bytes: 5612
# coding: utf-8

#BIT(Binary Indexed Tree)という高速処理があるらしい
#関連してSegment Treeなんかも重要みたい
#BITの処理は数列を大きさの順位に置き換える必要がある
class Bit:
    def __init__(self, num):
        self.size = num
        self.tree = [0] * (num + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

n = int(input().rstrip())
A = list(map(int,input().rstrip().split()))
#Aを大きさの順のインデックスにして０をなくすために１足す
A = [i+1 for i in sorted(range(len(A)), key=A.__getitem__)]
bit = Bit(n)

ans = 0
for i,ai in enumerate(A[::-1]):
    ans += bit.sum(ai)
    bit.add(ai, 1)
 
print(ans)


Measured memory_bytes: 30768
N = int(input())
A = list(map(int,input().split()))
numdic = {i:0 for i in range(1,N+1)}
for a in A:
    numdic[a] += 1
#print(numdic)
max = 0
for i in range(1,N+1):
    x = numdic[i]
    max += x * (x - 1) // 2
for a in A:
    x = numdic[a]
    tmp = max - (x * (x - 1) // 2) + ((x - 1) * (x - 2) // 2)
    print(tmp)

Measured memory_bytes: 38524
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  int a, b;
  cin >> a >> b;
  if( a + b >= 10 ) cout << "error" << endl;
  else cout << a+b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }else if(b == c){
    cout << a << endl;
  }else if(a == c){
    cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int>A(n+1);
    for (int i = 1;i<=n;i++)cin>>A[i];
    vector<vector<int>>dp(n+2,vector<int>(k+1,0));
    for (int i = 0;i<=k;i++){
        if (i>A[1])dp[1][i] = 0;
        else dp[1][i] = 1;
    }
    dp[0][0] = 1;
    for (int i = 2;i<=n;i++){
        for (int j = 0;j<=k;j++){
            if (j==0){dp[i][j] = dp[i-1][j];continue;}
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod;
            if (j>A[i])dp[i][j]-=dp[i-1][j-A[i]-1];
            dp[i][j]%=mod;
            if (dp[i][j]<0)dp[i][j]+=mod;
        }
    }
    cout<<dp[n][k];
    return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=100,mod=1e9+7,bit=61;
const ld PI=acos(-1.00);

ll a,b,n;

ll fun(ll x)
{
    ll ans=((a*x)/b)-a*(x/b);
    return ans;
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        scanf("%lld %lld %lld",&a,&b,&n);
        printf("%lld\n",fun(min(n,b-1)));
    }
    return 0;
}


















Measured memory_bytes: 3852
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    ll n,k;
    cin>>n>>k;
	n=n%k;
	ll ans1=abs(n-k);
	cout<<min(n,ans1)<<endl;	
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


LL calcMaxDepth(LL cur, LL parent, LL depth, vector<vector<LL>>& edge, vector<LL>& max_depth){
    LL ret = depth;
    for(LL next: edge[cur]){
        if(next == parent) continue;
        ret = max<LL>(ret, calcMaxDepth(next, cur, depth+1, edge, max_depth));
    }
    max_depth[cur] = ret;
    return ret;
}

bool findPath(LL cur, LL parent, LL target, vector<vector<LL>>& edge, vector<LL>& path){
    path.push_back(cur);
    if(cur == target) return true;
    for(LL next: edge[cur]){
        if(next == parent) continue;
        if(findPath(next, cur, target, edge, path)){
            return true;
        }
    }
    path.pop_back();
    return false;
}


// 0:0 1:0 2:1 3:2 4:3 5:4 6:5
int main(){
    LL n, u, v;
    cin >> n >> u >> v;
    --u; --v;
    vector<vector<LL>> edge(n);
    for(LL i = 0; i < n-1; ++i){
        LL a, b;
        cin >> a >> b;
        --a; --b;
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }
    vector<LL> max_depth(n, -1);
    calcMaxDepth(v, -1, 0, edge, max_depth);
    vector<LL> path;
    findPath(v, -1, u, edge, path);
    LL ans = 0;
    //cerr << path << endl;
    //cerr << max_depth << endl;
    for(LL i = path.size() / 2; i < path.size(); ++i){
        //cerr << i << ", " << path[i] << ", " << max_depth[path[i]] << endl;
        ans = max<LL>(ans, max_depth[path[i]]-1);
    }
    cout << ans << endl;
    return 0;
}



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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main() {
    int n, x, base=1, temp, anum=0, bnum=0, ans;
    VI a, b;
    a = {1, 1, 1, 1, 1, 1, 1, 1};
    b = {1, 1, 1, 1, 1, 1, 1, 1};
    cin >> n;
    for (int i = 1; i < n; ++i)
    {
        base *= i;
    }
    temp = base;
    REP(i, n-1){
        cin >> x;
        FOR(j, 1, x){
            if(a[j]==1)
                anum += base;
        }
        base /= n-1-i;
        a[x] = 0;
    }
    base = temp;
    cin >> ans;
    REP(i, n-1){
        cin >> x;
        FOR(j, 1, x){
            if(b[j]==1)
                bnum += base;
        }
        base /= n-1-i;
        b[x] = 0;
    }
    ans = abs(anum - bnum);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
s = gets.chomp
t = gets.chomp

x = n.lcm(m)
step_s = x / n
step_t = x / m
l = step_s.lcm(step_t)

puts (x / l).times.all? { |i| s[l / step_s * i] == t[l / step_t * i] } ? x : -1

Measured memory_bytes: 14492
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	double sum = 0;
	int N; cin>>N;
	double x[N];
	string u[N];
	rep(i ,N){
		cin>>x[i]>>u[i];
	}
	for(int t = 0; t < N; t++){
		if(u[t] == "JPY")sum += x[t];
		else sum += x[t] * 380000.0;
	}
	cout<<sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int edgenum[100000];
vector<pair<int, int>> edge;
int main() {
	int n, q,sum[100001];
	fill(sum, sum + 100001, 0);
	string s;
	cin >> n >> q>>s;
	for (int i = 2; i <= n; i++) {
		if (s[i - 2] == 'A'&&s[i - 1] == 'C')sum[i]++;
		sum[i] += sum[i - 1];
	}
	int ans[100000];
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		ans[i] = sum[r] - sum[l];
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;

	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	int N; cin >> N;
	int sum = 0;
	int min = 101;
	rep(i, 0, N) {
		int s; cin >> s;
		sum += s;
		if (s % 10 != 0 && min > s)min = s;
	}

	if (sum % 10 != 0)cout << sum << endl;
	else if(min==101)cout << 0 << endl;
	else cout << (sum-min) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, N):
        self.parent = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]

N, M = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(M):
    uf = UnionFind(N+1)
    for j in range(M):
        if i == j:
            continue
        u, v = edges[j]
        uf.unite(u, v)
    u, v = edges[i]
    if uf.get_size(u) != N:
        ans += 1
print(ans)

Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

int main() {
    int n;cin >> n;
    vector<P> a(n);
    for(int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        a[i]=P(x+y,x-y);
    } 
    sort(a.begin(),a.end());

    int ans=0,cur=-INF;
    for(int i = 0; i < n; i++) {
        if(cur<=a[i].second){
            ans++;
            cur=a[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    String s = br.readLine();
    String[] sa = s.split(" ");
    int[] na = Stream.of(sa).mapToInt(Integer::parseInt).toArray();
    int k = Integer.parseInt(br.readLine());
    int cnt = 0;
    boolean sortFlg = true;

    while (sortFlg) {
      int sortCnt = 0;
      for (int i = 0; i + 1 < na.length; i++) {
        if (na[i] >= na[i + 1]) {
          na[i + 1] *= 2;
          cnt++;
          sortCnt++;
        }
      }
      if (sortCnt == 0) sortFlg = false;
    }

    if (cnt <= k) {
      out.println("Yes");
    } else {
      out.println("No");
    }
    out.close();
  }
}

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

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

int main(){
	int n;
  cin >> n;
  cout << 0 << endl;
  string prev;
  cin >> prev;
  if(prev == "Vacant"){
    return 0;
  }

  vector<int> a(n);
  rep(i, n){
    a[i] = (prev == "Male") ? i & 1 : (i & 1) ^ 1;
  }
  
  int left = 0;
  int right = n;
  for(int i = 1; i < 20; ++i){
    int t = (left + right) / 2;
    cout << t << endl;
    
    string s;
    cin >> s;
    if(s == "Vacant"){
      return 0;
    }

    int tmp = (s == "Male") ? 0 : 1;
    if(a[t] == tmp){
      left = t;
    }
    else{
      right = t;
    }
  }
	return 0;
}



Measured memory_bytes: 1232
#include<cstdio>

using namespace std;

signed main(){
    int  n;
    while( scanf( "%d\n", &n ) != EOF )
    {
        int ret = 0l;
        for( int i = 0; i <= 9; i++ ){
            for( int j = 0; j <= 9; j++ ){
                for( int k = 0; k <= 9; k++){
                    for( int l = 0; l <= 9; l++ )
                    if( i + j + k + l == n ) ret++;
                }
            }
        }    
        printf( "%d\n", ret );
    }
    return 0;
}


Measured memory_bytes: 2668
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    dp = [0]*((N+1)*4)

    for i in range(3):
        a, b = A[i], B[i]
        for w in range(N+1):
            if w < a:
                dp[w*4+i+1] = dp[w*4+i]
            else:
                dp[w*4+i+1] = max(dp[w*4+i], dp[(w-a)*4+i+1] + b-a)

    M = dp[N*4+3] + N

    dp2 = [0]*((M+1)*4)
    for i in range(3):
        a, b = A[i], B[i]
        for w in range(M+1):
            if w < b:
                dp2[w*4+i+1] = dp2[w*4+i]
            else:
                dp2[w*4+i+1] = max(dp2[w*4+i], dp2[(w-b)*4+i+1] + a-b)

    print(dp2[M*4+3]+M)


if __name__ == "__main__":
    main()

Measured memory_bytes: 814748
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin >> h >> w;
	int g[10][10];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin >> g[i][j];
		}
	}
	int a[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> a[i][j];
		}
	}
	 
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				g[i][j]=min(g[i][j], g[i][k]+g[k][j]);
			}
		}
	}
	int sum=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			sum+=g[a[i][j]][1];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int secs = sc.nextInt();
            int hh = secs / (60 * 60);
            int hs = secs % (60 * 60);
            int mm = hs / 60;
            int ss = hs % 60;
            System.out.println(String.format("%d:%d:%d", hh, mm, ss));
        }
    }
}



Measured memory_bytes: 26340
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    int[] H = new int[N];

    for (int i = 0; i < N; i++) {
      H[i] = sc.nextInt();
    }

    sc.close();

    int prev = -999999; 

    for (int i = 0; i < N; i++) {

      if (prev <= H[i] - 1) {
        H[i]--;
        prev = H[i];
      } else if (prev <= H[i]) {
        prev = H[i];
      } else {
        System.out.println("No");
        return;
      }

    }

    System.out.println("Yes");
    
  }

}

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

int gcd(int x,int y){
  if(x<y) swap(x,y);
  //xの方が常に大きい
  while(y>0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int lcm(int x,int y){
  return int(x*y/gcd(x,y));
}

int main(){
  int n;cin >> n;
  vector<int> a(n);for(int i=0;i<n;i++){cin >> a[i];}
  int ans=lcm(a[0],a[1]);
  for(int i=1;i<n;i++){ans=lcm(ans,a[i]);}
  cout << ans << endl;
}



Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    static BufferedReader br;
    static StringTokenizer tok;
    static int h, w;
    static char[][] mat = new char[100][100];
    static boolean[] rowVisible = new boolean[100];
    static boolean[] colVisible = new boolean[100];
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        tok = new StringTokenizer(br.readLine());
        h = Integer.parseInt(tok.nextToken());
        w = Integer.parseInt(tok.nextToken());
        // 読み込み
        for (int i = 0; i < h; i++) {
            String row = br.readLine();
            for (int j = 0; j < w; j++) {
                char c = row.charAt(j);
                mat[i][j] = c;
                if (c == '#') {
                    rowVisible[i] = true;
                    colVisible[j] = true;
                }
            }
        }
        // 表示
        for (int i = 0; i < h; i++) {
            if (!rowVisible[i]) continue;
            for (int j = 0; j < w; j++) {
                if (!colVisible[j]) continue;
                System.out.print(mat[i][j]);
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    vector<int> pos;
    int temp;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        pos.push_back(temp);
    }
    
    int min = *min_element(pos.begin(), pos.end());
    int max = *max_element(pos.begin(), pos.end());
 
    cout << max-min << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  N,W = map(int,input().split())  #nは入力回数
  num_list = [list(map(int, input().split())) for _ in range(N)]
  dp = [[0] * (W+1) for i in range(N+1)]
  weight=[row[0] for row in num_list]
  value=[row[1] for row in num_list]
  for i in range(0,N):
    for sum_w in range(0,W+1):
      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(int(dp[N][W]))
if __name__ == '__main__':
    main()

Measured memory_bytes: 118896
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

i64 GCD(i64 a, i64 b) {
	if (b == 0)return a;
	return GCD(b, a % b);
}

int main() {
	i64 n;
	cin >> n;
	i64 ans;
	cin >> ans;
	ff(i, 0, n - 1) {
		i64 a;
		cin >> a;
		ans = ans/GCD(a, ans);
		ans *= a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true)
    {
        C -= B;
        if (C <= 0)
        {
            Yes;
        }
        A -= D;
        if (A <= 0)
        {
            No;
        }
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3620