akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair

int q[100002];
int r[100002];
int s[100002];
int main(){

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

}
for(i=0;i<n;i++){

    q[a[i]]++;
    r[a[i]+1]++;
    s[a[i]-1]++;
}
int ma=0;
for(i=0;i<=(100001);i++){
    int o=q[i]+r[i]+s[i];
    ma=max(o,ma);



}

cout<<ma<<endl;

return 0;
}


Measured memory_bytes: 1792
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define p push
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%s\n", a + b + c >= 22 ? "bust" : "win");

	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long k,c=0;
vector<long long> a,f;
bool F(long long product){
    long long ret=0;
    for(int i=0;i<n;i++){
        long long t=product/f[i];
        if(a[i]>t){ret+=a[i]-t;}
    }
    return (ret<=k);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long high=1e12,low=-1;
    cin>>n>>k;
    a.resize(n);
    f.resize(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>f[i];
    }
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    while(high-low>1){
        long long m=(high+low)/2;
        if(F(m)){high=m;}
        else{low=m;}
    }
    cout<<high;
}


Measured memory_bytes: 3328
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

vector<int> graph[100001];
int dp[100001]; // dp[i] = len of longest path starting at node i

int solve(int src)
{
        if(dp[src] != -1)
            return dp[src];

        bool leaf = 1;
        int bestChild = 0;
        for(int child : graph[src])
        {
            leaf = 0;
            bestChild = max(bestChild, solve(child));
        }
        return dp[src] = leaf ? 0 : 1 + bestChild;
}

int main() {
    int n,m;
    cin >> n >> m;
    memset(dp, -1, sizeof dp);

    for(int i = 0; i < m; i++)
    {
        int u,v;
        cin >> u >>v;
        graph[u].push_back(v);
    }
    
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, solve(i));
    cout << ans;
}


Measured memory_bytes: 8192
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>
#include <utility>
using namespace std;
using P = complex<double>;
using L = pair<P,P>;
#define X real()
#define Y imag()
const double EPS = 1e-10, INF = 1e9;

double dot(P a, P b){ return a.X*b.X + a.Y*b.Y; }
double cross(P a, P b){ return a.X*b.Y - a.Y*b.X; }

int ccw(P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > +EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return +2;
  if(norm(b) < norm(c)-EPS) return -2;
  return 0;
}

bool is_cross(L a, L b){
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return (ccw(af,as,bf)*ccw(af,as,bs) <= 0 and ccw(bf,bs,af)*ccw(bf,bs,as) <= 0);
}

double ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 and dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf),abs(a-ss));
}

double ss_dist(L a, L b){
  if(is_cross(a,b)) return 0;
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return min({ps_dist(af,b),ps_dist(as,b),ps_dist(bf,a),ps_dist(bs,a)});
}

int main(){
  int N;
  while(cin >> N, N){
    P s, t;
    double x, y;
    cin >> x >> y;
    s = P(x,y);
    cin >> x >> y;
    t = P(x,y);
    L l(s,t);
    //double mi = 0, ma = INF;
    double ans = 1e3;
    for(int i = 0; i < N; ++i){
      double x_[2], y_[2], h;
      cin >> x_[0] >> y_[0] >> x_[1] >> y_[1] >> h;
      double d = INF;
      for(int j = 0; j < 4; ++j){
        for(int k = 0; k < 4; ++k){
          double x1 = x_[j%2], y1 = y_[(j/2)%2];
          double x2 = x_[k%2], y2 = y_[(k/2)%2];
          d = min(d,ss_dist(l,L(P(x1,y1),P(x2,y2))));
        }
      }
      if(d <= h) ans = min(ans,d);// ma = min(ma,d);
      else ans = min(ans,(h*h+d*d)/2./h);//mi = max(mi,((h*h+d*d)/2/h));
    }
    // if(mi > ma+EPS) ans = 0;
    // else ans = mi;
    printf("%.12f\n",ans);
  }
}



Measured memory_bytes: 3160
#include <stdio.h>
#include <stdlib.h>
#define max(a,b) (a>b?a:b)
int main()
{
    char s[100001];
    int n, q;
    scanf("%d %d", &n, &q);
    fflush(stdin);
    scanf("%s", s);
    int ans[100001] = {0}, temp = 0;
    int len = strlen(s);
    for(int i = 0; i < len; i++)
    {
        if(i < len-1 && s[i] == 'A' && s[i+1] == 'C')
        {
            ans[i] = temp;
            temp++;
            ans[i+1] = temp;
            i++;
        }
        else
            ans[i] = temp;
    }

    while(q--)
    {
        int l, r, count=  0;
        scanf("%d %d", &l, &r);
        printf("%d\n", ans[r-1]-ans[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

    cin>>n;
    if(n==2){
      Cout(0);
      return 0;
    }
    std::vector<ll> r = enum_div(n);
	for(auto i : r){
        m=n/i;
        if(i-1>m)ans+=i-1;
    }
    Cout(ans+n-1);
    return 0;
}


Measured memory_bytes: 384
import math
n, m = map(int, input().split())
ans = 1
for k in range(1, math.ceil(math.sqrt(m))):
    l = m // k
    if m % k == 0 and n * k <= m:
        ans = max(k, ans)
    if m % l == 0 and n * l <= m:
        ans = max(l, ans)
print('%d' % ans)

Measured memory_bytes: 3060
n = int(input())
import itertools
l = [i for i in range(1, n+1)]
p_list = list(itertools.permutations(l, n))
C = []
for i in p_list:
    C.append(list(i))

A = list(map(int, input().split()))

B = list(map(int, input().split()))

print(abs(C.index(A) - C.index(B)))

Measured memory_bytes: 50544
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

int n;

int ketaNum(int a) {
	int ret = 0;
	while (a > 0) {
		ret++;
		a /= 10;
	}
	return ret;
}

int f(int a, int b) {
	return max(ketaNum(a), ketaNum(b));
}

signed main() {
	int a, b;
	int ans = 114514;
	
	cin >> n;
	for (a = 1; a * a <= n; a++) {
		if (n % a == 0) {
			b = n / a;
			ans = min(ans, f(a, b));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, K: int, a: "List[int]"):

    dp = [[0]*(K+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(1, N+1):
        acc = [0] + list(accumulate(dp[i-1]))
        for j in range(K+1):
            dp[i][j] = acc[j+1] - acc[max(j-a[i-1], 0)]
            dp[i][j] %= MOD
    print(dp[N][K])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 175112
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

ll f(int h, int E, vector<vector<ll> >& memo) {
	if (!h || !E) return 1;
	if (memo[h][E] != -1) return memo[h][E];
	return memo[h][E] = f(h - 1, E - 1, memo) + f(h - 1, E, memo);
}

int main() {
	vector<vector<ll> > memo(100, vector<ll>(100, -1));
	int T; cin >> T;
	while (T--) {
		ll N; int E; cin >> N >> E;
		int h;
		for (h = 0; f(h, E, memo) < N + 1; h++);
		cout << h << endl;
	}
}

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

using namespace std;
typedef long long int ll;
ll dp[5005][5005];
const int MOD=1e9+7;
ll powe(ll val, ll e,ll m)
{
    ll ret=1;
    while(e>0)
    {
        if(e&1) ret=(ret*val)%m;
        val=(val*val)%m;
        e>>=1;
    }
    return ret;
}

int main()
{
    dp[0][0]=1;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=s.size();
    for(int i=1;i<=n;i++)
    {
        dp[i][0]+=(dp[i-1][0] + dp[i-1][1]);
        dp[i][0]=dp[i][0]%MOD;
        for(int j=1;j<=n;j++)
        {
            dp[i][j]+=dp[i-1][j+1] + dp[i-1][j-1]*2LL;
            dp[i][j]=dp[i][j]%MOD;
        }
    }
    ll resp=dp[n][l];
    while(l--)
    {
        resp=(resp*powe(2,MOD-2,MOD))%MOD;
    }
    cout<<resp<<endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        long n = in.nextInt();
        long a = 1;
        long mod = (long)1e9+7;
        for(int i=0;i<n;i++)
        	a = (a*10)%mod;
        long b = 1;
        for(int i=0;i<n;i++)
        	b = (b*9)%mod;
        long c = 1;
        for(int i=0;i<n;i++)
        	c = (c*8)%mod;
        b = (b*2)%mod;
        out.println((a-((b-c+mod)%mod)+mod)%mod);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		Integer[] readArray(long n) {
		    Integer a[] = new Integer[(int)n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static class Pair implements Comparable<Pair> {
		int x, y;
		Pair(int a, int b){ x = a; y = b; }
		int getKey() { return x; }
		int getVal() { return y; }
		@Override
		public int compareTo(Pair o) {
			if(o.getVal() - this.getVal()>0)
				return -1;
			else if(o.getVal() - this.getVal()<0)
				return 1;
			else 
				return 0;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
	
	static long hashInt(int x,int y) {
		return x*(1_000_000_000L)+y;
	}
}



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

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

  vector<int> a(n+1);
  vector<int> b(n+1);
  vector<int> c(n+1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  vector<vector<int>> dp(3, vector<int>(n+1));
  vector<int> current = {1, 2, 3};
  
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      dp[0][1] = a[1];
      dp[1][1] = b[1];
      dp[2][1] = c[1]; 
    } else {
      dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
      dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
      dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
    }
  }

  int answer = 0;

  for (int i = 0; i < 3; i++) {
    answer = max(dp[i][n], answer);
  }

  cout << answer << endl;

}

Measured memory_bytes: 2944
# input
N, T = map(int, input().split())
T_lst = list(map(int, input().split()))

ans = 0

for i in range(1, N):
    if T_lst[i] <= T_lst[i - 1] + T:
        ans += T_lst[i] - T_lst[i - 1]
    else:
        ans += T

ans += T
print(ans)



Measured memory_bytes: 26832
N = int(input())
p = list(map(int, input().split()))

ans = 0
flag = False
for i in range(N - 1):
    if flag:
        n = p[i+1]
    else:
        n = p[i]
    if n == i+1:
        ans += 1
        flag = True
    else:
        flag = False
if flag:
    n = p[-2]
else:
    n = p[-1]
if n == N:
    ans += 1
print(ans)

Measured memory_bytes: 14008
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int64 gcd(int64 a, int64 b) {
    return b ? gcd(b, a % b) : a;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	int64 a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
              
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

using namespace std;

const int maxn = (int)2e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 

#define inf mod

typedef long double ld;                          
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        

struct line{
  int k, b;
  line(int _k, int _b){
    k = _k;
    b = _b;
  }
  int val(int x){
    return k * x + b;
  }
};
vector<line> v;
ld inter(line l1, line l2){
  return (ld)(l2.b - l1.b) / (l1.k - l2.k);
}
int bad(line l1, line l2, line l3){
  ld q1 = inter(l1, l2);
  ld q2 = inter(l1, l3);
  return q1 >= q2;
}
void add(line l){
  while(sz(v) > 1 && bad(v[sz(v) - 2], v[sz(v) - 1], l))
    v.pop_back();
  v.pb(l);
}
int get(int x){
  int l = 0, r = sz(v) - 1, res = 0;
  while(l < r){
    int mid = (l + r) >> 1;
    if(v[mid].val(x) > v[mid + 1].val(x)) l = mid + 1;
    else r = mid;
  }
  return v[r].val(x);
}
int n, c, h[maxn], dp[maxn];
int slow(){
  dp[1] = 0;
  forn(i, 2, n){
    dp[i] = inf;
    forn(j, 1, i - 1){
      dp[i] = min(dp[i], dp[j] + h[j] * h[j] - 2 * h[j] * h[i] + h[i] * h[i] + c  );
    }                    
  }
  return dp[n];
}
main () {
  cin >> n >> c;
  forn(i, 1, n) cin >> h[i];
  //cout << slow() << endl;
  dp[1] = 0;
  add(line(-2 * h[1], h[1] * h[1]));
  forn(i, 2, n){
    dp[i] = get(h[i]) + c + h[i] * h[i];
    add(line(-2 * h[i], dp[i] + h[i] * h[i]));
  } 
  cout << dp[n];
}

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


const long divv = 1000000007;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % divv;
		inv[i] = divv - inv[divv % i] * (divv / i) % divv;
		finv[i] = finv[i - 1] * inv[i] % divv;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % divv) % divv;
}



long nck(long n, long k) {
	long answer = 0;

	answer = COM(n,k);

	return answer;
}

long aka_ball(long n, long k) {
	long answer = 0;

	answer = nck(n+1,k);

	return answer;
}

long ball(long n, long k) {
	long answer = 1;

	if (k == 1) return 1;
	answer = nck(n+k-1, k-1) % divv;
	return answer;
}

int main()
{
	long n,k;
	cin >> n >> k;

	COMinit();

	for (long i = 1; i <= k; i++) {
		long answer = aka_ball(n-k, i);
		answer = (answer * ball(k-i, i)) % divv;
		cout << answer << endl;
	}

}

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

int main() {

    ll n; cin >> n;
    
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    
    ll length1 = -1;
    ll length2 = -1;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1] && length1 == -1) {
            length1 = a[i];
            i++;
        }
        else if (a[i] == a[i + 1] && length1 != -1  && length2 == -1) {
            length2 = a[i];
            break;
        }
    }

    if (length1 == -1 || length2 == -1) cout << 0 << endl;
    else cout << length1 * length2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
        vector<int> over;
        map<int,int> student;
        float w,h,bmi;
        int num;
        char cn,cn1;
        while(cin>>num>>cn1>>w>>cn>>h){
                h *= h;
                bmi = w / h;
                student.insert(map<int,int>::value_type(num,bmi));
        }
        map<int,int>::iterator it=student.begin();
        for(;it!=student.end();it++){
                if( (*it).second >=25) over.push_back((*it).first);
        }
        for(int i=0;i<over.size();i++) cout<<over[i]<<endl;
}

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

int H, W, sx, sy, gx, gy;
int grid[1005][1005];

void dfs(int x, int y, int c) {
    if (x < 0 || y < 0 || x >= H || y >= W) return;
    if (grid[x][y] == -2 || (grid[x][y] >= 0 && grid[x][y] <= c)) return;
    grid[x][y] = c;
    dfs(x - 1, y, c);
    dfs(x + 1, y, c);
    dfs(x, y + 1, c);
    dfs(x, y - 1, c);
    for (int i = x - 2; i <= x + 2; ++i) {
        for (int j = y - 2; j <= y + 2; ++j) {
            dfs(i, j, c + 1);
        }
    }
}

void dump() {
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] < 0) {
                if (grid[i][j] == -2) cout << "#" << " ";
                else cout << "." << " ";
            } else {
                cout<< grid[i][j] << " ";
            }
        }
        cout << endl;
    }
}

int main() {
    cin >> H >> W >> sx >> sy >> gx >> gy;
    --sx; --sy; --gx; --gy;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            if (c == '.') {
                grid[i][j] = -1;
            } else {
                grid[i][j] = -2;
            }
        }
    }
    // dump();
    // dfs(sx, sy, 0);
    priority_queue<pair<int, pair<int, int>>> q;
    q.push({0, {sx, sy}});
    while(!q.empty()) {
        int c = q.top().first;
        int x = q.top().second.first;
        int y = q.top().second.second;
        q.pop();
        if (x == gx && y == gy) {
            cout << -c << endl;
            return 0;
        }
        if (grid[x][y] == -1) {
            grid[x][y] = -c;
            if (x + 1 < H) q.push({c, {x + 1, y}});
            if (x - 1 >= 0) q.push({c, {x - 1, y}});
            if (y + 1 < W) q.push({c, {x, y + 1}});
            if (y + 1 >= 0) q.push({c, {x, y - 1}});
            for (int i = x - 2; i <= x + 2; ++i) {
                for (int j = y - 2; j <= y + 2; ++j) {
                    if (i == x && j == y) continue;
                    if (i == x - 1 && j == y) continue;
                    if (i == x + 1 && j == y) continue;
                    if (i == x && j == y + 1) continue;
                    if (i == x && j == y - 1) continue;
                    if (i >= 0 && j >= 0 && i < H && j < W) {
                        q.push({c - 1, {i, j}});
                    }
                }
            }
        }
    }
    // dump();
    if (grid[gx][gy] < 0) {
        cout << "-1" << endl;
    } else {
        cout << grid[gx][gy] << endl;
    }

    return 0;
}


Measured memory_bytes: 10104
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = b*(n-1)+a - (a*(n-1)+b) +1;
  cout << max(0LL,ans) << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3496
#include<iostream>
using namespace std ;
long long int data[102][11][1102]={} ; //??°???,?????¨?????°,????¨?
     
int main(){
    int n,s ;
     
    data[0][0][0] = 1 ;
    data[0][1][0] = 1 ;
     
    for( int i=0 ; i<101 ; i++ ){
        for( int j=0 ; j<10 ; j++ ){
            for( int k=0 ; k<1001 ; k++ ){
                data[i+1][j][k] += data[i][j][k] ;
                data[i+1][j+1][k+i+1] += data[i][j][k] ;
            }
        }
    }
     
    while(1){
        cin >> n >> s ;
        if( n==0 && s==0 ) break;
        cout << data[100][n][s] << endl ;
    }
     
return 0;
}

Measured memory_bytes: 10736
N = int(input())
prev_a = 0
prev_b = 0
prev_c = 0

for n in range(N):
    a, b, c = [int(i) for i in input().split(' ')]

    next_a = a + max(prev_b, prev_c)
    next_b = b + max(prev_a, prev_c)
    next_c = c + max(prev_a, prev_b)

    prev_a = next_a
    prev_b = next_b
    prev_c = next_c

print(max(prev_a, prev_b, prev_c))


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library

//
int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    double t, x;
    cin >> t >> x;
    double ans = t/x;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
const ll INF = 1e15 + 5;

int main() {
	string s, t; cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<vi> dp(n + 1, vi(m + 1, -1));
	for (int i = 0; i < n + 1; i++) dp[i][0] = 0;
	for (int i = 0; i < m + 1; i++) dp[0][i] = 0;
	vector<vi> p(n + 1, vi(m + 1));

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (dp[i - 1][j] > dp[i][j]){
				dp[i][j] = dp[i - 1][j];
				p[i][j] = 1;
			}
			if (dp[i][j - 1] > dp[i][j]){
				dp[i][j] = dp[i][j - 1];
				p[i][j] = 2;
			}
			if (s[i - 1] == t[j - 1]){
				if (dp[i - 1][j - 1] + 1 > dp[i][j]){
					dp[i][j] = dp[i - 1][j - 1] + 1;
					p[i][j] = 3;
				}
			}
		}
	}

	int u = n, v = m;
	string ans;
	while(p[u][v]){

		if (p[u][v] == 1){
			u--;
		}
		else if (p[u][v] == 2){
			v--;
		}
		else if (p[u][v] == 3){
			ans += s[u - 1];
			u--; v--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

}


Measured memory_bytes: 70912
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
          long long int a,b;
          cin>>a>>b;
          if((1<=a && a<=9) &&( 1<=b && b<=9))
                    cout<<a*b<<endl;
          else
                    cout<<"-1"<<endl;
return 0;
}


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

#define MAX 100
#define MOD 1000000007
#define pi 3.1415926535897932384246433832

#define ll long long
#define ld long double

#define vi vector <int>
#define vll vector<long long>
#define vb vector<bool>

#define vvi vector<vi>
#define vvll vector<vll>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);


void solve(){
    map<int, int> m;
    int a;
    for(int i = 1; i<= 3; i++){
        cin>>a;
        m[a]++;
    }
    if (m.size() == 2) cout<<"Yes";
    else cout<<"No";


}


int main(){
    fast
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    ll dp[n + 1][k + 1][2];
    // dp[in][ik][isn]: 上からin桁まで見て、0でない数字がik個ある。
    // isn:
    //     0 -> ちょうどn
    //     1 -> n以下が確定
    rep(i, n + 1) rep(j, k + 1) rep(l, 2) dp[i][j][l] = 0;

    dp[0][0][0] = 1;
    rep(in, n) {
        ll now = s[in] - '0';
        rep(ik, k + 1) {
            rep(isn, 2) {
                rep(d, 10) {
                    ll ni = in + 1, nk = ik, nisn = isn;
                    if (d != 0) nk++;
                    if (nk > k) continue;
                    if (d < now && isn == 0) nisn = 1;
                    else if (d > now && isn == 0) continue;

                    dp[ni][nk][nisn] += dp[in][ik][isn];
                }
            }
        }
    }
    cout << dp[n][k][0] + dp[n][k][1] << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  long sum = 0;
  for(int i = 0; i < S.size(); i++){
    sum += S.at(i) - '0';
  }
  if(sum % 9 == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3688
def input_parser():
    N=int(input())
    s=input()
    return N, s
N, s=input_parser()
s_bool=[_s is 'o' for _s in s]
ans=-1
for flag in range(0,4):
    if flag==0:
        animals=[True,True]
    elif flag==1:
        animals = [True, False]
    elif flag==2:
        animals=[False,True]
    else:
        animals=[False,False]
    for animal_index in range(1,N-1,1):
        animals.append((animals[animal_index] is animals[animal_index-1])is s_bool[animal_index])

    def last_check(s_bool,animals):
        global N
        # first animal witness
        if (((animals[N-2]==animals[0]) is s_bool[N-1]) is animals[N-1]) and ((((animals[N-1]==animals[1]) is s_bool[0]))is animals[0]):
            return True
        else:
            return False
    if last_check(s_bool,animals):
        ans=""
        for itr in range(0,N,1):
            if animals[itr]:
                ans += 'S'
            else:
                ans += 'W'
        break

def output_parser(output):
    print(output)

output_parser(ans)

Measured memory_bytes: 4988
#include <iostream>
#include <vector>
#include <map>
#include <string.h>
#include <algorithm>
#define INF (1<<30)
#define P pair<int,int>
using namespace std;

void dfs(int n,vector<vector<P>>& G,vector<int>& dist) {
	for (P p : G[n]) {
		int next = p.first, cost = p.second;
		if (dist[next] == INF) {
			dist[next] = dist[n] + cost;
			dfs(next, G, dist);
		}
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	int u;
	vector<vector<P>> G(n);
	vector<int> dist(n, INF);
	for (int i = 0; i < n - 1; i++) {
		int s, t, w; cin >> s >> t >> w;
		G[s].emplace_back(make_pair(t, w));
		G[t].emplace_back(make_pair(s, w));
	}

	dist[0] = 0;
	dfs(0,G,dist);

	auto maxIt = max_element(dist.begin(), dist.end());
	u = distance(dist.begin(), maxIt);

	fill(dist.begin(), dist.end(), INF);

	dist[u] = 0;
	dfs(u,G,dist);

	cout << *max_element(dist.begin(), dist.end()) << endl;
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int X,A,B;
	cin>>X>>A>>B;
	if(B-A<=X){
		if(A>=B){
			cout<<"delicious";
		}
		if(B>A){
			cout<<"safe";
		}
	}
	else{
		cout<<"dangerous";
	}
	cout<<endl;
}

Measured memory_bytes: 256
/*
	************	************    ************	***      ***	************	***               ***
	************	************    ************	****     ***	************	 ***             ***
	***      ***	***      ***    ***      ***	*****    ***	***      ***	  ***           ***
	***      ***	***      ***    ***      ***	******   ***	***      ***	   ***         ***
	************	************    ************	*** ***  ***	************	    ***       ***
	************	************    ************	***  *** ***	************	     ***     ***
	***				***   ***       ***      ***	***   ******	***      ***	      ***   ***
	***				***    ***      ***      ***	***    *****	***      ***	       *** ***
	***				***     ***     ***      ***	***     ****	***      ***	        *****
	***				***      ***    ***      ***	***      ***	***      ***	         ***
*/

#define named(blockname) goto blockname; \
                         blockname##_skip: if (0) \
                         blockname:

#define break(blockname) goto blockname##_skip
// #include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define readarr(a,n) for (int i=0; i<n; i++) {cin>>a[i];}
#define printarr(a,n) for (int i=0; i<n; i++) {cout<<a[i]<<' ';}
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vint vector <int>
#define pb push_back
#define pf push_front
#define endl "\n"

signed main() {
	
	fast ;
	
	ll q ;
	// cin >> q ;
	q = 1 ;
	while(q--)
	{
		ll a,b ;
		cin>>a>>b ;
		if (b>=a)
			cout << "unsafe" ;
		else
		cout << "safe" ;	}
	
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
inline int read() {
	int s = 0, w = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
	for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
	return s * w;
}

int main(){
   string s;
   int q,k,u;
   char c;
   cin>>s;
   int len=s.size();
   q=read();
   int flag=0;
   while(q--){
    u=read();
    if(u==1){
        flag++;
    }
    else{
        k=read();
        scanf("%c",&c);
        if(flag%2==0){
            if(k==1) s.insert(s.begin(),c);
            else s.insert(s.end(),c);
        }
        else{
            if(k==1) s.insert(s.end(),c);
            else s.insert(s.begin(),c);
        }
        len++;
    }
   }
   if(flag%2==1) {
        for(int i=len-1;i>=0;i--)
        printf("%c",s[i]);
   }
   else{
     for(int i=0;i<len;i++)
        printf("%c",s[i]);
   }
    return 0;
}



Measured memory_bytes: 900
#include <iostream>

using namespace std;

const int MAXN=1e5+5;
int N;
int a[MAXN];

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

        int four=0,two=0,one=0;
        for (int i=0; i<N; i++) {
                if (a[i]%4 == 0)
                        four++;
                else if (a[i]%4 == 2)
                        two++;
                else
                        one++;
        }

        if (four < one-1)
                cout << "No\n";
        else if (four == one-1 && two > 0)
                cout << "No\n";
        else
                cout << "Yes\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;

const double eps = 1e-12;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        complex<double> p1, p2, p3, m1, m2, d1, d2;
        cin >> p1.real() >> p1.imag() >> p2.real() >> p2.imag() >> p3.real() >> p3.imag();
        m1 = (p1 + p2) / 2.0;
        m2 = (p2 + p3) / 2.0;
        d1 = polar(1.0, arg(p2 - p1) + M_PI_2);
        d2 = polar(1.0, arg(p3 - p2) + M_PI_2);
        
        double t;
        t = (d1.real() * m1.imag() + d1.imag() * m2.real() - m1.real() * d1.imag() - d1.real() * m2.imag()) / (d1.real() * d2.imag() - d2.real() * d1.imag());
        
        double x = m2.real() + t * d2.real();
        double y = m2.imag() + t * d2.imag();
        double r = abs(complex<double>(x,y) - p1);
        
        printf("%.3lf %.3lf %.3lf\n", x, y, r);
    }
    return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    map<int, long> prime_factors;
    for(int i = 2; i <= N; i++){
        int tmp_i = i;
        for(int j = 2; j * j <= tmp_i; ){
            if(tmp_i % j == 0){
                prime_factors[j]++;
                tmp_i /= j;
            }else{
                j++;
            }
        }
        prime_factors[tmp_i]++;
    }
    long ans = 1;
    for(auto i: prime_factors){
        ans *= i.second + 1;
        ans %= long(1e9 + 7);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
int n,m,a[100005],cnt[100005];
char te[100005];
int main(){
	cin>>te;n=strlen(te);
	for(int i=0;i<n;i++){
		if(te[i]=='9'){
			cout<<"Yes";return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define li                list<int>
#define pii               pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
#define all(x)            (x).begin(), (x).end()
#define PI                3.14159265358979
void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("new2.txt", "r", stdin);
	freopen("halua.txt", "w", stdout);
#endif
}
// int aa[111111], bb[11111], c[1111111];
void solve()
{

	int n; cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for (int i = 0; i < n; i++)
	{
		string s; cin >> s;
		if (s == "AC")ac++;
		else if (s == "WA")wa++;
		else if (s == "TLE")tle++;
		else if (s == "RE")re++;
	}
	cout << "AC" << " " << "x" << " " << ac << "\n";
	cout << "WA" << " " << "x" << " " << wa << "\n";
	cout << "TLE" << " " << "x" << " " << tle << "\n";
	cout << "RE" << " " << "x" << " " << re << "\n";

}
int32_t main()

{
	c_p_c();
	solve();
}


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

int main()
{
	int M1;
	int M2;
	int D1;
	int D2;

	scanf("%d %d %d %d",&M1,&D1,&M2,&D2);

	if(M1!=M2)
	{
		printf("1\n");
	}else{
		printf("0\n");
	}

	return 0;
}


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

int main() {
    long double N;
    cin >> N;
    long double odd =0.0;
    for(int i=1;i<=N;i++){
        if(i%2 ==1){
            odd++;
        }
    }
    cout << setprecision(10)<<odd/N << endl;

    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  rep(i,n){
    ans+=(lower_bound(ALL(a),b[i])-a.begin())*(c.end()-upper_bound(ALL(c),b[i]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
	cin >> N >> M;
	vector<long double>v(N + 1);

	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] += v[i - 1];
	}
	vector<vector<long double>>dp(M + 1, vector<long double>(N + 1));
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			for (int k = 0; k < i; k++) {
				if (j == 1 && k) {
					continue;
				}
				dp[j][i] = max(dp[j][i], dp[j - 1][k] + (v[i] - v[k]) / (i - k));
			}
		}
	}
	cout << setprecision(15) << dp[M][N] << endl;
	return 0;
}


Measured memory_bytes: 6976
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n,k;cin>>n>>k;
	puts(n%k?"1":"0");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,k; cin >> n >> k;
	string s; cin >> s;
	int ans = 0;
	rep(i,n){
		if(i-1>=0&&s[i]=='L'&&s[i-1]=='L') ans++;
		if(i+1<n&&s[i]=='R'&&s[i+1]=='R') ans++;
	}
	ans = min(n-1,ans+k*2);
	cout << ans << endl;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    if(n < 3200) {
        cout << "red" << endl;
    } else {
        cout << s << endl;
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 3628
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

    vector<int> num_white(n+1, 0), num_black(n+1, 0);
    for(int i=1;i<=n;i++){
        num_white[i] = num_white[i-1];
        if(s[i-1] == '.'){
            num_white[i]++;
        }
        num_black[i] = i - num_white[i];
    }

    int minx = n + 1;
    // leftmost of B
    for(int i=0;i<=n;i++){
        int ret = num_black[i] + (num_white[n] - num_white[i]);
        if(minx > ret){
            minx = ret;
        }
    }

    cout << minx << endl;
    return 0;
}

Measured memory_bytes: 2180
#include<algorithm>
#include<array>
#include<climits>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, char *argv[])
{
	int N, P[8], Q[8];

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

	vector<int> v(N);
	iota(v.begin(), v.end(), 1);
	int po, qo, o = 0;
	do {
		o++;
		int pn = 0, qn = 0;
		for (int i = 0; i < N; i++) {
			if (v[i] == P[i]) {
				pn++;
			}
		}
		if (pn == N) {
			po = o;
		}
		for (int i = 0; i < N; i++) {
			if (v[i] == Q[i]) {
				qn++;
			}
		}
		if (qn == N) {
			qo = o;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << abs(po - qo) << endl;

	return 0;
}


Measured memory_bytes: 256