akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
  int s, h, m;

  scanf("%d", &s);
  h = s / 3600;
  s %= 3600;
  m = s / 60;
  s %= 60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  int sum = 0;
  
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      sum += d.at(i) * d.at(j);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c;
    int ans = 1;//Yes
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    
   
    /*if(a>b && b>c){ans = 0;}
    if(c>b && b>a){ans = 0;}*/
    
    if(a<c && c<b){ans = 0;}
    if(b<c && c<a){ans = 0;}
    
    if(ans == 0){printf("Yes\n");}
    else{printf("No\n");}
    
    return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

ui64 MOP(ui64 x, ui64 n, ui64 m) {
    ui64 r = 1;
    while (n > 0) {
        if (n & 1) (r *= x) %= m;
        (x *= x) %= m;
        n >>= 1;
    }
    return r;
}
ui64 inverse(ui64 x, ui64 m) {
    return MOP(x, m - 2, m);
}

i64 N, M;
vector<int> MODS = {(int)1e9 + 7, (int)1e9 + 9, 998244353, 1000001773};
vector<vector<pair<i64, i64>>> graph;
vector<ui64> dp;
vector<bool> visited;

bool dfs(int cur, ui64 cst, int MOD) {
    visited[cur] = true;
    dp[cur] = cst;
    for (auto& nxt_p: graph[cur]) {
        int nxt = nxt_p.first;
        ui64 new_cst = cst;
        if (nxt_p.second > 0) (new_cst *= nxt_p.second) %= MOD;
        else (new_cst *= inverse(-nxt_p.second, MOD)) %= MOD;
        if (visited[nxt]) {
            if (dp[nxt] != new_cst) return false;
        } else {
            if (not dfs(nxt, new_cst, MOD)) return false;
        }
    }
    return true;
}

signed main() {

    cin >> N >> M;
    
    graph.resize(N);
    REP(i, M) {
        i64 A, B, X;
        cin >> A >> B >> X;
        --A, --B;
        graph[A].emplace_back(make_pair(B, X));
        graph[B].emplace_back(make_pair(A, -X));
    }

    for (auto& mod: MODS) {
        dp.assign(N, 0);
        visited.assign(N, false);
        REP(i, N) {
            if (visited[i]) continue;
            if (not dfs(i, 1, mod)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d)
    puts("Yes");
    else if(abs(a-b)<=d && abs(b-c)<=d)
    puts("Yes");
    else
    puts("No");
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
	static int mod=1000000007;
	static long[] fact=new long[500001];
	static long[] rev=new long[500001];
	static long pow(long a,long x,long m){
		if(x==0) return 1;
		else if(x%2==0) return pow((a*a)%m,x/2,m)%m;
		else return (a*pow((a*a)%m,x/2,m))%m;
	}
	static long rev(long a,long mod){
		if(a%mod==0) return 0;
		return pow(a,mod-2,mod)%mod;
	}
	static long ncr(long n,long r){
		long res=1;
		if(n==0 || r==0 || n==r) return res;
		res*=fact[(int)n]; res%=mod;
		res*=rev[(int)r]; res%=mod;
		res*=rev[(int)(n-r)]; res%=mod;
		return res;
	}
	static void init(){
		fact[1]=1; rev[1]=1;
		for(long i=2;i<fact.length;i++){
			fact[(int)i]=i*fact[(int)(i-1)]; fact[(int)i]%=mod;
			rev[(int)i]=rev(fact[(int)i],mod);
		}
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		init();
		while(sc.hasNext()){
			long h=sc.nextLong(),w=sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
			long ans=0;
			for(long i=1;i<=h-a;i++){
				ans+=(ncr(b+i-2,i-1)*ncr(w-b-1+h-i,h-i))%mod;
				ans%=mod;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 17484
#include <stdio.h>

int sum[501][501];

int main(void) {
    int n, m, q;
    int l[200001], r[200001];

    scanf("%d%d%d", &n, &m, &q);
    for (int i = 1; i <= m; i++)
        scanf("%d%d", &l[i], &r[i]);

    for (int i = 1; i <= m; i++)
        for (int k = r[i]; k <= n; k++)
            sum[l[i]][k]++;

    for (int j = 0; j < q; j++) {
        int pp, qq;
        int count;
        scanf("%d%d", &pp, &qq);
        count = 0;
        for (int k = pp; k <= qq; k++)
            count += sum[k][qq];
        printf("%d\n", count);
    }

    return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

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

	unordered_map<string, int> hashmap;
	string s;
	for (int i = 0; i < N; i++) {
		cin >> s;
		hashmap[s]++;
	}

	int ans = 0;
	for (pair<string, int> p : hashmap) {
		//ans = max(ans, p.second);
		ans = ans + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 17768
// Example program
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int x=0;
    for (int i=0; i<strlen(s.c_str()); i++) {
        if (s.c_str()[i] == 'C' && x == 0) x++;
        if (s.c_str()[i] == 'F' && x == 1) x++;
    }
    if (x==2) cout << "Yes" << endl;
        else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);
  long long a[100];
  a[0]=2,a[1]=1;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }

  printf("%lld\n",a[n]);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    std::cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = i; j <= 9; j++){
            if(i * j == n){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
# a,b = map(float, input().split())

# print(int(a*b))

n = int(input())
l = list(map(int, input().split()))

ans = 1
if l.count(0) != 0:
    print(0)
    exit()
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;

  std::set<int64_t> has_snack;

  for (int64_t i = 0; i < k; i++) {
    int64_t d;
    std::cin >> d;
    std::vector<int64_t> a(d);
    std::cin >> a;
    for (const auto v : a) {
      has_snack.insert(v);
    }
  }

  std::cout << n - has_snack.size() << std::endl;
  return 0;
}


Measured memory_bytes: 3632
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
sum = a.inject(:+)

puts a.select{|e| e * 4 * m >= sum}.size >= m ? 'Yes' : 'No'


Measured memory_bytes: 2300
def examA():
    S = SI()
    d = defaultdict(bool)
    ans = "Yes"
    for s in S:
        d[s] = True
    if (d["S"] and (not d["N"])) or (d["N"] and (not d["S"])):
        ans = "No"
    if (d["E"] and (not d["W"])) or (d["W"] and (not d["E"])):
        ans = "No"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 38256
#include<stdio.h>
#include<math.h>
 
int main(void)
{
    int a, b, sum, out;
    while(scanf("%d %d",&a,&b) != EOF)
    {
        sum = a + b;
        out = (int)log10((float)sum) + 1;
        printf("%d\n",out);
    }
    return 0;
}

Measured memory_bytes: 644
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <numeric>
using namespace std;

int main()
{	
	long long int N;
	scanf("%lld", &N);
	long long int a[N];
	for(long long int i=0;i<N;i++){
		scanf("%lld", &a[i]);
	}
	long long int ans=0;
	for(long long int i=0;i<N;i++){
		ans=ans+(a[i]%2);
	}
	if(ans>0)
	{printf("first");}else{printf("second");}
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	int N;
	cin >> N;

	set<int> check;

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

		check.insert(a);
	}

	if (check.size() == N) cout << "YES";
	else cout << "NO";

	return 0;
}

Measured memory_bytes: 9600
import bisect

N, K = map(int, input().split())
x = list(map(int, input().split()))
ans, tmp = 10**9, 10**9

#print(bisect.bisect(x, 0))

for i in range(len(x) - K + 1):
  if x[i] <= 0 and x[i+K-1] >= 0:
    tmp = abs(x[i]) + x[i+K-1] + min(abs(x[i]), x[i+K-1])
  elif x[i] < 0 and x[i+K-1] <= 0:
    tmp = abs(x[i])
  elif x[i] >= 0 and x[i+K-1] > 0:
    tmp = x[i+K-1]
#  elif i == bisect.bisect(x, 0)-1:
#    tmp = x[i+K-1]
#  elif i+K-1 == bisect.bisect(x, 0)-1:
#    tmp = abs[x[i]]
#  print("i:{}, i+K-1:{}, tmp:{}".format(i, i+K-1, tmp))
  ans = min(tmp, ans)
print(ans)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long  n,m;
int main() {
	IO
	string s;
	cin>>s;
	if(s[1]=='B')
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    return 0;
}


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

N=int(input())
A=list(map(int,input().split()))

if N==0:
    if A[0]==1:
        print(1)
    else:
        print(-1)
    sys.exit()

if A[0]!=0:
    print(-1)
    sys.exit()

NODE=[0]*(N+5)
NODE[0]=1
rest=1
ANS=0
ind=0

for i in range(N+1):
    #print(i,ANS,NODE)
    if A[i]>rest:
        print(-1)
        sys.exit()

    else:
        x=A[i]
        while x:
            if NODE[ind]<=x:
                ANS+=(i-ind+1)*NODE[ind]
                x-=NODE[ind]
                rest-=NODE[ind]
                NODE[ind]=0
                ind+=1
            else:
                ANS+=(i-ind+1)*x
                NODE[ind]-=x
                rest-=x
                x=0

        NODE[i+1]=rest
        rest*=2
        if rest>10**20:
            rest=10**20

print(ANS)

Measured memory_bytes: 85228
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;




int main(){
	int a, b, c, x, y;

	cin >> a >> b >> c >> x >> y;

	int total = 0;
	//ABの値段に応じて場合分け
	if (a + b <= 2*c) {
		total = a * x + b * y;
	}
	else if (a + b > 2 * c) {
		if (x >= y) {
			if (c * 2 * y + a * (x - y) > c * 2 * x) {
				total = c * 2 * x;
			}
			else {
				total = c * 2 * y + a * (x - y);
			}
		}
		else {
			if (c * 2 * x + b * (y - x) > c * 2 * y) {
				total = c * 2 * y;
			}
			else {
				total = c * 2 * x + b * (y - x);

			}
		}
	}
	cout << total << endl;

	return 0;
}

Measured memory_bytes: 3564
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	k := readInt()
	s := readString()

	if len(s) <= k {
		fmt.Println(s)
	} else {
		fmt.Println(s[:k] + "...")
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
  public static void main(String[] args){
    Scanner nyuryoku = new Scanner(System.in);
    int x = nyuryoku.nextInt();
    int y = nyuryoku.nextInt();
    int tmp;
    if (x < y){
      tmp = x;
      x = y;
      y = tmp;
    }
    System.out.println(gcd(x, y));
  }
  public static int gcd(int x, int y){
    if (x == 0) return y;
    if (x == y) return x;
    return gcd(y%x, x);
  }
}


Measured memory_bytes: 26396
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	var ans int
	if (B-A)%2 == 0 {
		ans = (B - A) / 2
	} else {
		// 答えは以下の(A)+(B)+(C)になる
		// (A) 片方が1卓あるいはN卓に移動するまでに必要なラウンド - min(A-1, N-B)
		// (B) 偶奇を調整するラウンド - 1ラウンド
        // (C) 双方が出会うためのラウンド - 最初は同じ方向に進むので、距離が縮まらない。偶奇調整後は近くが、調整ラウンド1分だけ距離が縮まっているので、必要なラウンド数は(B-A-1)/2となる
		ans = min(A-1, N-B) + 1 + (B-A-1)/2
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int D_MAX_V=2002;
const int D_v_size=2002;
struct D_wolf{
	int t,c,r;
	D_wolf(){t=c=r=0;}
	D_wolf(int t1,int c1,int r1){
		t=t1;c=c1;r=r1;
	}
};
vector<D_wolf>D_G[D_MAX_V];
int D_level[D_MAX_V];
int D_iter[D_MAX_V];

void add_edge(int from,int to,int cap){
	D_G[from].push_back(D_wolf(to,cap,D_G[to].size()));
	D_G[to].push_back(D_wolf(from,0,D_G[from].size()-1));
}
void D_bfs(int s){
	for(int i=0;i<D_v_size;i++)D_level[i]=-1;
	queue<int> Q;
	D_level[s]=0;
	Q.push(s);
	while(Q.size()){
		int v=Q.front();
		Q.pop();
		for(int i=0;i<D_G[v].size();i++){
			if(D_G[v][i].c>0&&D_level[D_G[v][i].t]<0){
				D_level[D_G[v][i].t]=D_level[v]+1;
				Q.push(D_G[v][i].t);
			}
		}
	}
}
int D_dfs(int v,int t,int f){
	if(v==t)return f;
	for(;D_iter[v]<D_G[v].size();D_iter[v]++){
		int i=D_iter[v];
		if(D_G[v][i].c>0&&D_level[v]<D_level[D_G[v][i].t]){
			int d=D_dfs(D_G[v][i].t,t,min(f,D_G[v][i].c));
			if(d>0){
				D_G[v][i].c-=d;
				D_G[D_G[v][i].t][D_G[v][i].r].c+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	for(;;){
		D_bfs(s);
		if(D_level[t]<0)return flow;
		for(int i=0;i<D_v_size;i++)D_iter[i]=0;
		int f;
		while((f=D_dfs(s,t,99999999))>0){flow+=f;}
	}
	return 0;
}
int c[1100];
vector<pair<int,int> >g[1100];
int dfs(int a,int b){
	int ret=c[a];
	for(int i=0;i<g[a].size();i++){
		if(g[a][i].first!=b){
			int t=dfs(g[a][i].first,a);
			ret+=t;
			if(t){
				add_edge(a,g[a][i].first,g[a][i].second);
			}
		}
	}
	return ret;
}
int main(){
	int a;
	scanf("%d",&a);
	for(int i=1;i<a;i++)scanf("%d",c+i);
	for(int i=0;i<a-1;i++){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
	}
	dfs(0,-1);
	for(int i=1;i<a;i++)if(c[i])add_edge(i,a,99999999);
	printf("%d\n",max_flow(0,a));
}

Measured memory_bytes: 1232
def resolve():
	n = int(input())
	ans = int(input())
	for i in range(n-1):
		v = int(input())
		a = ans
		b = v
		r = a%b
		while r:
			a = b
			b = r
			r = a % b
		ans = ans * v // b
	print(ans)
resolve()

Measured memory_bytes: 3060
def dp_fib
  val = gets.chomp.to_i
  memo = []
  memo[0] = 1
  memo[1] = 1
  ind = 1
  while ind < val do
    memo[ind+1] = memo[ind-1] + memo[ind]
    ind += 1
  end
  memo[ind]
end

p dp_fib

Measured memory_bytes: 8632
#include <iostream>
#include <vector>
#include <set>

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

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

	int H, W, K;
	cin >> H >> W >> K;
	pii a, b;
	cin >> a.first >> a.second >> b.first >> b.second;
	-- a.first;
	-- a.second;
	-- b.first;
	-- b.second;
	vector<string> c(H);
	vector<set<int>> rs(H), cs(W);
	for(int i = 0; i < H; ++i) {
		cin >> c[i];
		for(int j = 0; j < W; ++j) {
			rs[i].insert(j);
			cs[j].insert(i);
		}
	}

	vector<pii> Q, Q2;
	int ans = 0;
	Q.push_back(a);
	rs[a.first].erase(a.second);
	cs[a.second].erase(a.first);
	while(!Q.empty()) {
		Q2.clear();
		++ans;
		for(const pii &p : Q) {
			int x = p.first, y = p.second;
			auto it = rs[x].lower_bound(y);
			while(it != rs[x].begin()) {
				--it;
				if(*it < y-K || c[x][*it] == '@') {
					++it;
					break;
				}
				if(x == b.first && *it == b.second) return cout << ans << "\n", 0;
				Q2.emplace_back(x, *it);
				cs[*it].erase(x);
				it = rs[x].erase(it);
			}
			while(it != rs[x].end()) {
				if(*it > y+K || c[x][*it] == '@') break;
				if(x == b.first && *it == b.second) return cout << ans << "\n", 0;
				Q2.emplace_back(x, *it);
				cs[*it].erase(x);
				it = rs[x].erase(it);
			}
			it = cs[y].lower_bound(x);
			while(it != cs[y].begin()) {
				--it;
				if(*it < x-K || c[*it][y] == '@') {	
					++it;
					break;
				}
				if(*it == b.first && y == b.second) return cout << ans << "\n", 0;
				Q2.emplace_back(*it, y);
				rs[*it].erase(y);
				it = cs[y].erase(it);
			}
			while(it != cs[y].end()) {
				if(*it > x+K || c[*it][y] == '@') break;
				if(*it == b.first && y == b.second) return cout << ans << "\n", 0;
				Q2.emplace_back(*it, y);
				rs[*it].erase(y);
				it = cs[y].erase(it);
			}
		}
		swap(Q, Q2);
	}
	cout << "-1\n";

	return 0;
}

Measured memory_bytes: 144832
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
// const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a != b && b != c && c != a){
        cout << 3 << endl;
    }
    else if(a == b && b == c){
        cout << 1 << endl;
    }
    else {
        cout << 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 888
def testcase_ends():
    n = int(input())
    if n == 0:
        return 1

    n = oct(n)[2:]
    n = n.replace('7', '9')
    n = n.replace('6', '8')
    n = n.replace('5', '7')
    n = n.replace('4', '5')
    print(n)
    return 0

def main():
    while not testcase_ends():
        pass

if __name__ == '__main__':
    main()



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct fstruct {
    ll aa;
    ll bb;
    ll cc;
};
bool operator<(const fstruct& l, const fstruct& r) {
    if (l.aa == r.aa) {
        if (l.bb == r.bb) {
            return l.cc < r.cc;
        }
        return l.bb < r.bb;
    }
    return l.aa < r.aa;
}
bool operator==(const fstruct& l, const fstruct& r) {
    return (l.aa == r.aa &&
            l.bb == r.bb &&
            l.cc == r.cc);
}
bool operator>(const fstruct& l, const fstruct& r) {
    return !(l == r) && !(l < r);
}
bool operator!=(const fstruct& l, const fstruct& r) {
    return !(l == r);
}
bool operator>=(const fstruct& l, const fstruct& r) {
    return (l == r) || (l > r);
}
bool operator<=(const fstruct& l, const fstruct& r) {
    return (l == r) || (l < r);
}

int main() {
    ll H, W, M;
    cin >> H >> W >> M;
    vector<vector<pair<ll, ll>>> hh(H);
    vector<vector<pair<ll, ll>>> ww(W);
    vector<ll> hsiz(H, 0);
    vector<ll> wsiz(W, 0);

    set<pair<ll, ll>> exist;
    for (ll i = 0; i < M; i++) {
        ll h, w;
        cin >> h >> w;
        h--;
        w--;
        // hh[h].push_back(make_pair(h, w));
        // hh[w].push_back(make_pair(h, w));
        hsiz[h]++;
        wsiz[w]++;
        exist.insert(make_pair(h, w));
    }

    vector<ll> max_h_i;
    ll max_h = -1;
    for (ll i = 0; i < H; i++) {
        if (max_h == hsiz[i]) {
            max_h_i.push_back(i);
        } else if (max_h < hsiz[i]) {
            max_h = hsiz[i];
            max_h_i.clear();
            max_h_i.push_back(i);
        }
    }

    vector<ll> max_w_i;
    ll max_w = -1;
    for (ll i = 0; i < W; i++) {
        if (max_w == wsiz[i]) {
            max_w_i.push_back(i);
        } else if (max_w < wsiz[i]) {
            max_w = wsiz[i];
            max_w_i.clear();
            max_w_i.push_back(i);
        }
    }
    ll result = max_h + max_w - 1;
    for (auto hi : max_h_i) {
        for (auto wi : max_w_i) {
            auto p = make_pair(hi, wi);
            if (exist.count(p) == 0) {
                print(max_h + max_w);
                return 0;
            }
        }
    }
    print(max_h + max_w - 1);
}


Measured memory_bytes: 49132
N = int(input())
LL = list(map(int,input().split()))
cnt = 0
L = sorted(list(set(LL)))
for i in range(len(L)-2):
    for j in range(1, len(L)-1-i):
        for k in range(1, len(L)-i-j):
#             print(L)
#             print(L[i],L[i+j],L[i+j+k])
            if L[i] + L[i+j] > L[i+j+k] and L[i+j] - L[i] < L[i+j+k]:
#                 print("------------")
#                 print(L[i],L[i+j],L[i+j+k])
#                 print(LL.count(L[i]),LL.count(L[i+j]),LL.count(L[i+j+k]))
                cnt += LL.count(L[i])*LL.count(L[i+j])*LL.count(L[i+j+k])
                
print(cnt) 

Measured memory_bytes: 73704
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) {
        cin >> p[i];
    }

    sort(all(p));
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

const string ans = "AKIHABARA";

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  cin >> s;

  if (s[0] != 'A') s = 'A' + s;
  if (s.length() < 5) {
    cout << "NO" << '\n';
    return 0;
  }
  if (s[4] != 'A') s = s.substr(0, 4) + 'A' + s.substr(4);
  if (s.length() < 7) {
    cout << "NO" << '\n';
    return 0;
  }
  if (s[6] != 'A') s = s.substr(0, 6) + 'A' + s.substr(6);
  if (s.length() == 8) s = s + 'A';
  cout << (s == ans ? "YES" : "NO") << '\n';

  





  
  return 0;
}

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

int l[12];
int main(){
	while(scanf("%d",l)!=-1){
		double s = l[0];
		for(int i = 1 ; i < 12 ; i++){
			scanf(",%d",&l[i]);
			if( i < 10 ) s += l[i];
		}
		double a = l[10];
		double b = l[11];
		double x = 1.0 * s / (a+b) * a;
		int s2 = 0;
		for(int i = 0 ; i < 10 ; i++){
			if( s2 + l[i] > x - 1e-9 ){
				cout << i+1 << endl;
				break;
			}
			s2 += l[i];
		}
		
		
		

	}
	
}

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

#define ll long long;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 2e5 + 10;
vector<int> a[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  queue<int> Q;
  vector<int> visit(n, -1);
  visit[0] = 0;
  Q.push(0);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto& v : a[u]) {
      if (visit[v] >= 0) continue;
      visit[v] = u;
      Q.push(v);
    }
  }
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if (visit[i] < 0) found = true;
  }
  if (found) {
    puts("No");
  } else {
    puts("Yes");
    for (int i = 1; i < n; ++i) {
      printf("%d\n", visit[i] + 1);
    }
  }
  return 0;
}


Measured memory_bytes: 12716
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}
int a[100];

int main() {
  int n;
  cin >> n;

  int result = 0;
  REP(i,n) cin >> a[i];
  REP(i,n-1) {
    if(a[i] == a[i+1]) {
      a[i+1] = -i;
      result++;
    }
  }

  cout << result << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll dp[3000];
ll ansmizu,anssatou;
double noudo;
int main(){
	ll a,b,c,d,e,f;
	scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
	rep(i,0,3001)rep(j,0,3001)if(i*c+j*d<=3000)dp[i*c+j*d]=1;
	
	rep(i,0,31)rep(j,0,31)if(i*a+j*b<=f/100){
		ll mizu=(i*a+j*b)*100;
		ll saidai=min(mizu/100*e,f-mizu);
		while(!dp[saidai])saidai--;
		if(1.0*saidai/(mizu+saidai)>=noudo){
			ansmizu=mizu;
			anssatou=saidai;
			noudo=1.0*saidai/(mizu+saidai);
		}
	}
	printf("%lld %lld\n",ansmizu+anssatou,anssatou);
}

Measured memory_bytes: 128
#include<algorithm>
#include<deque>
#include<iostream>
#define rep(a,b,c) for(int a=b;a<=c;++a)

using namespace std;

int N, a;
deque<int> q;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> N;
	rep(i, 1, N) {
		cin >> a;
		if(i & 1) q.push_back(a);
		else q.push_front(a);
	}
	if(N & 1) reverse(q.begin(), q.end());
	for(auto it = q.begin(); it != q.end(); ++it) cout << *it << ' ';
	cout << '\n';
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << "Alice";
    } else {
        cout << "Borys";
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 1000005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

int main(){
  int X, Y;
  cin >> X >> Y;

  int idx = -1;
  int base = 0;
  int cnt = 0;
  while(true){
    if(base-cnt>Y) break;
    if(base-cnt <= Y && Y <= base){
      if(X-base/2 == base-Y){
        idx = base-Y;
        break;
      }
    }
    base += 2;
    cnt++;
  }

  if(idx == -1){
    cout << 0 << endl;
  }else{
    //cout << base/2 << " " << idx << endl;
    mint ret = mutil.comb(base/2, idx);
    cout << ret << endl;
  }
  
  return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  long long a,b,v,w,t,x,y;
  scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
  if(v<=w){
    printf("NO\n");
    return 0;
  }
  x=abs(a-b);
  y=v-w;
  if(x<=t*y){
    printf("YES\n");
    return 0;
  }
  printf("NO\n");
  return 0;
}


Measured memory_bytes: 1612
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		
		for(;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int a = sc.nextInt();
			if( (n|m|a) == 0 ) break;
			a--;
				
			int[][] map = new int[1000][n];
			for(int i=0;i<m;i++) {
				int hh = sc.nextInt();
				int p = sc.nextInt();
				int q = sc.nextInt();
				if( (hh|p|q) == 0 ) break;
				hh--; p--; q--;
				map[hh][p] = q-p; map[hh][q] = p-q;
			}
			for( int i = 999;i>=0;i-- ) {
				a += map[i][a];
			}
			System.out.println((a+1));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unordered_map<string,int>m;
	int n;cin>>n;
	for(int i=0;i<n;i++) {
		string s;cin>>s;
		m[s]++;
	}
	vector<string> verdicts = {"AC", "WA", "TLE", "RE"};
	for(auto verdict: verdicts) {
		cout<<verdict << " x "<< m[verdict] << "\n";
	}
}

Measured memory_bytes: 3620
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

grid = []
for i in range(2):
    grid.append([0]*(n))

tmp = 0

for i in range(n):
    tmp += a[1][n-1-i]
    grid[1][n-1-i] = tmp

cnt = a[1][n-1]

for i in range(n):
    cnt += a[0][n-1-i]
    if cnt < a[0][n-1-i] + grid[1][n-1-i]:
        cnt = a[0][n-1-i] + grid[1][n-1-i]
    grid[0][n-1-i] = cnt

print(grid[0][0])

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

int w,h;
char rb[20][20];	//redblack
int n = 0;	//乗れる
void rob(int,int);	//red or black

int main(){

	int k = 0;	//セットの数
	queue<int> able;	//乗れる数メモ
	while(1){
		int x,y;
		cin >> w >> h ;
		if (w == 0 && h == 0){
			break;
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> rb[j][i];
				if(rb[j][i] == '@'){
					x = j;
					y = i;
				}
			}
		}	//入力終了

	rob(x,y);
	able.push(n);
	n = 0;
	k++;
	}
	for(int i = 0; i < k; i++){
		cout << able.front() << endl;
		able.pop();
	}
	return 0;
}

	void rob(int x,int y){
		rb[x][y] = '#';
		n++;
		if(0 <= x-1 && rb[x-1][y] == '.'){
			rob(x-1,y);
		}
		if(x+1 < w && rb[x+1][y] == '.'){
			rob(x+1,y);
		}
		if(0 <= y-1 && rb[x][y-1] == '.'){
			rob(x,y-1);
		}
		if(y+1 < h && rb[x][y+1] == '.'){
			rob(x,y+1);
		}	//十字

		return ;
	}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int m=(a*c),n=(a*d),o=(b*c),p=(b*d);
    if(m>n && m>o && m>p)
        cout<<m<<endl;
    else if(n>m && n>o && n>p)
        cout<<n<<endl;
    else if(o>m && o>n && o>p)
        cout<<o<<endl;
    else
        cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[1001];
LL K;
vector<LL>v;
int main(){
	cin>>N;
	cin>>K;
	REP(i,N){
		cin>>A[i];
	}

	LL sum=0;
	REP(i,N){
		sum+=A[i];
	}
	REP(i,100001){
		int x=i+1;
		if(sum%x==0){
			v.push_back(x);
			v.push_back(sum/x);
		}
	}
	LL ans=1;
	REP(i,v.size()){
		LL c=0;
		vector<LL>w;
		REP(j,N){
			w.push_back((A[j]%v[i]));
		}
		sort(w.begin(),w.end());
		LL now=0;
		REP(j,w.size()){
			//cout<<w[j]<<endl;
			now+=(v[i]-w[j]);
		}
		//cout<<now<<" now_aaaaaaaaa"<<endl;
		LL now2=0;
		REP(j,w.size()){
			now2+=w[j];
			now-=(v[i]-w[j]);
			if(now2>=now){
				break;
			}
		}
		//cout<<now2<<" now"<<now<<" "<<v[i]<<endl;
		if(now2>=now){
			if(now2<=K){
				ans=max(ans,v[i]);
			}
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  int r,c;
  cin >> r >> c;
  string t;
  cin >> t;
  if(t == a)cout << r-1 << " " << c <<endl;
  else cout << r << " " << c-1 <<endl;

}

Measured memory_bytes: 256
N = int(input())

sample = list(map(int, input().split()))
#sample = [100, 1, 2, 3, 14, 15, 58, 58, 58, 29]

max_idx = sample.index(max(sample))
sample.sort()
ans = 0
for i in range(len(sample)//2):
    ans += int(sample[i*2])
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


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

    string s;
    string t;
    cin>>s>>t;
    f(i,s.size()){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(t.size()!=s.size()+1){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;


    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    char a, b, c;
    cin >> a >> b >> c;
    cout << a << b << c << endl;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const ll INF = 1e9+17;
const ll MOD = 1e9+7;

int dp[200007][2];

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

	string s; cin >> s;
	int n = s.size();
	dp[0][0] = 1;
	dp[1][0] = (s[0]==s[1] ? 0 : 2);
	dp[1][1] = (s[0]==s[1] ? 1 : 1);

	for(int i = 2; i < n; i++){
		if(s[i]==s[i-1]){
			dp[i][0] = 1+dp[i-1][1];
			dp[i][1] = 1+max(dp[i-2][0], dp[i-2][1]);
		}else{
			dp[i][0] = 1+max(dp[i-1][0], dp[i-1][1]);
			dp[i][1] = 1+max(dp[i-2][0], dp[i-2][1]);
		}
	}
		
	cout << max(dp[n-1][0], dp[n-1][1]) << '\n';

	return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 10010;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    int S[MAX_N], T[MAX_N];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for(int i = 0; i < q; i++) cin >> T[i];
    int cnt = 0;
    for(int i = 0; i < q; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(T[i] == S[j])
            {
                 cnt++;
                 break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>

using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define ll long long

#define MAX_V 300

int main()
{
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
	}

	int d[MAX_V][MAX_V];
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i == j) { d[i][j] = 0; }
			else { d[i][j] = INF; }
		}
	}
	for (int i = 1; i <= M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		d[a][b] = c; 
		d[b][a] = c;
	}

	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	sort(r.begin(), r.end());
	int res = INF;
	do {
		int tmp = 0;
		for (int i = 0; i < R-1; i++) {
			tmp += d[r[i]][r[i + 1]];
		}
		if (res > tmp) {
			res = tmp;
		}
	} while (next_permutation(r.begin(), r.end()));

	cout << res << endl;

	return (0);
}

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

int main(){
  
  int N, count = 0;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++)
    cin >> a.at(i);
  
  for (int i=0; i<N-1; i++){
    for (int j=0; j<N-1; j++){
      if(a.at(j) < a.at(j+1))
        swap(a.at(j),a.at(j+1));
    }
  }
  
  for (int i=0; i<N; i++){
    if(i%2 == 0)
      count += a.at(i);
    else
      count -= a.at(i);
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Maxn (1<<20)

int n, a[Maxn], Res;

int main()
{
    scanf("%d", &n);
    int Lim = 1<<n;
    for (int i=0; i<Lim; i++) scanf("%d", &a[i]);
    for (int i=0; i<Lim; i++)
        if (!a[i])
        {
            for (int j=0; j<n; j++)
                if (i & (1<<j))
                    if (a[i ^ (1<<j)])
                    {
                        puts("-1");
                        return 0;
                    }
        }
        else
        {
            bool flag=1;
            for (int j=0; j<n; j++)
                if (i & (1<<j))
                    if (a[i ^ (1<<j)]) { flag=0; break; }
            Res+=flag;
        }
    
    printf("%d\n", Res);
}



Measured memory_bytes: 7308
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
        // code
        int n, x;
        cin >> n >> x;
        vector<int> d;
        d.push_back(x);
        REP(i, n) {
                int x_in;
                cin >> x_in;
                d.push_back(x_in);
        }

        sort(ALL(d));

        int ans = d[1] - d[0];
        REP(i, n) { ans = gcd(ans, d[i + 1] - d[i]); }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    string a;
    int n;
    cin >> n >> a;
    vector<ll> wyst(26, 0);
    for (int i = 0; i < n; ++i)
        ++wyst[a[i] - 'a'];
    ll odp = 1;
    for (int i = 0; i < 26; ++i)
        odp = (odp * (wyst[i] + 1)) % MOD;
    --odp;
    if (odp < 0)
        odp += MOD;
    cout << odp;
    return 0;
}


Measured memory_bytes: 512
a, b = map(int, input().split())
l = list(map(int, input().split()))
f = b - 1
g = b - 2
c = int(l[-1])
d = int(l[0])
v = list([1]*b)
for i in range (f):
  	v[i] = l[i+1]-l[i]
v[f] = a + l[0] - l[-1]
if	max(v) == v[f]:
	print(l[-1]-l[0])
else:
	print(a-max(v))

Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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;}
typedef long long ll;

int dist[10][10];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    REP(i,10) REP(j,10) cin >> dist[i][j];
    // dist : cost i to j
    REP(k,10) REP(i,10) REP(j,10) chmin(dist[i][j],dist[i][k] + dist[k][j]);
    ll ans = 0; int t;
    REP(i,n) REP(j,m){
        cin >> t;
        if(t==-1) continue;
        ans += dist[t][1];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    li = []
    for _ in range(N):
        a,b = [int(n) for n in input().split()]
        li.append([a-b,a+b])
    # li.sort(key=lambda x:x[0])
    # last = (-10**10,-10**10)
    res = N
    # for a in li:
        
    #     if last[1] > a[1]:
    #         last = a
    #         res-=1
    #     elif last[1] > a[0]:
    #         last = last
    #         res-=1
    #     else:
    #         last = a
    li.sort(key=lambda x:-x[0])
    # print(li)
    last = (10**10,10**10)
    for a in li:
        
        if a[1] > last[0]:
            last = last
            res-=1
        else:
            last=a
    print(res)

main()

Measured memory_bytes: 66520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;
	if (A + B == 15) co("+");
	else if (A * B == 15) co("*");
	else co("x");
	
	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
	
    int main(){
    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		int n;
		cin>>n;
		int arr[n];
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		int cost[n]={};
		cost[1]=abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			if (abs(arr[i]-arr[i-1])+cost[i-1]<abs(arr[i]-arr[i-2])+cost[i-2]){
				cost[i]=abs(arr[i]-arr[i-1])+cost[i-1];
			}
			else{
				cost[i]=abs(arr[i]-arr[i-2])+cost[i-2];
			}
		}
		cout<<cost[n-1]<<"\n";
        return 0;
    }

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

int main(){
    double x[4];
    double y[4];

    while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]){
        double xv1 = x[1] - x[0];
        double yv1 = y[1] - y[0];
        double xv2 = x[3] - x[2];
        double yv2 = y[3] - y[2];
        cout << ((xv1*xv2+yv1*yv2==0.0)?"YES":"NO") << endl;
    }

    return 0;
}

Measured memory_bytes: 0