akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repJ(j, n) for (int j = 0; j <(int)(n); j++)


int n, a[3][3], b[10];
bool appear[3][3];
int main(){
    rep(i, 3){
        repJ(j, 3){
            cin >> a[i][j];
        }
    }
    cin >> n;
    rep(i, n){
        cin >> b[i];
    }
    rep(i, n){
        repJ(j, n){
            appear[i][j] = false;
            for(int k = 0; k < n; k++){
                if (a[i][j] == b[k]){
                    appear[i][j] = true;
                }
            }
        }
    }
    string ans = "No";
    rep(i, 3){
        if (appear[i][0] and appear[i][1] and appear[i][2]) {
            ans = "Yes";
        }
    }
    rep(i, 3){
        if (appear[0][i] and appear[1][i] and appear[2][i]) {
            ans = "Yes";
        }
    }
    if (appear[0][0] and appear[1][1] and appear[2][2]){
        ans = "Yes";
    }
    if (appear[0][2] and appear[1][1] and appear[2][0]){
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N + 1), B(M + 1);
    for (int i = 0; i < N; ++i) {
        cin >> A[i + 1];
        A[i + 1] += A[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> B[i + 1];
        B[i + 1] += B[i];
    }

    int bidx = M, ans = 0;
    for (int aidx = 0; aidx <= N; ++aidx) {
        if (A[aidx] > K)
            break;
        while (bidx > 0 && A[aidx] + B[bidx] > K)
            --bidx;
        ans = max(ans, aidx + bidx);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6360
#include<stdio.h>
int main(void){
	int a,b,c,min,mid,max;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		if(a>c){
			max=a;
			if(c>b){
				mid=c;
				min=b;
			}else{
				mid=b;
				min=c;
			}
		}else{
			max=c;
			min=b;
			mid=a;
		}
	}else{
		if(b>c){
			max=b;
			if(a>c){
				mid=a;
				min=c;
			}else{
				mid=c;
				min=a;
			}
		}else{
			max=c;
			min=a;
			mid=b;
		}
	}
	printf("%d %d %d\n",min,mid,max);
			
	return 0;
}

Measured memory_bytes: 596
N,A,B = map(int,input().split())

c = 0
if A == 0:
    print(0)
    exit()
if B == 0:
    print(N)
    exit()

x = N // (A+B)
y = N % (A+B)
c = x * A
if A <= y:
    c += A
else:
    c += y

print(c)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

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

	std::vector<std::vector<int>> g(n);
	std::vector<std::vector<int>> h(n);
	std::vector<int> deg(n);
	for (int i = 0; i < n; i++) {
		int p;
		std::cin >> p;
		p--;
		g[p].push_back(i);
		h[i].push_back(p);
		deg[p]++;
	}

	std::queue<int> q;

	for (int i = 0; i < n; i++) {
		if (deg[i] == 0) {
			q.push(i);
		}
	}

	std::vector<int> ord(n, -1);
	std::vector<int> topo;
	int now = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		ord[u] = now++;
		topo.push_back(u);

		for (int v : h[u]) {
			if (--deg[v] == 0) {
				q.push(v);
			}
		}
	}

	std::vector<int> dp(n);
	for (int u : topo) {
		std::set<int> mex;
		for (int v : g[u]) if (ord[v] != -1) {
			mex.insert(dp[v]);
		}
		while (mex.count(dp[u])) {
			dp[u]++;
		}
	}

	std::vector<int> cycle;
	for (int i = 0; i < n; i++) {
		if (ord[i] == -1) {
			int j = i;
			while (j != i || cycle.empty()) {
				cycle.push_back(j);
				for (int k : g[j]) if (ord[k] == -1) {
					j = k;
					break;
				}
			}
			break;
		}
	}

	if (cycle.empty()) {
		puts("POSSIBLE");
		return 0;
	}

	int f = cycle[0];
	std::vector<int> cand;
	std::set<int> st;
	for (int u : g[f]) {
		if (ord[u] != -1) {
			st.insert(dp[u]);
		}
	}

	int mex = 0;
	while (st.count(mex)) mex++;

	cand.push_back(mex);
	mex++;
	while (st.count(mex)) mex++;
	cand.push_back(mex);

	for (int c : cand) {
		dp[f] = c;

		for (int i = cycle.size() - 1; i >= 0; i--) {
			int u = cycle[i];
			std::set<int> st;
			for (int v : g[u]) {
				st.insert(dp[v]);
			}
			dp[u] = 0;
			while (st.count(dp[u])) dp[u]++;
		}
		if (dp[f] == c) {
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
}

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

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

    set<string> str;

    for(int i = 0 ; i < N ; i++){
        string temp;
        cin >> temp;
        str.insert(temp);
    }
    cout << str.size() <<endl;

}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}



Measured memory_bytes: 3584
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main()
{
	string a,b;	cin >> a; 
	int d = 0;
	while(cin>>b,b!= "END_OF_TEXT"){
		int l = b.size();
		for (int i = 0; i < l; i++)
		{
			b[i] = tolower(b[i]);
		}
		if (a == b) { d++; }
	}cout << d << endl;
}

Measured memory_bytes: 3172
#include<iostream>
#include<map>
#include<vector>

int main(void){
    std::vector<int> ns(1500), ms(1500);
    std::map<int, int> nc, mc;
    while(1){
        int nl, ml, r = 0;
        std::cin >> nl >> ml;
        if(!(nl || ml)) break;
        for(int i = 0; i != nl; i++) std::cin >> ns[i];
        for(int i = 0; i != ml; i++) std::cin >> ms[i];
        for(int i = 0; i != nl; i++) for(int acc = 0, j = i; j != nl; j++) acc+=ns[j], nc[acc]++;
        for(int i = 0; i != ml; i++) for(int acc = 0, j = i; j != ml; j++) acc+=ms[j], mc[acc]++;
        for(std::map<int, int>::iterator it = nc.begin(); it != nc.end(); it++)
            r += (*it).second * mc[(*it).first];
        std::cout << r << std::endl;
        nc.clear(); mc.clear();
    }
    return 0;
}

Measured memory_bytes: 32460
import java.util.Scanner;

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

		long n = sc.nextLong();
		long m = sc.nextLong();

		if(m == 1) {
			System.out.println(0);
			return;
		}

		long ans = 0;

		if(n >= m) {
			ans = m / 2;
		}
		else {
			if(m < 2 * n) {
				ans = m / 2;
			}
			else if(m > 2 * n) {
				ans = n;
				ans += ((m - 2 * n) / 4);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int h =sc.nextInt();
    int w = sc.nextInt();

    int count = 0;
        for(int i = 0;i < n;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a >= h && b >= w)
                count++;
        }

        System.out.println(count);

    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 25044
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, L;
      cin >> n;
      cin >> L;
      lld A[n];
      lld orig_sum = 0;
     	for(lld i = 1; i <= n; i++){
     		orig_sum += (L+i-1);
     	}
     	lld temp_sum = orig_sum;
     	lld min_diff = MAX;
     	lld sum = 0;
     	for(lld i = 1; i <= n; i++){
     		temp_sum -= (L+i-1);
     		if (max(temp_sum, orig_sum)-min(temp_sum,orig_sum) < min_diff){
     			min_diff =max(temp_sum, orig_sum)-min(temp_sum,orig_sum);
     			sum = temp_sum;
     		}
     		temp_sum += (L+i-1);
     	}
     	cout << sum;
      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

char a[1001][1001];
ll dp[1001][1001];

ll mod = 1e9 + 7;

int main(){
	IOS;
	int H,W;
	cin >> H >> W;
	for(int i=1; i <=H ; ++i){
		for(int j=1; j<=W ; ++j){
			cin >> a[i][j];
		} 
	}

	dp[1][1] = 1;
	for(int i=2;i<=H ; ++i){
		if(a[i][1]=='.')dp[i][1] = dp[i-1][1];
		else dp[i][1] = 0;
	}
	for(int i=2;i<=W ; ++i){
		if(a[1][i]=='.')dp[1][i] = dp[1][i-1];
		else dp[1][i] = 0;
	}

	for(int i=2;i<=H ; ++i){
		for(int j=2;j<=W ; ++j){
			if(a[i][j]=='#')dp[i][j] = 0;
			else{
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
				if(dp[i][j] >=mod) dp[i][j] -=mod;
			}
 		}
	}
	cout << dp[H][W] << endl;
}

Measured memory_bytes: 9088
using System;

class Program{
  static void Main(){
    int cardsize = int.Parse(Console.ReadLine());
    int cnumber = int.Parse(Console.ReadLine());
    int ctype;
    int[] card = new int[cardsize*2];
    int[] subcard = new int[cardsize*2];
    for(int m = 0;m<cardsize*2;m++){
      card[m] = m+1;
    }
    for(int n = 0;n<cnumber;n++){
      ctype = int.Parse(Console.ReadLine());
      if(ctype == 0){
        for(int i = 0;i<cardsize;i++){
            subcard[i*2] = card[i];
            subcard[i*2+1] = card[i+cardsize];
        }
        for(int l = 0;l<cardsize*2;l++){
          card[l] = subcard[l];
        }
      }else{
        for(int i = 0;i<cardsize*2-ctype;i++){
            subcard[i] = card[ctype+i];
        }
        for(int i = cardsize*2-ctype,c = 0;i<cardsize*2;i++,c++){
            subcard[i] = card[c];
        }
        for(int l = 0;l<cardsize*2;l++){
          card[l] = subcard[l];
        }
      }
    }
    for(int n = 0;n<cardsize*2;n++){
      Console.WriteLine(card[n]);
    }
  }
}

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  vint ans(26,INF);
  string ANS;
  int n;
  cin >> n;
  rep(i,n){
    string a;
    cin >> a;
    vint temp(26,0);
    rep(j,a.size()){
      temp[a[j]-97]++;
    }
    rep(j,26){
      ans[j] = min(ans[j],temp[j]);
    }
  }
  rep(i,26){
    while(ans[i] > 0){
      ANS.push_back(i+97);
      ans[i]--;
    }
  }
  cout << ANS << endl;
}

Measured memory_bytes: 256
N, V = list(map(int, input().split()))
C = list(map(int, input().split()))
N = len(C)

if sum(C)==V:
  print(N)
else:
  cnt = 0
  for c in sorted(C):
    if V-c>0:
      cnt += 1
      V -= c
    elif V-c==0:
      cnt += 1
      break
    else:
      break
  print(min(cnt, N-1))


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

int main()
{
    string s;
    cin >> s;
    if (s.at(0) != s.at(1) && s.at(1) != s.at(2) && s.at(2) != s.at(3))
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;
    return 0;
}


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

int main(){

    int n;
    cin>> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int ans=1e+4;
    rep(i,n){
        int cnt=0;
        while(a[i]%2==0){
            a[i]/=2;
            cnt++;
        }
        ans=min(ans,cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 10000000

int main(){
	char S;
	cin >> S;
	switch(S){
		case 'A' : cout << 'T' << endl; break;
		case 'T' : cout << 'A' << endl; break;
		case 'C' : cout << 'G' << endl; break;
		case 'G' : cout << 'C' << endl; break;
		
	}	
	return 0;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
K.times do |k|
    imosu = Array.new(N+1, 0)
    0.upto(N-1) do |i|
        # l = [i - a[i], 0].max
        # r = [i + a[i] + 1, N].min
        l = i - a[i]
        l = 0 if l < 0
        r = i + a[i] + 1
        r = N if r > N
        imosu[l] += 1
        imosu[r] += -1
    end
    s = 0
    all_n = true
    0.upto(N-1) do |i|
        s += imosu[i]
        a[i] = s
        all_n = false if a[i] != N
    end
    break if all_n
end
puts a.join(' ')

Measured memory_bytes: 80724
#include <iostream>
#include <string>

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

	for (int i = 0; i < n; ++i) {
		int point = 0;
		int baseCount = 0;
		int outCount = 0;
		
		std::string str;
		while (outCount <= 2) {
			std::cin >> str;

			if (str == "HIT") {
				if (baseCount >= 3)
					++point;
				else
					++baseCount;
			}
			else if (str == "HOMERUN") {
				point += baseCount + 1;
				baseCount = 0;
			}
			else if (str == "OUT")
				++outCount;
		}

		std::cout << point << std::endl;
	}
}

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

using namespace std;

int main() {
    int n, m;
    while (scanf("%d %d", &n, &m), n) {
        int sz = n - 1;
        vector<bool> checked(n, false);

        int cnt = 1;
        for (int i = 0; sz; i = (i + 1) % n) {
            if (checked[i]) continue;
            if (!(cnt++ % m)) sz--, checked[i] = true;
        }

        for (int i = 0; i < n; i++)
            if (!checked[i]) cout << ++i << endl;
    }

    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 1000000001
#define MAXW 1000000007
#define INF 1000000007
#define MAXN 100001
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


template<typename T>
T pow(T i, T n){
    T re;
    if(n == 0) return 1;
    re = pow(i, n / 2);
    if(n % 2 == 0){
        return re * re;
    }else{
        return i * re * re;
    }
}

template<typename T>
T mod_pow(T i, T n, T m){
    T re;
    if(n == 0) return 1;
    re = mod_pow(i, n / 2, m);
    if(n % 2 == 0){
        return (re * re) % m;
    }else{
        return ((i * re % m) * re) % m;
    }
}


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long 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 N;
int A[MAXN];

int main(){
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }

    sort(A, A + N);

    bool flag = false;
    if(N % 2){
        if(A[0] != 0) flag = true;
        for(int i = 1;i < N;i += 2){
            if(A[i] != A[i + 1] || A[i] != i + 1){
                flag = true;
            }
        }
    }else{
        for(int i = 0;i < N;i += 2){
            if(A[i] != A[i + 1] || A[i] != i + 1){
                flag = true;
            }
        }
    }

    if(flag){
        printf("0\n");
        return 0;
    }else{
        printf("%lld\n", mod_pow<ll>(2, N / 2, MOD));
        return 0;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> rsum(n+1), gsum(n+1), bsum(n+1);
  for (int i = 0; i < n; i++) {
    rsum[i+1] = rsum[i];
    gsum[i+1] = gsum[i];
    bsum[i+1] = bsum[i];
    if (s[i] == 'R') rsum[i+1]++;
    if (s[i] == 'G') gsum[i+1]++;
    if (s[i] == 'B') bsum[i+1]++;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != 'R') continue;
    for (int j = i + 1; j < n; j++) {
      if (s[j] != 'G') continue;
      ans += bsum[n] - bsum[j+1];
      if (j + (j - i) < n) {
        if (s[j+(j-i)] == 'B') ans--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != 'G') continue;
    for (int j = i + 1; j < n; j++) {
      if (s[j] != 'R') continue;
      ans += bsum[n] - bsum[j+1];
      if (j + (j - i) < n) {
        if (s[j+(j-i)] == 'B') ans--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != 'R') continue;
    for (int j = i + 1; j < n; j++) {
      if (s[j] != 'B') continue;
      ans += gsum[n] - gsum[j+1];
      if (j + (j - i) < n) {
        if (s[j+(j-i)] == 'G') ans--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != 'B') continue;
    for (int j = i + 1; j < n; j++) {
      if (s[j] != 'R') continue;
      ans += gsum[n] - gsum[j+1];
      if (j + (j - i) < n) {
        if (s[j+(j-i)] == 'G') ans--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != 'G') continue;
    for (int j = i + 1; j < n; j++) {
      if (s[j] != 'B') continue;
      ans += rsum[n] - rsum[j+1];
      if (j + (j - i) < n) {
        if (s[j+(j-i)] == 'R') ans--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != 'B') continue;
    for (int j = i + 1; j < n; j++) {
      if (s[j] != 'G') continue;
      ans += rsum[n] - rsum[j+1];
      if (j + (j - i) < n) {
        if (s[j+(j-i)] == 'R') ans--;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int dp[1009][1009];
vector<string>s;
#define ll long long
#define mod 1000000007
int r,c;
bool issafe(int i,int j)
{
    if(i>=0&&i<r&&j>=0&&j<c&&s[i][j]=='.')return 1;
    return 0;
}
int call(int i,int j)
{
    //cout<<i<<"  "<<j<<endl;
    if(i==r-1&&j==c-1)
    {
        //cout<<i<<"  "<<j<<endl;
        return 1;
    }
    if(dp[i][j]!=-1)return dp[i][j];
    int f1,f2;
    f1=f2=0;
    if(issafe(i+1,j))
        f1=call(i+1,j);
    if(issafe(i,j+1))
        f2=call(i,j+1);
    ll ans=(f1%mod+f2%mod)%mod;
    dp[i][j]=ans;
    return ans;
}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>r>>c;
    for(int i=0;i<r;i++)
    {
        string st;cin>>st;
        s.push_back(st);
    }
    ll ans=call(0,0);
    cout<<ans<<endl;
    //cout<<dp[0][0]<<endl;
}


Measured memory_bytes: 5376
r,c,k=map(int,input().split())
lst=[[0]*(c+1) for i in range(r+1)]
for i in range(k):
  s,t,u=map(int,input().split())
  lst[s][t]=u


dp1=[[0]*(c+1) for i in range(r+1)]
dp2=[[0]*(c+1) for i in range(r+1)]
dp3=[[0]*(c+1) for i in range(r+1)]

for i in range(1,r+1):
  for j in range(1,c+1):
    dp1[i][j]=max(dp1[i][j-1],dp1[i-1][j]+lst[i][j],dp2[i-1][j]+lst[i][j],dp3[i-1][j]+lst[i][j])
    dp2[i][j]=max(dp2[i][j-1],dp1[i][j-1]+lst[i][j])
    dp3[i][j]=max(dp3[i][j-1],dp2[i][j-1]+lst[i][j])

print(max(dp1[-1][-1],dp2[-1][-1],dp3[-1][-1],0))


Measured memory_bytes: 358684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

int calc(vector<string> c, int h, int w, int x , int y) {
  for (int i = 0; i < h; i++) {
    if ((x>>i) & 1) {
      for (int j = 0; j < w; j++) c[i][j] = '.';
    }
  }
  for (int j = 0; j < w; j++) {
    if ((y>>j) & 1) {
      for (int i = 0; i < h; i++) c[i][j] = '.';
    }
  }
  int ret = 0;
  rep(i, h) rep(j, w) if (c[i][j] == '#') ret++;
  return ret;
}

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

  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < (1<<h); i++) {
    for (int j = 0; j < (1<<w); j++) {
      if (k == calc(c, h, w, i, j)) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int
main()
{
    uint64_t x;
    cin >> x;

    uint64_t a = 100;
    uint64_t y = 1;
    while(1){
        a = a + (a/100);
        if(a >= x){
            cout << y << endl;
            return 0;
        }
        y++;
    }

    return 0;
}


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

using namespace std;

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(i < B){
                if(j < A){
                    cout << 1;
                }
                else{
                    cout << 0;
                }
            }
            else{
                if(j < A){
                    cout << 0;
                }
                else{
                    cout << 1;
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
from collections import Counter

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

c=Counter(a)

def eratosthenes(lim):
  is_p=[1]*lim
  is_p[0]=1
  is_p[1]=1

  for i in set(a):
    if is_p[i]:
      for j in range(i*2,lim,i):
        is_p[j]=0

  return is_p

lim=10**6+5
is_p=eratosthenes(lim)

cnt=0
for i in a:
  if is_p[i]==1 and c[i]==1:
    cnt+=1

print(cnt)

Measured memory_bytes: 53204
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 

using namespace std;

int main(){
	//freopen("input.txt", "r", stdin);

	ll h, a;
	cin>>h>>a;
	ll arr[a+5];

	ll  sum = 0;
	for(int i=0; i<a; i++){
		cin>>arr[i];
		sum += arr[i];
	}


	//cout<<"sum: "<<sum<<endl;

	if(sum >= h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
vector<PP> ANS;
void solve(ll x, ll y) {
    if(x + y > k * 2) {
        if(x > k)
            ANS.push_back({-k, 0}), solve(x - k, y);
        else
            ANS.push_back({0, -k}), solve(x, y - k);
    } else if(x + y == k) {
        ANS.push_back({-x, -y});
    } else {
        if((x + y) % 2 == 0) {
            if(y >= x) {
                a = (x + y) / 2;
                b = k - a;
                ANS.push_back({b, -a});
                ANS.push_back({-b - x, a - y});
            } else {
                a = (x + y) / 2;
                b = k - a;
                ANS.push_back({-a, b});
                ANS.push_back({a - x, -b - y});
            }
        } else {
            if(y < k) {
                ANS.push_back({k - y, -y});
                solve(x + k - y, 0);
            } else {
                ANS.push_back({-x, k - x});
                solve(0, y + k - x);
            }
        }
    }
}
int main() {
    cin >> k >> x >> y;
    c = 1, d = 1;
    if(x < 0) {
        c = -1, x = -x;
    }
    if(y < 0) {
        d = -1, y = -y;
    }
    corner(k % 2 == 0 && (x + y) % 2 == 1, -1);
    solve(x, y);
    x=0;
    y=0;
    cout<<ANS.size()<<endl;
    rep(i, ANS.size()) {
        x -= ANS[i].first;
        y -= ANS[i].second;
        cout << x * c << " " << y * d << endl;
    }
}

Measured memory_bytes: 14828
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N;
int a[110];

int calc(int x){
	int ans = 0;
	REP(i,N){
		ans+=(x-a[i])*(x-a[i]);
	}
	return ans;
}

int main(){
	scanf("%d",&N);
	int s = 0, t = 0;
	REP(i,N){
		scanf("%d",a+i);
	}
	int ans = 1000000000;
	for(int x = -100; x<=100; x++){
		ans = min(ans,calc(x));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//234 Coloring Colorfully
	int n;
	cin>>n;
	vi a(n),b(n),c(n-1);
	for(int &i:a)cin>>i;
	for(int &i:b)cin>>i;
	for(int &i:c)cin>>i;
	ll sum = 0;
	sum+=b[a[0]-1];
	REP(i,1,n-1) {
		sum+=b[a[i]-1];
		if(a[i]-a[i-1]==1) {
			sum+=c[a[i-1]-1];
		}
	}
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll a[200010];

int main(){
  int n;
  cin >> n;
  rep(i,n)cin >> a[i];
  ll res=0;
  ll sum=0,Xor=0;
  int right = 0;     
  for(int left=0;left<n;left++){
    while(right<n && sum+a[right]==(Xor^a[right])){
      sum += a[right];
      Xor^=a[right];
        right++;
    }
    res+=right-left;
    if(right==left)right++;
    else{
      sum-=a[left];
      Xor^=a[left];
    }
  }
  cout << res << endl;
return 0;}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 1020;
const int maxm = 1000020;
const int MOd = 998244353;

int a, b;
int ar[maxn], mask[maxn];
int dn[maxn][1<<13];

int f( int n, int s ) {
	if( n == b+1 ) {
		if( s == (1<<a)-1 ) return 0;
		return 1e9;
	}
	int &ret = dn[n][s];
	if( ret != -1 ) return ret;
	ret = f( n+1, s );
	umin( ret, f( n+1, s|mask[n] ) + ar[n] );
	// for(int i=0;i<a;i++)
	// 	if( (1<<i)&mask[n] ) {
	// 		umin( ret, f( n+1, s|(1<<i) ) + ar[n] );
	// 	}
	return ret;
}

void solve() {
	memset( dn, -1, sizeof( dn ) );
	scanf("%d %d",&a,&b);
	for(int i=1,k;i<=b;i++) {
		scanf("%d %d",&ar[i],&k);
		for(int j=1,t;j<=k;j++) {
			scanf("%d",&t);
			mask[i] |= 1<<(t-1);
		}
	}
	int ans = f( 1, 0 );
	if( ans >= 1e9 ) ans = -1;
	cout << ans << endl;
}

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("output17.txt","w",stdout);

	int n = 1;
	//scanf("%d",&n);
	while( n-- ) solve();

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin >> n;
    int mx = 0;
    map<string, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> s;
        cnt[s]++;
        mx = max(mx, cnt[s]);
    }
    vector<string> res;
    tr(cnt, it) {
        if (it->second == mx) res.pb(it->first);
    }
    sort(all(res));
    for (int i = 0; i < sz(res); i++) cout << res[i] << '\n';

    return 0;
}


Measured memory_bytes: 25584
s1 = gets.to_s.chomp
s2 = gets.to_s.chomp

result = false
for i in 0...s1.length do
    for j in 0...s1.length do
        work = s1[j]
        s1[j] = s1[-1]
        s1[-1] = work
    end
    if s1 == s2
        result = true
        break
    end
end

if result
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

main(){
	string s,t;
	cin>>s>>t;
	set<int>x[26],y[26];
	rep(i,s.size()){
		x[s[i]-'a'].insert(t[i]-'a');
		y[t[i]-'a'].insert(s[i]-'a');
	}
	rep(i,26){
		if(x[i].size()>1||y[i].size()>1){
			dump("No");
			return 0;
		}
	}
	dump("Yes");
}



Measured memory_bytes: 776
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        q: usize,
        arr: [(usize, usize); q],
    }

    let mut prime_flag = vec![true; 100_001];
    for i in 2..100_001 {
        if !prime_flag[i] { continue; }
        for j in 2..=100_000/i {
            prime_flag[j*i] = false;
        }
    }
    prime_flag[0] = false;
    prime_flag[1] = false;

    let primes: Vec<usize> = prime_flag.iter().enumerate()
        .filter_map(|(i, &v)| if v { Some(i) } else { None }).collect();
    let mut cnt: Vec<usize> = vec![0; 100_000];
    for &p in &primes {
        let idx = 2*p-1;
        if idx < 100_001 && prime_flag[idx] {
            for i in idx..100_000 { cnt[i] += 1; }
        }
    }
    for &(l, r) in &arr {
        let ans = cnt[r] - cnt[l-1];
        println!("{}", ans);
    }
}


Measured memory_bytes: 5752
# -*- coding: utf-8 -*-
from itertools import permutations

N = int(input().strip())
pat_P = [ "".join( input().rstrip().split() )][0]
pat_Q = [ "".join( input().rstrip().split() )][0]
#-----

perm_list = [ "".join( map(str, pat) ) for pat in permutations(range(1,N+1))]
perm_list.sort()

a = perm_list.index(pat_P) + 1
b = perm_list.index(pat_Q) + 1
print(abs(a-b))


Measured memory_bytes: 6040
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

    return 0;
}

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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        mp[A[i]]++;
    }

    int ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int key = itr->first;
        int val = itr->second;

        if (val < key) ans += val;
        else if (val > key) ans += val - key;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	string t;
	cin >> s >> t;
	t.pop_back();
	if (s == t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vvec<char> S(H,vec<char>(W));
    vec<int> C(H,0);
    vvec<int> ans(H,vec<int>(W,0));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        cin >> S[i][j];
        C[i] += (S[i][j]=='#');
    }
    int cnt = 1;
    for(int i=0;i<H;i++){
        int c = 0;
        if(C[i]==0) continue;
        for(int j=0;j<W;j++){
            ans[i][j] = cnt;
            if(S[i][j]=='#'){
                c++;
                if(c!=C[i]) cnt++;
            }
        }
        cnt++;
    }

    for(int i=0;i<H;i++) if(C[i]==0){
        if(i==0){
            for(int k=1;k<H;k++) if(ans[k][0]!=0){
                for(int j=0;j<W;j++) ans[i][j] = ans[k][j];
                break;
            }
        }else{
            for(int j=0;j<W;j++) ans[i][j] = ans[i-1][j];
        }
    }
    assert(cnt-1==K);
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cout << ans[i][j] << (j!=W-1? " ":"\n");
}

Measured memory_bytes: 1280
#include <stdio.h>

int main()
{
    int n,x,ans=1,a=0;
    scanf("%d %d",&n,&x);
    int l[n];
    for(int i=0;i<n;i++){
        scanf("%d",&l[i]);
        a+=l[i];
        if(a<=x) ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
/**
 * author  : UshanGhosh
 * created : 2020-09-19 17:10:13
**/ 

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     (int)1e9+7
#define    inf     (long long)1e18
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    cout<<1-n<<" ";
}

Measured memory_bytes: 3636
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  int X[N];
  int Y[N];
  int A;
  for(int i = 0; i < N; i++) cin >> A, X[i] = A,Y[i] = A;
  sort(X,X+N);
  int B = X[N/2-1];
  int C = X[N/2];

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

}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans=300;
  int part_1=abs(a-max(b,c))+abs(max(b,c)-min(b,c));
  int part_2=abs(b-max(c,a))+abs(max(c,a)-min(c,a));  
  int part_3=abs(c-max(a,b))+abs(max(a,b)-min(a,b)); 
  ans=min(part_1,min(part_2,part_3));
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), cnt = 0, p = 100;
	while(p < n) p *= 1.01, cnt++;
	cout<<cnt<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, s;
	cin >> s;
	a = s / 1000;
	b = (s - a * 1000) / 100;
	c = (s - a * 1000 - b * 100) / 10;
	d = (s - a * 1000 - b * 100 - c * 10);
	if (a + b + c + d == 7) {
		cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
	}
	else if (a + b + c - d == 7) {
		cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
	}
	else if (a + b - c + d == 7) {
		cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
	}
	else if (a + b - c - d == 7) {
		cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
	}
	else if (a - b + c + d == 7) {
		cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
	}
	else if (a - b + c - d == 7) {
		cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
	}
	else if (a - b - c + d == 7) {
		cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
	}
	else if (a - b - c - d == 7) {
		cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        long x,a=100,c=0,d;
        x=in.nextLong();
        while(a<x)
        {
            d=(a*1)/100;
            a=a+d;
            c=c+1;
        }
        System.out.println(c);
    }
}



Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000000+7;

int main() {
  int n,k;
  cin >> n >> k;
  vector<bool> v(n+1,true);
  v.at(0) = false;

  for (int i=0; i<k; i++) {
    int d;
    cin >> d;
    for (int j=0; j<d; j++) {
      int a;
      cin >> a;
      v.at(a) = false;
    }
  }

  int ans=0;
  for (int i=1; i<n+1; i++) {
    ans += v.at(i);
  }

  cout << ans << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	int n, m;
	cin >> n >> m;
	vi v(m);
	for(int i = 0; i < m; i++) cin >> v[i];
	sort(all(v));
	vi raz;
	for(int i = 0; i < m - 1; i++){
		raz.push_back(abs(v[i] - v[i + 1]));
	}
	sort(all(raz));
	reverse(all(raz));
	ll res = 0;
	for(int i = n - 1; i < raz.size(); i++){
		res += raz[i];
	}
	cout << res;
}

Measured memory_bytes: 1276