akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
bool used1[200000], used2[200000];
ll dist1[200000], dist2[200000];
void dfs1(ll now, ll parent, ll depth, const vvc<ll>& G){
    dist1[now] = depth;
    for(auto to:G[now]){
        if (to == parent) continue;
        dfs1(to, now, depth + 1, G);
    }
}
void dfs2(ll now, ll parent, ll depth, const vvc<ll>&G){
    dist2[now] = depth;
    for(auto to:G[now]){
        if (to == parent) continue;
        dfs2(to, now, depth + 1, G);
    }
}
int main() {
    init();
    ll N;
    cin >> N;
    vvc<ll> G(N);
    rep(i,N-1){
        ll a,b;
        cin>>a>>b;
        a--, b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    dfs1(0, -1, 1, G);
    ll max_u = max_element(dist1, dist1 + N) - dist1;

    dfs2(max_u, -1, 1, G);
    ll L = *max_element(dist2, dist2 + N);

    if(L==1){
        cout << "First" << endl;
    }
    else if(L==2){
        cout << "Second" << endl;
    }
    else if((L-2)%3==0){
        cout << "Second" << endl;
    }
    else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 26880
#include<iostream>
#include<vector>
#include<memory>
#include<climits>
using namespace std;
using uint = unsigned int;

struct Vertex {
	uint d_u = UINT_MAX;
	uint d_v = UINT_MAX;
};

bool dijkstra_u(const uint vid, vector<Vertex>& V, const vector<vector<uint>>& E, const uint d) {
	
	if(V[vid].d_u <= d) {
		return false;
	}
	
	V[vid].d_u = d;
	
	for(auto nv : E[vid]) {
		dijkstra_u(nv, V, E, d+1);
	}
	
	return true;
}

bool dijkstra_v(const uint vid, vector<Vertex>& V, const vector<vector<uint>>& E, const uint d) {
	
	if(V[vid].d_v <= d) {
		return false;
	}
	
	V[vid].d_v = d;
	
	for(auto nv : E[vid]) {
		dijkstra_v(nv, V, E, d+1);
	}
	
	return false;
}

int main() {
	uint N, u, v;
	cin >> N >> u >> v; 
	
	vector<Vertex> V(N);
	vector<vector<uint>> E(N, vector<uint>());
	
	for(uint i=0; i<N-1; i++) {
		uint A, B;
		cin >> A >> B;
		E[A-1].push_back(B-1);
		E[B-1].push_back(A-1);
	}
	
	dijkstra_v(v-1, V, E, 0);
	dijkstra_u(u-1, V, E, 0);	
	
	uint ans = 0;
	for(uint i=0; i<N; i++) {
		if(E[i].size() == 1) { // leaf
			continue;
		}
		
		uint d_u = V[i].d_u;
		uint d_v = V[i].d_v;
		//cout << d_u << " " << d_v << endl;
		
		if(d_u > d_v) {
			continue;
		}
		
		ans = max(ans, d_v);
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

#define MAX 1000000
bool prime[MAX + 10];

void hurui(){
  prime[0] = prime[1] = true;
  lep(i,2,MAX){
    if(!prime[i]){
      for(int j = 2;j * i <= MAX;j++)prime[i * j] = true;
    }
  }
}

int main(){
  clr(prime,false);
  hurui();
  while(1){
    cin >> n >> m >> l;
    if(n == 0 && n == m && n == l)break;
    ll ans = 0,p = 0;
    rep(i,0,MAX){
      if(!prime[n + m * i]){
        p++;
        if(p == l){
          ans = n + m * i;
          break;
        }
      }
    }
    print(ans);
  }
  return 0;
}


Measured memory_bytes: 4116
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }  // O( log(a) )
bool isPrime(ll n) {                                  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) flag = false;
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'R') ans++;
  }
  if (s == "RSR") ans = 1;

  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define pb push_back
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
// typedef pair<int, int> P;
typedef pair<int, int> i_i;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int N;
int A, B;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> N;
  vector<vector<int>> G(N);
  REP(i,N-1) {
    cin >> A >> B;
    A--; B--;
    G[A].pb(B);
    G[B].pb(A);
  }
  vector<int> d(N, -1LL);
  priority_queue<i_i, vector<i_i>, greater<i_i>> pq;  //昇順に取り出す
  int K;
  cin >> K;
  while (K--) {
    int v, p;
    cin >> v >> p;
    v--;
    d[v] = p;
    pq.push(i_i(p, v));
  }
  while (!pq.empty()) {
    i_i p = pq.top(); pq.pop();
    int u = p.second;
    for (int v : G[u]) {
      if (d[v] == -1LL) {
        d[v] = d[u] + 1;
        pq.push(i_i(d[v], v));
      }
    }
  }
  REP(u,N) {
    for (int v : G[u]) {
      if (abs(d[u] - d[v]) != 1LL) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  REP(u,N) cout << d[u] << endl;
}

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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  ll ng = 0;
  ll nb = 0;
  ll nr = 0;
  rep(i, N){
    if(S[i] == 'R'){
      nr++;
    }else if(S[i] == 'G'){
      ng++;
    }else if(S[i] == 'B'){
      nb++;
    }
  }
  ll ans = nr * ng * nb;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      int k = 2*j-i;

      if(k >= N || k <=  j) continue;
      if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]){
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int n, m, A[100][100] ={{0}}, b[100], sum;
	int i, j;
	
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (j = 0; j < m; j++) {
		scanf("%d", &b[j]);
	}
	
	for (i = 0; i < n; i++) {
		sum = 0;
		for (j = 0; j < m; j++) {
			sum += A[i][j] * b[j];
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 648
s = int(input())
l = []
l.append(s)
a = [0] * 100000
a[0] = s 
for i in range(1, 1000000):
  if a[i-1] % 2 == 0:
    a[i] = a[i-1] // 2
  else:
    a[i] = 3 * a[i-1] + 1
  if a[i] in l:
    print(i+1)
    break
  else:
    l.append(a[i])


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  vector<long long> F(10000010,0);
  for(long long i=1;i<5000001;i++){
    for(long long j=1;j*i<=10000010;j++){
      F[j*i]++;
    }
  }
  for(long long i=5000001;i<=10000010;i++){
    F[i]++;
  }
  
  F[1]=1;
  long long ans=0;
  for(long long i=1;i<=N;i++){
    ans+=i*F[i];
    //cout<<ans<<endl;
  }
  

    cout<<setprecision(18)<<ans<<endl;
    
  
}


      
 

Measured memory_bytes: 81276
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        //A - 500 Yen Coins	   
        // int k = sc.nextInt();
        // int x = sc.nextInt();
        // boolean flg = false;
        // if(k*500>=x) {
        //     // System.out.println("k:"+k*500+"x:"+x);
        //     System.out.println("Yes");
        // } else {
        //     // System.out.println("k:"+k*500+"x:"+x);
        //     System.out.println("No");
        // }

        //B - Count ABC
        int n = sc.nextInt();
        String str = sc.nextLine();
        String s = sc.nextLine();
        int result = 0;
        int cnt = 0;
        while(true) {
            result = s.indexOf("ABC");
            if(result==-1) {
                // System.out.println("in");
                break;
            }
            // System.out.println("cnt:"+cnt);
            s = s.substring(result+3);
            // System.out.println("S:"+s);
            cnt++;
        }
        System.out.println(cnt);

    }
}

Measured memory_bytes: 23764
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

V = []

for i in range(1<<n):
    b = format(i, '0%db'%n)
    k = 0
    for j, bb in enumerate(b):
        if bb == '1':
            k += A[j]
    V.append(k)

for mm in m:
    if mm in V:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43096
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    al=0
    po=0
    for j in range(n):
        if a[i]>a[j]:
            if j<i:
                al+=1
            else:
                po+=1
                al+=1
    l.append((po,al))
ans=0
for i in l:
    ans += i[0]*k+i[1]*(k-1)*k//2
print(ans%(10**9+7))

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                int now=0;
                while(now<n){
                    if(s[now]-'0'==i){
                        ++now;
                        break;
                    }
                    ++now;
                }
                while(now<n){
                    if(s[now]-'0'==j){
                        ++now;
                        break;
                    }
                    ++now;
                }
                while(now<n){
                    if(s[now]-'0'==k){
                        ++ans;
                        break;
                    }
                    ++now;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	int q;
	cin >> q;
	ll a[100], b[100];
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i];
	}
	ll c;
	for (int i = 0; i < q; i++) {
		c = sqrt(a[i] * b[i]);
		if (c * c == a[i] * b[i]) {
			c--;
		}
		if (a[i] > b[i]) {
			swap(a[i], b[i]);
		}
		if (a[i] == b[i] || a[i] + 1 == b[i]) {
			cout << 2 * a[i] - 2 << endl;
		}
		else if (c * (c + 1) >= a[i] * b[i]) {
			cout << 2 * c - 2 << endl;
		}
		else if(c * c < a[i] * b[i]) {
			cout << 2 * c - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define int long long
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
signed main(){
    string s;
    int cnt1=0,cnt2=0;
    cin>>s;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]!='1')cnt1++;
            else cnt2++;
        }
        else{
            if(s[i]!='1')cnt2++;
            else cnt1++;
        }
    }
    cout<<min(cnt1,cnt2)<<endl;
}



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

int main(void)
{
  int n,k;
  cin >> n >> k;
  int l[51] = {0};
  for(int i = 0; i < n ; i++) cin >> l[i];
  sort(l,l+n);
  int ans = 0;
  for(int i = n-k; i < n ; i++) ans += l[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Digit(LLONG n)
{
	int digit = 0;
	do {
		n /= 10;
		++digit;
	} while (n > 0);
	return digit;
}

int main()
{
	LLONG N; cin >> N;
	// O(sqrt(N) * digit(N)) ~ O(10^6)
	int ans = 100;
	for (LLONG a = 1; a * a <= N; ++a)
	{
		if (N % a == 0)
		{
			int tmp = max(Digit(a), Digit(N / a));
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

    static class Student implements Comparable<Student> {
        int id, num;

        public Student(int id, int num) {
            this.id = id;
            this.num = num;
        }

        @Override
        public int compareTo(Student student) {
            return this.num - student.num;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        SortedSet<Student> students = new TreeSet<>();

        for (int i = 1; i <= N; i++) {
            students.add(new Student(i, sc.nextInt()));
        }

        for (Student student : students) System.out.print(student.id + " ");
    }
}

Measured memory_bytes: 69440
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],b[100010],c[100010],f[100010][3];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for (int i=1;i<=n;i++)
	{
		f[i][0]=max(f[i-1][1],f[i-1][2])+a[i];
		f[i][1]=max(f[i-1][0],f[i-1][2])+b[i];
		f[i][2]=max(f[i-1][0],f[i-1][1])+c[i];
	}
	cout<<max(max(f[n][0],f[n][1]),f[n][2])<<endl;
	return 0;
}


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

typedef long long LL;

string str;
int str_size;

LL f(int index, LL sum, LL value) {
    //cout << value << "\n";

    if (index == str_size)
        return sum + value;

    return f(index + 1, sum + value, str[index] - '0') + f(index + 1, sum, value * 10 + str[index] - '0');
}

int main() {
    cin >> str;

    str_size = str.size();

    LL ans = f(1, 0, str[0] - '0');
    cout << ans << "\n";
}

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

int main() {
	int H,W,K,r=0,s=0;
	cin >> H >> W >> K;
	vector<string> c(H);
	vector<int> a(H,0),b(W,0);

	rep(i,H) {
		cin >> c.at(i);
		rep(j,W)
			s += (c.at(i).at(j) == '#');
	}
	rep(i,H)
		rep(j,W)
			a.at(i) += (c.at(i).at(j) == '#');
	rep(i,W)
		rep(j,H)
			b.at(i) += (c.at(j).at(i) == '#');

	rep(i,1<<H) {
		int p=0;
		set<int> s1;
		rep(h,H)
			if(i & 1<<h) {
				p += a.at(h);
				s1.insert(h);
			}
		rep(j,1<<W) {
			int q=0;
			set<int> s2;
			rep(w,W)
				if(j & 1<<w) {
					q += b.at(w);
					s2.insert(w);
				}
			
			q += p;
			for(auto x : s1)
				for(auto y : s2)
					if(c.at(x).at(y) == '#')
						--q;
			if(s-q == K)
				++r;
		}
	}

	cout << r << endl;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  if(x % y == 0){
    cout << x / y << endl;
  }
  else if(x < y){
    cout << "1" << endl;
  }
  else{
    int k = x / y;
    cout << k + 1 << endl;
  }
}


Measured memory_bytes: 256
using System;

namespace ITP1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] strs = Console.ReadLine().Split(' ');
                int h = int.Parse(strs[0]);
                int w = int.Parse(strs[1]);
                if (h == 0 && w == 0) break;
                for (int i = 0; i < w; i++) Console.Write("#");Console.WriteLine();
                for (int i = 1; i < h-1; i++)
                {
                    Console.Write("#");
                    for (int j = 1; j < w-1; j++)
                    {
                        Console.Write(".");
                    }
                    Console.WriteLine("#");
                }
                for (int i = 0; i < w; i++) Console.Write("#");Console.WriteLine();
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8652
#include <stdio.h>
int main(void){
	int n,m,X,Y,i,j;
	scanf("%d%d%d%d",&n,&m,&X,&Y);
	int x[n],y[m];
	for(i=0;i<n;i++)scanf("%d",&x[i]);
	for(i=0;i<m;i++)scanf("%d",&y[i]);
	for(i=X+1;i<=Y;i++){
		int c=0,d=0;
		for(j=0;j<n;j++){
			if(x[j]<i){
				c=1;
			}else{
				c=0;
				break;
			}
		}
		for(j=0;j<m;j++){
			if(y[j]>=i){
				d=1;
			}else{
				d=0;
				break;
			}
		}
		if(c==1 && d==1){
			printf("No War");
			return 0;
		}
	}
	printf("War");
	
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	long INF = (long) (1e19);

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			long[] k = new long[n];
			for (int i = 0; i < n; ++i) {
				k[i] = sc.nextLong();
			}
			solve(n, k);
		}
	}

	void solve(int n, long[] k) {
		ArrayList<List<Long>> lis = new ArrayList<>();
		int ans = 0;
		out: for (long w = k[0] * 2 - 1; w <= 2 * k[0] + 1; ++w) {
			long A = 0, B = 0;
			for (int i = n - 1; i >= 0; --i) {
				if (k[i] == w) {
					B += 1L << i;
					if (i > 0)
						continue;
				} else if (k[i] == 0) {
					if (i > 0)
						continue;
				} else {
					if (i == 0) {
						B += k[0];
					} else {
						B += k[i] + (1L << i) - 1;
					}
				}
				A = B - w + 1;
				if (check(A, B, k, n)) {
					++ans;
					lis.add(Arrays.asList(A, B));
				}
				continue out;
			}
		}
		if (ans == 0) {
			System.out.println("None");
		} else if (ans == 1) {
			System.out.println(lis.get(0).get(0) + " " + lis.get(0).get(1));
		} else {
			System.out.println("Many");
		}
	}

	boolean check(long A, long B, long[] k, int n) {
		if ((1L << n) <= A || A <= 0 || (long) (1e18) < A)
			return false;
		if ((1L << n) <= B || B <= 0 || (long) (1e18) < B)
			return false;
		for (int i = n - 1; i >= 0; --i) {
			if (g(A, B, i) != k[i])
				return false;
		}
		return true;
	}

	long g(long A, long B, int i) {
		return f(B, i) - f(A - 1, i);
	}

	long f(long a, int i) {
		if (a <= 0)
			return 0;
		if (i == 0) {
			return (a + 1) / 2;
		}
		if ((1L << i) > a)
			return 0;

		int l = 0;
		while (1L << (l + 1) <= a) {
			++l;
		}
		if (i == l) {
			return a - (1L << i) + 1;
		}
		long d = a - ((1L << l) - 1);
		if (i == l) {
			return (1L << (l - 1)) + d;
		} else {
			return (1L << (l - 1)) + f(d - 1, i);
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 153140
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, 0, N) { cin >> A[i]; }
  int m = min_element(all(A)) - A.begin();

  dump(m);

  int ans = INF;
  rep(i, 0, N) {
    if (abs(i - m) <= K) {

      int a = (i + K - 2) / (K - 1);
      int b = (N - i - 1 + K - 2) / (K - 1);
      chmin(ans, a + b);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, K, h[100010];
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (h[i] >= K) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct node{
	int x,y;
	int num,pre;
}rec[maxn],nxt[maxn];
bool cmp(node a,node b){
	if(a.x == b.x) return a.y < b.y;
	return a.x < b.x; 
} 
bool bmp(node a,node b){
	return a.num < b.num; 
} 
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		rec[i].x = x;
		rec[i].y = y;
		rec[i].num = i;
	}
	sort(rec+1,rec+1+m,cmp);
	int idx = 1;
	int t = rec[1].x;
	for(int i = 1;i <= m;i++){
		if(rec[i].x != t){
			t = rec[i].x;
			idx = 1;
			rec[i].pre = idx;
			idx++;
		}
		else{
			rec[i].pre = idx;
			idx++;
		}
	}
	sort(rec+1,rec+1+m,bmp);
	for(int i = 1;i <= m;i++){
		printf("%06d%06d\n",rec[i].x,rec[i].pre);
	}
	return 0;
}

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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(max((10 * a) + b + c, a + (10 * b) + c), a + b + 10 * c) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//n??????
//Radix r;
//cout << r.to(n, 4) << endl;
class Radix {
private:
	const char* s;
	int a[128];
public:
	Radix(const char* s = "0123456789ABCDEF") : s(s) {
		for (int i = 0; s[i]; i++) a[(int)s[i]] = i;
	}
	string to(long long p, int q) {
		if (!p) return "0";
		char t[64] = {};
		int i;
		for (i = 62; p; i--) {
			t[i] = s[p % q];
			p /= q;
		}
		return string(t + i + 1);
	}
	string to(const string &t, int p, int q) {
		return to(to(t, p), q);
	}
	long long to(const string &t, int p) {
		long long sm = a[(int)t[0]];
		for (int i = 1; i < (int)t.length(); i++)
			sm = sm * p + a[(int)t[i]];
		return sm;
	}
};

signed main() {
	for (double n; cin >> n&&n >= 0;) {
		if ((int)n >= pow(2, 8)) { cout << "NA" << endl; continue; }
		Radix r;
		string a = r.to((int)n, 2);
		string b = "";
		n -= (int)n;
		rep(i, 0, 4) {
			n *= 2;
			b += to_string((int)n);
			n -= (int)n;
		}
		if (n != 0) { cout << "NA" << endl; continue; }
		cout << setfill('0') << setw(8) << a << "." << b << endl;
	}
	return 0;
}

Measured memory_bytes: 3280
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
    int D, N;
    cin >> D >> N;
    int count = 0;
    if(D == 0) {
        if(N == 100){ cout << 101;
            return 0;
        }
        cout << N;
    } else if(D== 1) {
        if(N == 100){
            cout << 10100;
            return 0;
        }
        cout << 100 * N;
    } else {
        if(N == 100) {
            cout << 1010000;
            return 0;
        }
        cout << 10000 * N;
    }

    return 0;
}


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


int main() {
    int N;
    set<string> S;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
}

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


int main() {
  
  ll n,k;
  cin >> n >> k;
  
  vector<ll>a(n);
  for(int i=0; i<n; i++){
   cin >> a[i]; 
  }
  
  vector<ll>front(n),back(n);
  for(int i=0; i<n; i++){
   for(int j=0; j<n; j++){
     if(i<j && a[i]>a[j]) back[i]++;//後ろよりでかい通り
     else if(i>j && a[i]>a[j]) front[i]++;//前よりでかい通り
   }
  }
  
  ll ans=0,f=0,b=0;
  for(int i=0; i<n; i++){
    b=k*(k+1)/2%1000000007;
    f=k*(k-1)/2%1000000007;
     
    ans+=f*front[i];
    ans%=1000000007;
    ans+=b*back[i];
    ans%=1000000007;
  }
  
  cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    cout <<A*B-C*B-A*D+C*D<<endl;
}

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

using namespace std;
 
int main(){
  string a,b;
  cin>>a>>b;
  int cnt=0;
  for(int i=0;i<a.size();i++){
    if(a.at(i)==b.at(i))cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n, m, p;
vector<tuple<int, int, int>> edges;
vint to[2505];
vint rto[2505];
vbool reach_from_1(2505, false);
vbool reach_to_n(2505, false);
vbool ok(2505);

void dfs(int v) {
    if (reach_from_1[v]) return;
    reach_from_1[v] = true;
    for (int u : to[v]) {
        dfs(u);
    }
}

void rdfs(int v) {
    if (reach_to_n[v]) return;
    reach_to_n[v] = true;
    for (int u : rto[v]) {
        rdfs(u);
    }
}

int main() {
    cin >> n >> m >> p;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        c -= p;
        edges.emplace_back(--a, --b, -c);
        to[a].push_back(b);
        rto[b].push_back(a);

    }
    dfs(0);
    rdfs(n-1);
    rep(i, n) ok[i] = reach_from_1[i] & reach_to_n[i];

    vint d(n, INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while(upd) {
        upd = false;
        rep(i, m) {
            int a, b, c;
            tie(a, b, c) = edges[i];
            if (!ok[a] || !ok[b]) continue;
            if (d[a] + c < d[b]) {
                upd = true;
                d[b] = d[a] + c;
            }
        }
        step++;
        if (step > n) {
            puts("-1");
            return 0;
        }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = getString(sc);
		List<String> weather = new ArrayList<>(Arrays.asList("Sunny", "Cloudy", "Rainy"));
		System.out.println(weather.get((weather.indexOf(s) + 1) % 3));
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	int row = 0;
	int col = 0;
	int candies = 0;

	public Status(int row, int col, int candies) {
		this.row = row;
		this.col = col;
		this.candies = candies;
	}
}


Measured memory_bytes: 21716
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

char num[10000];
int K;
int ans0[105][10];
int ans1[105][10];
signed main(){
    scanf("%s",num);
    scanf("%lld",&K);
    int sz=strlen(num);
    //printf("%lld",sz);
    for(int i=0;i<sz;i++){
        int x=num[i]-'0';
        rep(j,4){
            ans0[i][j]=0;
            ans1[i][j]=0;
            if(i==0){//一番上のけたについて(1以上)
                //k<xにした時、確定
                ans0[i][1]=x-1;
                ans0[i][0]=1;
                //k==xにした時、非確定
                ans1[i][1]=1;
                continue;
            }
            if(i>0)rep(k,10){//iけためをkにしたとき
                //0にしたとき、0以外の個数が増えない
                if(k==0){
                    if(k<x){
                        ans0[i][j]+=ans0[i-1][j]+ans1[i-1][j];
                    }else if(k==x){
                        ans0[i][j]+=ans0[i-1][j];
                        ans1[i][j]+=ans1[i-1][j];
                    }else{
                        ans0[i][j]+=ans0[i-1][j];
                    }
                }else if(j>0){
                //0以外の数にしたとき、0以外の個数が増える
                    if(k<x){
                        ans0[i][j]+=ans0[i-1][j-1]+ans1[i-1][j-1];
                    }else if(k==x){
                        ans0[i][j]+=ans0[i-1][j-1];
                        ans1[i][j]+=ans1[i-1][j-1];
                    }else{
                        ans0[i][j]+=ans0[i-1][j-1];
                    }
                }
            }
        }
    }
    int ansminus=0;//000が含まれているが、引くかどうか
    printf("%lld\n",ans0[sz-1][K]+ans1[sz-1][K]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;

string returnColumn(ll num) {
    ll init(26), power(1), steps(1);
    ll cpy(num);
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    string res = "";
    while (num > 0) {
        ll rem = num % 26;
        if (rem == 0) {
            res += 'z';
            num = num / 26 - 1;
        }
        else {
            res += alpha[rem - 1];
            num = num / 26;
        }
    }
    reverse(res.begin(), res.end());
    return res;
}

int main() {    
    ll num;
    cin >> num;
    cout << returnColumn(num) << "\n";
}

Measured memory_bytes: 3616
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc146/tasks/abc146_b
 *
 */
public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		String s = scanner.next();

		System.out.println(rotN(n, s));
	}

	private static String rotN(int n, String s) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			sb.append(rot(n, s.charAt(i)));
		}
		return sb.toString();
	}

	private static char rot(int n, char ch) {
		int code = (int) ch - 'A';
		return (char) (((code + n) % 26) + 'A');
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAX 500002
long long int egcd(long long int a,long long int b,long long int &x,long long int &y)
{
    if (a == 0)
    {
        x = 0;
        y = 1;
        return b;
    }
    long long int x1, y1;
    long long int d = egcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
long long int ModuloInverse(long long int a,long long int n)
{
    long long int x,y;
    long long int d=egcd(a,n,x,y);
    x=x%n;
    x=(x+n)%n;
    return x;
}
long long int bigmod(long long int a,long long int b,long long int m)
{
    if(b==0) return 1;
    long long int ans=bigmod(a,b/2,m);
    ans=(ans*ans)%m;
    if(b%2) ans=(ans*a)%m;
    return ans;
}
long long int C(long long int n,long long int a)
{
    long long i,nom=1,den=1;
    for(i=1; i<=a; i++)
    {
        nom=(nom*(n-i+1))%MOD;
        den=(den*i)%MOD;
    }
    den=ModuloInverse(den,MOD);
    return (nom*den)%MOD;
}
long long int fact[MAX],fact_inv[MAX];
void initialize()
{
    int i=0;
    fact[i]=fact_inv[i]=1;
    for(i=1; i<MAX; i++)
    {
        fact[i]=(fact[i-1]*i)%MOD;
        fact_inv[i]=ModuloInverse(fact[i],MOD);
    }
}
long long int C(int n,int r)
{
    long long int ans=fact[n];
    ans=(ans*fact_inv[n-r])%MOD;
    ans=(ans*fact_inv[r])%MOD;
    return ans;
}
int main()
{
    initialize();
    int n,k,i;
    scanf("%d %d",&n,&k);
    long long int ans=0;
    if(k>=n-1)
    {
        ans=C(n*2-1,n);

    }
    else
    {
        for(i=n;i>=n-k;i--)
        {
            long long int current=C(n,i);
            current=(current*C(n-1,i-1))%MOD;
            //printf("i=%d, current=%lld\n",i,current);
            ans=(ans+current)%MOD;
        }
    }
    printf("%lld",ans);
    return 0;
}


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

int main(){
  string s,ans;
  cin >> s;
  ans = "Good";
  for(int i = 0; i < 3;i++){
    if(s.at(i) == s.at(i+1)){
      ans = "Bad";
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(r: int, D: int, x: int):
    for _ in range(10):
        x = r * x - D
        print(x)
    return
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(r, D, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# all n integers can be divided into blocks of integers of size i  and in each 
# there will be total i-k integers which has remainder greater than k so we multiply this with no of blocks
# if there is a last block remaining we add all integers with remainder greater than k
def main():
	n , k = map(int , input().split())
	ans = 0
	for i in range(k+1 , n+1):
		ans = ans+(n//i*(i-k))
		if n%i>0:
			if k==0:
				ans = ans+n%i
			else:
				ans =ans +max(0 , n%i-k+1)
	print(ans)
if __name__=="__main__":
	main()

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int main(){
    int N; cin >> N;
    vector<string> S(N);
    vi cnt(4, 0);
    for(auto &x : S){
        cin >> x;
        if(x == "AC") cnt[0]++;
        else if(x == "WA") cnt[1]++;
        else if(x == "TLE") cnt[2]++;
        else cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
    return 0;
}

Measured memory_bytes: 6424
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
string N;
 
string ans = "Yes";
 
void solve(){
	for(int i=0;i<N.size();i++){
		if(N[i]=='7') return;
	}
	ans = "No";
}
 
int main(){
    cin >> N;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

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

int main() {
  int c[3][3];
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin >> c[i][j];
    }
  }
  int x[3], y[3];
  x[0]=0;
  for (int i=0; i<3; i++) {
    y[i]=c[0][i]-x[0];
  }
  for (int i=0; i<3; i++) {
    x[i]=c[i][0]-y[0];
  }
  bool good=true;
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      if (x[i]+y[j]!=c[i][j]) {
        good=false;
      }
    }
  }
  if (good) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int T = str.length();
        long mod = (long) Math.pow(10, 9) + 7;

        // dp[i][j]: 0からi-1まで, j個の文字を選んでいるときの, 残りの部分に対する処理の個数

        long[][] dp = new long[T + 1][4];

        dp[T][3] = 1;

        for (int i = T - 1; i >= 0; i--) {
            char c = str.charAt(i);

            // j == 3
            if (c == '?') {
                dp[i][3] = 3 * dp[i+1][3];
            } else {
                dp[i][3] = dp[i+1][3];
            }

            dp[i][3] %= mod;

            // j < 3
            for (int j = 0; j <= 2; j++) {
                if (c == '?') {
                    dp[i][j] = 3 * dp[i+1][j] + dp[i+1][j+1];
                } else if ((c == 'A' && j == 0) || (c == 'B' && j == 1) || (c == 'C' && j == 2)) {
                    dp[i][j] = dp[i+1][j] + dp[i+1][j+1];
                } else {
                    dp[i][j] = dp[i+1][j];
                }

                dp[i][j] %= mod;
            }
        }

        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 30704
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,x;
	cin>>n;
	int sum=-n;
	while(n--){
		cin>>x;
		sum+=x;
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/perl

use strict;
use warnings;

my ($a, $b);
{
    my $in = <STDIN>;
    ($a, $b) = split(" ", $in);
}
my $ans;

my $gcd = sub {
    my ($x, $y) = @_;
    
    while ($x>0 && $y>0) {
        if ($y > $x) {
            $y %= $x;
        } else {
	        $x %= $y;
        }
    }
    return $x if $x>0;
    return $y if $y>0;
};

$ans = $a/$gcd->($a, $b)*$b;
print "$ans\n";

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

using namespace std;
using ll = long long;
int main() {
	int N, K;
	cin >> N >> K;
	ll p=K ;
		for (int i = 0;i < N-1;i++) {
			p = p*(K - 1);
		}
		cout << p << endl;
		return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vector<pair<ll,ll>> data(N);
    for (int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        pair<ll,ll> p = make_pair(b, a);
        data[i] = p;
    }
    sort(data.begin(), data.end());
    ll time = 0, limit = 0;
    for (int i = 0; i < N; i++) {
        limit = data[i].first;
        time += data[i].second;
        if (limit < time) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define SORT(x) sort((x).begin(),(x).end())
#define MEMSET(x,y) memset((x),(y),sizeof(x))
#define P pair<int,int>

typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n,0);
  int mn=10000000;
  int res=0;
  rep(i,n) {
    cin >> p.at(i);
    if(p.at(i) < mn) {
      mn = p.at(i);
      res++;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024