akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k; cin >> n >> k;
  vector<bool> v(n + 1, false);
  for(int i = 1; i <= k; i++) {
    int m; cin >> m;
    for(int j = 0; j < m; j++) {
      int t; cin >> t;
      v[t] = true;
    }
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(!v[i]) ans++;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3664
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();

		System.out.println(A * B / gcd(A, B));

	}

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K, Q;
    
    cin >> N >> K >> Q;
    int temp = K - Q;

    vector<int> Person(N, temp);

    for (int i = 0; i < Q; i++)
    {
        cin >> temp;
        Person[temp - 1]++;
    }
    
    for (auto &&p : Person)
    {
        cout << ((p > 0)? "Yes": "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int A,B,K;
	
	cin >> A >> B;

	if (A % 2 == B % 2) cout << (A + B) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
/* ************************************************************************
	> File Name: a.cpp
	> Author: caowushang
	> Mail: 15630929347@163.com 
	> Created Time: 2017年02月18日 星期六 20时03分11秒
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;

int main()
{
	//freopen("in","r",stdin);
	//freopen("out","w",stdout);
	int n;
	cin >> n;
	int x=n/15;
	int ans=n*800-x*200;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
	int n,i,j,num;
	char string[10];
	scanf("%d",&n);
	for(i = 1;i <= n;i++){
		num = i;
		if(num%3 == 0){
			printf(" %d",i);
		}
		else{
			for(j = 0;j<5;j++){
				if(num%10 == 3){
					printf(" %d",i);
					break;
				}
				num /= 10;
				if(num == 0) break;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
template<class D>
vector<D> dijkstra(const vector<vector<pair<int,D>>>& G, int s = 0){	//G:(v,cost)
	using P = pair<D,int>;
	priority_queue<P,vector<P>,greater<P> > que;
	int N = G.size();

	D inf = 1e18;
	vector<D> d(N,inf);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v = p.sc;
		D c = p.fs;
		if(d[v]!=c) continue;
		for(auto p:G[v]){
			int to=p.fs;
			if(d[to]>d[v]+p.sc){
				d[to]=d[v]+p.sc;
				que.push(P(d[to],to));
			}
		}
	}

	return d;
}
using P = pair<int,ll>;
int main(){
	int N,M,S,T;
	cin>>N>>M>>S>>T;
	S--,T--;
	vector<vector<P>> G(N);
	rep(i,M){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--,b--,c--;
		G[a].pb(P(b,d));
		G[a].pb(P(c,d));
		G[b].pb(P(a,d));
		G[b].pb(P(c,d));
		G[c].pb(P(a,d));
		G[c].pb(P(b,d));
	}
	cout<<dijkstra(G,S)[T]<<endl;
}



Measured memory_bytes: 23716
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  bool[int] buf;
  foreach (_; 0..n) {
    auto a = readln.chomp.to!int;
    if (a in buf) {
      buf.remove(a);
    } else {
      buf[a] = true;
    }
  }

  writeln(buf.length);
}


Measured memory_bytes: 7932
s = input()

to_split = s.split()
a, b = to_split

a = int(a)
b = int(b)

def area(a, b):
    return a*b

def lap_length(a, b):
    return a*2 + b*2

x = area(a, b)
y = lap_length(a, b)
print(x, y)


Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int A[2000000];
int B[2000000];

int main(){

  int C[VMAX+1];
  int n, i, j, k = 0;

  scanf("%d", &n);
  
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(k < A[i])
      k = A[i];
  }

  for(i = 0; i <= k; i++)
    C[i] = 0;

  for(j = 1; j <= n; j++)
    C[A[j]]++;

  for(i = 1; i <= k; i++)
    C[i] = C[i] + C[i - 1];

  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    if(i == n)
      printf("%d\n", B[i]);
    else
      printf("%d ", B[i]);
  }
    
  return 0;
}


Measured memory_bytes: 17348
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<vector<int>> C;

void comb_init(int N){
  C = vector<vector<int>>(N+1, vector<int>(N+1));
  REP(i, N+1) REP(j, i+1){
    if(j == 0 || j == i) C[i][j] = 1;
    else C[i][j] = C[i-1][j-1]+C[i-1][j];
  }
}

int comb(int n, int r){
  return C[n][r];
}

signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  int M = A;

  map<int, int> m;
  REP(i, N){
    int v;
    cin >>  v;
    m[v]++;
  }

  vector<pair<int, int>> v;
  for(auto p : m) v.emplace_back(p);
  reverse(ALL(v));

  comb_init(51);

  int sum = 0;
  int ans = 1;
  bool flag = true;
  for(auto p : v){
    if(p.second < A){
      A -= p.second; B -= p.second;
      sum += p.first*p.second;
      flag = false;
    }else{
      ans = 0;
      if(flag){
        for(int i = A; i <= min(p.second, B); i++){
          ans += comb(p.second, i);
        }
      }else{
        ans = comb(p.second, A);
      }
      sum += p.first*A;
      break;
    }
  }

  cout << (double)sum/M << "\n";
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> city(n);
    int a,b;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        city.at(a-1)++;
        city.at(b-1)++;
    }
    for(int i=0; i<n; i++){
        cout << city.at(i) << endl;
    }
}

Measured memory_bytes: 3608
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        tank = []
        while par[x] >= 0:
            tank.append(x)
            x = par[x]
        for elt in tank:
            par[elt] = x
        return x
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

import sys
input = sys.stdin.buffer.readline
 
n,m = map(int,input().split())

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

 
for _ in range(m):
    a,b = map(int,input().split())
    unite(a-1,b-1)
 
res = 0
for e in par:
    if e < 0:
        res = max(res,-e)
print(res)

Measured memory_bytes: 75160
import std;

void main() {
    string s = read;
    string t = read;
    writeln(t.startsWith(s) ? "Yes" : "No");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


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

int t;
vector<vector<int>> seats; // 人が座っているか管理する
vector<vector<int>> memo; // 席を立つコストを先にメモしておく

void bfs(int _y, int _x) {
    queue<pair<int,int>> q;
    q.push({_y,_x});
    while(!q.empty()) {
        auto&& yx = q.front(); q.pop();
        int y = yx.first, x = yx.second;
        // 隣のマスのコストは、min(計算済みコスト, チェックしているマスのコスト + 人が座っていたら)となる
        if(y > 0 && memo[y - 1][x] > memo[y][x] + seats[y - 1][x]) {
            memo[y - 1][x] = memo[y][x] + seats[y - 1][x];
            q.push({y - 1, x}); // 値を更新したときだけ、探索対象にする
        }
        if(y < t - 1 && memo[y + 1][x] > memo[y][x] + seats[y + 1][x]) {
            memo[y + 1][x] = memo[y][x] + seats[y + 1][x];
            q.push({y + 1, x});
        }
        if(x > 0 && memo[y][x - 1] > memo[y][x] + seats[y][x - 1]) {
            memo[y][x - 1] = memo[y][x] + seats[y][x - 1];
            q.push({y, x - 1});
        }
        if(x < t - 1 && memo[y][x + 1] > memo[y][x] + seats[y][x + 1]) {
            memo[y][x + 1] = memo[y][x] + seats[y][x + 1];
            q.push({y, x + 1});
        }
    }
}

int main() {
    cin >> t;
    for(int y = 0; y < t; y++) {
        vector<int> row;
        for(int x = 0; x < t; x++) {
            // 初期値は簡単に計算可能
            row.push_back(min({x, t - x - 1, y, t - y - 1}));
        }
        memo.push_back(row);
        vector<int> humanRow(t, 1);
        seats.push_back(humanRow);
    }
    int result = 0;
    for(int i = 0; i < t * t; i++) {
        int number;
        cin >> number;
        number--;
        int x = number % t; // 列は割った余り
        int y = number / t; // 行は割った答え
        result += memo[y][x]; // 席を立つコストは計算済みなので、そのまま足す
        seats[y][x]--; // 席を立ったことをマーク
        memo[y][x]--; // 席を立ったので、メモ済コストを減らす
        bfs(y, x); // メモを更新したのでbfs
    }
    cout << fixed << result;
}

Measured memory_bytes: 5600
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int n = S.length();
		String X = "";
		for(int i =0; i<n; i++) {
			X = X + "x";
		}
		
		System.out.println(X);
}
}

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

int main(void){
	int n, m;
	cin >> n >> m;
	vector<bool> a(n+2, false);
	for(int i = 0; i < m; ++i){
		int tmp;
		cin >> tmp;
		a[tmp] = true;
	}
	vector<long long> dp(n+2, 0LL);
	dp[0] = 1;
	for(int i = 0; i < n; ++i){
		if(!a[i+1]){
			dp[i+1] += dp[i];
			dp[i+1] %= MOD;
		}
		if(!a[i+2]){
			dp[i+2] += dp[i];
			dp[i+2] %= MOD;
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;


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

	public void solve(Scanner sc) {
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		int div = b/a;
		if(div >= c) {
			System.out.println(c);
		} else {
			System.out.println(div);
		}
		
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,t=0,u=0;
    string s;
    cin >> n >> s;
    for (int i=0;i<n;i++) {
        if (s.at(i)=='.') t++;
    }
    u=t;
    for (int i=0;i<n;i++) {
        if (s.at(i)=='.') u--;
        else u++;
        t=min(t,u);
    }
    cout << t << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
int main(){
  int i;
  string moji;
  cin >> moji;
  int count=0;
  int len = moji.size();
 
  for(i = 0; i < len/2; i++){
    char A,B;
    A=moji[i];
    B=moji[len-i-1];
    
    if(A=='i'&& B=='i')continue;
    if(A=='w' && B=='w')continue;
    if(A=='(' && B==')')continue; 
    if(A==')' && B=='(')continue;
  count++;
  }
  if(len%2==1){
    if(moji[len/2]!='i'&&moji[len/2]!='w')count++;
  }
  cout << count << endl; 
  return 0;
    
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <ctype.h>

int P,Q,R;
char *p;

int formula(){
  int l,r;
  char c = *p++;
  if(isdigit(c)) return c-'0';
  if(isupper(c)) return (c == 'P' ? P : c == 'Q' ? Q : R);
  if(c == '-') return 2-formula();
  if(c == '('){
    l = formula();
    if(*p++ == '*'){
      r = formula();
      *p++;
      return (l < r ? l : r);
    }else{
      r = formula();
      *p++;
      return (l > r ? l : r);
    }  
  }
  return 0;
}

int main(){
  int ans;
  char s[100];
  while(scanf("%s",s), s[0] != '.'){
    ans = 0; 
    for(P = 0 ; P < 3 ; P++){
      for(Q = 0 ; Q < 3 ; Q++){
        for(R = 0 ; R < 3 ; R++){
          p = s;
          if(formula() == 2) ans++;
        }
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 964
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

string S;

long ans[100000];
 
void solve(){
	memset(ans,0,sizeof(long)*100000);
	int R_start_index = 0;
	int R_end_index = 0;
	int L_start_index = 0;
	int L_end_index = 0;
	char prev_char = 'R';
	for(int i=1;i<S.size();i++){
		char present_char = S[i];
		if(prev_char=='R' && present_char=='L'){
			R_end_index = i-1;
			L_start_index = i;
		}
		if((prev_char=='L' && present_char=='R') || i==S.size()-1){
			L_end_index = i-1 + (i==S.size()-1);

			int r_num = R_end_index-R_start_index+1;
			int l_num = L_end_index-L_start_index+1;
			int r_numof_even = (r_num)/2;
			int r_numof_odd = (r_num)/2+r_num%2;
			int l_numof_even = (l_num)/2;
			int l_numof_odd = (l_num)/2+l_num%2;
			ans[R_end_index] = l_numof_even + r_numof_odd;
			ans[L_start_index] = l_numof_odd + r_numof_even;

			R_start_index = i;
		}
		prev_char = S[i];
	}
}
 
int main(){
	cin>>S;

	solve();

	for(int i=0;i<S.size();i++){
		cout << ans[i] << ' ';
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream> // cout, endl, cin
#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
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] <= xx) {//<が元
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { 
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n,t=0,a;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		a = n / i;
		t += i*a * (a + 1) / 2;
	}
	cout << t << endl;
}


Measured memory_bytes: 3624
//
//AtCoder Beginner Contest 128
//A - Apple Pie
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int a, p;
    cin >> a >> p;

    cout << ((a*3)+p)/2 << endl;
    return 0;
}


Measured memory_bytes: 3624
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 for(int i=1;i<=9;i++)
 {
           int a=n/i;
           if(a*i==n && a<10) 
           {
                     cout<<"Yes";
                     return 0;
           }
 }
 cout<<"No";
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<String> strList = args.stream().skip(1).collect(toList());
            long ab = strList.stream()
                    .mapToLong(s -> {
                        long ans = 0;
                        for (int i = 0; i < s.length() - 1; i++) {
                            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B') {
                                ans++;
                            }
                        }
                        return ans;
                    }).sum();
            long endA = strList.stream().filter(s -> s.endsWith("A")).count();
            long startB = strList.stream().filter(s -> s.startsWith("B")).count();
            long endAAndStartB = strList.stream().filter(s -> s.startsWith("B") && s.endsWith("A")).count();
            long plus = (endA == endAAndStartB && startB == endAAndStartB) ? endA - 1 : Math.min(endA, startB);
            System.out.println(ab + Math.max(0, plus));
        };
    }

}


Measured memory_bytes: 44936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  string s;
  char k=' ';
  cin>>s;
  int n=s.size();
  int i=0,ans=0;
  while(i<n){
    if(k!=s[i]){
      k=s[i];
      i++;
      ans++;
    }
    else{
      i+=2;
      k=' ';
      if(i<=n)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


a, b, k = map(int, input().split())
m = min(a, b)
cnt = 0
for i in range(m, 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        break
print(i)


Measured memory_bytes: 3832
#include <stdio.h>

int main(void){

        int n,i,b,f,r,v=0,a[4][3][10]={0};
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d %d %d %d",&b,&f,&r,&v);
                a[b-1][f-1][r-1]+=v;
        }

        for(b=0;b<4;b++){
                for(f=0;f<3;f++){
                        for(r=0;r<10;r++)
                                printf("%2d",a[b][f][r]);
                        puts("");
                        }
                if(b!=3)        puts("####################");
        }
        return 0;
}

Measured memory_bytes: 1776
#include<iostream>
#include<queue>

using namespace std;

struct node{
  node(){};
  int x,y;
  node(int y,int x):y(y),x(x){}
};

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

int main(){
  int w,h,i,j;
  while(cin >> w >> h && w){
    char tile[h][w];
    int ans = 0;
    struct node now,next;
    queue<struct node> que;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        cin >> tile[i][j];
        if(tile[i][j]=='@'){
          que.push(node(i,j));
          tile[i][j]='#';
        }
      }
    }
    while(!que.empty()){
      now = que.front();
      ans++;
      que.pop();
      for(i=0;i<4;i++){
        int ddx = dx[i] + now.x;
        int ddy = dy[i] + now.y;
        if(ddx>w-1 || ddx<0 || ddy>h-1 || ddy<0)continue;
        if(tile[ddy][ddx]=='.'){
          que.push(node(ddy,ddx));
          tile[ddy][ddx] = '#';
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 111;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;


int A[MAX];
int DP[MAX][MAX][MAX];


int main()
{
    int n;
    scanf("%d", &n);
    int N = n + n - 1;
    FOR (i, 0, N)
        scanf("%d", &A[i]);
    sort(A, A + N);
    
    DP[0][1][0] = 1;
    FOR(i, 0, n)
    {
        FOR(j, 0, N + 1)
        {
            FOR(k, 0, j)
            {
                if (DP[i][j][k] == 0)continue;
                
                int l = n - i - 1;
                int r = n + i;
                
                int jj = j + (l > 0 && A[l] != A[l-1]) + (r < N && A[r] != A[r-1]);
                int kk = k + (l > 0 && A[l] != A[l-1]);
                
                FOR(x, 0, jj)
                {
                    int jjj = jj - max(0, abs(x - kk) - 1);
                    int kkk = min(x, kk + 1);
                    
                    DP[i+1][jjj][kkk] += DP[i][j][k];
                    if (DP[i+1][jjj][kkk] >= MOD)
                        DP[i+1][jjj][kkk] -= MOD;
                }
                
                
                
            }
        }
    }
    int res = 0;
    FOR(i, 0, N + 1)
        FOR(j, 0, i)
    {
        res += DP[n-1][i][j];
        if (res >= MOD)res -= MOD;
    }
    
    cout << res << endl;
    
    
}
    
    


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

int main() {
    int n;
    cin >> n;
    int max_i = 0;
    stack<int> st;
    for (; max_i * (max_i + 1) < 2 * n; max_i++);
    for (int i = max_i; i > 0; i--) {
        if ((i - 1) * i < 2 * n) {
            st.push(i);
            n -= i;
        }
    }
    while (!st.empty()) {
        cout << st.top() << endl;
        st.pop();
    }
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
ll B = 101;
ll power(ll base, ll exponent, ll modx = mod) {
    ll ret = 1 % modx; 
    base %= modx; 
    while(exponent) {
        if(exponent & 1) {
            ret = (ret * base) % modx;
        }
        base = (base * base) % modx;
        exponent >>= 1;
    }
    return ret;
}
ll inv(ll val, ll modx = mod) {
    return power(val, modx - 2, modx);
}
int main() {fio;
	int N;
	cin >> N;
	vector <vector <ll>> A(2 * N, vector <ll> (2 * N));
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < N; j++) {
			A[i][j] = s[j];
			A[i + N][j] = s[j];
			A[i][j + N] = s[j];
			A[i + N][j + N] = s[j];
		}
	}
	vector <vector <ll>> vertical(2 * N, vector <ll> (2 * N)), horizontal(2 * N, vector <ll> (2 * N));
	for(int i = 0; i < 2 * N; i++) {
		for(int j = 0; j < 2 * N; j++) {
			if(i == 0) {
				vertical[i][j] = A[i][j];
			} else {
				vertical[i][j] = (vertical[i - 1][j] * B + A[i][j]) % mod;
			}
			if(j == 0) {
				horizontal[i][j] = A[i][j];
			} else {
				horizontal[i][j] = (horizontal[i][j - 1] * B + A[i][j]) % mod;
			}
			if(i >= N) {
				vertical[i][j] = (vertical[i][j] - (A[i - N][j] * power(B, N)) % mod + mod) % mod;
				vertical[i][j] %= mod;
			}
			if(j >= N) {
				horizontal[i][j] = (horizontal[i][j] - (A[i][j - N] * power(B, N)) % mod + mod) % mod;
				horizontal[i][j] %= mod;
			}
		}
	}
	int ans = 0;
	// h[0][n]
	for(int i = N - 1; i < 2 * N - 1; i++) {
		for(int j = N - 1; j < 2 * N - 1; j++) {
			bool f = 1;
			for(int k = 0; k < N - 1; k++) {
				f &= horizontal[i - k][j] == vertical[i][j - k];
			}
			ans += f;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    int sum = 0, inx = 0;
    for (int i = 1; sum < N; i++)
    {
        sum += i;
        inx = i;
    }
    if (sum > N)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        int k = inx + 1, now = 1;
        cout << k << endl;
        vector<vector<int>> v(k);
        for (int i = 1; i < k; i++)
        {
            for (int j = 0; j < i; j++)
            {
                v[j].push_back(now);
                v[i].push_back(now);
                now++;
            }
        }
        for (int i = 0; i < k; i++)
        {
            cout << v[i].size() << " ";
            for (int j = 0; j < v[i].size(); j++)
            {
                cout << v[i][j] << (j == v[i].size() - 1 ? "\n" : " ");
            }
        }
    }
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>

int main(void) {
 
  // 入力
  int n,max=0,cnt=0,tmp,left;
  scanf("%d",&n);
  scanf("%d",&left);
  for(int i=1;i<n;i++){
    scanf("%d",&tmp);
    if(left>=tmp){
      cnt+=1;
    }else{
      if(max<cnt)max=cnt;
      cnt=0;
    }
    left=tmp;
  }
  if(max<cnt)max=cnt;

  printf("%d\n",max);
  

  return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,q = LI()
    s = S()
    aa = [LS() for _ in range(q)]
    ml = -1
    mr = n
    li = -1
    ri = n
    for t,d in aa[::-1]:
        if s[li+1] == t and d == 'L':
            li += 1
            if ml < li:
                ml = li
                if ml == n-1:
                    return 0
        elif li >= 0 and s[li] == t and d == 'R':
            li -= 1
        if s[ri-1] == t and d == 'R':
            ri -= 1
            if mr > ri:
                mr = ri
                if mr == 0:
                    return 0
        elif ri < n and s[ri] == t and d == 'L':
            ri += 1

    r = n - (li + 1) - (n - ri)

    return r


print(main())




Measured memory_bytes: 45268
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        m: usize
    }
    let mut mem: HashMap<(usize, usize), usize> = HashMap::new();
    let ans = count((1 << (n + 2)) - 3, m, &mut mem);
    println!("{}", ans);
}

fn count(n: usize, m: usize, mem: &mut HashMap<(usize, usize), usize>) -> usize {
    if let Some(x) = mem.get(&(n, m)) {
        return *x;
    }
    let x = if m > n - 1 {
        (n + 1) / 2
    } else if m > (n + 1) / 2 {
        count((n - 3) / 2, m - (n + 1) / 2, mem) + 1 + count((n - 3) / 2, (n - 3) / 2, mem)
    } else if m == (n + 1) / 2 {
        1 + count((n - 3) / 2, (n - 3) / 2, mem)
    } else if m > 1 {
        count((n - 3) / 2, m - 1, mem)
    } else {
        0
    };
    mem.insert((n, m), x);
    x
}


Measured memory_bytes: 4352
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N,M,C,ans=0,sum=0;
    cin>>N>>M>>C;
    int B[M];
    for(int i=0;i<M;i++)cin>>B[i];
    int A[N][M];
    for(int i=0;i<N;i++){
        for(int k=0;k<M;k++){
            cin>>A[i][k];
        }
    }
    for(int k=0;k<N;k++){
         for(int i=0;i<M;i++){
                  sum=sum+A[k][i]*B[i];
         }
         if(sum+C>0) ans++ ;
        sum=0;
    }
    cout<<ans<<endl;
    return 0;
}

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

void insertionsort(int n){
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++){
    for(int j = i; j > 0; j--){
      if(a[j-1] > a[j]){
        int t = a[j-1];
        a[j-1] = a[j];
        a[j] = t;
      }else break;
    }
    for(int j = 0; j < n; j++){
      cout << a[j];
      if(j != n-1) cout << " ";
    }
    cout << endl;
  }
}

int main(){
  int n;
  cin >> n;
  insertionsort(n);
  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,L,R,pl,pr;
int d,k;
inline ll read(){
    ll res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
int main(){
    a=read(),b=read(),d=0,k=0;
    if(a<b) swap(a,b);
    for (int i=60;i;i--){
        if(((1ll<<i-1)&a)^((1ll<<i-1)&b)){
            d=i;
            break;
        }
        else{
            if(((1ll<<i-1)&a)){
                a^=1ll<<i-1;
                b^=1ll<<i-1;
            }
        }
    }
    if(!d){
        printf("1\n");
        return 0;
    }
    for (int i=d-1;i;i--){
        if((1ll<<i-1)&a){ 
            k=i;
            break;
        }
    }
    L=b,R=(1ll<<d-1)+(1ll<<k)-1;
    pl=(1ll<<d-1)+b,pr=(1ll<<d)-1;
    if(pl>R) printf("%lld\n",R-L+1+pr-pl+1);
    else printf("%lld\n",pr-L+1);
    return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
   int main(void){
      int W,H,x,y,r;
      scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


      if((x-r)>=0 && (x+r)<=W && (y-r)>=0 &&(y+r)<=H){
         printf("Yes\n");
      }

      if((x-r)<0 || (x+r)>W || (y-r)<0 || (y+r)>H){
         printf("No\n");
      }


      return 0;
   }


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

using namespace std;

vector<int> v[100001];
bool visited[100001];
int dp[100001];

void dfs(int idx)
{
    int num=0;
    for(int i=0;i<(int)v[idx].size();i++)
    {
        if(!visited[v[idx][i]])
        {
            visited[v[idx][i]]=1;
            dfs(v[idx][i]);
        }
        num=max(num,dp[v[idx][i]]+1);
    }
    dp[idx]=num;
}

int main()
{
    int n,m;
    cin >> n >> m;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin >> x >> y;
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++) dfs(i);
    int res=0;
    for(int i=1;i<=n;i++) res=max(res,dp[i]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 8192
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
vector<int> a,b;
int suma=0,sumb=0;
int main()
{
	while(1)
	{
	a.clear();
	b.clear();
	suma=0;
	sumb=0;
	int n,m;
	cin >> n >> m;
	if(n==0&&m==0)break;
	for(int i=0;i<n;i++)
	{
		int k;
		cin >> k;
		suma+=k;
		a.pb(k);
	}
	for(int i=0;i<m;i++)
	{
		int k;
		cin >> k;
		sumb+=k;
		b.pb(k);
	}
	SORT(a);
	SORT(b);
	int diff=suma-sumb;
	if(diff%2!=0)
	{
		cout << -1 << endl;
		goto end;
	}
	for(int i=0;i<n;i++)
	{
		if(binary_search(b.begin(),b.end(),a[i]-diff/2))
		{
			cout << a[i] << ' ' << a[i]-diff/2 << endl;
			goto end;
		}
	}
	cout << -1 << endl;
	end:;
	}
	return 0;
}

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

int data[20][20];
int dp[20][20];
int w,h,n;

int main(){
	int i,j;
	int x,y;
	
	while(1){
		cin >> w >> h;
		if( !w )break;
		cin >> n;
		
		for( i = 0; i < 20; i++ ){
			for( j = 0; j < 20; j++ ){
				data[i][j] = 0;
				dp[i][j] = 0;
			}
		}
		
		for( i = 0; i < n; i++ ){
			cin >> x >> y;
			x--;y--;
			data[y][x] = 1;
		}
		
		dp[0][0] = 1;
		for( i = 0; i < h; i++ ){
			for( j = 0; j < w; j++ ){
				if( i+1 < h && !data[i+1][j] )
					dp[i+1][j] += dp[i][j];
				if( j+1 < w && !data[i][j+1] )
					dp[i][j+1] += dp[i][j];
			}
		}
		cout << dp[h-1][w-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n, m;
	cin >> n >> m;

	vector<int> h(n);
	rep(i, n) cin >> h[i];

	vector<bool> good(n, true);
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;

		if(h[a[i]] == h[b[i]]){
			good[a[i]] = false;
			good[b[i]] = false;
 		}else if(h[a[i]] < h[b[i]]){
			good[a[i]] = false;
		}else{
			good[b[i]] = false;
		}
	}

	int ans = 0;
	rep(i, n) if(good[i]) ans++;

	cout << ans << endl;
}


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

#define int long long
using namespace std;

signed main()
{
  int n,m; cin>>n>>m;
  int flag[n + 1] = {};
  int flag1[n + 1] = {};
  int cnt = 0;
  int count = 0;
  for(int i = 0; i < m; i++ )
  {
    int a; cin>>a;
    string str; cin>>str;
    if(str == "AC") {
      	flag[a] = 1;
    }
    else
    {
      if(!flag[a]) flag1[a]++;
    }
  }
  for (int i = 0; i < n + 1; i++)
  {
	  cnt += flag[i];
	  if(flag[i]) count += flag1[i];
  }
  cout<<cnt << " " << count<<endl;
  
  return 0;
}


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

typedef long long int LL;
LL a, b, c, d;

string solve() {
	if (ceil((double) c / b) <= ceil((double) a / d))
		return "Yes";
	return "No";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	while (cin >> a >> b >> c >> d)
		cout << solve() << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("Ofast")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

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;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=998244353;
constexpr int inf=3e18;

int mod_pow(int x, int y, int m = mod) {
	int res = 1;
	x %= m;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;cin>>s;
	map<P,int>mp;
	int now=0,now2=0,now3=1;
	mp[{0,0}]=1;
	int ans=0,p=673;
	rep(i,s.size()){
		now=now*10+(s[i]-'0');
		now%=p;
		now2+=s[i]-'0';
		now2%=3;
		ans+=mp[{now*mod_pow(now3,p-2,p)%p,now2}];
		mp[{now*mod_pow(now3,p-2,p)%p,now2}]++;
		now3=now3*10%p;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a, b;
    cin >> a >> b;

    cout << max(0LL, a-2*b) << endl;

    return 0;
}

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

int main(){
    int n,a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0&&a%3&&a%5)cout<<"DENIED\n",exit(0);
    }
    cout<<"APPROVED\n";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)

mod = 10 ** 9 + 7
def dfs(v, p, k):
    ret = 1
    if len(graph[v]) > k:
        return 0
    kc = k - 2
    if p == -1:
        kc = k - 1
    for vi in graph[v]:
        if vi != p:
            ret *= kc
            ret = ret % mod
            kc -= 1
    for vi in graph[v]:
        if vi != p:
            ret *= dfs(vi, v, k)
            ret = ret % mod
    return ret

n, k = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
    
print((dfs(0, -1, k) * k) % mod)


Measured memory_bytes: 87364
#include<stdio.h>

int main(){
	long long N,ans=0,tmp=0;
	scanf("%lld",&N);
	for(long long i=0;i<N;i++){
		long long a;
		scanf("%lld",&a);
		tmp+=a;
		if(a==0 || i==N-1){
			ans+=tmp/2;
			tmp=0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
S = list(input())

cnt = 0

if len(S) == 1:
    print(0)
    exit()

if S[0] == 'R' and S[1] == 'R':
    cnt += 1

if S[-1] == 'L' and S[-2] == 'L':
    cnt += 1


for i in range(1, n - 1):
    lft = S[i - 1]
    rgt = S[i + 1]
    me = S[i]
    if lft == me == 'L':
        cnt += 1

    if rgt == me == 'R':
        cnt += 1

ans = min(cnt + 2 * k, n - 1)

print(ans)


Measured memory_bytes: 4084
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(make([]byte, 500000), 500000)
	sc.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()

	if b == 1 {
		fmt.Println("0")
	} else if a >= b {
		fmt.Println("1")
	} else {
		count := 1
		num := a
		for {
			num += a - 1
			count++
			if num >= b {
				break
			}
		}
		fmt.Println(count)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

int main()
{
	int N;
	string str;
	cin >> N;
	map<string,int> mp;
	rep(i, N)
	{
		cin >> str;
		mp[str]++;
	}
	cout << mp.size() << endl;
}

Measured memory_bytes: 19176
#include <stdio.h>
#include <stdlib.h>

int main(void){
    char s[11];
    int i=0, leng=0, flag=0, c=0, big=0;
    scanf("%s", s);
    while(1){
        if(s[i] != 0) i++;
        else break;
    }
    leng = i;
    if(s[0] != 'A') flag = 1;
    for(i=2; i<=(leng-2); i++){
        if(s[i] == 'C') c++;
    }
    if(c != 1) flag = 1;
    for(i=0; i<leng; i++){
        if(s[i]>=65 && s[i]<=90) big++;
    }
    if(big != 2) flag = 1;
    if(flag == 1) printf("WA");
    else printf("AC");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;

//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}







int main(){
    ll n;
    cin>>n;
    ll sum = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            for(ll k = 1;k<=n;k++){
                sum+= gcd(i,gcd(j,k));
            }
        }
    }
    cout<<sum<<endl;
	
	
}

Measured memory_bytes: 3648