akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	int N;
	string s, t;
	cin >> N >> s >> t;
	for(int i = 0; i <= N; ++i){
		if(s.substr(i) == t.substr(0,N-i)){
			cout << N + i << endl;
			return 0;
		}
	}
	return 0;
}


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

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int X;
  cin >> X;
  if (X % 100 <= (X / 100) * 5) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3684
#include<iostream>
#include<queue>
using namespace std;
#define max 70
class Node{
public:
	int cost;
	int x;
	int y;
	Node(int c,int _x,int _y){
		cost=c;
		x=_x;
		y=_y;
	}
};

typedef queue <Node> bq;
int map[max][max];
bool visited[max][max];
int dx[]={ 0, 1, 0,-1};
int dy[]={ 1, 0,-1, 0};
int w,h;

void
init(){
	int i,j;
	for(i=0;i<max;i++){
		for(j=0;j<max;j++){
			map[i][j]=0;
			visited[i][j]=false;
		}
	}
}

int
bfs(){
	bq q;
	q.push(Node(1,0,0));


	while(!q.empty()){
		Node cur = q.front();q.pop();
		if(cur.x==2*(w-1) && cur.y==2*(h-1)){
			return cur.cost;
		}

		if(visited[cur.y][cur.x])continue;
		visited[cur.y][cur.x]=true;
		for(int i=0;i<4;i++){
			if(cur.y+dy[i]<0
					|| cur.y+dy[i]>2*(h-1)
					|| cur.x+dx[i]<0
					|| cur.x+dx[i]>2*(w-1)
					|| map[cur.y+dy[i]][cur.x+dx[i]]==1     )continue;
			q.push(Node(cur.cost+1, cur.x+2*dx[i], cur.y+2*dy[i]));
		}

	}
	return 0;
}

int
main(){
	int i,j;
	while(cin>>w>>h&&(w||h)){
		init();
		for(i=0;i<2*h-1;i++){
			int k;
			if(i%2==0){
				for(j=0,k=1;j<w-1;j++){
					cin>>map[i][k];
					k+=2;
				}
			}
			else{
				for(j=0,k=0;j<w;j++){
					cin>>map[i][k];
					k+=2;
				}
			}
		}
		cout<<bfs()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>      
#define ll long long int       
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {   
     int n,m;      
     cin >> n >> m;
     vector<int> a, b;
     int c;        
     REP(i,m) {    
         cin >> c; 
         a.push_back(c);
         cin >> c; 
         b.push_back(c);
     }             
     int ans=0;    
     for(int i=0;i<n;i++) {
         ans = 0;  
         REP(j,m) {
            if(i+1 == a[j]) ans++;
            if(i+1 == b[j]) ans++;                                                                                                       
         }         
         cout << ans << endl;
     }             
} 

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

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

    int x, a, b;
    cin >> x >> a >> b;
    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s == "nobiro") x = max(0, x + a);
        if(s == "tidime") x = max(0, x + b);
        if(s == "karero") x = 0;
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 3168
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count = 0

for i in range(N):
    wa = 0
    A = list(map(int, input().split()))
    for j in range(M):
        wa += A[j] * B[j]
    wa += C
    if wa > 0:
        count += 1

print(count)
     

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	ll k;
	cin>>k;
	vector<ll> ans(50);
	ll lp=k%50;
	for(int i=0;i<50;i++){
		if(i>49-lp)ans[i]=50;
		else ans[i]=49-lp;
	}
	ll d=k/50;
	for(int i=0;i<50;i++)ans[i]+=d;
	cout<<50<<endl;
	for(int  i=0;i<50;i++){
		cout<<ans[i];
		if(i!=49)cout<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())

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

A.sort()
F.sort(reverse=True)

H=10**12
L=0

while abs(H-L)>4:
    Mid=(H+L)//2
    #print(H,Mid,L)
    cnt=0
    for i in range(N):
        f=0
        if A[i]*F[i]>Mid:
            cnt+=(A[i]-int(Mid/F[i]))
            if cnt>K:
                f=1
                break
    if f==1:
        L=Mid
    else:
        H=Mid
for j in range(5):
    M=H-j
    cnt=0
    for i in range(N):
        if A[i]*F[i]>M:
            cnt+=(A[i]-int(M/F[i]))
            if cnt>K:
                print(M+1)
                exit()
print(0)

Measured memory_bytes: 119500
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class rect {

		double xa;

		double ya;

		double xb;

		double yb;



		rect(double xa, double ya, double xb, double yb) {

			this.xa = xa;

			this.xb = xb;

			this.ya = ya;

			this.yb = yb;

		}



		boolean in(double x, double y) {

			if ((xa - x) * (xb - x) <= 0)

				if ((ya - y) * (yb - y) <= 0)

					return true;

			return false;

		}

	}



	void run() {

		for (; sc.hasNextDouble();) {

			double xa = sc.nextDouble();

			double ya = sc.nextDouble();

			double xb = sc.nextDouble();

			double yb = sc.nextDouble();

			rect a = new rect(xa, ya, xb, yb);

			xa = sc.nextDouble();

			ya = sc.nextDouble();

			xb = sc.nextDouble();

			yb = sc.nextDouble();

			rect b = new rect(xa, ya, xb, yb);

			boolean in = false;

			in |= a.in(b.xa, b.ya);

			in |= a.in(b.xb, b.yb);

			in |= a.in(b.xa, b.yb);

			in |= a.in(b.xb, b.ya);

			in |= a.in((b.xa+b.xb)/2, (b.ya+b.yb)/2);

			in |= b.in(a.xa, a.ya);

			in |= b.in(a.xb, a.yb);

			in |= b.in(a.xa, a.yb);

			in |= b.in(a.xb, a.ya);

			in |= b.in((a.xa+a.xb)/2, (a.ya+a.yb)/2);			

			System.out.println(in?"YES":"NO");

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();



	}

}

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

int main() {
	int Q, l, r;
	cin >> Q;
	vector<bool> a(100001, true);
	a[1] = false;
	for (int i = 2; i * i < 100001; ++i) {
		for (int j = 2 * i; j < 100001; j += i) a[j] = false;
	}
	vector<int> b(100001);
	for (int i = 1; i < 100001; ++i) {
		b[i] = b[i - 1];
		if (a[(1 + i) / 2] && a[i] && i % 2) ++b[i];
	}
	for (int i = 0; i < Q; ++i) {
		cin >> l >> r;
		cout << b[r] - b[l - 1] << endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h> 
#include <queue>
#include <stack>
using namespace std;
char str[55][55];
int vis[55][55];
int d[4][2] = {-1,0,1,0,0,-1,0,1};
struct figuer{
		int x, y, step;
	}t,f;
int bfs (int n, int m);
int main()
{
	memset(vis,0,sizeof(vis[0]));
	int i, j, m, n, sum;
	scanf("%d %d", &n ,&m);
	sum = 0;
	for (i = 1;i <= n;i++) {
		getchar();
		for (j = 1;j <= m;j++) {
			scanf("%c",&str[i][j]);
			if (str[i][j] == '.')
				sum++;
		}
	}
		
	int x = bfs(n,m); 
//	for ( i = 1;i <= n;i++) {
//		for (j = 1;j <= m;j++) {
//			printf("%d ",vis[i][j]);
//		}
//		printf("\n");
//	}
	if (x == -1)
		printf("%d\n",x);
	else
		printf("%d\n",sum - x);
	return 0;
} 
int bfs(int n, int m)
{
	int i;
	queue<figuer> q;			//
	t.x = t.y = t.step = 1;
	q.push(t);
	while (!q.empty()) {		//队列不为空 
		t = q.front() ;			//取第一个元素 
		q.pop();
		if (vis[t.x][t.y])		//坐标是否走过 
			continue;
		vis[t.x][t.y] = t.step;
		if (t.x == n && t.y == m) 
			return t.step;
		for (i = 0;i < 4;i++) {	//坐标移动 
			f.x = t.x + d[i][0];
			f.y = t.y + d[i][1];
			int a = f.x, b = f.y;
			if (a>=1&&a<=n&&b>=1&&b<=m&&str[a][b]=='.') {
				f.step = t.step + 1;
				q.push(f);
			}
		}	
	}
	return -1;
}

Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())
if H > W:
  C1 = N % H
  C2 = N // H
  if C1 == 0:
    print(C2)
  else:
      print(C2 + 1)
elif H < W:
  C1 = N % W
  C2 = N // W
  if C1 == 0:
    print(C2)
  else:
      print(C2 + 1)
else:
  C1 = N % H
  C2 = N // H
  if C1 == 0:
    print(C2)
  else:
    print(C2 + 1)

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

int A,B,C,D;

int main(){
    cin >> A >> B >> C >> D;
    int count =1;
    while(A>0 && C>0){
        if(count%2==1){
            C -=B;
            count++;
        }
        else{
            A-=D;
            count++;
        }
    }
    if(count%2==0) cout << "Yes";
    else cout << "No";
    return 0;
    
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

const LL MAX_N=(LL)1e5+3;
LL fact[MAX_N],ifact[MAX_N],inv[MAX_N];


void _inv(){
    inv[0]=inv[1]=1LL;
    for(LL i = 2LL;i < MAX_N;i++){
        inv[i]= (inv[MOD%i] * (MOD - MOD/i)) % MOD;
    }
}
void calc(){
    _inv();
    fact[0]  =1LL;
    ifact[0] =1LL;
    for(LL i = 1LL;i < MAX_N;i++){
        fact[i] = (fact[i-1LL] * i) % MOD;
        ifact[i]= (inv[i] * ifact[i-1]) % MOD;
    }
}
LL C(LL n, LL r){
    if(n < 0 || r < 0 || r > n)return 0;
    if(r>n/2LL)r = n - r;
    //cout<<"!"<<fact[4]<<" "<<(fact[4]*ifact[4])%MOD<<endl;
    return (fact[n]*ifact[n-r]%MOD)*ifact[r]%MOD;
}

LL a[MAX_N];
int main(){
    int N;
    cin>>N;
    calc();
    set<LL>st;
    int pos2=0;
    REP(i,N+1){
        cin>>a[i];
        if(st.find(a[i])!=st.end())pos2=i;
        st.insert(a[i]);
    }
    int pos1=0;
    REP(i,N)if(a[i]==a[pos2]){
        pos1=i;break;
    }
    //cout<<a[pos]<<endl;
    //cout<<"!"<<p1<<endl;
    //cout<<"!"<<p2<<endl;
    REP(i,N+1){
        cout<<(C(N+1,i+1)-C(pos1+N-pos2,i)+MOD)%MOD<<endl;
    }
    return 0;
}

Measured memory_bytes: 8960
s = input()
k = int(input())

if len(s) == 1:
    print(s)
else:
    countone = 0
    for i in s:
        if i == '1':
            countone += 1
        else:
            break
    if k <= countone:
        print('1')
    else:
        print(s[countone])

Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
ll x;
cin>>x;
for(ll i=-1000;i<=1000;i++){
    for(ll j=-1000;j<=1000;j++){
    ll d=i*i*i*i*i,d2=j*j*j*j*j;
    if(d-d2==x){
        cout<<i<<" "<<j<<"\n";
        return 0;
    }
    }
}
}



Measured memory_bytes: 3612
n,k=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
c=0;i=0
a.sort(key=lambda a: a[0])
#print(a)
while c<k:
    c+=a[i][1]
    i+=1
#print(c)
print(a[i-1][0])


Measured memory_bytes: 29144
n,m=gets.split.map &:to_i
nr=n.times.map{gets.split.map &:to_i}
mr=m.times.map{gets.split.map &:to_i}
nr.each do |i|
  res=[]
  mr.each_with_index do |el,j|
    res << [j, ([i,el].transpose.map{|i|i.reduce(:-).abs}).inject(:+)]
  end
  puts res.sort{|a,b|a[1]<=>b[1]}[0][0] + 1
end


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

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
factor_cnt = [0] * (maxval+1)
factor_cnt[0] = 2
for i in range(n):
    if factor_cnt[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        factor_cnt[k] += 1

result = sum(factor_cnt[v] <= 1 for v in a)
print(result)

Measured memory_bytes: 95752
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int a, b;
 	cin >> a >> b;
 	if(a<1||a>9||b<1||b>9) cout << -1;
 	else cout << a*b << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		int[][] list = new int[a][b];
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				list[i][j] = scanner.nextInt();
			}
		}
		int[] list2 = new int[b];
		for (int i = 0; i < b; i++) {
			list2[i] = scanner.nextInt();
		}
		int sum;
		for (int i = 0; i < a; i++) {
			sum = 0;
			for (int j = 0; j < b; j++) {
				sum += list[i][j] * list2[j];
			}
			System.out.println(sum);
		}

	}
}



Measured memory_bytes: 40520
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

struct UnionFind{
private:
    vector<int> data;
public:
    UnionFind(int n){
        data.assign(n,-1);
    }
    int root(int x){
        if(data[x]<0)return x;
        else return data[x]=root(data[x]);
    }
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    bool merge(int x,int y){
        x=root(x),y=root(y);
        if(x==y)return false;
        if(data[x]>data[y])swap(x,y);
        data[x]+=data[y];
        data[y]=x;
        return true;
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main(){
    ll n,m;
    cin>>n>>m;
    UnionFind uf(n+n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a,--b;
        uf.merge(a+n,b);
        uf.merge(a,b+n);
    }
    bool bi=true;
    rep(i,n){
        bi&=!uf.issame(i,i+n);
    }
    if(!bi){
        cout<<n*(n-1)/2-m<<endl;
        return 0;
    }
    int r=uf.root(0);
    ll ans=0;
    rep(i,n){
        if(r==uf.root(i))++ans;
    }
    cout<<ans*(n-ans)-m<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int i=0; i<3; i++) {
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    int x = 0;
    x = (d*3600+e*60+f)-(a*3600+b*60+c);
    cout << x/3600 << " ";
    cout << x%3600/60 << " ";
    cout << x%3600%60 << endl;
  }
}


Measured memory_bytes: 3120
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C] = input[0].map(Number);

  return A === B ? C : B === C ? A : B;
};

console.log(main(read()));


Measured memory_bytes: 29644
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}

signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s,t;
        cin>>s>>t;
        int l=s.length();
        string v = t.substr(0,l);
        if(s==v&&s.length()+1==t.length())
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
       

    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 3640
# coding: utf-8
# Your code here!
import math
import sys
N = int(input())

def divisor(N):
    lst = []
    for i in range(2,math.ceil(math.sqrt(N))+1):
        if N%i == 0:
            lst.append(i)
            #if i != int(N/i):
                #lst.append(int(N/i))
    #lst.sort()
    return lst
    
ans = divisor(N)
#print(ans,len(ans))
if N == 2:
    print(1)
    sys.exit()
    
if len(ans) > 0:
    A = ans[-1]
    if A*A < N:
        B = int(N/A)
        print(A+B-2)
    else:
        print(2*A-2)
else:
    print(N-1)

'''
if len(ans)%2 == 0 and len(ans)>1:
    A = ans[len(ans)//2-1]
    B = ans[len(ans)//2]
    #print(A,B)
    print(A+B-2)
elif len(ans)%2 == 1 and len(ans)>1:
    A = ans[len(ans)//2]
    print(2*A-2)
else:
    print(N-1)
'''
  
    

Measured memory_bytes: 9124
N = int(input())
D , X = map(int,input().split())
A = list(int(input()) for _ in range(N))

# 植木算的に2 ~ D日目のチョコレートを食べた日を加算し、最後に1を足す
D -= 1
ans = N
for a in A:
    ans += D // a
print(ans + X)

Measured memory_bytes: 2940
s = gets.chomp.split("")
t = gets.chomp.split("")
kai = s.size - t.size + 1
i = 0
int = []
kai.times do |i|
    arr =  s[i..(i + (t.size)-1)]
    j = 0
    count = 0
    while true
        if arr[j] != t[j]
            count += 1
        end
        if t.size == j - 1
            break
        end
        j += 1
    end
    int << count
end
puts int.sort.shift

Measured memory_bytes: 14372
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#define N 100010
#define Pa pair<ll,int>
#define ll long long
#define mo ((ll)1e9+7)
//10000000000037ll
//21993833369ll
#define db double
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
bool cmp(int a, int b) {return a > b;}
inline ll read() {
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
ll a[200010]; ll s[200010];
int main() {
	ll n = read();
	rep(i, 1, n)a[i] = read(), s[i] = (s[i - 1] + a[i]) % mo;
	ll ans = 0;
	rep(i, 2, n) {
		//printf("%lld\n", s[i - 1] * 1ll * a[i]);
		ans = (ans + s[i - 1] * 1ll * a[i]) % mo;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6876
#include<stdio.h>
#include<iso646.h>
 
#include<stdio.h>
#include<string.h>
#include<iso646.h>
 
int main(){
  char N[2];
 
  scanf("%s",N);
 
  if(N[0] == '9' or N[1] == '9'){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
 
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define endl '\n'
using namespace std;
const LL MOD = 1e9+7;
const LL INF = 1e9+7;


int main(){

	int n;
	cin>>n;
	int tot = 0;
	for(int i = 0; i < n; i++){
		int a,b;
		cin>>a>>b;
		tot += (abs(a - b) + 1);
	}
	cout<<tot<<endl;
	return 0;
	
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

const int N = 100010;
vii G(N);
vi p(N, -1);


int main() {
  int n, m;
  cin >> n >> m;
  set<int> st;
  rep (i, n) {
    st.insert(i);
  }
  vector<set<int> > g(n);
  rep (i, n + m - 1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    st.erase(v);
    g[v].insert(u);
  }
  int root = *st.begin();
  p[root] = 0;
  queue<int> qu;
  qu.push(root);
  while (!qu.empty()) {
    int u = qu.front();
    qu.pop();
    rep (i, G[u].size()) {
      int v = G[u][i];
      if (g[v].size() == 1) {
        p[v] = u;
        qu.push(v);
      }
      g[v].erase(u);
    }
  }
  rep (i, n) {
    if (i == root) {
      cout << 0 << endl;
    }
    else {
      cout << p[i] + 1 << endl;
    }
  }
}
  


Measured memory_bytes: 16000
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/*
制約
 1≤n≤100
 0≤ci≤100,000
 |E|≤10,000
 0から各ノードへは必ず経路が存在する
*/

#define MAX 200

int Minimum(int, int);

int main(){
  int n, i, j, sum;
  int c, v, k, u;
  int D[MAX][MAX];
  int x, y;

  for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++){
      D[i][j] = 1e9;
      if(i == j) D[i][j] = 0;
    }
  }

  scanf("%d", &n);
  if(n<1 || n>100) exit(1);
  
  for(i=0; i<=n-1; i++){
    scanf("%d %d", &u, &k);
    for(j=0; j<=k-1; j++){
      scanf("%d %d", &v, &c);
      D[u][v] = c;
    }
  }

  for(k=0; k<=n-1; k++){
    x = 0;
    y =0;
    for(i=0; i<=n-1; i++){
      x += y;
      y=1;
      for(j=0; j<=n-1; j++){
	sum = 0;
	sum = D[i][k]+D[k][j];
	D[i][j] = Minimum(D[i][j], sum);
      }
      y++;
    }
  }
      
  for(i=0; i<=n-1; i++) printf("%d %d\n", i, D[0][i]);
  x = 0;
  
  return 0;
}

int Minimum(int x, int y){
  if(x<y) return x;
  else return y;
} 



Measured memory_bytes: 2104
main=do
 getLine
 txy<-map(map read.words).lines<$>getContents
 putStrLn$if f 0 0 0 txy then"Yes"else"No"
f t x y[]=True
f t x y([nt,nx,ny]:txy)
 |(nt-t+nx-x+ny-y)`mod`2==0&&nt-t>=(abs$nx-x)+(abs$ny-y)=f nt nx ny txy
 |otherwise=False

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



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

        rep(a, 0, M+1) {
                ll b = M - a;
                rep(x, 0, N+1) {
                        ll y = N - x;
                        if (a*x + b*y == K) {
                                cout << "Yes" << endl;
                                return 0;
                        }
                }
        }

        cout << "No" << endl;
}


Measured memory_bytes: 3636
n, k = list(map(int, input().split()))
q, m = divmod(n, k)
a = 0
b = 0
lst = list(range(1, k)[::-1]) + [k]
for i in lst:
    if (i*2)%k != 0:
        a_ = 0
    else:
        a_ = q+1 if i<=m else q
        a_ *= a_
    a += a_
    if i == k-m and i != k:
        b = a
print(a*q+b)

Measured memory_bytes: 12892
n,q = map(int,input().split())
a = list(map(int,input().split()))

def segfunc(x,y):
    return x + y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
init(a)

for _ in range(q):
    q1,p,x = map(int,input().split())
    if q1 == 0:
        update(p, seg[p+num-1] + x)
    else:
        print(query(p, x))


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, count;
  cin >> n;
  vecll b(n);
  
  forll(i, 0, n-1){
	cin >> b[i];
  }

  count = b[0] + b[n-2];

  forll(i, 1, n-1)
	count += min(b[i-1], b[i]);

  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
using namespace std;

int main(){
    string s;
    cin>>s;
    int ct=0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='o'){
            ct++;
        }
    }
    cout<<700+ct*100<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int N, K;
int A[200005];
int cnt[200005];

int main(void)
{
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	for(int i = 0; i < N; i++){
		cnt[A[i]]++;
	}
	sort(cnt+1, cnt+N+1);
	
	int ans = 0;
	for(int i = 1; i <= N-K; i++){
		ans += cnt[i];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))

b = []

b_odd = []
b_even = []

for i in range(len(a)):
    if i%2==0:b_even.append(a[i])
    else:b_odd.append(a[i])

if len(a)%2==0:
    b_odd.reverse()
    b_odd+=b_even
    print(*b_odd)
else:
    b_even.reverse()
    b_even+=b_odd
    print(*b_even)

Measured memory_bytes: 26180
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long double a, b; cin >> a >> b;
	long double c = a * b;
	cout << (long long)floor(c);

	return 0;
}

Measured memory_bytes: 3708
/**
 *    author:  Aurthur
 *    Created : 19.09.2020      
**/
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define per(i, a, n) for(int i = n-1; i >= a; --i)
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < n; ++i){
		if(s[n-1] == 's'){
			cout << s+"es" << endl;
			return 0;
		}
		else{
			cout << s+"s" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 K;
  cin >> K;
  bitset<1010101> vis;
  i64 now = 0;
  i64 cnt = 0;
  while(!vis[now]) {
    vis[now] = 1;
    now = (now * 10 + 7) % K;
    cnt++;
    if(now == 0) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1e9+7;

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

	vector<string> grid(n);
	for(int i=0;i<n;i++) cin >> grid[i];

	ll dp[n][m];
	// dp[i][j] ---> ways to reach end from i,j cell

	dp[n-1][m-1]=1;

	for(int i=m-2;i>=0;i--){
		if(grid[n-1][i]=='#') dp[n-1][i]=0;
		else dp[n-1][i] = dp[n-1][i+1];
	}

	for(int i=n-2;i>=0;i--){
		if(grid[i][m-1]=='#') dp[i][m-1]=0;
		else dp[i][m-1] = dp[i+1][m-1];
	}

	for(int i=n-2;i>=0;i--){
		for(int j=m-2;j>=0;j--){
			if(grid[i][j]=='#') dp[i][j] = 0 ;
			else dp[i][j] = dp[i+1][j]%mod + dp[i][j+1]%mod;
			dp[i][j] %= mod;
		}
	}

	cout << dp[0][0]%mod << endl;
	return 0;
}



Measured memory_bytes: 13288
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    int a, b, t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val X = sc.nextInt

  val z =
    if (X >= 400 && X <= 599) 8
    else if (X >= 600 && X <= 799) 7
    else if (X >= 800 && X <= 999) 6
    else if (X >= 1000 && X <= 1199) 5
    else if (X >= 1200 && X <= 1399) 4
    else if (X >= 1400 && X <= 1599) 3
    else if (X >= 1600 && X <= 1799) 2
    else 1
  println(z)
}


Measured memory_bytes: 55340
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  string s;
  cin >> s;
  bool l=false,n=false,a1=false,a2=false;
  if(s.size()>=6) l=true;
  rep(i,s.size()) {
    if(isdigit(s[i])) n=true;
    if(islower(s[i])) a1=true;
    if(isupper(s[i])) a2=true;
  }
  if(l && n && a1 && a2) pr("VALID");
  else pr("INVALID");
  return 0;
}


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

using namespace std;

int ctoi(char a)
{
	return a-'0';
}
int itoc(int n)
{
	return '0'+n;
}

int main(void)
{
	int k;
	cin >> k;
	string s = "1";
	int count = 0;
	for (int i = 1; i < k; i++) {
		/*
		for (int j = s.size()-1; j >= 0; j--) {
			if (j == 0) {
				if (ctoi(s[j])+1 == 10) {
					s[j] = '0';
					s.insert(s.begin(), '1');
				} else {
					s[j] = itoc(ctoi(s[j]) + 1);
				}
			} else {
			*/
		if (s.size() == 1) {
			if (ctoi(s.back()+1)== 10) {
				s[0] = '0';
				s.insert(s.begin(), '1');
			} else {
				s[0] = itoc(ctoi(s[0])+1);
			}
		} else if (s.size() >= 2) {
			if (ctoi(s.back())+1 == 10 || abs(ctoi(s.back())+1 - ctoi(s[s.size()-2])) >= 2) {
				int k;
				for (k = s.size()-1; k > 0; k--) {
					if (abs(ctoi(s[k])+1 -ctoi(s[k-1]))<= 1 && ctoi(s[k])+1 <= 9) {
						break;
					}
				}

				bool add = false;
				if (ctoi(s[k])+1 == 10 && k== 0)
					add = true;
				s[k] = itoc((ctoi(s[k])+1)%10);
				for (int j = k+1; j < s.size(); j++) {
					s[j] = itoc(max(ctoi(s[j-1])-1, 0));
				}
				if (add)
					s.insert(s.begin(), '1');
			} else {
				s[s.size()-1] = itoc(ctoi(s.back())+1);
			}

		}
		//cout << s << endl;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3632
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[2] == 'X':
    ans += 1
elif f[2] == 'X' and s[1] == 'X' and t[0] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
elif ans == 0:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

#define NUMBER 100

int d(int p, int x[],int n)
{
    int i;
    int c = 0;
    for (i = 0;i < n;i++){
        c = c + pow(x[i] - p,2);
    }
    return c;
}

void sort_min(int x[],int n)
{
    int i,j;
    int tmp;
    for (i = 0;i < n-1;i++){
        for (j = 0;j < n-1;j++){
            if (x[j] > x[j+1]){
                tmp = x[j];
                x[j] = x[j+1];
                x[j+1] = tmp;
            }
        }
    }
}
int main(void)
{
    int n;
    int x[NUMBER];
    int i;
    
    scanf ("%d",&n);
    for (i = 0;i < n;i++){
        scanf("%d",&x[i]);
    }
    
    sort_min(x,n);
    
    int m = d(x[0],x,n);
    
    for (i = x[0];i < x[n-1];i++){
        if (d(i,x,n) >= d(i+1,x,n)){
            m = d(i+1,x,n);
        }
        else break;
    }
    printf("%d\n",m);
    return 0;
}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

const ll INF = 1LL << 60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

/*
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

ll w[110];
ll v[110];
ll dp[110][100100] = {0};

void Main()
{
	int N, W;
	cin >> N >> W;

	for (int i = 0; i < N; ++i) {
		std::cin >> w[i] >> v[i];
	}

	for (int i = 0; i < N; ++i) {
		for (int sum_w = 0; sum_w <= W; ++sum_w) {
			if (sum_w - w[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
			}
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W];
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

    using namespace std;
    int n;
    const int maxn=1e7+5;
    int ans[maxn];
    char s[maxn];
    int main()
    {
        cin>>n;
        getchar();
        int f=0;
        int mark;
        scanf("%s",s+1);
        for(int k=0;k<=1;k++){
            for(int l=0;l<=1;l++){
                ans[1]=l;
                ans[2]=k;

        for(int i=3;i<=n;i++){
            if(ans[i-1]==0){
                if(s[i-1]=='o'){
                    ans[i]=ans[i-2];
                }
                else{
                    ans[i]=1-ans[i-2];
                }
            }
            else{
                if(s[i-1]=='o'){
                    ans[i]=1-ans[i-2];
                }
                else{
                   ans[i]=ans[i-2];
                }

            }
        }
        if(ans[n]==0){
            if(s[n]=='o'){
                if(ans[n-1]!=ans[1]){
                    continue;
                }
            }
            else{
                if(s[n]=='x'){
                    if(ans[n-1]==ans[1]){
                        continue;
                    }
                }
            }
        }
        else{
            if(s[n]=='o'){
                if(ans[n-1]==ans[1]){
                    continue;
                }
            }
            else{
                if(s[n]=='x'){
                    if(ans[n-1]!=ans[1]){
                        continue;
                    }
                }
            }
        }
        if(ans[1]==0){
            if(s[1]=='o'){
                if(ans[2]!=ans[n]){
                    continue;
                }
            }
            else{
                if(ans[2]==ans[n]){
                    continue;
                }
            }
        }
        else{
            if(s[1]=='o'){
                if(ans[2]==ans[n]){
                    continue;
                }
            }
            else{
                if(ans[2]!=ans[n]){
                    continue;
                }
            }
        }
        f=1;
        goto solve;







        }
        }
        solve:

        if(f){
            for(int i=1;i<=n;i++){
                if(ans[i]==0){
                    printf("S");
                }
                else{
                    printf("W");
                }
            }
        }
        else{
            printf("-1");
        }
        cout<<endl;

        return 0;
    }


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

int main()
{
	char b;
	cin >> b;
	if (b == 'A') cout << "T" << endl;
	else if (b == 'C') cout << "G" << endl;
	else if (b == 'G') cout << "C" << endl;
	else if (b == 'T') cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 256