akhauriyash/Code-Regression huggingface dataset:
//
// Created by 李青坪 on 2018/10/29.
//

#include <cstdio>
#include <algorithm>
#include <string>
#include <iostream>

#define MAXN 150
#define MAXLEN 1000
using namespace std;

int c[MAXLEN+1][MAXLEN+1];

int getSubsequence(string x, string y){
    int i = 0, j = 0;
    while (i <= x.length()){
        while (j <= y.length()){
            if (i == 0 || j ==0){
                c[i][j] = 0;
            } else if (x[i-1] == y[j-1]){
                c[i][j] = c[i-1][j-1] + 1;
            } else if (x[i-1] != y[j-1]){
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            ++j;
        }
        ++i;
        j = 0;
    }
    return c[x.length()][y.length()];
}

int main(){
    int n;
    scanf("%d", &n);
    string x, y;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        printf("%d\n", getSubsequence(x, y));
    }

}
/*
3
abcbdab
bdcaba
abc
abc
abc
bc
 */


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int h, n;
	cin>>h>>n;
	int s = 0, v;
	for (int i = 0; i < n; i++) {
		cin>>v;
		s += v;
	}
	cout<<((s >= h) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

vector<string> g[300][300];
int n;

struct P {
  int now;
  string s;
  P(int now, string s) :
    now(now), s(s) {}
};

bool operator<(const P &e, const P &f) {
  return e.s != f.s ? e.s > f.s : e.now<f.now;
}

// a<b:1 a>b:-1 a<>b:0(undifined)
int lessthan(const string &a, const string &b) {
  REP(i, min(a.size(), b.size()))
    if (a[i]!=b[i]) return a[i]<b[i]?1:-1;
  return 0;
}

bool canGo[40][40];

string dijkstra(int a, int t) {
  set<string> dist[n];
  priority_queue<P> Q; // "e < f" <=> "e.weight > f.weight"
  dist[a].insert("");
  map<P, bool> visited;
  for (Q.push(P(a, "")); !Q.empty(); ) {
    P p = Q.top(); Q.pop();
    string s = p.s;
    int now = p.now;

    //cout << now << " " << s << " " << visited[p] << endl;
    if (visited[p]) continue;
    visited[p] = 1;
    
    if (s.size() > n*6) return "NO";
    if (now == t) return s;
    if (lessthan(*dist[now].begin(), s) == 1) continue;
    
    REP(i, n) {
      if (canGo[i][t] || i==t) {
        FOR(it, g[now][i]) {
          if (dist[i].size() == 0) {
            dist[i].insert(s+*it);
            Q.push(P(i,s+*it));
          } else {
            int a = lessthan(s+*it, *dist[i].begin());
            if (a == 1) {
              dist[i].clear();
              dist[i].insert(s+*it);
              Q.push(P(i,s+*it));
            } else if (a == 0) {
              dist[i].insert(s+*it);
              Q.push(P(i,s+*it));
            }
          }
        }
      }
    }
  }
  return "NO";
}


int main() {
  int m,s,t;
  int NN = 0;
  while(cin>>n>>m>>s>>t,n) {
    if (NN++==15) {
      // cout << n << " " << m << " " << s << " " << t << endl;
    }
    REP(i,n)REP(j,n) g[i][j] = vector<string>();
    memset(canGo,0,sizeof(canGo));
    REP(i, m) {
      int a,b;string s;
      cin >> a>> b>> s;
      g[a][b].push_back(s);
      canGo[a][b] = 1;
    }
    REP(k,n) REP(i,n) REP(j,n) {
      if (canGo[i][k]&&canGo[k][j]) canGo[i][j] = 1;
    }
    
    cout << dijkstra(s,t) << endl;
  }
}

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

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

    queue<unsigned long> que;
    que.push(0);

    unsigned long ans{0};

    while(!que.empty()){
        auto t = que.front();
        que.pop();
        if(t > N)break;
        que.push(t * 10 + 3);
        que.push(t * 10 + 5);
        que.push(t * 10 + 7);

        auto k = 0;
        while(t){
            k |= 1 << (t % 10);
            t /= 10;
        }
        if(k == 168)++ans;
    }

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

Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
  char input[2][4];
  if(scanf("%s %s",input[0],input[1]));
  int num=atoi(strcat(input[0],input[1]));
  if(sqrt(num)==(int)sqrt(num))
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int arr[b],ans=0;
    for(int i=0;i<b;i++)
        cin>>arr[i];
    while(a--)
    {
        int sum=c;
        for(int i=0;i<b;i++)
        {
            int x;
            cin>>x;
            sum+=x*arr[i];
        }
        if(sum>0)
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x = abs(a-b);
    int y = abs(b-c);
    int z = abs(a-c);

    if(x <= d && y <= d)
    {
        cout << "Yes" << endl;
    }
    else if(z <= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
l, r = map(int, input().split())

if r - l >= 2019:
    print(0)
else:
    ans = 2018
    for i in range(l, r + 1):
        for j in range(l, r + 1):
            if i >= j:
                continue
            else:
                ans = min(ans, i * j % 2019)

    print(ans)


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

using namespace std;

void change(int *x, int *y);
void BubbleSort(struct Card c[], int n);
void SelectionSort(struct Card c[], int n);
bool isStable(struct Card c1[], struct Card c2[], int n);
void print(struct Card c[], int n);

struct Card{
		char suit, value;
};

int main(void)
{
	int n;
	Card c1[36], c2[36];
	
	cin >> n;
	for(int i = 0; i < n; ++i)
		cin >> c1[i].suit >> c1[i].value;
	for(int i = 0; i < n; ++i) c2[i] = c1[i];
	BubbleSort(c1, n);
	SelectionSort(c2, n);
	
	print(c1, n);
	cout << "Stable" << endl;
	print(c2, n);
	if(isStable(c1, c2, n))
		cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}

void change(struct Card *x, struct Card *y){
	struct Card tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
	
}

void BubbleSort(struct Card c[], int n){
	bool flag = true;
	while(flag){
		flag = false;
		for(int i = n - 1; i > 0; --i){
			if(c[i].value < c[i-1].value){
				change(&c[i], &c[i-1]);
				flag = true;
			}
		}
	}
}

void SelectionSort(struct Card c[], int n){
	int min;
	for(int i = 0; i < n; ++i){
		min = i;
		for(int j = i; j < n; ++j)
			if(c[min].value > c[j].value) min = j;
		change(&c[min], &c[i]);
	}
}

bool isStable(struct Card c1[], struct Card c2[], int n){
	for(int i = 0; i < n; ++i){
		if(c1[i].suit != c2[i].suit) return false;
	}
	return true;
}

void print(struct Card c[], int n){
	for(int i = 0; i < n; ++i){
		if(i > 0) cout << ' ';
		cout << c[i].suit << c[i].value;
	}
	cout << endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cmath>
#define casti static_cast<int>
using namespace std;

long long x;

int main() {
	cin >> x;
	bool flag = false;
	for (long long a=-1000; a<=1000; a++) {
		for (long long b=-1000; b<=1000; b++) {
			if (casti(pow(a, 5) - pow(b, 5)) == x) {
				cout << a << ' ' << b << "\n";
				flag = true;
				break;
			}
		}
		if (flag) break;
	}
}

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

using namespace std;
typedef long long ll;

ll N;
ll a[100000][3];
ll dp[100000][3];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = 0;
        }
    }
    for(int i=0;i<3;i++) dp[0][i] = a[0][i];
    for(int i=1;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k) continue;
                dp[i][j] = max(dp[i-1][k]+a[i][j], dp[i][j]);
            }
        }
    }
    cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << endl;
    return 0;
}

Measured memory_bytes: 4992
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    a = ri()
    b = ri()
    num = [True for _ in range(4)]
    num[a] = False
    num[b] = False
    for i in range(1, 4):
        if num[i]:
            print(i)

if __name__ == '__main__':
    main()


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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    vi a(n);
    forn(i, n) cin >> a[i];
    int s = 0;
    forn(i, n) s += a[i]; 
    sort(all(a), greater<int>());
    cout << (a[m-1]*4*m < s ? "No" : "Yes") << endl; 

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

N, *P = map(int, read().split())

class UnionFind:
    def __init__(self, N):
        self.root = list(range(N))
        self.size = [1] * (N)
        self.has_loop = [False] * N

    def __getitem__(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def merge(self, x, y):
        x = self[x]
        y = self[y]
        if x == y:
            self.has_loop[x] = True
            return False
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            x, y = y, x
            sx, sy = sy, sx
        self.root[y] = x
        self.size[x] += sy
        self.has_loop[x] |= self.has_loop[y]
        return True

uf = UnionFind(N + 1)
for i, x in enumerate(P, 1):
    if x == -1:
        continue
    uf.merge(i, x)

loop = 0
sizes = []
for v in range(1, N + 1):
    if v != uf[v]:
        continue
    if uf.has_loop[v]:
        loop += 1
    else:
        sizes.append(uf.size[v])

S = len(sizes)

f = np.zeros(S + 10, np.int64)
f[0] = 1
for x in sizes:
    f[1:] += x * f[:-1]
    f %= MOD
f[1] -= S

fact = np.empty(N + 1, np.int64)
fact[0] = 1
for n in range(1, N + 1):
    fact[n] = n * fact[n - 1] % MOD
power = np.empty(N + 1, np.int64)
power[0] = 1
for n in range(1, N + 1):
    power[n] = (N - 1) * power[n - 1] % MOD

coef = fact[:S] * power[:S][::-1] % MOD

x = (f[1:S+1] * coef % MOD).sum() % MOD
x += loop * pow(N-1, S, MOD) % MOD

x = N * pow(N-1, S, MOD) - x
x %= MOD
print(x)

Measured memory_bytes: 27972
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    

    int[] n = new int[3];
    n[0] = sc.nextInt();
    n[1] = sc.nextInt();
    n[2] = sc.nextInt();

    sc.close();

    Arrays.sort(n);

    int n1 = n[0] + n[1] + n[2];
    int n2 = n[2] * 3;
    int n3 = 0;
    
    if (n1 % 2 == n2 % 2) {
      n3 = n[2];
    } else {
      n3 = n[2] + 1;
    }

    int count = 0;

    if (n3 != n[2]) {
      n[2]++;
      if (n[0] % 2 == 0) {
        n[0]++;
      } else {
        n[1]++;
      }
      count++;
    }

    while (n[1] != n3){
      if (n3 - n[1] == 1) {
        n[1]++;
        n[0]++;
      } else {
        n[1] += 2;
      }
      count++;
    }

    while (n[0] != n3){
      n[0] += 2;
      count++;
    }
    
    System.out.println(count);

  }

}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int a[200000];
int b[200000];
ll c[200001];
ll d[200001];

int main() {
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        c[i + 1] = c[i] + a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        d[i + 1] = d[i] + b[i];
    }
    for (int i = 0; i <= n; ++i) {
        if (c[i] > k)
            continue;
        int t = upper_bound(d, d + m + 1, k - c[i]) - d;
        chmax(ans, i + t - 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8316
import Data.Array.IO
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

type Memo = IOUArray (Int, Int) Int
type Road = IOUArray (Int, Int) Bool

main = do
  n <- readLn :: IO Int
  input <- concat <$> getIntListBC :: IO [Int]
  let index = [(i, j, k) | i <- [1..n], j <- [i+1..n], k <- [1..n], j /= k, k /= i]
  memo <- newListArray ((1, 1), (n, n)) input :: IO Memo
  road <- newArray ((1, 1), (n, n)) True :: IO Road
  memo' <- foldM (memoizeWF road) memo index
  ans <- getElems memo'
  if input /= ans then putStrLn "-1"
                  else do
                    necessary <- getElems road
                    print $ flip div 2 . sum $ zipWith (\x y -> if x then y else 0) necessary ans

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [[Int]]
getIntListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

memoizeWF :: Road -> Memo -> (Int, Int, Int) -> IO (Memo)
memoizeWF road memo (i, j, k) = do
  let (ii, jj) = if i < j then (i, j) else (j, i)
  b <- readArray road (ii, jj)
  x <- readArray memo (ii, jj)
  y <- readArray memo (ii, k)
  z <- readArray memo (k, jj)
  let minWeight = min x $ y + z
  writeArray road (ii, jj) $ b && x < y + z
  writeArray memo (ii, jj) minWeight
  writeArray road (jj, ii) $ b && x < y + z
  writeArray memo (jj, ii) minWeight
  return memo


Measured memory_bytes: 23932
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b)/2<<endl;
    
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,A[1000010],B[1000010],pre[100010],ans,cnt[100010];
vector<int> r[100010],c[100010];
set<int> S[2][100010];
int Find(int x){
	if(pre[x]==x)return x;
	return pre[x]=Find(pre[x]);
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=1e5;i++)pre[i]=i;
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&A[i],&B[i]);
		r[A[i]].push_back(i);
		c[B[i]].push_back(i);
	}
	//for(int j=0;j<c[1].size();j++)cout<<c[1][j]<<" ";
	for(int i=1;i<=n;i++){
		int x=A[i],y=B[i];
		if(r[x].size()>=2&&c[y].size()>=2){
			for(int j=0;j<r[x].size();j++){
				int fx=Find(r[x][j]),fy=Find(i);
				//if(fx==fy)continue;
				pre[fx]=fy;
				//cout<<r[x][j]<<" ";
			}
			for(int j=0;j<c[y].size();j++){
				int fx=Find(c[y][j]),fy=Find(i);
				//if(fx==fy)continue;
				pre[fx]=fy;
				//cout<<c[x][j]<<" ";
			}
		}
	}
	for(int i=1;i<=n;i++){
		int f=Find(i);
		S[0][f].insert(A[i]);
		S[1][f].insert(B[i]);
		cnt[f]++;
	}
	//for(int i=1;i<=n;i++)cout<<Find(i)<<" "<<cnt[i]<<endl;
	for(int i=1;i<=n;i++){
		if(S[0][i].size()>1){
			ans+=(S[0][i].size()*S[1][i].size())-cnt[i];
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

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

    int n,k;
    cin>>n>>k;
    if(n%k == 0)cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

int total_ways(vector<int> &v, int n) {

    sort(v.begin(), v.end());
    n = n / 2 - 1;

    return (v[n + 1] - v[n]);
}

int main() {
    int n;

    cin >> n;
    vector<int> v(n);

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

    int r = total_ways(v, n);

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
N=int(input())
lst=[[] for _ in range(N)]
for i in range(N):
  for j in range(int(input())):
    x,y=map(int,input().split())
    x-=1
    lst[i].append([x,y])
ans=0
for i in range(2**N):
  honest=[]
  unkind=[]
  flag=0
  for j in range(N):
    if (i>>j)&1:        # jは正直者
      honest.append(j)
    else:
      unkind.append(j)
  for p in honest:
    for l in lst[p]:
      x,y=l[0],l[1]
      if y:
        if x in unkind:
          flag=1
          break
      else:
        if x in honest:
          flag=1
          break
  if flag!=1:
    ans=max(ans,len(honest))
print(ans)

Measured memory_bytes: 3064
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define debug(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int n;
int arr[maxn];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    File();
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    vector<int>dp(n+1,oo);
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=1; i<n; i++)
        for(int j=1; j<=i and j<=2; j++)
            dp[i] = min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));

    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod = numeric_limits<ll>::max()) {
  assert(n >= 0);
  if (n == 0) return 1;
  return power(x * x % mod, n / 2, mod) * (n % 2 ? x : 1) % mod;
}
ll inv(ll x, ll p = mod) {
  assert((x %= p) != 0);
  return power(x, p - 2, p);
}
ll comb(ll n, ll r, ll mod = 0) {
  assert(n >= 0 and r >= 0);
  if (r > n) return 0;
  r = min(r, n - r);
  ll res = 1;
  if (mod) for (ll i = 0; i < r; i++) res = res * (n - i) % mod * inv(i + 1) % mod;
  else for (ll i = 0; i < r; i++) res = res * (n - i) / (i + 1);
  return res;
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll h, w, a, b; cin >> h >> w >> a >> b;
  ll res = comb(h + w - 2, h - 1, mod);
  if (a < b) {
    swap(a, b);
    swap(h, w);
  }
  vector<ll> former(b), latter(b);
  former[0] = comb(h - a + b - 1, 0, mod);
  latter[0] = comb(w + a - b - 1, a - b, mod);
  for (ll i = 0; i < b - 1; i++) {
    former[i + 1] = former[i] * (h - a + b - 1 - i) % mod * inv(i + 1) % mod;
    latter[i + 1] = latter[i] * (w - i - 1) % mod * inv(a - b + i + 1) % mod;
  }
  for (ll i = 0; i < b; i++) cerr << former[i] << " " << latter[i] << "\n";
  for (ll i = 0; i < b; i++) res = (res + mod - former[i] * latter[i] % mod) % mod;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[11][2][2][2][2];//dp[i][j][3][5][7] i桁　j：flag

int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           int n=s.size();
           dp[0][0][0][0][0]=1;
           rep(i,1,n+1)rep(a,0,2)rep(b,0,2)rep(c,0,2){
             int h=s[i-1]-'0';
             rep(l,0,10){
              if(l!=3&&l!=5&&l!=7&&l!=0)continue;
               if(l==3){
                 if(a-1>=0){
                   dp[i][1][a][b][c]+=dp[i-1][1][0][b][c]+dp[i-1][1][1][b][c];
                   if(l<h)dp[i][1][a][b][c]+=dp[i-1][0][0][b][c]+dp[i-1][0][1][b][c];
                   if(l==h)dp[i][0][a][b][c]+=dp[i-1][0][0][b][c]+dp[i-1][0][1][b][c];
                           }
               }
               if(l==5){
                 if(b-1>=0){
                   dp[i][1][a][b][c]+=dp[i-1][1][a][b][c]+dp[i-1][1][a][b-1][c];
                   if(l<h)dp[i][1][a][b][c]+=dp[i-1][0][a][b][c]+dp[i-1][0][a][b-1][c];
                   if(l==h)dp[i][0][a][b][c]+=dp[i-1][0][a][b][c]+dp[i-1][0][a][b-1][c];
                           }
               }
               if(l==7){
                 if(c-1>=0){
                   dp[i][1][a][b][c]+=dp[i-1][1][a][b][c]+dp[i-1][1][a][b][c-1];
                   if(l<h)dp[i][1][a][b][c]+=dp[i-1][0][a][b][c]+dp[i-1][0][a][b][c-1];
                   if(l==h)dp[i][0][a][b][c]+=dp[i-1][0][a][b][c]+dp[i-1][0][a][b][c-1];
                           }
               }
              if(l==0){
                 if(a==0&&b==0&&c==0)
                dp[i][1][a][b][c]+=1;
               }
               //cout<<i<<" "<<l<<"  "<<a<<" "<<b<<" "<<c<<"  "<<dp[i][0][a][b][c]<<" "<<dp[i][1][a][b][c]<<endl;
             }
           }
           int ans=0;
           ans=dp[n][0][1][1][1]+dp[n][1][1][1][1];
           cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N), B(N), C(M), D(M);
    REP(i, 0, N) cin >> A[i] >> B[i];
    REP(i, 0, M) cin >> C[i] >> D[i];

    REP(i, 0, N) {
        int dist = 1 << 30, checkpoint;
        REP(j, 0, M) {
            if (dist > abs(A[i] - C[j]) + abs(B[i] - D[j])) {
                dist = abs(A[i] - C[j]) + abs(B[i] - D[j]);
                checkpoint = j;
            }
        }
        cout << checkpoint + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int n,k;
long long  a[2005][2005];
const long long  N=(long long )1e9+7;
int main ()
{
    cin>>n>>k;
        a[0][0]=1;
    for(int i=1;i<2000;i++)
    {
        a[i][0]=1;
        for(int j=1;j<=2000;j++)
        {
            a[i][j]=(a[i-1][j-1]+a[i-1][j])%N;
        }
    }
    for(int i=1;i<=k;i++)
        cout<<a[k-1][i-1]*a[n-k+1][i]%N<<endl;





    return 0;
}


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

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

using namespace std;

int main(){
	string s; cin>>s;
	bool f[128]={};
	for(char c:s) f[c]=true;

	for(char c='a';c<='z';c++) if(!f[c]) return cout<<c<<endl,0;
	cout<<"None"<<endl;

	return 0;
}


Measured memory_bytes: 512
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>

using namespace std;
typedef string::const_iterator State;
const long double Ma_PI = 3.1415926535897932384626433832795028841971L;
#define eps 1e-7
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
typedef struct BigInt{
    string s = "0";
    BigInt operator +(BigInt obj) {
        string c;
        while (max(obj.s.length(), this->s.length()) + 1 > c.length()) {
            c.pb('0');
        }
        for (int q = 0; q < obj.s.length(); ++q) {
            c[c.length() - 1 - q] = obj.s[obj.s.length() - q - 1];
        }
        for (int q = 0; q < this->s.length(); ++q) {
            c[c.length() - 1 - q] += this->s[this->s.length() - 1 - q] - '0';
            if (c[c.length() - 1 - q] > '9') {
                c[c.length() - 2 - q]++;
                c[c.length() - 1 - q] -= 10;
            }
        }
        if (c.front() == '0') {
            c.erase(c.begin());
        }
        return BigInt{ c };
    }
    BigInt operator *(BigInt obj) {
        BigInt ans;
        for (int i = this->s.length() - 1; i >= 0; --i) {
            REP(q, this -> s[i] - '0') {
                ans = ans + obj;
            }
            obj.s.pb('0');
        }
        return ans;
    }
}BigInt;

void solve() {
    string s;
    cin >> s;
    cout << (char)((s[0] - 'a' + 1) % 26 + 'a') << endl;
}

int main() {
    init();
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a<=b)
    {
        for(i=0;i<b;i++)
        {
            cout<<a;
        }
    }
    else{
        for(i=0;i<a;i++)
        {
            cout<<b;
        }

    }

}


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

typedef long long ll;
const ll INF = 1LL << 60;

ll N;
vector<ll> dp, h;

int main() {
    // cout << INF << endl;
    // return 0;
    cin >> N;
    h.resize(N);
    dp.resize(N + 5);

    rep(i, N) cin >> h[i];
    rep(i, N + 5) dp[i] = INF;

    dp[0] = 0;

    rep(i, N) {
        if (i + 1 <= N - 1) {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        }
        if (i + 2 <= N - 1) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
        }
    }

    cout << dp[N - 1] << endl;
    // rep(i, N) {
    //     cout << dp[i] << endl;
    // }
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 3e5 + 205;
const int INF = 0x3f3f3f3f; 
using namespace std;

int n, m, k, stk1[N], stk2[N], top1, top2, ans; 
struct node
{
	int x, y;
	node(int a = 0, int b = 0) { x = a, y = b; }
	bool operator == (const node &p) const
		{
			return x == p.x && y == p.y; 
		}
} a[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

namespace SegTree
{
	struct Tree { int mx, tag; } t[N << 2]; 
	void pushup(int p) { t[p].mx = max(t[p << 1].mx, t[p << 1 | 1].mx) + t[p].tag; }
	void build(int p, int l, int r)
	{
		t[p].tag = 0; 
		if(l == r) return (void) (t[p].mx = -a[l].x); 
		int mid = (l + r) >> 1; 
		build(p << 1, l, mid), build(p << 1 | 1, mid + 1, r); 
		pushup(p); 
	}
	void modify(int p, int l, int r, int ql, int qr, int k)
	{
		if(ql > qr) return; 
		if(ql <= l && r <= qr) return (void) (t[p].tag += k, t[p].mx += k);
		int mid = (l + r) >> 1;
		if(ql <= mid) modify(p << 1, l, mid, ql, qr, k);
		if(mid < qr) modify(p << 1 | 1, mid + 1, r, ql, qr, k);
		pushup(p); 
	}
	int query(int p, int l, int r, int ql, int qr)
	{
		if(ql <= l && r <= qr) return t[p].mx; 
		int mid = (l + r) >> 1, ans = -INF; 
		if(ql <= mid) ans = query(p << 1, l, mid, ql, qr); 
		if(mid < qr) ans = max(ans, query(p << 1 | 1, mid + 1, r, ql, qr));
		return ans + t[p].tag; 
	}
};

bool cmp1(node a, node b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }

void solve()
{
	sort(a + 1, a + k + 1, cmp1), SegTree :: build(1, 1, k), top1 = top2 = 0;
	for(int i = 1; i <= k; i++)
	{
		if(i > 1) SegTree :: modify(1, 1, k, i - 1, i - 1, m);
		if(i > 1) ans = max(ans, a[i].x + SegTree :: query(1, 1, k, 1, i - 1));
		if(a[i].y >= m / 2)
		{
			if(!top1) SegTree :: modify(1, 1, k, 1, i - 1, a[i].y - m); 
			else SegTree :: modify(1, 1, k, stk1[top1], i - 1, a[i].y - m); 
			while(top1 && a[i].y < a[stk1[top1]].y)
				SegTree :: modify(1, 1, k, max(stk1[top1 - 1], 1), stk1[top1] - 1, a[i].y - a[stk1[top1]].y), top1--;
			stk1[++top1] = i; 
		}
		else
		{
			if(!top2) SegTree :: modify(1, 1, k, 1, i - 1, -a[i].y); 
			else SegTree :: modify(1, 1, k, stk2[top2], i - 1, -a[i].y); 
			while(top2 && a[i].y > a[stk2[top2]].y)
				SegTree :: modify(1, 1, k, max(stk2[top2 - 1], 1), stk2[top2] - 1, a[stk2[top2]].y - a[i].y), top2--;
			stk2[++top2] = i; 
		}
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> (), m = read <int> (), k = read <int> (); 
	for(int i = 1; i <= k; i++) a[i].x = read <int> (), a[i].y = read <int> (); 
	a[++k] = node(0, 0), a[++k] = node(n, m);
	sort(a + 1, a + k + 1, cmp1), k = unique(a + 1, a + k + 1) - a - 1; 
	solve(), swap(n, m); 
	for(int i = 1; i <= k; i++) swap(a[i].x, a[i].y); 
	solve(), printf("%d\n", 2 * ans); 
	return 0; 
}


Measured memory_bytes: 14368
#include <bits/stdc++.h>    
using namespace std;
 
#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
 
int main(){
    CIN1(x) 
    cout << ((x==7||x==5||x==3)?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <int> A(1 << n);
	for (int i = 0; i < (1 << n); i++) {
		cin >> A[i];
	}
	auto cmp = [&](int x, int y) {
		return A[x] > A[y];
	};
	vector <pair<int, int>> F(1 << n, {0, 0});
	F[0] = {0, 0};
	for (int mask = 1; mask < (1 << n); mask++) {
		vector <int> cur;
		for (int i = 0; i < n; i++) {
			if((mask & (1 << i)) != 0) {
				int x = (mask ^ (1 << i));
				cur.push_back(F[x].ff);
				cur.push_back(F[x].ss);
			}
		}
		cur.push_back(mask);
		sort(all(cur), cmp);
		cur.resize(unique(all(cur)) - cur.begin());
		F[mask] = {cur[0], cur[1]};
	}
	int now = 0;
	for (int i = 1; i < (1 << n); i++) {
		now = max(now, A[F[i].ff] + A[F[i].ss]);
		cout << now << "\n";
	}
}


Measured memory_bytes: 6144
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

int main(void)
{
	//変数の宣言
	ll int n;

	//よく使う変数
	int i,j,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%lld",&n);
//	scanf_s("%lld",&n);

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	ans=100;

	for(i=1;i<sqrt(n)+1;i++){
		if(n%i==0){
			count=0;
			temp=n/i;
			while(temp!=0){
				temp=temp/10;
				count++;
			}
			ans=min(ans,count);
		}
	}


	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



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

int main(void){
	int len;
	char str[11], s[11] = {0};

	scanf("%s", str);

	for(int i=0; str[i] != '\0'; i++) {
		if(str[i] == 'B') {
			len = strlen(s);
			if(len == 0)
				s[0] = '\0';
			else
				s[len-1] = '\0';
		}else{
			strncat(s, str+i, 1);
		}
	}
	printf("%s", s);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
double startTime;
double getCurrentTime()
{
	return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

lli pwr(lli x,lli n)
{
	lli res=1;
	for(; n!=0;n>>=1)
	{
		if(n&1)
			res=(res*x)%MOD;
		x=(x*x)%MOD;
	}
	return res;
}
lli inver(lli num)
{
	return pwr(num,MOD-2);
}
lli findncr(lli n,lli r)
{
	r=min(r,n-r);
	if(n==0||n==1||r==0)
		return 1;
	lli numer=1;
	for(lli i=n;i>=n-r+1;i--)
		numer=(numer*i)%MOD;
	lli den=1;
	for(lli i=2;i<=r;i++)
		den=(den*i)%MOD;
	den=inver(den);
	lli res=(numer*den)%MOD;
	return res;
}
lli gcd(lli a,lli b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	int n,k;
	cin>>n>>k;
	vector<int>vec(n+1,0);
	fr2(i,n)
	cin>>vec[i];
	vector<int>win(k+1,2);
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(vec[j]-i>0)
				continue;
			else
			{
				if(win[i-vec[j]]==2)
					win[i]=1;
			}
		}
	}
	auto p =win[k]==1 ? "First":"Second";
	cout<<p<<endl;
}


Measured memory_bytes: 640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int dp[8][1002]= {};

long long int saiki(int now, int x, string str)
{
	if (str.size() == x)
	{
		return 1;
	}

	int c = str[x]=='J'?1:str[x]=='O'?2:4;

	long long int count = 0;
	if (now&c)
	{
		for (int i = 1; i < 8; i++)
		{
			if (i&c)
			{
				if (dp[i][x + 1] == 0)
				{
					dp[i][x + 1] = saiki(i, x + 1, str);
				}
				count += dp[i][x + 1];
				count %= 10007;
			}
		}
	} else
	{
		for (int i = 1; i < 8; i++)
		{
			if ((i&now)&&(i&c))
			{
				if (dp[i][x + 1] == 0)
				{
					dp[i][x + 1] = saiki(i, x + 1, str);
				}
				count += dp[i][x + 1];
				count %= 10007;
			}
		}
	}
	return count;
}

int main()
{
	int N;
	cin >> N;
	string str;
	cin >> str;
	cout << saiki(1, 0, str) << endl;
}

Measured memory_bytes: 2316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Great_Ocean_View
{
    class Program
    {
        static void Main(string[] args)
        {
            int otpt = 1;
            int no = Convert.ToInt16(Console.ReadLine());
            string[] inp = (Console.ReadLine()).Split(' ');
            int[] mountain = new int[no];
            for (int i =0;i<=no-1;i++)
            {
                mountain[i] = Convert.ToInt16(inp[i]);
            }
            int maxheight = mountain[0];
            for (int j = 1; j <= no - 1; j++)
            {
                if (mountain[j]>=maxheight)
                {
                    maxheight = mountain[j];
                    otpt++;
                }
            }
            Console.WriteLine(otpt);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[5000000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 5000000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[100];
signed main() {
	cin >> n;
	for (int i = 0; i < 50; i++) {
		a[i] = i + (n / 50);
	}
	n %= 50;
	for (int i = 0; i < 50; i++) {
		if (i < n) {
			a[i] += 51;
		}
		a[i] -= n;
	}
	cout << 50 << endl;
	for (int i = 0; i < 50; i++) {
		cout << a[i] << (i == 50 - 1 ? "\n" : " ");
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] rate = new int[9];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            int idx = Math.min(a[i] / 400, 8);
            rate[idx]++;
        }
        int ans = 0;
        for (int i = 0; i < rate.length - 1; i++) {
            if (rate[i] == 0) {
                continue;
            }
            ans++;
        }
        StringJoiner sj = new StringJoiner(" ");
        sj.add(String.valueOf(Math.max(ans, 1)));
        sj.add(String.valueOf(ans + rate[8]));
        System.out.println(sj.toString());
    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++)
			if (a[j] < a[minj])
				minj = j;
		if (i != minj) {
			swap(a[i], a[minj]);
			ans++;
		}
	}
	for (int i = 0; i < n; i++)
		cout << a[i] << (i == n - 1 ? '\n' : ' ');
	cout << ans << endl;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include<algorithm>
#include<string>
#include<iostream>
#include<queue>
using namespace std;
int s[105];
struct node
{
    int num;
    int m;
    string name;
} a[105];
int comp(node a1,node a2)
{
    if(a1.name==a2.name)
    {
        return a1.m>a2.m;
    }
    else
    {
        return a1.name<a2.name;
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    int i,j;
    for(i=1; i<=n; i++) a[i].num=i;
    for(i=1; i<=n; i++)
    {
        cin>>a[i].name;
        scanf("%d",&a[i].m);
//       cout<<a[i].name<<" ";
//       printf("%d\n",a[i].m);
    }
    sort(a+1,a+n+1,comp);
    for(i=1;i<=n;i++) printf("%d\n",a[i].num);
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  int si, sj, ti, tj;
  cin >> si >> sj >> ti >> tj;
  --si, --sj, --ti, --tj;
  vector<string> s(h);
  for (auto&& e : s) cin >> e;
  vector<set<int>> row(h), col(w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      row[i].insert(j);
      col[j].insert(i);
    }
  }
  vector d(h, vector(w, -1));
  queue<pair<int, int>> que;
  d[si][sj] = 0;
  que.emplace(si, sj);
  row[si].erase(sj), col[sj].erase(si);
  while (not empty(que)) {
    auto [i, j] = que.front();
    que.pop();
    DEBUG(i, j);
    if (i == ti and j == tj) {
      cout << d[i][j] << '\n';
      exit(0);
    }
    for (auto it = row[i].lower_bound(j); it != end(row[i]) and *it <= j + k and s[i][*it] != '@'; ) {
      d[i][*it] = d[i][j] + 1;
      que.emplace(i, *it);
      col[*it].erase(i);
      it = row[i].erase(it);
    }
    while (true) {
      auto it = row[i].upper_bound(j);
      if (it == begin(row[i])) break;
      --it;
      if (*it < j - k or s[i][*it] == '@') break;
      d[i][*it] = d[i][j] + 1;
      que.emplace(i, *it);
      col[*it].erase(i);
      row[i].erase(it);
    }
    for (auto it = col[j].lower_bound(i); it != end(col[j]) and *it <= i + k and s[*it][j] != '@'; ) {
      d[*it][j] = d[i][j] + 1;
      que.emplace(*it, j);
      row[*it].erase(j);
      it = col[j].erase(it);
    }
    while (true) {
      auto it = col[j].upper_bound(i);
      if (it == begin(col[j])) break;
      --it;
      if (*it < i - k or s[*it][j] == '@') break;
      d[*it][j] = d[i][j] + 1;
      que.emplace(*it, j);
      row[*it].erase(j);
      col[j].erase(it);
    }
  }
  cout << "-1\n";
}


Measured memory_bytes: 152592
N, A, B = map(int, input().split())
mod = 10 ** 9 + 7
 
fact = [1]
num = [N]
for i in range(1, B + 1):
    fact.append(fact[-1] * (i + 1) % mod)
    num.append(num[-1] * (N - i) % mod)
 
 
def comb(x):
    res = num[x-1] * pow(fact[x-1], mod - 2, mod) % mod
    return res
 
 
ans = (pow(2, N, mod) - comb(A) - comb(B) -1 ) % mod

print(ans)

Measured memory_bytes: 66544
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    double a,b,x; cin>>a>>b>>x;
    double maxyouryo = a*a*b;
    double hanbunyouryo = maxyouryo/2;
    double theta = 0.0;
    if(x<=hanbunyouryo){ // 半分より少ないとき、
        double i;
        i = x * 2.0 / (a*b);
        theta = atan(b/i);
    }else{
        double yoryo;
        double i;
        for (i = 0.0; i < b; i+=0.0000001) {
            yoryo = a*a*i / 2.0;
            if(x>=maxyouryo-yoryo) break;
        }
        i = (maxyouryo - x)/(a*a/2.0);
        theta = atan(i/a);
    }
    double ans = theta * 180.0 / M_PI;
    //cout<<ans<<endl;
    printf("%.7lf",ans);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[2][n],dp[2][n];
    rep(i,2){
        rep(j,n)cin >> a[i][j];
    }
    rep(i,2){
        rep(j,n){
            if(i == 0 && j == 0) dp[i][j] = a[i][j];
            else if(i == 0) dp[i][j] = dp[i][j-1] + a[i][j];
            else if(j == 0) dp[i][j] = dp[i-1][j] + a[i][j];
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]) + a[i][j];
        }
    }
    cout << dp[1][n-1] << endl;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    s_dict = {}
    for i in range(n):
        commandLine = input().split()
        if commandLine[0] == "insert":
            s_dict[commandLine[1]] = commandLine[1]
        elif commandLine[0] == "find":
            if s_dict.get(commandLine[1]) != None:
                print("yes")
            else:
                print("no")



Measured memory_bytes: 37976
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)

using namespace std;

int main()
{
    ll N, M, ans=0;
    cin >> N >> M;

    if(M/2 <= N) { ans = M/2; }
    else { ans = N + (M-N*2) / 4; }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256