akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    using namespace std;
    const int N=3e5+5;
    int n,a[N],b[N];
    void work(){
    	puts("No");
    	exit(0);
    }
    void check(int l,int r){
    	for(int i=l,ml=0,mr=0;i<=r;i++)
    		if(a[i]<i){
    			if(ml>a[i]||a[i]>r||a[i]<l)	work();
    			ml=max(ml,a[i]);
    		}
    		else	if(a[i]>i){
    			if(mr>a[i]||a[i]>r||a[i]<l)	work();
    			mr=max(mr,a[i]);
    		}
    }
    int main(){
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)	scanf("%d",&a[i]),b[i]=a[i]==i;
    	for(int i=2;i<n;i++)	if(!b[i-1]&&!b[i]&&!b[i+1])	work();
    	for(int l=1;l<=n;l++)
    		if(!b[l]){
    			int r=l,now=1;
    			while(r<=n&&b[r]^now)	++r,now^=1;
    			check(l,--r),l=r;
    		}
    	puts("Yes");
    	return 0;
    }

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		String[] nico = sc.nextLine().split(" ");
		int n = Integer.parseInt(nico[0]);
		int q = Integer.parseInt(nico[1]);

		int[] list = new int[n + 1];
		for (int i = 0; i < list.length; i++) {
			list[i] = 0;
		}
		
		int max = 0;
		int no = 1;
		for (int i = 0; i < q; i++) {
			String[] set = sc.nextLine().split(" ");
			int[] data = new int[set.length];
			
			for (int j = 0; j < set.length; j++) {
				data[j] = Integer.parseInt(set[j]);
			}

			list[data[0]] = list[data[0]] + data[1];
			
			if ((no == data[0]) && (data[1] < 0)) {
				int tmp = list[data[0]];
				int newno = data[0];
				
				for (int j = 1; j < list.length; j++) {
					if (tmp <= list[j]) {
						if (tmp == list[j]) {
							if (newno > j) newno = j;
						} else {
							tmp = list[j];
							newno = j;
						}
					}
				}
				
				max = tmp;
				no = newno;
			}
			
			if (max <= list[data[0]]) {
				if (max == list[data[0]]) {
					if (no > data[0]) no = data[0];
				} else {
					max = list[data[0]];
					no = data[0];
				}
			}
			System.out.println(no + " " + max);
		}
	}
}

Measured memory_bytes: 170388
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    int wa = a + b + c;

    if (wa <= 21)cout << "win" << endl;
    else cout << "bust" << endl;

    return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
N, W = map(int, input().split())
v = [None] * N
w = [None] * N

for i in range(N):
  v[i], w[i] = map(int, input().split())
  
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
  for j in range(W+1):
    if j >= w[i]:
      dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j], dp[i+1][j-w[i]] + v[i])
    else:
      dp[i+1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 42300
<?php
fscanf(STDIN,"%d %d",$d,$n);
if($n==100) $n=101;
switch($d){
    case 0:
        echo $n;
        break;
    case 1:
        echo $n*100;
        break;
    case 2:
        echo $n*10000;
        break;
}
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll maxv = -2000000050, minv = 2000000050;
    for (int i = 0; i < n; i++) {
        ll r; cin >> r;
        maxv = max(maxv, r - minv);
        minv = min(minv, r);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main() {
    fastio;
    int n,l;
    cin>>n>>l;
    int a[n],s=0,b=0,m=99999,c;
    for(int i=0;i<n;i++){ a[i]=l+i; s+=a[i];}
    for(int i=0;i<n;i++)
    {
        if(abs(a[i])<=m)
        {
            m=abs(a[i]);
            c=i;
        }
    }
    cout<<s-a[c]<<endl;
	return 0;
}

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

using namespace std;

constexpr double eps = 1e-9;
using matrix = vector<vector<int>>;

int myrank(matrix A) {
  const int n = A.size(), m = A[0].size();
  int r = 0;
  for (int i = 0; r < n && i < m; ++i) {
    int pivot = r;
    for (int j = r + 1; j < n; ++j)
      if (abs(A[j][i]) > abs(A[pivot][i])) pivot = j;
    swap(A[pivot], A[r]);
    if (abs(A[r][i]) < eps) continue;
    for (int k = m - 1; k >= i; --k) A[r][k] /= A[r][i];
    for (int j = r + 1; j < n; ++j)
      for (int k = i; k < m; ++k) A[j][k] -= A[r][k] * A[j][i];
    ++r;
  }
  return r;
}

using ll = long long;
constexpr ll mod = 998244353;

template <typename T>
T mypow(T a, T b) {
  if (b == 0) return 1;
  T tmp = mypow(a, b / 2);
  if (b % 2)
    return (((tmp * tmp) % mod) * a) % mod;
  else
    return (tmp * tmp) % mod;
}

int main() {
  ll n, m;
  cin >> n >> m;
  matrix a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  int rank = 0;
  for (int j = 0; j < m; j++) {
    int pivot = -1;
    for (int i = rank; i < n; i++) {
      if (a[i][j]) {
        pivot = i;
        break;
      }
    }
    if (pivot >= 0) {
      if (pivot != rank)
        for (int k = 0; k < m; k++) swap(a[pivot][k], a[rank][k]);
      for (int i = rank + 1; i < n; i++) {
        if (a[i][j])
          for (int k = 0; k < m; k++) a[i][k] ^= a[rank][k];
      }
      rank++;
    }
  }

  ll ret = mypow(2LL, n + m - 1) + mod - mypow(2LL, n + m - rank - 1);
  cout << ret % mod << endl;
}


Measured memory_bytes: 640
from collections import Counter
s = input()
ans=0

for i in range(-1,len(s)*-1-1,-1):
    t = s[len(s)*-1:i]
    if len(t)%2==0:
        if t[:len(t)//2]==t[len(t)//2:]:
            print(len(t))
            break 

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
 
int main() {
  int n ,k;
  string s;
  cin >> n >> k >> s;
  if (s[k-1] == 'A') {
    s[k-1] = 'a';
  } else if(s[k-1] == 'B') {
    s[k-1] = 'b';
  } else {
    s[k-1] = 'c';
  }
  cout << s;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = s[0];
            long b = s[1];
            long c = s[2];
            WriteLine(
                c-a-b >= 0 && 4*a*b < (c-a-b)*(c-a-b) ? "Yes" : "No"
                );
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		ll h[T];
		for(ll i=0;i<T;i++)
			cin>>h[i];
		ll dp[T+1];
		dp[0]=0;
		dp[1]=0;
		for(ll i=2;i<=T;i++)
		{
			dp[i]=min(dp[i-2]+abs(h[i-1]-h[i-3]),dp[i-1]+abs(h[i-1]-h[i-2]));
		}
		cout<<dp[T];
		return 0;
	}


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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define SUM(v) accumulate(ALL(v),0)

void solve(int n, int k, int s) {
    vector<int> v(n);
    rep(i,n) v[i] = i+1;

    int ans = 0;
    rep(mask, 1<<n) {
        vector<int> a;
        rep(i,n) if(mask&(1<<i)) a.push_back(v[i]);
        if(SZ(a) != k) continue;
        if(SUM(a) == s) ++ans;
    }

    cout << ans << "\n";
}

int main() {
    int n,k,s;
    while(cin>>n>>k>>s, n) solve(n,k,s);
    return 0;
}

Measured memory_bytes: 3000
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int A,B,ans;
    cin>>A>>B;
    ans=A*B;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    ld A[n];
    ld s=0;
    for(int i=0;i<n;i++)cin>>A[i],s+=log2l(A[i]*1.0);
    s=s/log2l(10);
    //coud(s,10);
    if(s>18)
    {
        cout<<-1;
        return 0;
    }
	int x=1;

    for(int i=0;i<n;i++)
    {
        x=x*A[i];
    }
    cout<<x;

return 0;
}

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

int main() {
	int x = 0, y = 0, z = 0;
	char a[10];
	while (1) {
		cin >> x >> a >> y;
		if (a[0] == '+') { 
			z = x + y;
		}else if (a[0] == '-') {
			z = x - y;
		}else if (a[0] == '*') {
			z = x * y;
		}else if (a[0] == '/') {
			z = x / y;
		}else if (a[0] == '?') {
			break;
		}
		cout << z << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
H, W = list(map(int, input().split()))
X = []
h = 0
for i in range(H):
	a = input()
	if a == "." * W:
		pass
	else:
		X.append(list(a))
		h += 1

Y = []
w = 0
for i in range(W):
	x = ""
	for j in range(h):
		x += X[j][i]
	if x == "." * h:
		pass
	else:
		Y.append(list(x))
		w += 1

for i in range(h):
	n = ""
	for j in range(w):
		n += Y[j][i]

	print(n)


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>

int f(int map[], int cur)
{
    int x[6] = { 0 };
    x[cur] = 1;
    x[5 - cur] = 1;
    for (int i = 0; i < 4; i++)
        x[map[i]] = 1;
        
    for (int i = 0; i < 6; i++)
        if (x[i] == 0)
            return i;
}

int main(int argc, char *argv[])
{
    int d[6];
    char op[101];

    for (int i = 0; i < 6; i++)
        scanf("%d", &d[i]);

    int cur = 0;
    int next[4] = { 3, 1, 4, 2 };
    char dirs[] = "ENSW";

    scanf("%s", op);
    for (char *p = op; *p; p++) {
        int o = strchr(dirs, *p) - dirs;

        next[3 - o] = cur;
        cur = next[o];
        next[o] = f(next, cur);
    }
    printf("%d\n", d[cur]);   

    return 0;
}



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

int main(void){
  int n;
  int ans;
  
  cin >> n;
  ans = -1;
  for (int i=1; i<=n; i++){
    if (n==(int)(i*1.08)) ans = i;
  }
  if (ans==-1) cout << ":(" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int,readline().split())
INF = 10 ** 9
A = INF * (np.frombuffer(read(),'S1').reshape(H,-1)[:,:W] == b'.')

for _ in range(4):
    # 回転
    A = A.T[:,::-1]
    N = A.shape[0]
    for i in range(1,N):
        A[i] = np.minimum(A[i-1] + 1, A[i])

answer = A.max()
print(answer)

Measured memory_bytes: 27396
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=1e5+5;
int a[N],b[N],c[N],n,m,q,sz,f[N],c0;

void OK(){
	puts("Yes");
	exit(0);
}

void GG(){
	puts("No");
	exit(0);
}

int getf(int x){
	if(f[x]==x) return x;
	return f[x]=getf(f[x]);
}

bool merge(int x,int y){
	x=getf(x);y=getf(y);
	if(x==y) return 0;
	f[x]=y;sz--;
	return 1;
}

signed main(){
	read(n,m,q);sz=n;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=q;i++){
		read(a[i],b[i],c[i]);
		if(!c[i]) c0++,merge(a[i],b[i]);
	}
	if(m<=n-1){
		if(m<n-1) GG();
		if(q==c0) OK();
		GG();
	}
	int l=n,r=n-sz+sz*(sz-1)/2;
	for(int i=1;i<=q;i++) if(c[i]&&getf(a[i])==getf(b[i])) GG();
	if(m>=l&&m<=r) OK();
	else GG();
}

Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int f(int n) {
    set<int> div;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            div.insert(i);
            div.insert(n / i);
        }
    }
    return div.size();
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        if (f(i) == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
diffs = [0]
for i in range(len(x) - 1):
    diffs.append(abs(x[i] - x[i + 1]))
diffs.sort()
for i in range(n - 1):
    if len(diffs) < 2:
        break
    diffs.pop()
print(sum(diffs))


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	cout << max(a*b, max(a + b, a - b)) << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(a, b, k);
  vector<int> ok;
  rep(i, k) {
    int target = a + i;
    ok.push_back(target);
    if(target >= b) {
      break;
    }
  }
  rep(i, k) {
    int target = b - i;
    ok.push_back(target);
    if(target <= a) {
      break;
    }
  }

  set<int> result(ok.begin(), ok.end());
  forin(v, result) {
    out(v);
  }
}


Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  INF = Float::INFINITY
  def chmin(a, b) a < b ? a : b end

# 1000 2000 5000 4 3
# 1000 2000 5000 3 4
a,b,c,x,y = gets.split.map(&:to_i)

if x < y
  x,y = y,x
  a,b = b,a
end


min_mix = chmin(a+b,2*c)
min_a = chmin(a, 2*c)
s = min_mix * y + (x-y)*min_a
puts s

Measured memory_bytes: 3836
#include <iostream>

using namespace std;

int binary_search(int n, int* S, int v) {
  int s = 0, t = n;
  while (s < t) {
    int j = (s + t) / 2;
    if (v == S[j]) {
      return 1;
    } else if (v < S[j]) {
      t = j;
    } else {
      s = j+1;
    }
  }
  return 0;
}



int main() {
  int n,q,v,cnt;
  cin >> n;
  int S[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }

  cin >> q;
  cnt = 0;
  for (int i = 0; i < q; i++) {
    cin >> v;
    cnt += binary_search(n, S, v);
  }

  cout << cnt << endl;
  return 0;
}

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define mod 1000000007

const int N = 100005;

vector<int> gr[N];
int dp[N][2];

void dfs(int cur, int par) {
	dp[cur][0] = dp[cur][1] = 1;
	for (auto x : gr[cur]) {
		if (x != par) {
			dfs(x, cur);
			dp[cur][0] *= (dp[x][0] + dp[x][1]);
			dp[cur][1] *= dp[x][0];
			dp[cur][0] %= mod;
			dp[cur][1] %= mod;
		}
	}
}

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		gr[x].pb(y);
		gr[y].pb(x);
	}
	dfs(1, 0);
	cout << (dp[1][0] + dp[1][1]) % mod;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}


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

const long long int MOD = 1e9+7;
#define pb push_back
typedef long long ll;
const long long int N = 1e5;



int main(){
    int n;
    cin>>n;
    cout.precision(17);
    vector<vector<long double>> dp(n+5,vector<long double>(n+5,0));
    long double p[n+5];
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    dp[1][0]=1-p[1];
    dp[1][1]=p[1];
    for(int i=2;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j>0)
                dp[i][j]=dp[i-1][j]*(1-p[i]) + p[i]*dp[i-1][j-1];
            else
                dp[i][0]=(1-p[i])*dp[i-1][0];
        }
    }
    long double ans=0.0;
    for(int i=n/2 + 1;i<=n;i++){
        ans+=dp[n][i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 144484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int cnt=0, cnt2=1e9;
  int a=s.size(), b=t.size();
  for(int i=0; i<a; i++) {
    cnt=b;
    for(int j=0; j<b; j++) {
      if(i+t.size()<=a) {
        if(s.at(i+j)==t.at(j)) {
          cnt--;
        }
        if(cnt2>cnt) {
          cnt2=cnt;
        }
      }
    }
  }
  cout << cnt2 << endl;
  return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

const int MOD = 1e9 + 7;

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}

int mul(int x, int y) {
    return (1LL * x * y) % MOD;
}

int bin_pow(int a, int p) {
    if (!p)
        return 1;
    if (p % 2)
        return (1LL * bin_pow(a, p - 1) * a) % MOD;
    int t = bin_pow(a, p / 2);
    return (1LL * t * t) % MOD;
}

int inv(int x) {
    return bin_pow(x, MOD - 2);
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <string> a(n + 1);
    forn (i, 1, n + 1) {
        cin >> a[i];
        a[i] = '.' + a[i];
    }
    vector <vector <int>> dp(n + 1, vector <int> (m + 1, 0));
    dp[1][0] = 1;
    forn (i, 1, n + 1) {
        forn (j, 1, m + 1) {
            if (a[i - 1][j] == '.')
                dp[i][j] = add(dp[i][j], dp[i - 1][j]);
            if (a[i][j - 1] == '.')
                dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    }
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N, 0);
    rep(i,N) cin >> A[i];
    ll sum = 0;
    ll highest = A[0];
    rep(i,N){
        if(A[i] < highest){
            sum += highest - A[i];
        }
        highest = max(highest,A[i]);
    }
    cout << sum << endl;
}


Measured memory_bytes: 4836
n = int(raw_input())
a = map(int, raw_input().split())
print " ".join(map(str, a))
for j in range(1,len(a)):
    key = a[j]
    i = j -1
    while i >= 0 and a[i] > key:
        a[i + 1] = a[i]
        i = i -1
    a[i+1]= key
    print " ".join(map(str, a))

Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll LIM = 1000000000000000LL;

int s(ll x){
    int ret = 0;
    while(x){
        ret += x%10;
        x/=10;
    }
    return ret;
}

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

    vector<ll> v;
    rep(i,15){
        string nine(i,'9');
        for(int j=1; j<=999; ++j){
            string t = to_string(j) + nine;
            ll val = stoll(t);
            if(val <= LIM) v.pb(val);
        }
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    sort(all(v), [](const ll &lh, const ll &rh){
        return (lh*s(rh) == rh*s(lh)) ? lh<rh : lh*s(rh) < rh*s(lh);
    });

    vector<ll> ans;
    ll pre = 0;
    for(ll i:v){
        if(pre<i){
            pre = i;
            ans.pb(i);
        }
    }
    rep(i,k) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n<=k)cout << n*x << endl;
  else{
    cout << (k*x)+((n-k)*y) << endl;
  }
    return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	string kata;
	int i,j;
	cin>>kata;
	int pjg = kata.length();
	int cntK = 0, cntI = 0, cntH = 0, cntB = 0, cntR = 0, cntA=0, lain = 0;;
	int idxK = 0, idxI = 0, idxH = 0, idxB = 0, idxR = 0;
	for(i=0;i<pjg;i++){
		char kar = kata[i];
		if(kar=='K'){cntK++; idxK = i;}
		else if(kar=='I'){cntI++; idxI = i;}
		else if(kar=='H'){cntH++; idxH = i;}
		else if(kar=='B'){cntB++; idxB = i;}
		else if(kar=='R'){cntR++; idxR = i;}
		else if(kar=='A'){cntA++;}
		else{lain++;}
	}
	if(lain>0){printf("NO\n"); return 0;}
	if(cntK!=1 || cntI!=1 || cntB!=1 || cntH!=1 || cntR!=1){printf("NO\n"); return 0;}
	
	if(cntA>4){printf("NO\n"); return 0;}
	//cek sebelah kiri K

	cntA = 0;
	for(i=idxK-1;i>=0;i--){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>1){printf("NO\n"); return 0;}
	//cek sebelah kanan R
	cntA = 0;
	for(i=idxR+1;i<pjg;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>1){printf("NO\n"); return 0;}
	//cek banyak Aantara tiap indeks
	//K I
	if(idxK > idxI){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxK;i<=idxI;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>0){printf("NO\n"); return 0;}
	//K H
	if(idxK > idxH){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxK;i<=idxH;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>0){printf("NO\n"); return 0;}
	//K B
	if(idxK > idxB){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxK;i<=idxB;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>1){printf("NO\n"); return 0;}
	//K R
	if(idxK > idxR){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxK;i<=idxR;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>2){printf("NO\n"); return 0;}

	//I H
	if(idxI > idxH){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxI;i<=idxH;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>0){printf("NO\n"); return 0;}
	//I B
	if(idxI > idxB){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxI;i<=idxB;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>1){printf("NO\n"); return 0;}

	//I R
	if(idxI > idxR){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxI;i<=idxR;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>2){printf("NO\n"); return 0;}
	//H B
	if(idxH > idxB){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxH;i<=idxB;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>1){printf("NO\n"); return 0;}
	//H R
	if(idxH > idxR){printf("NO\n"); return 0;}
	cntA = 0;
	for(i=idxH;i<=idxR;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>2){printf("NO\n"); return 0;}
	//B R
	cntA = 0;
	if(idxB > idxR){printf("NO\n"); return 0;}
	for(i=idxB;i<=idxR;i++){
		if(kata[i]=='A'){cntA++;}
	}
	if(cntA>1){printf("NO\n"); return 0;}
	printf("YES\n");
	return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  bool flag = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') {
      flag = 1;
    }
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  if (flag) {
    x = -x;
  }
}
const int N = 300005;
int w, h, n, x[N], y[N], ans;
int px[N], nx, py[N], ny;
struct SegmentTree {
  int l[N << 2], r[N << 2];
  int val[N << 2], lazy[N << 2];
  inline void pushup(int p) {
    val[p] = max(val[p << 1], val[p << 1 | 1]);
  }
  void build(int p, int L, int R) {
    l[p] = L, r[p] = R;
    val[p] = -py[L - 1] + w;
    lazy[p] = 0;
    if (L == R) {
      return;
    }
    int mid = l[p] + r[p] >> 1;
    build(p << 1, L, mid);
    build(p << 1 | 1, mid + 1, R);
  }
  inline void tag(int p, int v) {
    val[p] += v;
    lazy[p] += v;
  }
  inline void pushdown(int p) {
    if (lazy[p]) {
      tag(p << 1, lazy[p]);
      tag(p << 1 | 1, lazy[p]);
      lazy[p] = 0;
    }
  }
  void modify(int p, int L, int R, int v) {
    if (l[p] >= L && r[p] <= R) {
      tag(p, v);
      return;
    }
    pushdown(p);
    int mid = l[p] + r[p] >> 1;
    if (mid >= L) {
      modify(p << 1, L, R, v);
    }
    if (mid < R) {
      modify(p << 1 | 1, L, R, v);
    }
    pushup(p);
  }
} smt;
inline void process() {
  static int lef[N], rig[N];
  smt.build(1, 1, ny);
  for (int i = 1; i <= ny; ++i) {
    lef[i] = 0;
    rig[i] = w;
  }
  for (int i = 1; i <= n; ++i) {
    int X = px[x[i]], Y = y[i];
    if (X <= w / 2) {
      lef[Y] = max(lef[Y], X);
    } else {
      rig[Y] = min(rig[Y], X);
    }
  }
  static int sl[N], sr[N];
  int tl = 0, tr = 0;
  for (int i = 1; i <= ny; ++i) {
    ans = max(ans, 2 * (py[i] + smt.val[1]));
    smt.modify(1, i, i, -lef[i] + rig[i] - w);
    while (tl && lef[sl[tl]] < lef[i]) {
      smt.modify(1, sl[tl - 1] + 1, sl[tl], lef[sl[tl]] - lef[i]);
      --tl;
    }
    sl[++tl] = i;
    while (tr && rig[sr[tr]] > rig[i]) {
      smt.modify(1, sr[tr - 1] + 1, sr[tr], rig[i] - rig[sr[tr]]);
      --tr;
    }
    sr[++tr] = i;
  }
}
int main() {
  scanf("%d%d%d", &w, &h, &n);
  px[nx = 2] = w;
  py[ny = 2] = h;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    px[++nx] = x[i];
    py[++ny] = y[i];
  }
  sort(px + 1, px + nx + 1);
  sort(py + 1, py + ny + 1);
  nx = unique(px + 1, px + nx + 1) - px - 1;
  ny = unique(py + 1, py + ny + 1) - py - 1;
  for (int i = 1; i <= n; ++i) {
    x[i] = lower_bound(px + 1, px + nx + 1, x[i]) - px;
    y[i] = lower_bound(py + 1, py + ny + 1, y[i]) - py;
  }
  process();
  swap(w, h);
  swap(px, py);
  swap(nx, ny);
  swap(x, y);
  process();
  printf("%d\n", ans);
  return 0;
}

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

#define int long long
const int INF = (1LL << 31) - 1;
const int MAX_N = 100001;

struct Node {
  int type;
  int value;
  Node(int a, int b) { type = a; value = b; }
};

struct LazySegTree {
  int n;
  vector<Node> lazy;
  vector<int> tree;

  LazySegTree(int n_) {
    n = 1;
    while ( n < n_ ) n <<= 1;
    tree = vector<int>(2 * n - 1, INF);
    lazy = vector<Node>(2 * n - 1, Node(0, INF));
  }

  void propagate(int k, int l, int r) {
    Node p = lazy[k];
    lazy[k].type = 0;
    if ( p.type == 0 || r - l == 1 ) return;
    lazy[k * 2 + 1] = lazy[k * 2 + 2] = p;
    tree[k * 2 + 1] = tree[k * 2 + 2] = p.value;
  }

  void update(int a, int b, int x) { update(a, b, x, 0, 0, n); }
  void update(int a, int b, int x, int k, int l, int r) {
    if ( b <= l || r <= a ) return;
    propagate(k, l, r);
    if ( a <= l && r <= b ) {
      lazy[k] = Node(1, x);
      tree[k] = x;
    } else {
      int mid = (l + r) / 2;
      update(a, b, x, k * 2 + 1, l, mid);
      update(a, b, x, k * 2 + 2, mid, r);
      tree[k] = min(tree[k * 2 + 1], tree[k * 2 + 2]);
    }
  }

  int get_min(int a, int b) { return get_min(a, b, 0, 0, n); }
  int get_min(int a, int b, int k, int l, int r) {
    if ( b <= l || r <= a ) return (1LL << 60);
    propagate(k, l, r);
    if ( a <= l && r <= b ) {
      return tree[k];
    } else {
      int mid = (l + r) / 2;
      int l_value = get_min(a, b, k * 2 + 1, l, mid);
      int r_value = get_min(a, b, k * 2 + 2, mid, r);
      return min(l_value, r_value);
    }
  }
};

signed main() {
  int n, q;
  cin >> n >> q;

  LazySegTree tree(n);
  while ( q-- ) {
    int type, a, b, x;
    cin >> type;
    if ( type ) {
      cin >> a >> b;
      cout << tree.get_min(a, b + 1) << endl;
    } else {
      cin >> a >> b >> x;
      tree.update(a, b + 1, x);
    }
  }

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  for(int i=1;i<=50000;i++){
    if(N==i*108/100){cout << i << endl; return 0;}
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[][] a = new int[2][n];
		for(int i=0;i<2;i++){
			for(int j=0;j<n;j++){
				a[i][j] = scanner.nextInt();
			}
		}
		int max = 0, sum = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<=i;j++){
				sum += a[0][j];
			}
			for(int j=i;j<n;j++){
				sum += a[1][j];
			}
			max = Math.max(max, sum);
			sum = 0;
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)

using namespace std;

const long long int inf = 1 << 29 ;


int main(void) {
  int n, m;
  cin >> n >> m;
  
  vector<int> keys(m), a(m);
  
  rep(i,m){
    int b;
    cin >> a[i] >> b;
    
    rep(j,b) { 
      int c;
      cin >> c;
      c--;
      keys[i] |= 1 << c;
    }
  }
  
  vector<int> dp(1 << n, inf);
  dp[0] = 0;
  
  rep(i, 1 << n) rep(j,m){
    dp[i | keys[j]] = min(dp[i | keys[j]], dp[i] + a[j]);
  }
  
  if (dp[(1 << n) - 1] >= inf) cout << -1 << endl;
  else cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        Deque<String> dq = new ArrayDeque<String>();
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                dq.addLast(sc.next());
            }else{
                dq.addFirst(sc.next());
            }
        }
        while(dq.size() > 0){
            System.out.print((n%2 == 0 ? dq.pollFirst() : dq.pollLast()) + " ");
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 84448
#include<bits/stdc++.h>
#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<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

void solve() {
  string s;
  cin >> s;
  ll n = s.size();
  if (s[n-1] == 's')
    cout <<  s << "es" << endl;
  else
    cout <<  s << "s" << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k;
	string s;
	cin>>n>>s>>k;
	for(auto i:s) cout<<(i==s[k-1]?i:'*');
	cout<<"\n";
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<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>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define 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 };


int main() {
	ll h, w, n;
	ll i, j, k, l;
	cin >> h >> w >> n;
	vector< pii > cnt;
	for (i = 0; i < n; i++) {
		pii p;
		cin >> p.second >> p.first;
		p.second--; p.first--;
		if (!(p.first < 1 || p.first >= w - 1 || p.second < 1 || p.second >= h - 1)) {
			cnt.push_back(p);
		}
		for (j = 0; j < 8; j++) {
			pii p2 = make_pair(p.first + dy2[j], p.second + dx2[j]);
			if (p2.first < 1 || p2.first >= w-1 || p2.second < 1 || p2.second >= h-1) {
				continue;
			}
			cnt.push_back(p2);
		}
	}
	sort(cnt.begin(), cnt.end());
	pii pre = make_pair(-1, -1);
	vl ans(10);
	int ct = 1;
	for (i = 0; i < cnt.size(); i++) {
		if (pre == cnt[i]) {
			ct++;
		}
		else {
			ans[ct]++;
			pre = cnt[i];
			ct = 1;
		}
	}
	ans[ct]++;
	ans[1]--;
	ll sum = 0;
	for (i = 1; i < 10; i++) {
		sum += ans[i];
	}
	cout << (h - 2)*(w - 2) - sum << endl;
	for (i = 1; i < 10; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 10348
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

struct Data
{
    string str;
    int num;

    Data() {}
    Data(string _str, int _num) : str(_str), num(_num) {}
};

int main()
{
    int n;
    cin >> n;
    vector<vector<Data>> v(n, vector<Data>());
    v[0].emplace_back(Data(string{'a'}, 1));
    for (int len = 0; len < n - 1; len++)
    {
        for (Data parent : v[len])
        {
            for (int i = 0; i <= parent.num; i++)
            {
                Data tmp = parent;
                char c = 'a' + i;
                tmp.str.push_back(c);
                tmp.num = max(tmp.num, i + 1);
                v[len + 1].emplace_back(tmp);
            }
        }
    }
    for (Data x : v[n - 1])
    {
        cout << x.str << endl;
    }
    return 0;
}


Measured memory_bytes: 10736
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n,ans,a[MAXN],dp[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	for (int i=n-1;i>=1;i--) {
		dp[i]=(a[i]>=a[i+1]?dp[i+1]+1:0);
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end(), greater<long long>());
    return ret;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int sum = 0;
    REP(i, N) {
        cin >> A.at(i);
        sum += A[i];
    }
    auto d = divisor(sum);  // 合計値の約数

    vector<int> r(N);
    REP(i, d.size()) {
        REP(j, N) { r[j] = A[j] % d[i]; }
        sort(ALL(r));
        vector<int> L(N + 1), R(N + 1);
        L[0] = 0;
        R[N] = 0;
        REP(j, N) { L[j + 1] += r[j] + L[j]; }
        for (int j = N - 1; j >= 0; j--) {
            R[j] += (d[i] - r[j]) + R[j + 1];
        }
        REP(j, N + 1) {
            if (L[j] == R[j] && L[j] <= K) {
                cout << d[i] << endl;
                return 0;
            }
        }
    }

    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

ATGC = ['A','T','G','C']
count = 0
goukei = []
for i in range(len(S)):
	count = 0
	for j in range(i,len(S)):
		if(S[j] in ATGC):
			count += 1
			if(j == len(S)-1):
				goukei.append(count)
				break
		else:
			goukei.append(count)
			break
print(max(goukei))

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

int main(){
    int N,Y;
    cin >> N >> Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(Y==10000*i+5000*j+1000*(N-i-j)){
                cout << i << " " << j << " " << N-i-j << endl;
                return 0;
            }
        }
    }

cout << -1 << " " << -1 << " " << -1 << endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 1000005
int n,m,tot,pos[N],cnt,head[N],ans,vis[N],dis[N];
struct edge{ int to,nxt,v; }e[N<<1];
map<pii,int> Mp; vector<int> ve[N];
void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}
void ins(int x,int y){
	adde(x,y); adde(y,x);
}
queue<int> q;
#define w(x) (x>tot)
void spfa(){
	while (!q.empty()){
		int u=q.front(); q.pop(); vis[u]=0;
		for (int i=head[u],v; i; i=e[i].nxt){
			v=e[i].to;
			if (dis[v]>dis[u]+w(v)){
				dis[v]=dis[u]+w(v);
				if (!vis[v]) vis[v]=1,q.push(v);
			}
		}
	}
}
//#define local
int main(){
#ifdef local
	freopen("my.in","r",stdin); freopen("my.out","w",stdout);
#endif
	n=read(),m=read();
	rep (i,1,m){
		int x=read(),y=read(),z=read();
		if (!Mp[pii(x,z)]) Mp[pii(x,z)]=++tot,pos[tot]=x;
		if (!Mp[pii(y,z)]) Mp[pii(y,z)]=++tot,pos[tot]=y;
		x=Mp[pii(x,z)]; y=Mp[pii(y,z)]; ins(x,y);
	}
	rep (i,1,tot) ins(pos[i]+tot,i);
	mset(dis,0x3f);
	rep (st,1,tot) if (pos[st]==1) q.push(st),vis[st]=1,dis[st]=1;
	spfa();
	ans=inf; rep (ed,1,tot) if (pos[ed]==n) cmin(ans,dis[ed]);
	if (ans>=inf) puts("-1"); else printf("%d\n",ans);
	return 0;
}
// sample data:
/*
3 3
1 2 1
2 3 1
3 1 2

8 11
1 3 1
1 4 2
2 3 1
2 5 1
3 4 3
3 6 3
3 7 3
4 8 4
5 6 1
6 7 5
7 8 5
*/

// rest:
/*

*/

/*
If you find any bug in my code or solution, please tell me. Thanks so much.
email: 2411280037@qq.com
*/

Measured memory_bytes: 81024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static int[][] minpath(int[][] c){
        int[][] path = c.clone();
        /*
        for(int i=0; i<c.length; i++){
            for(int j=0; j<c[0].length; j++){
                path[i][j] = Integer.MAX_VALUE;
            }
        }
        */

        for(int k=0; k<c.length; k++){
            for(int i=0; i<c.length; i++){
                for(int j=0; j<c.length; j++){
                    path[i][j] = Math.min(path[i][j], path[i][k]+path[k][j]);
                }
            }
        }
        return path;
    }

    static int minMF(int[][] c, int[][] A){
        int result = 0;
        int[][] minpath = minpath(c);
        for(int i=0; i<A.length; i++){
            for(int j=0; j<A[0].length; j++){
                if(A[i][j] == -1) continue;
                else result += minpath[A[i][j]][1];
            }
        }
        return result;
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputstr = br.readLine().trim().split(" ");
        int[][] A = new int[Integer.parseInt(inputstr[0])][Integer.parseInt(inputstr[1])];
        int[][] c = new int[10][10];
        for(int i=0; i<c.length; i++){
            inputstr = br.readLine().trim().split(" ");
            for(int j=0; j<c[0].length; j++){
                c[i][j] = Integer.parseInt(inputstr[j]);
            }
        }
        for(int i=0; i<A.length; i++){
            inputstr = br.readLine().trim().split(" ");
            for(int j=0; j<A[0].length; j++){
                A[i][j] = Integer.parseInt(inputstr[j]);
            }
        }
        System.out.println(minMF(c, A));

    }
}

Measured memory_bytes: 26196
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	string a;
	cin >>a;
	string A = "No";
	if (a.at(0) == a.at(2)) {
		A = "Yes";
	}
	cout <<A<< endl;
}


Measured memory_bytes: 256