akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}


constexpr int contest_num {26};
constexpr int order_max_cnt {10000}; // TODO : changeble

ll calc_satisfy(const vector<vector<ll>>& S, const vector<ll>& C, const vector<int>& order, const int& D) {
  ll answer {};
  vector<int> fin_day(contest_num, -1);
  rep(i, D) {
    answer += S[i][order[i]-1];
    fin_day[order[i]-1] = i;
    rep(j, contest_num) {
      answer -= C[j]*(i-fin_day[j]);
    }
  }
  return answer;
}

#include <random>

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

  int D;
  cin >> D;
  vector<ll> c(contest_num);
  rep(i, contest_num) cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(contest_num));
  rep(i, D) {
    rep(j, contest_num) {
      cin >> s[i][j];
    }
  }
  //vector<int> order(D);
  //rep(i, D) cin >> order[i];
  //int M;
  //cin >> M;
  //vector<std::pair<int, int>> query(M);
  //rep(i, M) cin >> query[i].first >> query[i].second;
  //rep(i, M) {
  //  order[query[i].first-1] = query[i].second;
  //  calc_satisfy(s, c, order, D);
  //}
  std::random_device rnd;

  ll max_params {-LLINF};
  vector<int> max_order(D);
  rep(i, order_max_cnt) {
    vector<int> order(D);
    rep(j, D) {
      order[j] = (rnd() % contest_num) +1;
    }
    ll tmp = calc_satisfy(s, c, order, D);
    if (max_params < tmp) {
      max_order = order;
    }
  }
  rep(i, D) cout << max_order[i] << '\n';
}


Measured memory_bytes: 3736
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

std::string S;


int main(int argc, char **argv) {
    std::cin >> S;

    int cnt = 0;
    
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'x') {
            cnt++;
        }
    }

    if (8 <= cnt) {
        std::cout << "NO" << std::endl;
    } else {
        std::cout << "YES" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();
        int[][] a = new int[h][w];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                a[i][j] = sc.nextInt() % 2;
            }
        }
        int[] b = new int[h*w];
        int[] c = new int[h*w];
        int[] d = new int[h*w];
        int[] e = new int[h*w];
        int[] y = new int[h*w];
        int[] x = new int[h*w];
        int cnt = -1;
        for(int i = 0; i < h; i++){
            if(i % 2 == 0){
                for(int j = 0; j < w; j++){
                    ++cnt;
                    y[cnt] = i;
                    x[cnt] = j;  
                }
            }else{
                for(int j = w - 1; j >= 0; j--){
                    ++cnt;
                    y[cnt] = i;
                    x[cnt] = j;
                } 
            }
        }
        int ans = -1;
        for(int i = 0; i < cnt; i++){
            if(a[y[i]][x[i]] % 2 == 1){
                ans++;
                b[ans] = y[i] + 1;
                c[ans] = x[i] + 1;
                d[ans] = y[i+1] + 1;
                e[ans] = x[i+1] + 1;
                a[y[i+1]][x[i+1]]++;
            }
        }
        System.out.println(++ans);
/*        int cnt = -1;
        for(int i = 0; i < h; i++){
            if(i % 2 == 0){
                for(int j = 0; j < w-1; j++){
                    if(a[i][j] % 2 == 1){
                        cnt++;
                        b[cnt] = i+1;
                        c[cnt] = j+1;
                        d[cnt] = i+1;
                        e[cnt] = j+2;
                        a[i][j+1]++;
                    }
                }
                if(i == h-1) break;
                else if(a[i][w-1] % 2 == 1){
                    cnt++;
                    b[cnt] = i+1;
                    c[cnt] = w;
                    d[cnt] = i+2;
                    e[cnt] =w;
                    a[i+1][w-1]++;
                }
            }
            else{
                for(int j = w-1; j > 0; j--){
                    if(a[i][j] % 2 == 1){
                        cnt++;
                        b[cnt] = i+1;
                        c[cnt] = j+1;
                        d[cnt] = i+1;
                        e[cnt] = j;
                        a[i][j-1]++;
                    }
                }
                if(i == h-1) break;
                else if(a[i][0] % 2 == 1){
                    cnt++;
                    b[cnt] = i+1;
                    c[cnt] = 0;
                    d[cnt] = i+2;
                    e[cnt] = 0; 
                    a[i+1][0]++;
                }
            }
        }
        System.out.println(++cnt);*/
        for(int i = 0; i < ans; i++){
            System.out.println(b[i] + " " + c[i] + " " + d[i] + " "  + e[i]);
        }
    }
}




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

#define ll long long
#define mod 1e9+7
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll n;
vector<double>arr(3000);
vector<vector<double> >dp(3000,vector<double>(3000,-1));

double solve(ll i,ll j){
	if(i==0 && j==0)
		return 1-arr[0];
	if(i==0 && j==1)
		return arr[0];
	if(i==0)
		return 0;
	if(j<0)
		return 0;
	
	if(dp[i][j] != -1)
		return dp[i][j];
	dp[i][j] = arr[i] * solve(i-1,j-1) + (1-arr[i]) * solve(i-1,j) ;
	return dp[i][j];
}

int main(){
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
    if(n==1){
    	cout<<arr[0];
    	return 0;
    }
    dp[0][0]=1;
    double ans=0;
    for(ll i=n/2+1;i<=n;i++){
    	ans=ans+solve(n-1,i);
    }
    
    cout<<setprecision(27)<<ans;
    return 0;
}



Measured memory_bytes: 70912
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long ans = 1L;
        int[] b = new int[3];
        for (int x : a) {
            long cnt = 0L;
            for(int y : b){
                if(x == y) cnt++;
            }
            ans = ans * cnt % 1000000007L;
            for (int i = 0; i < 3; i++) {
                if(b[i] == x){
                    b[i]++;
                    break;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 50736
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String input = sc.next();

        List<Boolean> stones = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            stones.add(input.charAt(i) == 'R');
        }

        int current;
        int wIndex;
        long steps = 0;
        while ((wIndex = stones.indexOf(false)) < (current = stones.lastIndexOf(true))
                && stones.contains(false)
                && stones.contains(true)
        ) {
            stones.set(wIndex, true);
            stones = stones.subList(wIndex, current);
            steps++;
        }
        System.out.println(steps);
    }
}

Measured memory_bytes: 46364
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;

#define MOD 1000000007
#define PI 3.14159265359

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

    string s;
    cin >> s;

    bool flag[26] = {false};

    for(int i = 0; i < s.size(); i++){
        flag[s[i] - 'a'] = true;
    }

    for(int i = 0; i < 26; i++){
        if(flag[i] == false){
            p((char)(i + 'a'));
            return 0;
        }
    }
    p("None");
}

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

using namespace std;

double call(vector<double> & a, vector<vector<double> > &dp, int i, int x){
    if(x==0)
        return 1;
    if(i==0)
        return 0;
    if(dp[i][x]>-0.9)
        return dp[i][x];
    return dp[i][x] = a[i]*call(a,dp,i-1,x-1) + (1-a[i])*call(a,dp,i-1,x);
}

int main(){
    int n;
    cin>>n;
    vector<double> a(n+1,0.0);
    vector<vector<double> > dp(n+1, vector<double>(n+1,-1));
    for(int i=1;i<=n;i++)
        cin>>a[i];
    cout<<fixed<<setprecision(10)<<call(a,dp,n,(n+1)/2)<<endl;
    return 0;
}


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

using namespace std;

int main() {
    #ifdef LOCAL
    freopen("in", "r", stdin);
    #endif // LOCAL
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
    for (int k = j + 1; k < n; k++) {
        if (a[i] != a[j] && a[i] != a[k] && a[k] != a[j] && a[i] + a[j] > a[k] && a[i] +a[k] > a[j] && a[j] + a[k] > a[i]) {
//            cerr << i << ", " << j << ", " << k << endl;
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long
#define INF 1000000000000000
#define pii pair<long long,long long>
lint dp[100010];
lint h[100010];
int main() {

	lint N, K; cin >> N >> K;
	
	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	for (int i = 2; i < N; i++)
	{
		vector<pii> cost(K);
		for (int j = 0; j < K; j++)
		{	
			if (i - (j + 1) < 0) {
				cost[j] = make_pair(INF, j + 1);
				continue;
			}
			lint c = dp[i - (j + 1)] + abs(h[i] - h[i - (j + 1)]);
			cost[j] = make_pair(c, j + 1);

		}
		sort(cost.begin(), cost.end());
		dp[i] = dp[i - (cost[0].second)] + abs(h[i] - h[i - (cost[0].second)]);

	}

	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	_ "strings"
)

var sc = bufio.NewScanner(os.Stdin)

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

func convertToInt(s []string, len int) []int {
	ret := make([]int, len)
	for i := 0; i < len; i++ {
		ret[i], _ = strconv.Atoi(s[i])
	}
	return ret
}

func main() {
	N, _ := strconv.Atoi(nextLine())
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i], _ = strconv.Atoi(nextLine())
	}
	sort.Ints(a)
	a2 := a
	mid := N / 2
	b := make([]int, N)
	b[mid] = a[0]
	a = a[1:]
	maxTurn := true
	for i := 1; i <= N/2; i++ {
		if maxTurn {
			if mid-i >= 0 {
				b[mid-i] = a[len(a)-1]
				a = a[:len(a)-1]
			}
			if mid+i < N {
				b[mid+i] = a[len(a)-1]
				a = a[:len(a)-1]
			}
			maxTurn = false
		} else {
			if mid-i >= 0 {
				b[mid-i] = a[0]
				a = a[1:]
			}
			if mid+i < N {
				b[mid+i] = a[0]
				a = a[1:]
			}
			maxTurn = true
		}
	}

	sum1 := 0.0
	for i := 0; i < N-1; i++ {
		sum1 += math.Abs(float64(b[i] - b[i+1]))
	}

	b2 := make([]int, N)
	b2[mid] = a2[len(a2)-1]
	a2 = a2[:len(a2)-1]
	minTurn := true
	for i := 1; i <= N/2; i++ {
		if minTurn {
			b2[mid-i] = a2[0]
			a2 = a2[1:]

			if mid+i < N {
				b2[mid+i] = a2[0]
				a2 = a2[1:]
			}
			minTurn = false
		} else {
			b2[mid-i] = a2[len(a2)-1]
			a2 = a2[:len(a2)-1]
			if mid+i < N {
				b2[mid+i] = a2[len(a2)-1]
				a2 = a2[:len(a2)-1]
			}
			minTurn = true
		}
	}

	sum2 := 0.0
	for i := 0; i < N-1; i++ {
		sum2 += math.Abs(float64(b2[i] - b2[i+1]))
	}

	if sum1 > sum2 {
		fmt.Println(int(sum1))
	} else {
		fmt.Println(int(sum2))
	}

}


Measured memory_bytes: 4608
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a[] = new int [3];
        int place;
        a[0]=sc.nextInt();
        a[1]=sc.nextInt();
        a[2]=sc.nextInt();
        if(a[0]>a[1]){
            place=a[0];
            a[0]=a[1];
            a[1]=place;
        }
        if(a[1]>a[2]){
            place=a[1];
            a[1]=a[2];
            a[2]=place;
        }
        if(a[0]>a[1]){
            place=a[0];
            a[0]=a[1];
            a[1]=place;
        }
        System.out.println(a[0]+" "+a[1]+" "+a[2]);
    }
}



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

int main(){
    int a,b,q;
    cin >> a >> b >> q;
    ve<ll> s(a), t(b);
    rep(i,a) cin >> s[i];
    rep(i,b) cin >> t[i];
    rep(Q,q){
        ll x;
        cin >> x;
        auto ita = lower_bound(s.begin(), s.end(), x);
        auto itb = lower_bound(t.begin(), t.end(), x);
        ll es,et,ws,wt;
        if(ita == s.begin()) es = -2e15;
        else es = *prev(ita);
        if(ita == s.end()) ws = 2e15;
        else ws = *ita;
        if(itb == t.begin()) et = -2e15;
        else et = *prev(itb);
        if(itb == t.end()) wt = 2e15;
        else wt = *itb;
        ll ans = min(max(x-es,x-et),max(ws-x,wt-x));
        ans = min(ans,(x-es)+wt-es);
        ans = min(ans,(x-et)+ws-et);
        ans = min(ans,ws-x+ws-et);
        ans = min(ans,wt-x+wt-es);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4800
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

count = 0
for _ in range(N):
  A = list(map(int, input().split()))
  ans = 0
  for i, j in enumerate(B):
    ans += A[i] * j
  if ans + C > 0:  
    count += 1
print(count)

Measured memory_bytes: 3060
#ライブラリインポート
from collections import defaultdict, deque

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	#入力
	N, M = getlist()
	s = list(input())
	outE = defaultdict(list)
	inEA = defaultdict(int)
	inEB = defaultdict(int)
	E = set()
	for i in range(M):
		a, b = sorted(getlist())
		a = a - 1
		b = b - 1
		E.add((a, b))
	E = list(E)
	#print(E)
	m = len(E)
	for i in range(m):
		a = E[i][0]
		b = E[i][1]
		outE[a].append(b)
		outE[b].append(a)
		if s[a] == "A":
			inEA[b] += 1
		else:
			inEB[b] += 1

		if s[b] == "A":
			inEA[a] += 1
		else:
			inEB[a] += 1
	
	Q = deque()
	for i in range(N):
		if inEA[i] == 0 or inEB[i] == 0:
			Q.append(i)

	visit = ["No"] * N
	check = ["Yes"] * N
	while Q:
		u = Q.popleft()
		if visit[u] == "Yes":
			continue
		visit[u] = "Yes"
		check[u] = "No"
		for v in outE[u]:
			if s[u] == "A":
				inEA[v] -= 1
				if inEA[v] == 0:
					check[v] = "No"
					Q.append(v)
			else:
				inEB[v] -= 1
				if inEB[v] == 0:
					check[v] = "No"
					Q.append(v)

	judge = "No"
	#print(check)
	for i in range(N):
		if check[i] == "Yes":
			judge = "Yes"
	print(judge)

if __name__ == '__main__':
	main()

Measured memory_bytes: 131236
s=input()

ans = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        if s[i:j].count("A")+s[i:j].count("C")+s[i:j].count("G")+s[i:j].count("T")==j-i:
            ans = max(ans,j-i)
print(ans)


Measured memory_bytes: 8980
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n,m,t=0,k=1,l=0,h=0,ans=1,u=1,v=2,w=1;
    cin >> n >> m;
    vector<int> a(m+1);
    vector<int> b(0);
    for (int i=0;i<m;i++){
        cin >> a.at(i);
    }
    while (true){
        if (k==a.at(l)){
            if (t==1) {cout << 0 << endl;return 0;}
            b.push_back(h);
            h=-1;
            t=1;
            l++;
            }
        else {
            t=0;
            h++;
        }
        if (k==n) break;
        k++;
    }
    b.push_back(h);
    for (int i=0;i<b.size();i++){
        for (int j=2;j<b.at(i);j++){
            w=(u+v)%1000000007;
            u=v;v=w;
        }
        if (b.at(i)==2) ans=(ans*2)%1000000007;
        else ans=ans*w%1000000007;
        u=1;v=2;w=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string ans="yes", s;
    cin >> s;
    int cnt[26];
    for(int i=0; i<26; i++) cnt[i] = -1;
    for(int i=0; i<s.size(); i++){
      if(cnt[s[i]-'a']==0){
        ans = "no";
        break;
      }
      cnt[s[i]-'a'] = 0;
    }

    cout << ans << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
vi move1 = {0,0,1,-1};
vi move2 = {1,-1,0,0};

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int x,y,s;
    while(cin >> x>>y>>s) {
        if(x==0&&y==0&&s==0) break;

        int ans = -1;
        for(int i = 1; i < s; ++i) {
            int p = i;
            int q = s-i;
            int pa = p, qa = q;////
            p = (p+1)*100/(100+x);  //切り上げ
            q = (q+1)*100/(100+x);  //切り上げ
            p = p*(100+y)/100;
            q = q*(100+y)/100;
            if(((p+1)*100/(100+y))*(100+x)/100!=pa) continue;
            if(((q+1)*100/(100+y))*(100+x)/100!=qa) continue;
            if(chmax(ans, p+q)) {/*
                debug(pa);debug(qa);
                debug(p);debug(q);
                debug(ans);*/
            }
        }
        cout << ans << '\n';
    }
}


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

#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=(Factorial[i-1]*i)%MOD;
  Finverse[4999999]=pw(Factorial[4999999],MOD-2);
  for(int i=4999998;i>=0;i--)Finverse[i]=(i+1)*Finverse[i+1]%MOD;
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  (res*=Finverse[k])%=MOD;
  (res*=Finverse[n-k])%=MOD;
  return res;
}

signed main(){
  int s;cin>>s;
  int ans=0;
  for(int i=1;i<=s/3;i++){
    int tmp=s-i*3;
    ans+=nCk(tmp+i-1,i-1);
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 81256
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
kari=[0]
for i in range(n):
 cnt=s.count(s[i])
 cnt-=t.count(s[i])
 kari.append(cnt)
 cnt=0

print(max(kari))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
	while(1){
		long n, i, sum=0;
		int a;
		
		scanf(" %ld", &n);
		if(n==0) break;
			
		for(i=0; i<n/4; i++){
			scanf(" %d", &a);
			sum += a;
		}
	
		printf("%ld\n", sum);
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
  long long int A,B,C,K;
  cin >> A >> B >> C >> K;
  long long int ans=0;
  if(K<=A)ans=K;
  else if(K<=A+B)ans=A;
  else ans=2*A-K+B;
  cout << ans << endl;
}

Measured memory_bytes: 3596
//package compilers;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int [][]arr=new int[n][2];
		int sum=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<2;j++) {
				arr[i][j]=in.nextInt();
				if(j==1)
					sum+=arr[i][j];
			}
		}
		
		long dp[]=new long [sum+1];
		//System.out.println(sum);
		Arrays.fill(dp, (long)1e18+5);
		dp[0]=0;
		for(int i=0;i<n;i++) {
			for(int j=sum;j>=0;j--) {
				if(j-arr[i][1]>=0) {
				dp[j]=Math.min(dp[j], dp[j-arr[i][1]]+arr[i][0]);
				
				}
			}
		}
		long ans=0;
		for(int i=0;i<=sum;i++) {
			//System.out.print(dp[i] + " ");
			if(dp[i]<=k)
				ans=Math.max(i,ans);
		}
		System.out.println(ans);
		
	}

}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;

vector<vector<int>> g, pref, suff;
vector<int> dp, ans;

void dfs1(int v, int p = -1) {
	pref[v].resize(g[v].size(), 1);
	suff[v].resize(g[v].size(), 1);
	for (int i = 0; i < g[v].size(); i++) {
		int u = g[v][i];
		if (u != p) {
			dfs1(u, v);
			dp[v] = dp[v] * (dp[u] + 1) % MOD;
		}
	}
	for (int i = 0, j = (int) g[v].size() - 1; i < g[v].size(); i++, j--) {
		int u1 = g[v][i];
		int u2 = g[v][j];
		if (u1 != p) {
			pref[v][i] = (i ? pref[v][i - 1] : 1) * (dp[u1] + 1) % MOD;
		}
		else {
			pref[v][i] = (i ? pref[v][i - 1] : 1);
		}
		if (u2 != p) {
			suff[v][j] = (j != (int)g[v].size() - 1 ? suff[v][j + 1] : 1) * (dp[u2] + 1) % MOD;
		}
		else {
			suff[v][j] = (j != (int)g[v].size() - 1 ? suff[v][j + 1] : 1);
		}
	}
}

void dfs2(int v, int p = -1, int up = 0) {
	ans[v] = (up + 1) * dp[v] % MOD;
	for (int i = 0; i < g[v].size(); i++) {
		int u = g[v][i];
		if (u != p) {
			int val = (up + 1) * (i ? pref[v][i - 1] : 1) % MOD;
			val = val * (i == (int)g[v].size() - 1 ? 1 : suff[v][i + 1]) % MOD;
			dfs2(u, v, val);
		}
	}
}

void solve() {
	int n;
	cin >> n >> MOD;
	g.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	
	dp.resize(n, 1);
	pref.resize(n);
	suff.resize(n);
	ans.resize(n);

	dfs1(0);
	dfs2(0);
	for (int i : ans) cout << i << '\n';
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int s;
	cin >> s;
	map<int, int> mp;
	mp[s]++;
	
	int a = s;
	int i = 1;
	while(1){
		++i;
		if(a & 1){
			a = 3 * a + 1;
		}
		else{
			a /= 2;
		}
		if(mp.count(a)){
			cout << i << endl;
			return 0;
		}
		mp[a]++;
	}
	
	return 0;
}



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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> vec(n);
  
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    vec[a-1]+=1;
    vec[b-1]+=1;
  }
  for(int i=0;i<n;i++){
    cout<<vec[i]<<endl;
  }
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from collections import Counter 
from random import randrange
def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            ast(vf)
    return par, order

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res


N = int(readline())
Edge = [[] for _ in range(N)]
Leaf = [0]*N
for _ in range(N-1):
    a, b = map(int, readline().split())
    Leaf[a] += 1
    Leaf[b] += 1
    Edge[a].append(b)
    Edge[b].append(a)

Leaf = [i for i in range(N) if Leaf[i] == 1]
M = len(Leaf)
ANS = 10**9+7 
for idx in [0] + [randrange(1, M) for _ in range(10)]:
    root = Leaf[idx]
    P, L = parorder(Edge, root)
    C = getcld(P)
    
    dp = [0]*N
    countone = [0]*N
    for l in L[::-1][:-1]:
        p = P[l]
        dp[l] += 1 + max(0, countone[l] - 1)
        if dp[l] == 1:
            countone[p] += 1
        dp[p] += dp[l] - 1
        
    dp[root] += 1 + max(0, countone[root] - 1)
    ANS = min(ANS, dp[root])
print(ANS)

Measured memory_bytes: 134208
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

#define mod 998244353
 
int main(){
    int n,m; cin >> n >> m;
    vector<int> x(m);
    rep(i,m) cin >> x[i];
    if(m == 1){
        cout << 0 << endl;
        return 0;
    }
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    ll ans = x[m-1] - x[0];
    priority_queue<int> q;
    
    for(int i=0; i<m-1; i++){
        q.push(abs(x[i+1] - x[i]));
    }
    while (n > 1) {
        ans -= q.top();
        q.pop();

        n--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define f first
#define s second
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define CLR(x)  memset(x,0,sizeof(x))
#define RESET(x,a) memset(x,a,sizeof(x))
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;

ll a[1005],b[1005];

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int t,n,m,i,j;
    ll tot,c,d,e,f,x,y;
    si(n);
    for(i=0;i<n;i++)
    {
        sl(a[i]);
        sl(b[i]);
    }
    for(m=1;m<n;m++)
    {
    c=a[m];
    d=b[m];
    x=c;
    y=d;
    for(i=m-1;i>=0;i--)
    {
        e=a[i];
        f=b[i];
        if(c<e)
        {
            ll tim=(e-c)/x;
            if((e-c)%x)
                tim++;
            c=c+tim*x;
            d=d+tim*y;
        }
        if(d<f)
        {
            ll tim=(f-d)/y;
            if((f-d)%y)
                tim++;
            c=c+tim*x;
            d=d+tim*y;
        }
    }
    a[m]=c;
    b[m]=d;
    //printf("%lld %lld\n",c,d);
    }
    tot=a[n-1]+b[n-1];
    printf("%lld\n",tot);
    return 0;
}



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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long> L(n);
	for (long i = 0; i < n; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());

	//for (long i = n-2; i >=0; i--) {
	//	if (L[i] == L[i + 1]) {
	//		L.erase(L.begin() + i+1);
	//	}
	//}
	
	n = L.size();

	long long counter = 0;
	for (long i = 0; i < n-2; i++) {
		for (long j = i+1; j<n-1 ; j++) {
			for (long k = j+1; k < n; k++) {

				if (L[i] + L[j] > L[k]) { counter++; }
				else { break; }

			}
		}
	}

	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double x;
    string u;
    double ans=0;
    for(int i=0;i<n;i++){
        cin>>x>>u;
        if(u=="JPY") ans+=x;
        if(u=="BTC") ans+= 380000.0*x;
    }
    cout <<  ans << endl;
}



Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]

for i in range(1, n + 1):
    print(*A)
    if i >= n: break

    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = key



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

const int mod = 924844033;

int N, K;
vector<int> L;

int cc[2010][2010][3][2];
int dp(int n, int k, int la, int sol) {
    int &ret = cc[n][k][la][sol];
    if(ret != -1) return ret;
    if(n == N) return ret = k == 0;

    if(L[n] < K) {
        ret = dp(n + 1, k, 0, 1);
        if(k) {
            ret += 1LL * k * dp(n + 1, k - 1, 0, 0) % mod;
            ret %= mod;
        }
        ret += 1LL * (n - k) * dp(n + 1, k, 0, 0) % mod;
        ret %= mod;
        return ret;
    }
    if(la == 2) {
        ret = dp(n + 1, k, 0, 1);
        ret += 1LL * (k - 2) * dp(n + 1, k - 1, 0, 0) % mod;
        ret %= mod;
        ret += 1LL * 2 * dp(n + 1, k, 1, 0) % mod;
        ret %= mod;
        ret += 1LL * (n - k) * dp(n + 1, k, 0, 0) % mod;
        ret %= mod;
        return ret;
    }
    if(la == 1) {
        ret = dp(n + 1, k, 0, 1);
        ret += 1LL * (k - 1) * dp(n + 1, k - 1, 0, 0) % mod;
        ret %= mod;
        ret += dp(n + 1, k, 1, 0) % mod;
        ret %= mod;
        ret += dp(n + 1, k + 1, 1, 0) % mod;
        ret %= mod;
        ret += 1LL * (n - 1 - k) * dp(n + 1, k, 0, 0) % mod;
        ret %= mod;
        return ret;
    }
    if(sol) {
        ret = dp(n + 1, k, 0, 1);
        if(k) {
            ret += 1LL * k * dp(n + 1, k - 1, 0, 0) % mod;
            ret %= mod;
        }
        ret += dp(n + 1, k + 2, 2, 0) % mod;
        ret %= mod;
        ret += 1LL * (n - 1 - k) * dp(n + 1, k, 0, 0) % mod;
        ret %= mod;
        return ret;
    }
    ret = dp(n + 1, k, 0, 1);
    if(k) {
        ret += 1LL * k * dp(n + 1, k - 1, 0, 0) % mod;
        ret %= mod;
    }
    ret += 1LL * 2 * dp(n + 1, k + 1, 1, 0) % mod;
    ret %= mod;
    ret += 1LL * (n - k - 2) * dp(n + 1, k, 0, 0) % mod;
    ret %= mod;
    return ret;
}

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

    for(int i = 0; i < K; i++) {
        for(int j = 0;; j++) {
            if(j * K + i >= N) break;
            L.push_back(j * K + i);
        }
    }

    memset(cc, -1, sizeof(cc));
    cout << dp(0, 0, 0, 0);
}


Measured memory_bytes: 95104
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

vector<int64_t> divisor(int64_t n) {
    vector<int64_t> res;
    for(int64_t i=1; i*i<=n; i++) {
        if(n%i == 0) {
            res.push_back(i);
            if(i != n/i)  res.push_back(n/i);
        }
    }
    return res;
}

map<int64_t, int64_t> prime_factor(int64_t n) {
    map<int64_t, int64_t> res;
    for(int64_t i=2; i*i<=n; i++) {
        while(n%i == 0)  res[i]++, n/=i;
    }
    if(n != 1)  res[n] = 1;
    return res;
}

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

    auto div = divisor(n);
    auto pf2 = prime_factor(n-1);

    lint ans1 = 0;
    for(auto e : div) {
        if(e == 1)  continue;
        lint tmp = n;
        while(tmp % e == 0)  tmp /= e;
        ans1 += (tmp%e == 1);
    }

    lint ans2 = 1;
    for(auto& e : pf2) {
        ans2 *= e.second + 1;
    }
    --ans2;

    cout << ans1 + ans2 << endl;
}

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


int main() {
    int n, m; cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    vector<vector<int>> g(n, vector<int>());
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    rep(i, n) {
        vector<int> u = g[i];
        bool ok = true;
        for (int j = 0; j < u.size(); j++) {
            if (h[u[j]] >= h[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9288
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int n;
	std::cin >> n;
	V<lnt> a(1<<n);
	fill(a);
	int max=0;
	V<std::pair<std::pair<int,int>,std::pair<int,int> > > dp(1<<n);
	/*
	rep(i,n) {
		dp[1<<i]=std::make_pair(std::make_pair(a[0],0),std::make_pair(a[1<<i],1<<i));
	}
	*/
	for(int k=1;k<(1<<n);k++) {
		std::set<std::pair<int,int> > set;
		rep(i,n) {
			if(k&(1<<i)) {
				if((k^(1<<i))==0) set.emplace(a[0],0);
				else {
					auto p=dp[k^(1<<i)];
					set.emplace(p.first);
					set.emplace(p.second);
				}
			}
		}
		set.emplace(a[k],k);
		auto f=*set.rbegin();
		dp[k].first=f;
		set.erase(f);
		auto s=*set.rbegin();
		dp[k].second=s;
		max=std::max(max,f.first+s.first);
		print(max);
	}
}


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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b;
    
    cin>>a>>b;
    if(a>0){
        cout<<"Positive";
        return 0;
    }
    if(a<=0 && b>=0){
        cout<<"Zero";
        return 0;
    }
    cout<<((b-a)%2?"Positive":"Negative");
    return 0;
    
    
    
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr ll MOD = 1000000007;

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll N;
  cin >> N;
  vec<ll> A(N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);

  ll ans = 0;
  rep(i, 0, 62) {
    int count = count_if(all(A), [i](auto num) { return num & (1LL << i); });

    ans += (mod(1LL << i, MOD) * mod((N - count) * count, MOD)) % MOD;
    ans = mod(ans, MOD);
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 2560
#include<stdio.h>
 
int main() 
{
 
int S;
int h,m,s;
int a;
 
scanf("%d",&S);
 
a=S%3600;
h=(S-a)/3600;
 
s=a%60;
m=(a-s)/60;
 
printf("%d:%d:%d\n",h,m,s);
 
return 0;
 
}


Measured memory_bytes: 2100
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in();
	string prev,current=in<string>();
	set<string> history;
	history.insert(current);
	prev = current;
	REP(i,N-1){
		current = in<string>();
		auto res = history.insert(current);
		if(!res.second || prev.back()!=current.front()){
			cout << "No" << endl;
			return 0;
		}
		prev = current;
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum = 0
for i in a:
	sum += i
cnt = 0
for j in range(len(a)):
	if a[j] * 4 * m >= sum:
		cnt += 1

if cnt >= m:
	print('Yes')
else:
	print('No')

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

int main(){
  int a, b;
  cin >> a >> b;
  if(b != 1 && (a > b || a == 1)){
    cout << "Alice" << endl;
  }else if(a == b){
    cout << "Draw" << endl;
  }else{
    cout << "Bob" << endl;
  }
}


Measured memory_bytes: 256
const val mod = 1000000007L

fun modpow(n:Long,p:Long = mod-2L):Long = when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d = modpow(n,p/2)
		d*d%mod
	}
}

fun nCr(n:Int,r:Int,modpowCache:Long):Long = (n-r+1L..n).asSequence().fold(modpowCache) {a,b-> a*b%mod}
fun modpowCache(r:Int) = (2L..r).asSequence().map {modpow(it.toLong())}.fold(1L) {a,b-> a*b%mod}

fun main(args:Array<String>) {
	abc000X()
}

fun abc000X() {
	val s = java.util.Scanner(System.`in`)
	val n = s.nextInt()
	val k = s.nextInt()
	if(k==1) {
		println(0)
		return
	}
	val a = LongArray(n) {s.nextLong()}.sorted()

	val modpowCache = modpowCache(k-2)
	val cache:LongArray = when {
		k<3->LongArray(n-1) {modpowCache}
		else-> {
			val t = LongArray(n-1) {0L}
			t[k-2] = nCr(k-2,k-2,modpowCache)
			for(i in k-1..n-2) {
				t[i] = t[i-1]*i%mod*modpow(i-k+2L)%mod
			}
			t
		}
	}

	for(i in 1..n-2)
		cache[i] = (cache[i]+cache[i-1])%mod

	var r = 0L
	for(i in a.indices) {
		val l = if(i-1<0) 0 else cache[i-1]
		val m = if(n-2-i<0) 0 else cache[n-2-i]
		r = ((l-m+mod)%mod*a[i]%mod+r+mod)%mod
	}
	println(r)
}


Measured memory_bytes: 54616
#include <stdio.h>
int main() {
  int A,B,tmp;
  scanf("%d" "%d",&A,&B );
  if (A<B) {
    tmp = B*2-1;
  }else if(A>B){
    tmp = 2*A-1;
  }else{
    tmp = A*2;
  }
  printf("%d\n",tmp);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
ll n, k, arr[105], dp[105][100005];
ll solve(int i, ll sum){
    if(i==n)
        return !sum;
    if(i<0 || sum<0)return 0;
    if(!sum)return 1;
    if(dp[i][sum]!=-1)return dp[i][sum];
    ll res=solve(i+1,sum) + solve(i,sum-1);
    res-=solve(i+1,sum-arr[i]-1);
    return dp[i][sum]=(res+mod)%mod;
}
int main()
{
    Fastio();
    cin>>n>>k;
    for(int i=0; i<n; i++){cin>>arr[i];}
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,k)<<'\n';

    return 0;
}


Measured memory_bytes: 90496
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
C = [[0 for j in range(l)] for i in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]

for i in range(n):
    print(" ".join(map(str, C[i])))


Measured memory_bytes: 6884
N = int(input())
A = list(map(int,input().split()))

R = [0]*N
L = [0]*N

for i in range(N):
    R[i] = - A[i] + i
    L[i] = A[i] + i

R.sort()
L.sort()

p = 0
q = 0

ans = 0
while p < N and q < N:
    if L[p] == R[q]:
        a = 1
        b = 1
        while p+a < N and L[p+a] == L[p]:
            a += 1
        while q+b < N and R[q+b] == R[q]:
            b += 1
        ans += a*b
        p += a
        q += b
    elif L[p] < R[q]:
        p += 1
    else:
        q += 1
    
    ###
    #if p < N and q < N:
    #    print(L[p],R[q],ans)
    ###

###
#print(L)
#print(R)
###

print(ans)

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//class Timer {
//    clock_t start;
//    string name;
//public:
//    Timer() {name = "";start = clock();}
//    Timer(string s){name = s;start = clock();}
//    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
//};

//#define isValid(a, b) ((a) >= 0 && (a) < (b))
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define um unordered_map
#define us unordered_set
#define endl '\n'
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0);

template<typename T> inline T sq(T a){return a*a;}
template<typename T1, typename T2> inline pair<T1, T2> mp(T1 a, T2 b){return make_pair(a, b);}
template<typename T1, typename T2> inline T1 safeMod(T1 a, T2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename T1, typename T2> inline bool isEq(T1 a, T2 b){return abs(a - b) < EPS;}
template<typename T1, typename T2, typename T3> inline bool isEq(T1 a, T2 b, T3 eps){return abs(a - b) < eps;}
template<typename T> inline bool isKthBitOn(T n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;return bool((n & (ONE<<k)));}
template<typename T> inline void setKthBit(T& n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;n = (n|(ONE<<k));}
//mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
//template<typename T> inline T nextRand(T lo, T hi){return uniform_int_distribution<T>(lo, hi)(rng);}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

int main()
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        if(n%i == 0){
            int d = n/i;
            if(1 <= d && d <= 9){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

#define MAX 2000100
ll fac[MAX],finv[MAX],inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (ll i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
// 二項係数計算
ll combi(ll n,ll k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//mainに   COMinit();   を入れる

ll modpow(ll x,ll n) {
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*x%mod;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x=x*x%mod;
        n>>=1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(){
    COMinit();
    ll k;string s;cin>>k>>s;
    ll n=s.size();

    ll minus=0,ans=modpow(26ll,n+k);
    rep(i,n){
        minus+=(combi(n+k,i)*modpow(25ll,n+k-i))%mod;
        minus%=mod;
    }

    ans-=minus;
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 52136