akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            int K = sc.nextInt();

            char[][] c2 = new char[H][W];
            for (int r = 0; r < H; r++) {
                c2[r] = sc.next().toCharArray();
            }

            int count = 0;
            for (int maskR = 0; maskR < 1 << H; maskR++) {
                for (int maskC = 0; maskC < 1 << W; maskC++) {

                    int numBlacks = 0;
                    for (int r = 0; r < H; r++) {
                        if ((maskR & (1 << r)) == 0) {
                            continue;
                        }
                        for (int c = 0; c < W; c++) {
                            if ((maskC & (1 << c)) == 0) {
                                continue;
                            }

                            if (c2[r][c] == '#') {
                                numBlacks++;
                            }
                        }
                    }

                    if (numBlacks == K) {
                        count++;
                    }

                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 27412
#include <stdio.h>

int main(void){
  int a[3][3];
  int n;
  int b[10];
  
  for(int i=0; i < 3; i++){
    for(int j=0; j<3; j++){
      scanf("%d", &a[i][j]);
    }
  }
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &b[i]);
  }
  int flag;
  for(int i=0; i<3; i++){
    flag = 0;
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        if(a[i][j] == b[k]) flag++;
      }
    }
    if(flag==3){
      printf("Yes");
      return 0;
    }
  }
  for(int i=0; i<3; i++){
    flag = 0;
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        if(a[j][i] == b[k]) flag++;
      }
    }
    if(flag==3){
      printf("Yes");
      return 0;
    }
  }
  flag=0;
  for(int k=0; k<10; k++){
    if(b[k] == a[0][0] || b[k] == a[1][1] || b[k] == a[2][2]) flag++;
    if(flag==3){
      printf("Yes");
      return 0;
    }
  }
  flag=0;
  for(int k=0; k<10; k++){
    if(b[k] == a[0][2] || b[k] == a[1][1] || b[k] == a[2][0]) flag++;
    if(flag==3){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;

int main() {
    ll N, M, P; cin >> N >> M >> P;
    vector< vector< pair<ll, ll> > > G(N);
    vector<ll> dist(N, INF);
    for(int i=0; i<M; i++) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        G[a].emplace_back(b, P - c);
    }

    dist[0] = 0;
    for(int i=0; i<2*N; i++) {
        for(int j=0; j<N; j++) {
            for(auto e : G[j]) {
                ll k, c; tie(k, c) = e;
                if(dist[j] != INF and dist[k] > dist[j] + c) {
                    dist[k] = dist[j] + c;
                    if(i >= N) dist[k] = -INF;
                }
            }
        }
    }

    if(dist[N-1] == -INF) cout << -1 << endl;
    else cout << max(0LL, -dist[N-1]) << endl;
    return 0;
}


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


signed main(){
    int n,k;
    cin >> n >> k;
 
    int x[n];
    int p=0;
    for(int i =0;i<n;i++){
        cin >> x[i];
    if(x[i]<0) p++;
    
    }
    int r;
    if(p==0){
        r = x[k-1];
    }else {if(n==p){
        r = -1*x[p-k];
        }
        else{
            int y =max(0,p-k+1);
            r = -1*x[y]*2 + x[k-1+y];
            if(r> -1*x[y] +2* x[k-1+y])r= -1*x[y] +2* x[k-1+y];
            for(int i =y+1;i<p && k+i-1 <n ;i++){
                if(r>abs(x[i]*2- x[k+i-1]))r=abs(x[i]*2- x[k+i-1]);
                if(r>abs(x[i] - 2* x[k+i-1]))r=abs(x[i] - 2* x[k+i-1]);
             }
        }
    }
    
      

    
   

   
    cout << r ;

 
    return 0;

}

Measured memory_bytes: 640
S = input()
L = len(S)
T = []
U = []
for i in range(L-1):
    if S[i] == "R" and S[i+1] == "L":
        T.append(i+1)
    elif S[i] == "L" and S[i+1] == "R":
        U.append(i+1)
U.append(L)
state = 0
Ans = [0] * L
l = len(T)
for t in range(l):
    for i in range(state,T[t]-1):
        Ans[i] = 0
    a = T[t] - state
    b = U[t] - T[t]
    if (a//2) * 2 != a:
        Ans[T[t]-1] += (a+1)//2
        Ans[T[t]] += (a-1)//2
    else:
        Ans[T[t]-1] += a//2
        Ans[T[t]] += a//2
    if (b//2) * 2 != b:
        Ans[T[t]-1] += (b-1)//2
        Ans[T[t]] += (b+1)//2
    else:
        Ans[T[t]-1] += b//2
        Ans[T[t]] += b//2
    state = U[t]
for A in Ans:
    print(A,end = " ")

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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}


int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	tint x,y,a,b,c;
	while (cin >> x >> y >> a >> b >> c)
	{
		vector<tint> red (a), green(b), candidates(c);
		forn(i,a)
			cin >> red[i];
		forn(i,b)
			cin >> green[i];
		forn(i,c)
			cin >> candidates[i];
		
		sort(red.rbegin(),red.rend());
		sort(green.rbegin(),green.rend());
		
		forn(i,x)
			candidates.emplace_back(red[i]);
		forn(i,y)
			candidates.emplace_back(green[i]);
		
		sort(candidates.rbegin(),candidates.rend());
		
		tint ans = 0;
		forn(i,x+y)
			ans += candidates[i];
		
		cout << ans << "\n";
			
			
			
	}
	
	
	return 0;
}





Measured memory_bytes: 6256
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input());ans=-inf
F=[] ;P=[]
for i in range(n):
    F.append(list(map(int,input().split())))
for i in range(n):
    P.append(list(map(int,input().split())))

for bit in range(1,1<<10):
    L=[(bit>>i)&1 for i in range(10)]
    now=0
    for i in range(n):
        cnt=0
        for cc in range(10):
            if (F[i][cc]==1 and L[cc]==1) : cnt+=1
        now+=P[i][cnt]
    ans=max(ans,now)
print(ans)


Measured memory_bytes: 9988
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)1e6 + 5;
const int mod = (int)1e9 + 9;
using namespace std;

ll x[maxn];
int v[maxn];
ll c[maxn], cc[maxn];
ll cmx[maxn], ccmx[maxn];

int main()
{
	int n; ll C; scanf("%d %lld", &n, &C);
	for(int i = 1; i <= n; i++) scanf("%lld %d", &x[i], &v[i]);
	for(int i = 1; i <= n; i++){
		c[i] = c[i-1] + v[i] - (x[i] - x[i-1]);
		cmx[i] = max(cmx[i-1], c[i]);
	}
	x[n+1] = C;
	for(int i = n; i >= 1; i--){
		cc[n-i+1] = cc[n-i] + v[i] - (x[i+1] - x[i]);
		ccmx[n-i+1] = max(ccmx[n-i], cc[n-i+1]); 
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		ans = max(ans, c[i] - x[i] + ccmx[n-i]);
		ans = max(ans, cc[i] - (C - x[n-i+1]) + cmx[n-i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 15360
N, K, C = map(int, input().split())
S = list(input())

l = [0] * N
r = [0] * N
cnt = 1
yutori = 10 ** 10
for i, s in enumerate(S):
    if s == "o" and yutori > C:
        l[i] = cnt
        yutori = 0
        cnt += 1
    yutori += 1

S.reverse()
yutori = 10 ** 10
cnt = K
for i, s in enumerate(S):
    if s == "o" and yutori > C:
        r[i] = cnt
        yutori = 0
        cnt -= 1
    yutori += 1

ans = set()
r.reverse()
for i in range(N):
    if l[i] == r[i] and l[i] > 0:
        ans.add(i+1)

print(*ans, sep="\n")


Measured memory_bytes: 121248
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> al = new ArrayList<>();
		
		for(int i = 0; i < 5; i++) {
			al.add(sc.nextInt());
		}
		
		Collections.sort(al);
		Collections.reverse(al);
		
		for(int i = 0; i < 5; i++) {
			if(i == 4) {
				System.out.print(al.get(i));
			} else {
				System.out.print(al.get(i) + " ");
			}
		}
		
		System.out.println();
	}
}

Measured memory_bytes: 26224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;

template<class T>
class SegTree{
public:
    int N;
    vector<T> dat;
    T def;
    function<T(T, T)> ope;
    function<T(T, T)> upd;

    SegTree(int _N, T _def, function<T(T, T)> _ope, function<T(T, T)> _upd){
        N = 1;
        while(N < _N) N *= 2;

        def = _def;
        ope = _ope;
        upd = _upd;
        dat.resize(2 * N - 1, def);
    }

    T Query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return dat[k];
        else {
            T c1 = Query(a, b, 2 * k + 1, l, (l + r) / 2);
            T c2 = Query(a, b, 2 * k + 2, (l + r) / 2, r);
            return ope(c1, c2);
        }
    }

    T query(int a, int b){
        return Query(a, b, 0, 0, N);
    }

    void update(int k, T x){
        k += N - 1;
        dat[k] = upd(dat[k], x);
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = ope(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
};

//---------------------------------------------------------------------

int main(){
    int N, Q;
    string s;
    cin >> N >> s >> Q;

    SegTree<ll> sg = SegTree<ll>(N, 0,
                            [](ll a, ll b){return a | b;},
                            [](ll a, ll b){return b;});

    for(int i = 0; i < N; i++){
        sg.update(i, (1 << (int)(s[i] - 'a')));
    }


    vector<ll> ans;

    for(int i = 0; i < Q; i++){
        int c;
        cin >> c;

        if(c == 1){
            int x;
            char y;
            cin >> x >> y;
            sg.update(x - 1, (1 << (int)(y - 'a')));
        } else {
            int x, y;
            cin >> x >> y;
            int t = sg.query(x - 1, y);
            int cnt = 0;
            for(int j = 0; j < 30; j++) {
                if(t & (1 << j)) cnt++;
            }
            ans.push_back(cnt);
        }
    }

    for(ll x : ans){
        cout << x << endl;
    }
    return 0;
}

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

int main(){
    string a_str,b_str,c_str;
    cin >> a_str >> b_str >> c_str;
    int a = a_str.size(),b= b_str.size(),c= c_str.size();
    int card_a=0,card_b=0,card_c=0;
    char card='a';
    while(1){
        if(card=='a'){
            card = a_str[card_a];
            card_a++;
            a--;
            if(a==-1)break;
        }
        else if(card=='b'){    
            card = b_str[card_b];
            card_b++;
            b--;
            if(b==-1)break;
        }
        else if(card=='c'){
            card = c_str[card_c];
            card_c++;
            c--;
            if(c==-1)break;
        }
    }
    if(a==-1)cout << "A" << endl;
    else if(b==-1)cout << "B" << endl;
    else if(c==-1)cout << "C" << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 200010;
const double eps = 1e-6;

int n, k;
int cnt[N];

int main()
{
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        cnt[x]++;
    }
    sort(cnt, cnt + n);
    reverse(cnt, cnt + n);

    int sum = 0;
    for(int i = 0; i < k; i++) sum += cnt[i];

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


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %5lf\n",d,r,f);
  
  return 0;
}



Measured memory_bytes: 2100
//In The Name Of GOD
 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int mod = 1000000007;
const int inf = 2000000000;
const int maxn = 500*1000+500*1000+15;
const int MLOG = 18;

#define int long long
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())

int32_t main(){
	string s;
	cin >> s;
	int n =  s.size();
	int all = 0;
	for(int i = 0; i < ( 1 << (n-1) ) ; i++){
		string ss;
		int ans=0;
		for(int j = 0; j < n; j++){
			ss += s[j];
			if( (i >> j) & 1 ){
				ans += atoll( ss.c_str() );
				ss.clear();
			}
		}
		ans += atoll( ss.c_str() );
		all += ans;
	}
	cout << all;
}

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

using namespace std;

vector <int> a;
void solve(int n,int val){
    if (val==1||val==2*n-1){
        printf("No");
        return;
    }
    printf("Yes\n");
    if (n==2){
        for(int i=1;i<4;i++) printf("%d\n",i);
        return;
    }
    if (val>2){
        for(int i=1;i<2*n;i++) if (i<val-2||i>val+1) a.push_back(i);
        for(int i=1;i<=n-2;i++) printf("%d\n",a[i-1]);
        printf("%d\n%d\n%d\n%d\n",val-1,val,val+1,val-2);
        for(int i=n-1;i<2*n-4;i++) printf("%d\n",a[i-1]);
    }else
    if (val<2*n-2){
        for(int i=1;i<2*n;i++) if (i<val-1||i>val+2) a.push_back(i);
        for(int i=1;i<=n-2;i++) printf("%d\n",a[i-1]);
        printf("%d\n%d\n%d\n%d\n",val+1,val-1,val,val+2);
        for(int i=n-1;i<2*n-4;i++) printf("%d\n",a[i-1]);
    }
}
int main(){
    int n,x;
    cin>>n>>x;
    solve(n,x);
}


Measured memory_bytes: 2420
#ABC162-E Sum of gcd of Tuples(Hard)
"""
問題を「1~kまでの数字を用いた長さnの数列において、gcdがDになる数列はいくつあるか」
というふうに置き換える。(1<=D<=k)
更に制約を替えて、gcdが"Dの倍数"(但し,k以下)でも良いのでそれを全て求めよ、
というふうになった場合、全ての要素はD*n(nは整数,D*n<=k)となる。
この制約によって、そのような数列の数は(k/D)^nとして表せる。(これが大事)
例：
n = 3,k = 4の場合で、D(gcd)=2について求める
(4//2)**3 = 8※

そこで、大きい方からgcdがDになる数列の個数(これをメモ化)を求めていった場合、
Dの倍数がk以下であるならば、予めメモしておいたその値分を引いてやる。
これによって全ての通り数が求まる。
例の続き:
D=2について、D*n <= k という制約のもとでn=2が存在する。
D = 2*2 = 4の時の通り数は、4,4,4の1通り※なので、
D(gcd)=2となるパターン数は、※より、
8-1=7 となる。
(この7通りは2と4からなる数列で、全ての値が4になる場合を引いている)
"""
import sys
readline = sys.stdin.buffer.readline
n,k = map(int,readline().split())
mod = 10**9+7

ans = 0
count = [0]*(k+1)
for D in range(k,0,-1):
    mul = k//D #何倍まであり得るか(あり得るものをcountから引く)
    res = pow(mul,n,mod)
    for i in range(2,mul+1):
        res -= count[i*D]
    count[D] = res #個数
    ans += res*D #個数*値(求めたいのはgcdの合計値のため)
    ans %= mod

print(ans)

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update> ost;
// name.find_by_order(x) or name.order_of_key(x)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;

void yes() {printf("YES\n");}
void no() {printf("NO\n");}

int dx4[] = {-1, 1, 0, 0};
int dy4[] = {0, 0, -1, 1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

const int maxn = 2e5 + 5, maxv = 2e6 + 5;
const int MOD = 1e9 + 7;

int mult(ll a, ll b) {return (a * b) % MOD;}
int pot(int n, int k) {
	int ret = 1, pot = n;
	for(;k > 0;k >>= 1, pot = mult(pot, pot)) 
		ret = mult(ret, (k & 1) ? pot : 1);
	return ret;
}
int divide(int a, int b) {return mult(a, pot(b, MOD - 2));}
int add(int a, int b) {a += b;if(a >= MOD) a -= MOD;return a;}
int sub(int a, int b) {a -= b;if(a < 0) a += MOD;return a;}

vector<int> fact;
void calc_fact(int n) {
	fact = vector<int>(n + 1, 1);
	for(int i = 1;i <= n;i++) fact[i] = mult(fact[i - 1], i);
}
int choose(int n, int k) {return divide(fact[n], mult(fact[n - k], fact[k]));}

bool prime(ll a) {
	if (a == 1) return 0;
	for(ll i = 2;i * i <= a;i++) 
		if (a % i == 0) return 0;
	return 1;
}

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

ll phi(ll x) {
	double ret = x;
	for(ll i = 2;i * i <= x;i++) {
		if (x % i) continue;
		ret *= (1.0 - 1.0 / (double)i);
		while (x % i == 0) x /= i;
	}
	if (x > 1) ret *= (1.0 - 1.0 / (double)x );
	return (ll)ret;
}

void solve() {
	int x;
	scanf("%d", &x);
	printf("%d\n", !x);
}

int main() {
	int t = 1;
	//scanf("%d", &t);
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3844
a,b,m = map(int, input().split())		# 5 7 2

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=min(A) + min(B)

for i in range(m):
	x,y,c = map(int, input().split())		# 5 7 2
	ans=min(ans,A[x-1]+B[y-1]-c)


print(ans)
	

Measured memory_bytes: 18736
program tenquestionfour
 implicit none
 integer A, B, C, X, i, j, k, res
 read(*,*) A
 read(*,*) B
 read(*,*) C
 read(*,*) X
 ! read(*,*) A, B, C, X でよい
 res = 0
 do i=0,A
  do j=0,B
   do k=0,C
   if ((500*i + 100*j + 50*k).eq.X) res = res + 1
   !if ((500*i + 100*j + 50*k).gt.x) exit 
   end do
   !if ((500*i + 100*j).gt.x) exit
  end do
  !if ((500*i).gt.x) exit
 end do
 write(*,*) res
end program

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin>>N>>S;
  int red = 0;
  int blue = 0;
  for(int i = 0;i<N;i++){
    if(S[i]=='R'){
      red++;
    }
    else{
      blue++;
    }
  }
  if(red>blue){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int n,m;

void solve()
{
	int bef = 0, in;
	int res = 0;
	priority_queue<int, vector<int>, greater<int> > pq;

	for(int i = 0; i < n + m; i++){
		cin >> in;
		pq.push(in);
	}
	while(pq.size()){
		in = pq.top();
		pq.pop();
		res = max(res, in - bef);
		bef = in;
	}

	cout << res << endl;
}


int main(void)
{
	while(cin >> n >> m, n | m)
		solve();
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct pairhash {
    size_t operator()(const pair<int, int>& p) const {
        return hash<int>()(p.first) ^ hash<int>()(p.second);
    }
};
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, M, K = 1; cin >> N >> M;
    unordered_map<pair<int, int>, int, pairhash> mapping;
    mapping.reserve(1e6);
    int id = 0;
    auto node2id = [&](int i, int c) {
        auto it = mapping.find({i, c});
        if (it != end(mapping)) return it->second;
        mapping[{i, c}] = ++id;
        return id;
    };
    vector<vector<pair<int, int>>> G(1e6);
    vector<set<int>> C(N);
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c; a--, b--;
        G[node2id(a, c)].emplace_back(node2id(b, c), 0);
        G[node2id(b, c)].emplace_back(node2id(a, c), 0);
        C[a].insert(c);
        C[b].insert(c);
    }
    for (int a = 0; a < N; a++) {
        for (int c : C[a]) {
            G[node2id(a, -1)].emplace_back(node2id(a, c), 1);
            G[node2id(a, c)].emplace_back(node2id(a, -1), 0);
        }
    }
    int s = node2id(0, -1);
    int e = node2id(N-1, -1);
    deque<pair<int, int>> D;
    D.emplace_back(s, 0);
    vector<bool> visited(1e6);
    while (!D.empty()) {
        int node, cost; tie(node, cost) = D.front();
        D.pop_front();
        if (visited[node]) continue;
        visited[node] = true;
        if (node == e) {
            cout << cost * K << '\n';
            return 0;
        }
        for (auto& p : G[node]) {
            int next, c; tie(next, c) = p;
            if (visited[next]) continue;
            if (c == 0) {
                D.emplace_front(next, cost + 0);
            } else {
                D.emplace_back(next, cost + 1);
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    for (int i = i; i < s.size(); i++){
        if (i % 2 == 0){
            if (s[i] == 'L'){
                cout << "No";
                return 0;
            }
        }
        if (i % 2 == 1){
            if (s[i] == 'R'){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}  


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
 
#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 DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}
 
#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"
 
// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;
 
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;
 
int main()
{
	FAST_IO;
 
 	ll k;
 	cin >> k;
 	k /= __gcd(k, 7ll);
 	if(k % 2 == 0)
 	{
 		cout << -1 << endl;
 		return 0;
 	}
 	ll curr = 0;
 	for(int i=1;i<10000000;i++)
 	{
 	    curr *= 10;
 		curr += 1;
 		curr %= k;
 		if(curr == 0)
 		{
 			cout << i << endl;
 			return 0;
 		}
 	}
 	cout << -1 << endl;
    return 0;
}

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

using namespace std;

typedef long long llint;

int main() {
  llint x;
  cin >> x;
  llint ans = (x / 500) * 1000;
  x %= 500;
  ans += (x / 5) * 5;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]A = new int[N];
			for(int i= 0;i<N;i++) {
				A[i] = scan.nextInt();
			}
			
			Map<Integer,Integer>map = new HashMap<Integer,Integer>();
			
			for(int i = 0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i], map.get(A[i])+1);
				}else{
					map.put(A[i], 1);
				
				}
			}
			long goukei2 =0;
			long anstemp = 0;
			for(Integer key:map.keySet()) {
					goukei2+=sa(map.get(key),2);
				//long v = map.get(key);
				   //anstemp+=(v*(v-1)/2);
			}
			for(int i= 0;i<N;i++) {
				long goukei = 0;
				goukei +=goukei2;
				goukei-=sa(map.get(A[i]),2);
				goukei+=sa(map.get(A[i])-1,2);
				System.out.println(goukei);
				
				 /*long ans = anstemp;
				   long v = map.get(A[i]);
				   ans -= (v*(v-1)/2);
				   ans += ((v-1)*(v-2)/2);
				   System.out.println(ans);*/
				
			}
			
		}
		
		
	}
	
	private static long sa(long n,int b) {
		return n*(n-1)/b;
	}
	
	

}


Measured memory_bytes: 103100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  ll ans1 = 0, ans2 = 0;
  rep(i, n){
    if(i % 2 == 0 && s[i] == '0')ans1++;
    if(i % 2 == 0 && s[i] == '1')ans2++;
    if(i % 2 == 1 && s[i] == '1')ans1++;
    if(i % 2 == 1 && s[i] == '0')ans2++;
  }
  cout << min(ans1, ans2) << endl;
}

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

using namespace std;
using ll = long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;
    
    string aa;
    string bb;
    for(int i =0;i<b;++i)aa += to_string(a);
    for(int i=0;i<a;++i)bb += to_string(b);
    if(aa > bb)cout << bb << endl;
    else cout << aa << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<=a;i++){
		for(int j=0;i+j<=a;j++){
			int rem=b-10000*i-5000*j;
			if(rem>=0&&rem/1000==a-i-j){
				printf("%d %d %d\n",i,j,a-i-j);return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int na=scan.nextInt();
int[] nb=new int[na];

int i=0;
for(i=0;i<na;i++){
    nb[i]=scan.nextInt();
}

int sum=0;
int rul=0;
for(i=0;i<na;i++){
    if(i==0){
        sum=sum+1;
        rul=nb[i];
    }else if(rul>nb[i]){
        sum=sum+1;
        rul=nb[i];
    }
}

System.out.println(sum);
}
}

Measured memory_bytes: 66184
import operator
while True:
    n = int(input())
    if n==0:
        break
    rst = {}
    for _ in range(n):
        [id,m1,s1,m2,s2,m3,s3,m4,s4] = list(map(int, input().strip().split()))
        rst[id] = m1*60+s1 + m2*60+s2 + m3*60+s3 + m4*60+s4
    
    r = sorted(rst.items(),key=operator.itemgetter(1))
    print(r[0][0])
    print(r[1][0])
    print(r[-2][0])

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	int n; cin >> n;
	vi a(n); Loop(i, n) cin >> a[i];
	multiset<int, greater<int>> st;
	Loop(i, n) {
		auto itr = st.upper_bound(a[i]);
		if (itr == st.end()) {
			st.insert(a[i]);
		}
		else {
			st.erase(itr);
			st.insert(a[i]);
		}
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int[] cost = new int[n+1];
		for(int i=0;i<cost.length;i++) {
			cost[i] = 0;
		}

		for (int i=0;i<m;i++) {
			int am = sc.nextInt();
			cost[am] = 1;
		}
		System.out.println(calcCost(x,cost));

	}

	private static int calcCost(int x, int[] costtable) {
		int left=0;
		for(int i=0;i<x;i++) {
			left+=costtable[i];
		}
		int right=0;
		for(int i=x;i<costtable.length;i++) {
			right+=costtable[i];
		}
		return left<right?left:right;
	}

}

Measured memory_bytes: 21844
//
//  main.cpp
//  Simple_Calculator
//
//  Created by Uttam Datta on 31/05/19.
//

#include <iostream>
#include <cstdlib>
using namespace std;

int x,y;

int find(int a, int b){
    int k = min(a,b);
    int l = max(a,b);
    int pos = 0;
    while(k != l){
        k++;
        pos++;
    }
    return pos;
}


int ans(){
    if(x == y){
        return 0;
    }
    if(x > 0 && y > 0){
        if(x > y){
            return find(x*-1,y*-1) + 2;
        }
        else{
            return find(x,y);
        }
    }
    else if(x < 0 && y < 0){
        if(x < y){
            return find(x,y);
        }
        else{
            return find(x*-1,y*-1) + 2;
        }
    }
    else if(x == 0){
        if(y > 0){
            return find(x,y);
        }
        else{
            return find(x,y) + 1;
        }
    }
    else if(y == 0){
        if(x > 0){
            return find(x,y) + 1 ;
        }
        else{
            return find(x,y);
        }
    }
    else if(x > 0 && y < 0){
        return find(x , y*-1) + 1;
    }
    else if(x < 0 && y > 0){
        return find(x*-1, y) + 1;
    }
    else{
        return 0;
    }
}

int main(){
    cin >> x >> y;
    cout << ans() << endl;
    return 0;
}


Measured memory_bytes: 256
#再帰関数作ったら再帰回数の上限を超えてエラーになったっぽい
"""
def kaijo(n):
  if n ==1:
    return n
  return n * kaijo(n-1)
"""

import math

n = int(input())

print(math.factorial(n)%1000000007)

#print(kaijo(n)%1000000007)


Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define R return
#define MEM(dp,i) memset(dp,i,sizeof(dp))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll inf=(1ll<<60);
const int MX = 300009;
int n,m;
char a[60][60],b[60][60];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)scanf("%s",&a[i]);
    for(int i=0;i<m;i++)scanf("%s",&b[i]);
    for(int l=0;l<=n-m;l++){
        for(int k=0;k<=n-m;k++){
            bool ok=1;
            for(int i=0,c=l;i<m;i++,c++){
                for(int j=0,d=k;j<m;j++,d++){
                    if(a[c][d]!=b[i][j]){
                        ok=0;
                    }
                }
            }
            if(ok){
                puts("Yes");
                R 0;
            }
        }
    }
    puts("No");
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, i, ans = 0;
  int value[20], cost[20];

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &value[i]);
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &cost[i]);
  }

  for (i = 0; i < n; i++) {
    if ( value[i] > cost[i] ) {
      ans += (value[i] - cost[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

static const int MAXN = 1000;
static const int MAXH = 10000;

int dp[MAXH], ans = 1<<30;
int A[MAXN], B[MAXN];

int main(){
    int h, n;
    cin >> h >> n;
    rep(i,n) cin >> A[i] >> B[i];
    rep(i,h) dp[i] = 1<<30;
    dp[0] = 0;

    rep(i,n){
        rep(j,h){
            if(j+A[i] >= h){
                ans = min(ans, dp[j] + B[i]);
            }
            else{
                dp[j+A[i]] = min(dp[j+A[i]], dp[j] + B[i]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define int long long

int n,k;
int C[555][555];
int inv[555];
char seq[75];
int mat[75],fact[555];
int pos[75],cnt;
int ln[75];
int ans;
const int mod = 1000000007;

int qpow(int base,int tms)
{
	int tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * 1ll * base % mod;
		base = base * 1ll * base % mod;
		tms >>= 1;
	}
	return tmp;
}

bool chk(int cn)
{
	if(cn > cnt) return false;
	static int sum[75]; memset(sum,0,sizeof(sum));
	for(int i = cn;i >= 1; -- i)
	{
		if(!pos[i]) return false;
		sum[pos[i]] ++;
		if(ln[cn - i + 1] >= 2)
		{
			if(!mat[pos[i]]) return false;
			sum[mat[pos[i]]] += ln[cn - i + 1] - 1;
		}
	}
	for(int i = k;i >= 1; -- i)
	{
		sum[i] += sum[i + 1];
		if(sum[i] > k - i + 1) return false;
	}
	return true;
}

bool dfs(int mi,int cnt,int mus)
{
	if(!chk(cnt)) return false;
	int k = cnt + 1;
	for(int i = 1;i <= cnt; ++ i)
		k += 2 * ln[i] - 1;
	int as = C[n - mus + k - 1][k - 1];
	if(k > 500) cerr << k << endl; 
	int p = 0;
	for(int i = 1;i <= cnt; ++ i)
	{
		if(ln[i] != ln[i - 1])
			as = as * 1ll * inv[p] % mod,p = 0;
		p ++;
	}
	as = as * 1ll * inv[p] % mod;
	as = as * 1ll * fact[cnt] % mod;
	ans = (ans + as) % mod; 
	for(int i = mi;i <= 70; ++ i)
	{
		ln[cnt + 1] = i;
		int nw = mus;
		if(cnt) nw ++;
		nw += i <= 2 ? 1 : 2 * i - 3;
		if(nw > n) break;
		if(!dfs(i,cnt + 1,nw)) break;
	}
	return true;
}

signed main()
{
	scanf("%lld%lld",&n,&k);
	scanf("%s",seq + 1);
	int po = 1;
	for(int i = 1;i <= k; ++ i)
	{
		if(seq[i] == 'r')
		{
			po = max(po,i);
			while(po <= k && seq[po] != 'b') po ++;
			if(po <= k)
				mat[i] = po ++;
			pos[++ cnt] = i;
		}
	}
	C[0][0] = 1;
	fact[0] = 1;
	inv[0] = 1;
	int pre = 1;
	for(int i = 1;i <= 550; ++ i)
	{
		pre = pre * 1ll * i % mod;
		fact[i] = pre;
		inv[i] = qpow(pre,mod - 2);
		C[i][0] = 1;
		for(int j = 1;j <= i; ++ j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	}
	dfs(1,0,0);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2688
n,k = map(int,input().split())
s = list(input())
if s[0] == "0":
    x_1 = [[0,0]]
else:
    x_1 = []
i = 0
while i < n:
    j = 0
    y_s = i
    while s[i] == s[i+j]:
        if i+j >= n-1:
            j += 1
            break
        j += 1
    y_e = i+j
    if s[i] == "1":
        x_1.append([y_s,y_e])
    i += j
if s[-1] == "0":
    x_1.append([n,n])
ans = 0
i = 0
if k >= len(x_1):
    ans = n
while i < n:
    if i+k >= len(x_1):
        break
    ans = max(ans,x_1[i+k][1]-x_1[i][0])
    i += 1
print(ans)

Measured memory_bytes: 17352
#include <iostream>
#include <algorithm>
#define llint long long int

using namespace std;

int N;
llint G[305][305];
llint dist[305][305];
bool del[305][305];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> G[i][j];
			dist[i][j] = G[i][j];
		}
	}
	
	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if( k != i && k != j && dist[i][k] + dist[k][j] == dist[i][j]) del[i][j] = true;
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	bool check = false;
	llint ans = 0;
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			if(G[i][j] > dist[i][j]){
				check = true;
				goto end;
			}
			if(!del[i][j]) ans += G[i][j];
		}
	}
	
	end:
	if(check) ans = -1;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

def solve(test):
	s = input()
	t = input()
	t = t[:-1]
	print('Yes' if s == t else 'No')




if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)


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

public class Main {

	private class HashSet {

		private int M = 1046527;
		private String[] H = new String[M];
		
		private int getChar(char ch) {
			if (ch=='A') return 1;
			else if (ch=='C') return 2;
			else if (ch=='G') return 3;
			else if (ch=='T') return 4;
			else return 0;
		}
		
		private int getKey(String str) {
			int sum = 0, p = 1;
			for (int i = 0; i < str.length(); i++) {
				sum += p*(getChar(str.charAt(i)));
				p *= 3;
			}
			return sum;
		}

		private int h1(int key) {return key % M;}
		private int h2(int key) {return 1 + (key % (M-1));}

		public boolean find(String str) {
			int key, i, h;
			key = getKey(str);
			for (i = 0 ;; i++) {
				h = (h1(key) + i * h2(key)) % M;
				if (H[h] != null && H[h].equals(str)) return true;
				else if (H[h] == null || H[h].length() == 0) return false;
			}
		}
		
		public void insert(String str) {
			int key, i, h;
			key = getKey(str);
			for (i = 0 ;; i++) {
				h = (h1(key) + i * h2(key)) % M;
				if (H[h] != null && H[h].equals(str)) return;
				else if (H[h] == null || H[h].length() == 0) {
					H[h] = new String(str);
					return;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		HashSet set = new HashSet();
		int n = Integer.parseInt(reader.readLine());
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			String cmd = st.nextToken();
			String str = st.nextToken();
			if (cmd.equals("insert")) {
				set.insert(str);
			} else if (cmd.equals("find")) {
				if (set.find(str)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 127272
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 998244353;
void inc(int &a, int b) {(a += b) >= P ? a -= P : 0;}
int dif(int a, int b) {return (a -= b) < 0 ? a += P : a;}
int power(int base, int exp) {
    int result = 1;
    while (exp > 0) {
        if (exp & 1)
            result = 1LL * result * base % P;
        base = 1LL * base * base % P;
        exp >>= 1;
    }
    return result;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    vector<int> factorial(k + 1), inv_factorial(k + 1);
    factorial[0] = 1;
    for (int i = 1; i <= k; ++i)
        factorial[i] = 1LL * factorial[i - 1] * i % P;
    inv_factorial[k] = power(factorial[k], P - 2);
    for (int i = k; i >= 1; --i)
        inv_factorial[i - 1] = 1LL * inv_factorial[i] * i % P;
    auto binom = [&](int n, int m)->int {
        if (m < 0 || n < m)
            return 0;
        return 1LL * factorial[n] * inv_factorial[m] % P * inv_factorial[n - m] % P;
    };
    auto countPath = [&](int x, int y, int t) {
        if (t < 0)
            return 0;
        return dif(binom(x + y, x), binom(x + y, x + t));
    };
    for (int red = 0; red <= k; ++red) {
        int blue = k - red;
        if (red < blue)
            continue;
        if (red == blue)
            inc(ans, countPath(red, blue - 1, red - n + 1));
        else
            inc(ans, countPath(red, blue, red - n + 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
# 写経
# https://atcoder.jp/contests/dp/submissions/6401166
# 私が再帰関数でTLEした計算方法だが、
# 3重ループを使うと、間に合うらしい

def main():
    from collections import Counter

    def tami(i, j, k):
        if i is 0 and j is 0 and k is 0:
            return

        res = fN
        if i > 0:
            res += dp[i - 1][j][k] * i
        if j > 0:
            res += dp[i + 1][j - 1][k] * j
        if k > 0:
            res += dp[i][j + 1][k - 1] * k
        res *= divTable[i + j + k]

        dp[i][j][k] = res
        return

    N = int(input())
    fN = float(N)
    a = list(map(int, input().split()))

    c = Counter(a)
    one = c[1]
    two = c[2]
    three = c[3]

    dp = tuple(tuple([0.0] * (N + 1) for _ in range(N + 1)) for _ in range(N + 1))

    divTable = [1]
    for i in range(1, N * 3 + 1):
        divTable.append(1.0 / i)

    for k in range(N + 1):
        for j in range(N - k + 1):
            for i in range(N - k - j + 1):
                tami(i, j, k)

    print(dp[one][two][three])


if __name__ == '__main__':
    main()


Measured memory_bytes: 254344
X,Y,A,B,C = map(int,input().split())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
R = [int(i) for i in input().split()]
from collections import deque
P_sort = sorted(P,reverse=True)[0:X]
Q_sort = sorted(Q,reverse=True)[0:Y]
R_sort = deque(sorted(R,reverse=True)[0:X+Y])
PQ = sorted(P_sort + Q_sort)
for i in range(len(PQ)):
    if R_sort[0] > PQ[i]:
        r = R_sort.popleft()
        PQ[i] = r
    if not R_sort:
      break
print(sum(PQ))

Measured memory_bytes: 110956
#include <iostream>

using namespace std;

int getMinimumCost(int arr[], int dp[], int currentIndex, int size)
{
    if(currentIndex < 2 || dp[currentIndex] > -1)
    {
        return dp[currentIndex];
    }
    dp[currentIndex] = min(abs(arr[currentIndex] - arr[currentIndex-1]) + getMinimumCost(arr, dp, currentIndex-1, size), abs(arr[currentIndex] - arr[currentIndex-2]) + getMinimumCost(arr, dp, currentIndex-2, size));
    return dp[currentIndex];
}

int main(int argc, const char * argv[])
{
    int size;
    cin>>size;
    int arr[size];
    int dp[size];
    for(int i = 0 ; i < size ; i++)
    {
        cin>>arr[i];
        dp[i] = -1;
    }
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    size > 0 ? cout<<getMinimumCost(arr, dp, size-1, size)<<endl : cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans;
  ll tmpans;
  tmpans = 0;
  ll sum = A[0];
  for(int i=0;i<N-1;++i) {
    if(i%2==0 && sum<=0) {
      tmpans += 1-sum;
      sum = 1;
    }
    if(i%2==1 && sum>=0) {
      tmpans += 1+sum;
      sum = -1;
    }
    sum += A[i+1];
  }
  if(N%2==0 && sum>=0) {
    tmpans += 1+sum;
  }
  if(N%2==1 && sum<=0) {
    tmpans += 1-sum;
  }
  ans = tmpans;
  sum = A[0];
  tmpans = 0;
  for(int i=0;i<N-1;++i) {
    if(i%2==0 && sum>=0) {
      tmpans += 1+sum;
      sum = -1;
    }
    if(i%2==1 && sum<=0) {
      tmpans += 1-sum;
      sum = 1;
    }
    sum += A[i+1];
  }
  if(N%2==0 && sum<=0) {
    tmpans += 1-sum;
  }
  if(N%2==1 && sum>=0) {
    tmpans += 1+sum;
  }
  ans = min(ans, tmpans);
  cout<<ans<<endl;
}



Measured memory_bytes: 4416
#include <stdio.h>

int main(void)
{
	int n, r;

	scanf("%d%d", &n, &r);

	if (n >= 10)
	{
		printf("%d", r);
	}
	else
	{
		printf("%d", r + 100 * (10 - n));
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  vector<long long> h(N);
  for(int i = 0;i < N;i++) {
    cin >> h.at(i);
  } 

  long long dp[100100];
  for(int i = 0;i < 100100;i++) {
    dp[i] = 10000000000;
  }

  dp[0] = 0;
  

  for(int i = 0;i < N;i++) {
    for(int j = i + 1;j <= min(i + K,N - 1);j++) {
      dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
    }
  }

  cout << dp[N - 1] << endl;

  }



Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

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 S(): return input()
     
def main():
    a = I()
    s = S()
    if a >= 3200:
        print(s)
    else:
        print("red")

main()



Measured memory_bytes: 67308
#include<stdio.h>

int a, x, y;

int gcd(int x, int y){
    int z=x%y;
    while(z!=0)
        x=y, y=z, z=x%y;
    printf("%d\n", y);
}

int main(void){
    scanf("%d %d", &x, &y);
    if(y>x)
        a=y, y=x, x=a;
    gcd(x,y);
    return 0;
}


Measured memory_bytes: 2092