akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int D;
vector<int> C;
vector<vector<int>> S;

long long getTime() {
	timespec ts;
	clock_gettime(CLOCK_REALTIME_COARSE, &ts);
	long long r = ts.tv_sec;
	r *= 1000000000;
	r += ts.tv_nsec;
	return r;
}

ll calcScore(const vector<int>& T) {
	vector<int> last(26, -1);
	ll score = 0;
	for (int i = 0; i < D; ++ i) {
		int d = i - last[T[i]];
		score -= C[T[i]] * d * (d-1) / 2;
		last[T[i]] = i;
		score += S[i][T[i]];
	}
	for (int j = 0; j < 26; ++ j) {
		int d = D - last[j];
		score -= C[j] * d * (d-1) / 2;
	}
	return score;
}

int hoge(const vector<int>& T) {
	vector<int> last(26, -1);
	vector<ll> pena(26);
	for (int i = 0; i < D; ++ i) {
		last[T[i]] = i;
		for (int j = 0; j < 26; ++ j) {
			pena[j] += C[j] * (i - last[j]);
		}
	}
	int r = 0, cnt = 1;
	for (int j = 1; j < 26; ++ j) {
		if (pena[j] > pena[r]) {
			r = j; cnt = 1;
		} else if (pena[j] == pena[r]) {
			if (rand() % ++cnt == 0) { r = j; }
		}
	}
	return r;
}

int main() {
	auto startTime = getTime();

	cin >> D;
	C.resize(26);
	for (auto& x : C) cin >> x;
	S = vector<vector<int>>(D, vector<int>(26));
	for (auto& x : S) for (auto& y : x) cin >> y;

	vector<int> res(D);
	for (int i = 0; i < D; ++ i) {
		res[i] = 0;
		for (int j = 1; j < 26; ++ j) {
			if (S[i][j] > S[i][res[i]]) res[i] = j;
		}
	}

	for (int tt = 1; ; ++ tt) {
		int x = hoge(res);
		int ii = 0;
		ll m = -(1LL<<62);
		for (int i = 0; i < D; ++ i) {
			int tmp = res[i];
			res[i] = x;
			auto s1 = calcScore(res);
			if (s1 > m) {
				ii = i;
				m = s1;
			}
			res[i] = tmp;
		}
		if (res[ii] == x) break;
		res[ii] = x;
	}

	ll maxScore = calcScore(res);
	auto ans = res;

	auto s0 = maxScore;
	for (int tt = 1; ; ++ tt) {
		if (tt % 1024 == 0 && getTime() - startTime >= 1900000000) break;
		int i = rand() % D;
		int tmp = res[i];
		res[i] = rand() % 26;
		if (tmp == res[i]) continue;
		auto s1 = calcScore(res);
		if (s1 > maxScore) { maxScore = s1; ans = res; cerr << s1 << endl; }
		if (s1 <= s0) {
			auto d = s0 - s1;
			if (rand() / (1.0 + RAND_MAX) < 1 - exp(-0.0009 * d)) {
				res[i] = tmp;
			} else {
				s0 = s1;
			}
		} else {
			s0 = s1;
		}
	}

	for (auto x : ans) cout << x + 1 << endl;
}


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

#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
const long long INF=1e18;
typedef pair<ll,ll> pll;
#define F first
#define S second



int main(){
  ll r,s,p;
  cin>>r>>s>>p;
  vector<ll> A(p);
  for(int i=0;i<p;i++){
    ll x,y;
    cin>>x>>y;
    if(y<=s){y--;}
    x--;
    A[i]=abs(s-y)+r-x;
  }
  sort(A.begin(),A.end());
  for(int i=1;i<p;i++){
    A[i]=max(A[i],A[i-1]+1);
  }
  cout<<A.back()<<endl;

  
  
  return 0;
}



Measured memory_bytes: 6688
#include<iostream>
using namespace std;
#include<string>
#include <set>
int main()
{
	int n;
	set <string, greater <string> > str1;
	string str;
	cin >> n;
	while(n--)
	{
		cin >> str;
		str1.insert(str);
	}
	cout<<str1.size()<<endl;
	return 0;
}
	
			


Measured memory_bytes: 19092
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define dbg(x) cerr << #x << ": " << x << endl
#define all(x) (x).begin(), (x).end()

int dp[1000100][2];
const int INF = 1000000005;
int main() {
  string s;
  cin >> s;
  reverse(all(s));
  s += '0';
  int m = s.size();
  rep(i, m + 1) rep(j, 2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, m) rep(j, 2) {
    int n = s[i] - '0';
    n += j;
    rep(a, 10) {
      int ni = i + 1, nj = (a - n < 0);
      int b = a - n >= 0 ? a - n : 10 + a - n;
      dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
    }
  }
  cout << dp[m][0] << endl;
  return 0;
}

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  if(a < 1200){
    cout<<"ABC"<<'\n';
  }
  else if(a >= 1200 && a < 2800){
    cout<<"ARC"<<'\n';
  }
  else{
    cout<<"AGC"<<'\n';
  }
  return 0;
}
  


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

int main()
{
	int price, amount;
	int sum = 0, ave = 0, i = 0;
	while(scanf("%d,%d", &price, &amount) != EOF)
	{
		sum += price * amount;
		ave += amount;
		i++;
	}
	
	printf("%d\n%d\n", sum, (int)(ave / (double)i + 0.5));
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll N, K;
  cin >> N >> K;
  ll keta = 1;
  while (1) {
    ll max = pow(K, keta) - 1;
    if (max >= N) {
      COUT(keta);
      return 0;
    }
    keta++;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			me = scanner.nextInt();
			if (me == 0)
				break;
			n = scanner.nextInt();
			a = new int[n + 2];
			for (int i = 1; i <= n; i++)
				a[i] = scanner.nextInt();
			n += 2;
			boolean[] vis = new boolean[n];
			bfs(0, vis);
			if (!vis[n - 1]) {
				System.out.println("NG");
				continue;
			}
			boolean ok = true;
			for (int s = 1; s < n - 1; s++) {
				if (vis[s]) {
					boolean[] vis2 = new boolean[n];
					bfs(s, vis2);
					if (!vis2[n - 1]) {
						ok = false;
						break;
					}
				}
			}
			System.out.println(ok ? "OK" : "NG");
		}
	}

	private void bfs(int s, boolean[] vis) {
		for (int i = 0; i < n; i++)
			vis[i] = (i == s);
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.push(s);
		while (!deque.isEmpty()) {
			int x = deque.poll();
			for (int d = 1; d <= me; d++) {
				int xx = Math.min(x + d, n - 1);
				xx = Math.max(Math.min(xx + a[xx], n - 1), 0);
				if (!vis[xx]) {
					vis[xx] = true;
					deque.push(xx);
				}
			}
		}
	}

	int n, me;
	int[] a;
}

Measured memory_bytes: 62064
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
ll n,m,ans[55][55];
char a[55][55];
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#')ans[i][j]=-1;
			else{
				if(a[i-1][j-1]=='#')ans[i][j]++;
				if(a[i-1][j]=='#')ans[i][j]++;
				if(a[i-1][j+1]=='#')ans[i][j]++;
				if(a[i][j-1]=='#')ans[i][j]++;
				if(a[i][j+1]=='#')ans[i][j]++;
				if(a[i+1][j-1]=='#')ans[i][j]++;
				if(a[i+1][j]=='#')ans[i][j]++;
				if(a[i+1][j+1]=='#')ans[i][j]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ans[i][j]==-1)cout<<'#';
			else cout<<ans[i][j];
		}
		cout<<endl;
	}
	
    return 0;
}


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

using namespace std;

using ll = long long;

const int N = 101;
bool seen[N];
int main() {
  int x, n;
  cin >> x >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    seen[x] = true;
  }
  int mn = 1e9;
  int val = -1;
  for (int i = -100; i <= 105; i++) {
    if (i > 0) {
      if (!seen[i]) {
        if (abs(i - x) < mn) {
          mn = abs(i - x);
          val = i;
        }
      }
    } else {
      if (abs(i - x) < mn) {
        mn = abs(i - x);
        val = i;
      }
    }
  }
  cout << val;

  return 0;
}


Measured memory_bytes: 3604
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int s; cin >> s;
  set<int> used;
  used.insert(s);
  for (int i = 1;; ++i) {
    int ns = (s % 2 == 0) ? s/2 : 3*s+1;
    if (used.count(ns)) {
      cout << i + 1 << endl;
      return 0;
    }
    s = ns;
    used.insert(s);
  }
}


Measured memory_bytes: 3584
w,h,n = map(int, input().split())

o,p,q,r = 0,0,0,0
for _ in range(n):
  x,y,a = map(int, input().split())
  if a == 1: o = max(o,x)
  elif a == 2: p = max(p,w-x)
  elif a == 3: q = max(q, y)
  elif a == 4: r = max(r,h-y)

w -= o+p
h -= q+r
if w > 0 and h > 0: print(w*h)
else: print(0)

Measured memory_bytes: 9128
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

mia = sorted([i for i in a if i < 0], reverse=True)
pla = sorted([i for i in a if i >= 0])

cnt = 1
if len(pla) == 0 and k % 2 == 1:
    for i in mia[:k]:
        cnt = cnt * i % mod
else:
    while k > 0:
        if k == 1 or len(mia) <= 1:
            if len(pla) == 0:
                cnt *= mia.pop()
            elif len(pla) > 0:
                cnt *= pla.pop()
            k -= 1
        elif len(pla) <= 1:
            cnt *= mia.pop() * mia.pop()
            k -= 2
        elif len(pla) >= 2 and len(mia) >= 2:
            if pla[-1] * pla[-2] > mia[-1] * mia[-2]:
                cnt *= pla.pop()
                k -= 1
            elif pla[-1] * pla[-2] <= mia[-1] * mia[-2]:
                cnt *= mia.pop() * mia.pop()
                k -= 2
        cnt %= mod
print(cnt)


Measured memory_bytes: 33304
N,M = map(int,input().split())
S = input()
N0 = 2**(N-1).bit_length()
INF = 2**31-1

# k番目の要素をxに更新
def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

# [l,r)の最小値
def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s



data1 = [INF]*(3*N0)
update(0,0,data1)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(max(0,n-M+1),n+1,data1)+1,data1)

S = S[::-1]
data2 = [INF]*(3*N0)
update(0,0,data2)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(max(0,n-M+1),n+1,data2)+1,data2)

cost1 = [INF]*(N+1)
cost2 = [INF]*(N+1)
for n in range(N+1):
    cost1[n] = query(n,n+1,data1)
    cost2[n] = query(N-n,N-n+1,data2)

ans = []
cost = 0
for n in range(N+1):
    if cost != cost1[n] and cost1[n]+cost2[n]==cost1[N]:
        ans.append(n)
        cost = cost1[n]
ans = [0]+ans
for i in range(len(ans)-2,-1,-1):
    ans[i+1] = ans[i+1]-ans[i]

ans = ' '.join([str(c) for c in ans[1:]])
if cost2[0]==INF:
    ans = '-1'
print(ans)


Measured memory_bytes: 75740
import sys
readline = sys.stdin.readline
import math

def main():
    N, K = map(int, readline().rstrip().split())
    S = [0] * N
    for _ in range(K):
        d = int(readline())
        A = list(map(int, readline().rstrip().split()))
        for a in A:
            S[a-1] += 1
    
    print(len([s for s in S if s == 0]))


if __name__ == '__main__':
    main()

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

int A, B, C, D, E, F;

int main() {
   cin >> A >> B >> C >> D >> E >> F;

   // 砂糖、水をそれぞれ独立して作る
   set<int> water, sugar;
   // 水
   for (int i = 0; i <= 33; i++) {
      for (int j = 0; j <= 33; j++) {
         int w = 100*A*i + 100*B*j;
         if (w <= F) water.insert(w);
      }
   }

   // 砂糖
   for (int i = 0; i < 3010; i++) {
      for (int j = 0; j < 3010; j++) {
         int s = C*i + D*j;
         if (s <= F) sugar.insert(s);
      }
   }

   const double kijun = (double)E/(100+E);
   double noudo = -1; // 初期値を-1にしないと死ぬ
   // double noudo = 0;
   int a = 0, b = 0;
   for (int s : sugar) {
      for (int w : water) {
         int sum = s + w;
         double x = (double)s/sum;
         if (sum <= F && x <= kijun && x > noudo) {
            noudo = x;
            a = sum, b = s;
         }
      }
   }
   printf("%d %d\n", a, b);

   return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int r;
    cin >> r;
    double ans = 2 * M_PI * r;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3764
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    static int n,m;
    static long mod = 998244353;
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt(); m = sc.nextInt();
        int[][] a= new int[n][m];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++) a[i][j]=sc.nextInt();
        }
        int rank = getRank(a);
        long ans = (power(2,n+m-1)-power(2,n+m-rank-1)+mod)%mod;
        System.out.println(ans);
    }
    static long power(long base, long q){
        long ans = 1;
        while(q>0){
            if(q%2==1) ans = ans*base%mod;
            base = base*base%mod;
            q /= 2;
        }
        return ans;
    }
    static int getRank(int[][] A){
        int rank = 0;
        for(int j=0;j<m;j++){
            int pivot = -1;
            for(int i=rank;i<n;i++){
                if(A[i][j]>0){
                    pivot = i;
                    break;
                }
            }
            if(pivot<0) continue; // following col may still contains non-zero. need to go on
            if(pivot!=rank){ // swap the chosen line to the top of the concerned area
                for(int k=0;k<m;k++){
                    int c = A[pivot][k];
                    A[pivot][k] = A[rank][k];
                    A[rank][k] = c;
                }
            }
            for(int i=rank+1;i<n;i++){
                if(A[i][j]==0) continue;
                for(int k=j;k<m;k++) A[i][k]^=A[rank][k];
            }
            rank++;
        }
        return rank;
    }
}


Measured memory_bytes: 49516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define null NULL
#define test cout<<"#"
#define maX 1000000000
 
vector<ll> ans(100001, 10000000000000);
void solve(vector<ll> &v, ll n)
{
	ans[0] = 0;
	for(ll x = 1; x <=n-1; x++)
	{
		ans[x] = LONG_LONG_MAX;
		if(x-1>=0)
			ans[x] = min(ans[x], abs(v[x] - v[x-1]) + ans[x-1]);
		if(x-2>=0)
			ans[x] = min(ans[x], abs(v[x] - v[x-2]) + ans[x-2]);		
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
	cin>>n;
    vector<ll> v(n);
    for(ll x = 0; x < n; x++)
		cin>>v[x];
	solve(v, n);
	/*for(ll x = 0; x < n; x++)
		cout<<ans[x]<<" ";*/
	cout<<"\n";
	cout<<ans[n-1];
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define gsort(x,n) sort(x,x+n,greater<int>())
#define rv(s) reverse((s).begin(),(s).end())
//#define abs(a) llabs(a)
//#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define INF 1000000000;

int x[1000010],mem[1000010];
int dp(int i){
    if(i == 1) return 0;
    if(i < 1 ) return INF;
    if(mem[i]!=-1) return mem[i];

    int a1 = dp(i-1) + abs(x[i-1]-x[i]);
    int a2 = dp(i-2) + abs(x[i-2]-x[i]);
    return mem[i] = min(a1,a2);
}

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

  int n;
  cin >> n;

  memset(mem,-1,sizeof(mem));
 
  reps(i,n) cin>>x[i];

  cout<<dp(n)<<'\n';
}

Measured memory_bytes: 9472
#include<queue>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include <cstring>
#include <string.h>
#include <cmath>
#include <math.h>
#include <time.h>
#define ll long long
#define N 100003
#define M 103
#define db double
#define P putchar
#define G getchar
#define inf 998244353
using namespace std;
char ch;
void read(int &n)
{
	n=0;
	ch=G();
	while((ch<'0' || ch>'9') && ch!='-')ch=G();
	ll w=1;
	if(ch=='-')w=-1,ch=G();
	while('0'<=ch && ch<='9')n=(n<<3)+(n<<1)+ch-'0',ch=G();
	n*=w;
}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
ll abs(ll x){return x<0?-x:x;}
ll sqr(ll x){return x*x;}
void write(ll x){if(x>9) write(x/10);P(x%10+'0');}

int nxt[N*2],to[N*2],v[N*2],lst[N],tot;
int n,x,y,z,m,pos,si[N];
ll ans,mi;

void ins(int x,int y,int z)
{
	nxt[++tot]=lst[x];
	to[tot]=y;
	v[tot]=z;
	lst[x]=tot;
}

void dfs(int x,int fa)
{
	int mx=0;
	si[x]=1;
	for(int i=lst[x];i;i=nxt[i])
		if(to[i]!=fa)dfs(to[i],x),si[x]+=si[to[i]],mx=max(mx,si[to[i]]);
	mx=max(mx,n-si[x]);
	
	if(mx<m)m=mx,pos=x;
}

void dfs1(int x,int fa,ll len)
{
	si[x]=1;
	ans+=len;
	for(int i=lst[x];i;i=nxt[i])
		if(to[i]!=fa)dfs1(to[i],x,len+v[i]),si[x]+=si[to[i]];
}

int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	read(n);
	for(int i=1;i<n;i++)
		read(x),read(y),read(z),ins(x,y,z),ins(y,x,z);
		
	m=n;mi=2147483647;
	dfs(1,0);
	dfs1(pos,0,0);
	
	for(int i=lst[pos];i;i=nxt[i])
		if(si[to[i]]==(n+1)/2)
		{
			mi=v[i];
			break;
		}
		else mi=min(mi,v[i]);
	
	write(ans*2-mi);
	
	return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = \
    std::priority_queue<T, std::vector<T>, std::greater<T> >;

signed main() {
  string s, t;
  cin >> s >> t;
  ll N = s.size();
  if (s == t.substr(0, N)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
using namespace std;
int main()
{
    signed char t[20002];
    int out[20002],in[20002];
    int i,j,k,n,max,min,x1=-1,c=0,sum=0;
    cin>>t;
    //for(i=1;t[i-1]!='\0';i++)
       // in[i] = t[i];
    in[0]=0;
    for(i=0;i<20002;i++)
        out[i] = 0;
    for(i=0;t[i]!='\0';i++)
    {
        if(t[i]=='\\')
            t[i] = -1;
        else if(t[i]=='_')
            t[i] = 0;
        else
            t[i] = 1;
        in[i+1] = in[i] + t[i];
    }
    n = i+1;//length of int array
    max = min = 0;
    for(i=0;i<n;i++)
    {
        if(in[i]<min)
            min = in[i];
        if(in[i]>max)
            max = in[i];
    }
    for(i=max;i>=min;i--)
    {
        x1 = -1;
        for(j=0;j<n;j++)
        {
            if(in[j]==i)
            {
                if(x1==-1)
                    x1 = j;
                else if(in[x1]>in[x1+1])
                {
                    out[j] = 0;
                    for(k=x1;k<=j;k++)
                    {
                        out[j] +=  i-in[k];
                        in[k] = i;
                    }
                    c++;
                    sum += out[j];
                }
                x1 = j;
             }
        }
    }
    cout<<sum<<endl;
    cout<<c;
    for(i=0;i<20002;i++)
    {
        if(out[i]!=0)
            cout<<' '<<out[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int n,i;
	cin>>n;
	ll p=1;
	loop(i,1,n+1){
		p=(p*i)%MOD;
	}
	cout<<p<<endl;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

N, M = LI()
A = LI()

aa = sum(A)

if aa <= N:
    print(N - aa)
else:
    print(-1)


Measured memory_bytes: 72120
#include<math.h>
#include<iostream>
using namespace std;
int main() {
	long n;
	cin >> n;
	long num = 1;
	for (long i = 1; i <= n; i++) {
		num = (num*i) % (long(pow(10.0,9.0)) + 7);
	}
	cout << num << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int a,b,c,n;cin>>a>>b>>c>>n;
  int i,j,k;
  int cnt=0;
  rep(i,n+1){
    rep(j,n+1){
      int tmp=n-i*a-j*b;
      if(tmp<0) continue;
      if(tmp%c==0) {cnt++;
        //cout<<i<<" "<<j<<endl;
      }
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
int main()
{
  int N;
  std::cin >> N;
  std::vector<int> H(N);
  int maxh=0,maxn=0;
  for (int i=0;i<N;++i)
  {
    std::cin >> H.at(i);
    if(maxh<=H.at(i))
    {
      maxh=H.at(i);
      maxn++;
    }
  }
  std::cout << maxn <<std::endl;
  return 0;
}

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

int main(){
  
  while(1){
    int n,p;
    int May_wan[50];
    int i,ans;

  cin >> n >> p;
  int p_max = p;
  if(n == 0&&p == 0)break;
  for(int i = 0; i < 50; i++)May_wan[i] = 0;
   i =0,ans = 0;
  while(1){
    if(p_max == May_wan[i]){
      ans = i;
      break;
    }    
    if(p > 0){
      May_wan[i]++;
      p--;
    }

    else if(p == 0){
      p+=May_wan[i];
      May_wan[i] = 0;
    }
    

    if(i == n-1)i = 0;
    else i++;
  }
  cout << i << endl;
  }
  return 0;
}

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

int main() {
  int64_t H;
  cin >> H;
  int64_t count = 0;
  int64_t i = 1;
  while(H > 0) {
    count += i;
    i *= 2;
    H /= 2;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=4100,mod=998244353;
int n,r,b,f[N][N]; char s[N];

void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	f[0][0]=1;
	rep (i,1,2*n){
		if (s[i]=='0') r+=2; else
		if (s[i]=='1') r++,b++; else
		if (s[i]=='2') b+=2;
		rep (j,0,i){
			int k=i-j;
			if (r>=j) upd(f[i][j],f[i-1][j-1]);
			if (b>=k) upd(f[i][j],f[i-1][j]);
		}
	}
	printf("%d\n",f[2*n][r]);
	return 0;
}

Measured memory_bytes: 64256
list_S = list(input())
S = [int(s) for s in list_S]
s1 = S[::2]
s2 = S[1::2]
sums1 = sum(s1)
sums2 = sum(s2)
if sums1>sums2: print(len(s1)-sums1+sums2)
else: print(len(s2)-sums2+sums1)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back

typedef long long ll;

void solve() {
	ll n;cin >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	string str;cin >> str;

	vector<ll> mp;
	REV(i, n){
		REP(j, mp.size())v[i] = min(v[i], v[i] ^ mp[j]);
		if(v[i] == 0)continue;
		if(str[i] == '1'){
			cout << 1 << endl;
			return;
		}
		mp.PB(v[i]);
	}
	cout << 0 << endl;
}

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

	ll t;cin >> t;
	REP(i, t)solve();

	return 0;
}


Measured memory_bytes: 3512
from collections import deque


def bfs():
    INF = float('inf')
    check = [[INF] * W for _ in range(H)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([])
    que.append((sy, sx))
    check[sy][sx] = 1
    while que:
        y, x = que.popleft()
        if y == gy and x == gx:
            break
        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]
            if 0 <= ny < H and 0 <= nx < W and maze[ny][nx] != '#' and check[ny][nx] == INF:
                que.append((ny, nx))
                check[ny][nx] = check[y][x] + 1
    return check[gy][gx]


H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]
black = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            black += 1

sy = 0
sx = 0
gy = H - 1
gx = W - 1
ret = bfs()
if ret == float('inf'):
    print(-1)
else:
    ans = H * W - black - ret
    print(ans)

Measured memory_bytes: 3316
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod =10**9+7
    N,M = map(int,input().split())
    A =[]
    for _ in range(M):
        a = int(input())
        A.append(a)

    dp= [0]*(N+1)
    ds= [0]*(N+1)
    for j in A:
        ds[j] =1

    dp[0] =1
    if ds[1] ==0:
        dp[1] =1
    for i in range(2,N+1):
        if ds[i] ==1:
            continue
        dp[i] = dp[i-1]+dp[i-2]
        dp[i] %=mod
    print(dp[N])





if __name__ == "__main__":
    main()


Measured memory_bytes: 77928
#include<iostream>
using namespace std;
int main()
{

    long long int n,sum=0,num=0,a[10005],m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum+=a[i];}
    if(sum<=n){
    cout<< n-sum;}
    else{
        cout<<"-1";
    }
}


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

const int C = 121;
const int N = C * C * 3, M = N * 32;
char c[C][C];

const int inf = 500;

using Flow = int;
struct Dinic {
	int n, m, fe[N], ne[M], ev[M]; Flow f[M];
	void clear(int n)
	{ this->n = n; fill(fe, fe + n + 1, 0); m = 1; }
	void add_(int x, int y, Flow F)
	{ ne[++m] = fe[x]; fe[x] = m; ev[m] = y; f[m] = F; }
	void add1(int x, int y, Flow F)
	{ add_(x, y, F); add_(y, x, 0); }
	int T, arc[N], lev[N];
	Flow extend(int x, Flow lim) {
		if (x == T) return lim;
		Flow re = 0;
		for (int &e = arc[x]; e; e = ne[e])
			if (f[e] && lev[ev[e]] == lev[x] + 1) { // sgn(f[e]) &&
				Flow t = extend(ev[e], min(lim - re, f[e]));
				if (t) { // sgn(t)
					f[e] -= t, f[e ^ 1] += t;
					if ((re += t) == lim) break; // !sgn((re+=t), lim)
			}}
		if (!re) lev[x] = 0; // !sgn(re)
		return re;
	}
	int q[N], *qb, *qe;
	Flow dinic(int S, int T) {
		Flow re = 0; this->T = T;
		for (;;) {
			fill(lev, lev + n + 1, 0);
			copy(fe, fe + n + 1, arc);
			for (qb = qe = q, lev[*qe++ = S] = 1; qb != qe;) {
				int x = *qb++;
				if (lev[T]) break;
				for (int e = fe[x]; e; e = ne[e])
					if (f[e] && !lev[ev[e]]) // sgn(f[e]) &&
						lev[*qe++ = ev[e]] = lev[x] + 1;
			}
			if (!lev[T]) break;
			re += extend(S, inf);
		}
		return re;
	}
}d;

int main() {
	int n, m; cin >> n >> m;
	auto f = [&](int i, int j) {
		return (i - 1) * m + j;
	};

	for(int i = 1; i <= n; i ++)
		scanf("%s", c[i] + 1);

	d.clear(n * m * 2 + n + m);
	int S, T;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++) if(c[i][j] != '.') {
			if(c[i][j] == 'o')
				d.add1(f(i, j), f(i, j) + n * m, 1);
			else if(c[i][j] == 'S') {
				S = f(i, j);
				d.add1(f(i, j), f(i, j) + n * m, inf);
			} else {
				T = f(i, j) + n * m;
				d.add1(f(i, j), f(i, j) + n * m, inf);
			}
			d.add1(n * m * 2 + i, f(i, j), inf);
			d.add1(n * m * 2 + n + j, f(i, j), inf);

			d.add1(f(i, j) + n * m, n * m * 2 + i, inf);
			d.add1(f(i, j) + n * m, n * m * 2 + n + j, inf);
		}
	int x = d.dinic(S, T);
	if(x < inf) cout << x << '\n';
	else cout << -1 << '\n';
}

Measured memory_bytes: 5120
/**
*    created: 02.08.2020 20:10:30
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s, t; cin >> s >> t;
    int n = s.size(), l = t.size();
    if (n < l) return 0;
    else {
        rep(i,n-l+1) {
            string tmp = s.substr(i,l);
            if (tmp == t)  printf("%d\n", i);
        }
    }
    return 0;
}



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

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

	priority_queue<int>qu;
	string p = "";
	int x;

	while (p != "end")
	{
		cin >> p;
		if (p == "insert")
		{
			cin >> x;
			qu.push(x);
		}
		if (p == "extract")
		{
			cout << qu.top() << endl;
			qu.pop();
		}
	}

	return 0;
}


Measured memory_bytes: 7088
#include <bits/stdc++.h>
using namespace std;
int ans[30000];
int main()
{
	int n;
	scanf("%d",&n);
	int t=(int)sqrt(n)+1;
	for(int i=1;i<=t;i++)
	{
		for(int j=1;j<=t;j++)
		{
			for(int z=1;z<=t;z++)
			{
				if(i*i+j*j+z*z+i*j+j*z+i*z<=n) ans[i*i+j*j+z*z+i*j+j*z+i*z]++;
			}
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
 } 

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m;
int vec[200005];

struct maintain_interval{
	int bit[(1<<18)+5];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<18);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}mt;

P forbid[200005][2];
bool ok[200005],ok2[200005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<2*n;i++){
		scanf("%d",&vec[i]);
	}
	sort(vec,vec+2*n);
	
	int lb = -1,ub = m-1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		for(int i=0;i<2*n;i++){
			//vec[i]と足してmod mでmidより大な区間
			for(int j=0;j<2;j++){
				//[mid+1+m*j,m*(j+1)-1]
				int L = mid+1+m*j-vec[i];
				int R = m*(j+1)-1-vec[i];
				L = lower_bound(vec,vec+2*n,L)-vec;
				R = upper_bound(vec,vec+2*n,R)-vec; R--;
				if(L <= R) forbid[i][j] = mp(L+i,R+i);
				else forbid[i][j] = mp(-1,-1);
			}
		}
		mt.init();
		for(int i=0;i<2*n;i++){
			for(int j=0;j<2;j++) if(forbid[i][j].fi >= 0){
				mt.add((forbid[i][j].fi+2)/2,1);
				mt.add((forbid[i][j].sc+1)/2+1,-1);
			}
			if(i%2 == 1){
				ok[i] = !mt.sum((i+1)/2);
			}
		}
		mt.init();
		for(int i=2*n-1;i>=0;i--){
			for(int j=0;j<2;j++) if(forbid[i][j].fi >= 0){
				mt.add((forbid[i][j].fi+2)/2,1);
				mt.add((forbid[i][j].sc+1)/2+1,-1);
			}
			if(i%2 == 0){
				ok2[i] = !mt.sum((2*n+i)/2);
			}
		}
		ok2[2*n] = true;
		bool flag = 0;
		for(int i=0;i<2*n;i++){
			if(i%2 == 1){
				if(ok[i] && ok2[i+1]){
					flag = 1;
					break;
				}
			}
		}
		if(flag) ub = mid;
		else lb = mid;
	}
	printf("%d\n",ub);
	return 0;
}


Measured memory_bytes: 5504
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
const int maxn = 2600000;
typedef pair<int, int> P;

int kj[maxn], kji[maxn];

int modpow(int x, int n, int md) {
	if (!n)return 1;
	int res = modpow(x*x%md, n / 2, md);
	if (n & 1)res = res*x%md;
	return res;
}
int comb(int n, int r) {
	if (n < 0 || r<0 || n < r)return 0;
	int ans = kj[n];
	ans = ans*kji[r] % mod;
	ans = ans*kji[n - r] % mod;
	return ans;
}


void kjinit(int n) {
	kj[0] = 1;
	rep(i, n) {
		kj[i + 1] = kj[i] * (i + 1);
		kj[i + 1] %= mod;
	}
	rep(i, n)kji[i] = modpow(kj[i], mod - 2, mod);

}
signed main() {
	int n, m; cin >> n >> m;
	kjinit(maxn);
	int ans = comb(3 * m + n - 1, n - 1);
	for (int i = 2 * m + 1; i <= 3 * m; i++) {
		int t = n*comb(3*m-i+n-2, n - 2)%mod;
		ans = ans + mod - t;
		ans %= mod;
	}
	for (int i = m + 1; i <= 3 * m; i++) {
		if (i > n)break;
		int M = 3 * m - i;
		if (M & 1)continue;
		int t = comb(n, i)*comb(M/2 + n-1, n - 1)%mod;
		ans = ans + mod - t;
		ans %= mod;
	}
	

	cout << ans%mod << endl;
}

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

using namespace std;
typedef long long LL;
int main(){
	int n;
	cin>>n;
	int a[200];
	int cnt = 0;
	for(int i = 0; i < n; i++)cin>>a[i];
	for(int i = 0; i < n; i++) if(a[i] & 1 && (i + 1) & 1) cnt++;
	cout<<cnt;
} 

Measured memory_bytes: 3644
n = int(raw_input())
ais = map(int, raw_input().split())
bis = map(int, raw_input().split())
cis = map(int, raw_input().split())


count = 0
ais.sort()
bis.sort()
cis.sort()

i,j = 0,0
for b in bis:
	while(i < len(ais) and ais[i] < b):
		i += 1
	while(j < len(cis) and cis[j] <= b):
		j += 1
	count += i * (n - j)
print count

Measured memory_bytes: 115172
//Try until you reach your goal
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll y;
    cin>>y;
    str s,s1;
    cin>>s>>s1;
    for(ll i=0;i<s.length();i++){
        cout<<s[i]<<s1[i];
    }
    return 0;
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}";}
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "<<arg1<<endl;}
template<typename Arg1, typename ... Args>void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,','); cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
	
	int a ,b ,c;
	cin>>a>>b>>c;
	cout<<(a+b+c>=22 ? "bust" : "win");
    
    

#ifdef np
    cerr <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
 return 0; 
 }


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

template <typename T>
class segmenttree
{
private:
    using F = function<T(T, T)>;
    int n;

    T dif = 0;
    F f;

    T query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
        {
            return dif;
        }

        if (a <= l && r <= b)
        {
            return st[k];
        }
        else
        {
            T x = query_(a, b, 2 * k + 1, l, (l + r) / 2);
            T y = query_(a, b, 2 * k + 2, (l + r) / 2, r);

            return f(x, y);
        }
    }

public:
    vector<T> st;

    segmenttree(int size, T init, F f) : f(f)
    {
        n = 1;

        while (n < size)
        {
            n *= 2;
        }

        st.assign(2 * n - 1, init);
    }

    void set(int i, T x)
    {
        st[i + n - 1] = x;
    }

    void build()
    {
        for (int i = n - 2; i >= 0; i--)
        {
            st[i] = f(st[i * 2 + 1], st[i * 2 + 2]);
        }
    }

    void update(int i, T x)
    {
        i += n - 1;
        st[i] = x;

        while (i > 0)
        {
            i = (i - 1) / 2;
            st[i] = f(st[2 * i + 1], st[2 * i + 2]);
        }
    }

    T query(int a, int b)
    {
        return query_(a, b, 0, 0, n);
    }
};

//初期化例 segmenttree<bitset<26>> seg(n, 0, [](bitset<26> a, bitset<26> b) { return a | b; });

int main(void)
{
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    ll ma = 0;

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

        ma = max(ma, a[i]);
    }

    segmenttree<ll> s(ma + 1, 0, [](ll a, ll b) { return max(a, b); });

    ll ans = 0;

    s.build();

    for (int i = 0; i < n; i++)
    {
        ll l, r;

        l = max(a[i] - k, 0ll);
        r = min(a[i] + k + 1, ma + 1);

        ll x = s.query(l, r) + 1;

        s.update(a[i], x);
        ans = max(ans, x);
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    
    long long res = max(1LL * a * c, 1LL * b * d);
    res = max(res, 1LL * a * d);
    res = max(res, 1LL * b * c);

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


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

int main()
{
    vector<int> data(3);
    cin >> data.at(0) >> data.at(1) >> data.at(2);
    sort(data.begin(), data.end());
    cout << data.at(0);
    for (int i = 1; i < data.size(); i++) {
        cout << " " << data.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 3076
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

bool iseven(long n){
  return n%2==0;
}

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

  long a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(iseven(a[i])){
        a[i] = a[i]/2;
      }else{
        cout << ans << endl;
        return 0;
      }
    }
    ans++;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    boolean tmp = true;

    while(tmp){
      int m = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      String ans = "";

      if(m == -1 && f == -1 && r == -1){
        tmp = false;
        break;
      }

      if(m == -1 || f == -1){
        ans = "F";
      } else if(m + f >= 80){
        ans = "A";
      } else if(m + f >= 65){
        ans = "B";
      } else if(m + f >= 50){
        ans = "C";
      } else if(m + f >= 30 && r >= 50){
        ans = "C";
      } else if(m + f >= 30 && r < 50){
        ans = "D";
      } else {
        ans = "F";
      }

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



Measured memory_bytes: 26212
s = input()
ans = 0
L = []
flag = False
for i in range(len(s)):
    if not flag:
        if i != len(s)-1 and s[i] == 'B':
            flag = True
        else:
            L.append(s[i])
    else:
        if s[i] == 'C':
            L.append('D')
        else:
            L.append('B')
            L.append(s[i])
        flag = False
new = []
num = []
flag = False
L.append('B')
for i in range(len(L)):
    if L[i] == 'A' and flag == False:
        setnum = 1
        flag = True
        cur = ['A']
    else:
        if flag == False:
            None
        else:
            if L[i] == 'B' or L[i] == 'C':
                flag = False
                new.append(cur)
                num.append(setnum)
            else:
                if L[i] == 'A':
                    cur.append('A')
                    setnum += 1
                else:
                    cur.append('D')
for i in range(len(new)):
    T = new[i]
    add = num[i]
    cur = 0
    for j in range(len(T)):
        if T[len(T)-j-1] == 'D':
            cur += add
        else:
            add -= 1
    ans += cur
print(ans)


Measured memory_bytes: 9704
/* -- Basic Headers -- */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>

/* -- STL Iterators -- */
#include <vector>
#include <string>
#include <stack>
#include <queue>

/* -- External Headers -- */

/* -- Defined Functions -- */
#define For(a,x,y) for (int a = x; a <= y; ++a)
#define Forw(a,x,y) for (int a = x; a < y; ++a)
#define Bak(a,y,x) for (int a = y; a >= x; --a)

/* -- Defined Words -- */

using namespace std;

namespace FastIO {
    void DEBUG(char comment[], int x) {
        cerr << comment << x << endl;
    }

    inline int getint() {
        int s = 0, x = 1;
        char ch = getchar();
        while (!isdigit(ch)) {
            if (ch == '-') x = -1;
            ch = getchar();
        }
        while (isdigit(ch)) {
            s = s * 10 + ch - '0';
            ch = getchar();
        }
        return s * x;
    }
    inline void __basic_putint(int x) {
        if (x < 0) {
            x = -x;
            putchar('-');
        }
        if (x >= 10) __basic_putint(x / 10);
        putchar(x % 10 + '0');
    }

    inline void putint(int x, char external) {
        __basic_putint(x);
        putchar(external);
    }
}

namespace Solution {

}

int main() {
    #define HANDWER_FILE
    #ifndef HANDWER_FILE
    freopen("testdata.in", "r", stdin);
    freopen("testdata.out", "w", stdout);
    #endif
    using namespace Solution;
    using namespace FastIO;
    int n = getint();
    switch(n) {
        case 1: {
            puts("Hello World");
            break;
        }
        case 2: {
            int a = getint();
            int b = getint();
            putint(a + b, '\n');
            break;
        }
    }
    return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;


const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 1e5;
const int MOD = 1e9 + 7;

int n;
char s1[60], s2[60];
LL d[60];

int main()
{
		cin>>n;
		scanf("%s", s1 + 1);
		scanf("%s", s2 + 1);
		d[0] = 1;
		if(s1[1] == s1[2]) d[1] = 6;
		else d[1] = 3;
		for(int i = 2; i <= n; i++) {
			if(s1[i] == s1[i + 1]) {
				if(s1[i - 1] == s2[i - 1]) {
					d[i] = d[i - 1] * 2 % MOD;
				}
				else {
					d[i] = d[i - 1] * 3 % MOD;
				}
				d[i + 1] = d[i];
				i++;
			}
			else if(s1[i] == s2[i]) {
				if(s1[i - 1] == s2[i -1]) {
					d[i] = d[i - 1] * 2 % MOD;
				}
				else if(s1[i - 1] != s2[i - 1]) {
					d[i] = d[i - 1] % MOD;
				}
			}
			else d[i] = d[i - 1];
		}
		printf("%lld\n", d[n]);
	
	return 0;
}


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

int main()
{
  ll h, n; cin >> h >> n;
  ll sum = 0;
  rep(i, n) {
    int a; cin >> a;
    sum += a;
  }
  if (h > sum) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

int main(){
  long A,B;cin>>A>>B;
  long count;
  int X=min(A,B);
  for(int i=1;i<=X;i++){
    if(A%i==0 && B%i==0) count=i;
  }
  cout<<A*B/count<<endl;
}

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

int main() {
    long long n, a; cin >> n;
    vector<long long> v;

    vector<long long> dp(n);
    fill(dp.begin(), dp.end(), 0);

    for(long long i = 0; i < n; ++i) {
        cin >> a;
        v.push_back(a);
    }

    dp[1] = abs(v[0] - v[1]);
    dp[2] = abs(v[0] - v[2]);

    for(long long i = 3; i < n; ++i) {
        dp[i] = min(dp[i-1] + abs(v[i-1] - v[i]), dp[i-2] + abs(v[i-2] - v[i]));
    }

    cout << dp[n - 1];
}


Measured memory_bytes: 2168
#include<stdio.h>
#include<ctype.h>
int main()
{
	int n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	scanf("%d", &n);
	while (n--) {
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		puts((y1-y2)*(x3-x4)==(y3-y4)*(x1-x2) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int k,a,b;
	cin >> k >> a >> b;
	for(int i = a;i <= b;i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
}


Measured memory_bytes: 3624
n, m = map(int, raw_input().split())
arr = []
for i in range(m):
    pi, yi = map(int, raw_input().split())
    arr.append([pi, yi, i+1])

def six_digit(n):
    if len(str(n)) < 6:
        n = "0"*(6-len(str(n)))+str(n)
    else:
        n=str(n)
    return n
arr.sort()
cp = 1
num = 0
for lst in arr:
    if lst[0]!=cp:
        cp=lst[0]
        num = 1
    else:
        num += 1
    lst.reverse()
    id = six_digit(cp)+six_digit(num)
    lst.append(id)

arr.sort()
for lst in arr:
    print lst[3]

Measured memory_bytes: 33912