akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int last[40];
int s[400][400];
int c[26];
int d;
int calc(int x,int y){
    int ret = 0;
    //use t[i];
    ret += s[x][y];
    last[y] = x+1;
    rep(j,26){
        ret -= c[j]*(x+1-last[j]);
    }
    return ret;

}
signed main(){
    cin >> d;
    rep(i,26)cin >> c[i];
    vector<int> ans(d);
    vector<int> t(d);
    rep(i,d)rep(j,26)cin >> s[i][j];
    int cnt = 0;
    int res = 0;
    int mx[400];
    //rep(i,d){
    //    P v = P(0,0);
    //    rep(j,26){
    //        v = max(v,P(s[i][j],j));
    //    }
    //    mx[i] = v.second + 1;
    //}

    rep(i,d){
        int res = 0;
        rep(j,26){
            if(res < calc(i,j)){
                ans[i] = j+1;
                res = calc(i,j);
            }
        }
    }
   
    rep(i,d)cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  char a;
  cin >> a;
  if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') co("vowel");
  else co("consonant");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

vector< vector<int> > cnt(26);

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
    cnt[s[i] - 'a'].push_back(i);
  }
  int ans = 0;
  int left;
  for(int i = 0; i < 26; i++){
    int cnt_size = cnt[i].size();

    for(int j = 0; j < cnt_size; j++){
      left = cnt[i][j];
      for(int k = cnt_size - 1, right = cnt[i][k]; k > j  && right - left > ans ; k--, right = cnt[i][k]){
        if(N - right <= ans) continue;
        int t = 0;
        for(int m = 0; left + m < right; m++){
          if(s[left+m] == s[right+m]) t++;
          else break;
        }
        if(t > ans) ans = t;

      }
    }
  }
  cout << ans << endl;
}


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

Measured memory_bytes: 580
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void push(int *a,int x);
int pop(int *a);
int isEmpty();
int top=0;
int main()
{
  int i=0,j=0,k=0,num=0,a,b,c,d[100],h,r;
  char n[10],ch,dum,fi;
  while(1){
    fi=scanf("%s",n);
    
    if(fi==EOF)break;
    switch(n[0]){
    case '+':
      a=pop(d);
      b=pop(d);
      push(d,a+b);
      break;
    case '-':
      a=pop(d);
      b=pop(d);
      push(d,b-a);
      break;
    case '*':
      a=pop(d);
      b=pop(d);
      push(d,b*a);
      break;
    case ' ':
      break;
    default:
      num=atoi(n);
      push(d,num);
      break;
    }
  }
  printf("%d\n",d[top]);
  return 0;
}
void push(int *a, int x){
  top=top+1;
  a[top]=x;
  //printf("%d\n",a[top]);
}
int pop(int *a){
  if(isEmpty()==1){
    exit(2);
    }else{
    top=top-1;
    return a[top+1];
  }
}
int isEmpty(){
  if(top==0){
    return 1;
  }else{
    return 0;
  }
}



Measured memory_bytes: 2136
#include <iostream>
#include <cmath>
#include <limits.h>
using namespace std;
 
int main() {
    int n,r;
    int min = INT_MAX, ans=INT_MIN;
    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> r;
        if(r-min>ans) ans= r-min;
        if(r<min) min =r;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

int main(){
    ll N, T; cin >> N >> T;
    ll d = 0;
    vector<ll> a(N), dp(N, INF);
    rep(i, N) cin >> a[i];
    rep(i, N){
        chmin(dp[i], a[i]);
        if (0 < i) chmin(dp[i], dp[i - 1]);
        chmax(d, a[i] - dp[i]);
    }
    ll ans = 0;
    map<ll, ll> mp;
    rep(i, N){
        mp[a[i]]++;
        ans += mp[a[i] - d];
    }
    pt(ans);
    return 0;
}

Measured memory_bytes: 14336
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h1 = s.nextInt(), m1 = s.nextInt(), h2 = s.nextInt(), m2 = s.nextInt(), k = s.nextInt();
		int time = (h2 - h1) * 60 + (m2 - m1);
		System.out.println(Math.max(0, time - k));

	}
	
	

}


Measured memory_bytes: 35796
#include <stdio.h>
int main(void)
{
	int N,T,c[101],t[101],i,mini=10000,a=0;
	scanf("%d%d",&N,&T);
	for(i=0; i<N; i++){
		scanf("%d%d",&c[i],&t[i]);
		if(t[i]<=T){
			if(mini>c[i])mini=c[i];
			a=1;
		}
	}
	if(a==0)puts("TLE");
	else	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
const int MOD = 1000000007;
using namespace std;

int main(){
    int N,maxnum=1,maxcount=0;

	cin >> N;
    for(int i=1;i<=N;i++){
        int num = i;
        int count = 0;
        while(true){
            // printf("%d ",num);
            if(num%2!=0 || num == 0){
                break;
            }else{
                num /= 2;
                count++;
            }
        }
        // printf("\n");
        if(count>maxcount){
            maxcount=count;
            maxnum = i;
        }
    }
    cout << maxnum << endl;
}

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


int main(){
  int g = 0, f, ans = 1, n, temp;
  int a[200200];

  cin>>n;

  for(int i = 1; i <= n; i++){
    cin>>a[i];
    if(i != 1 && a[i-1] != a[i]){g = 1;}
  }

  if(g == 1){
    
    for(int i = 2; i * i <= n; i++){
      if(n%i == 0){
	f = 0;
	for(int k = 1; k <= i; k++){
	  for(int l = k; l <= n; l+= i){
	    if(a[k] != a[l]){
	      f = 1;
	    break;
	    }
	    
	  }
	  if(f == 1) break;
	}
	
	if(f == 0){//cout<<ans<<endl;
	ans = n/i;
	break; 
	}


	 temp = n/i;
      f = 0;
      for(int k = 1; k <= temp; k++){
	for(int l = k; l <= n; l+= temp){
	  if(a[k] != a[l]){
	    f = 1;
	    break;
	  }
	  
	}
	if(f == 1) break;
      }
      if(f == 0){
	ans = i;
      }

      }
     
    }
  }else ans = n;
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 3880
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {	
	while(1) {
		char s[210];
		int n, a;
		scanf("%s", s);
		if(s[0] == '-' && s[1] == '\0') break;
		cin >> n;
		string s1 = s;
		rep(i,n) {
			cin >> a;
			string s2 = s1.substr(0, a);
			string s3 = s1.substr(a);
			s1 = s3 + s2;
		}
		cout << s1 << endl;
	}
	return 0;
}

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

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

using namespace std;

struct Event {
  int id,time,score;
  bool operator < ( const Event& event ) const {
    if( time != event.time ) return time < event.time;
    if( id   != event.id   ) return id   < event.id;
    return score > event.score;
  }
};

struct Data {
  int id,score;
  bool operator < ( const Data& data ) const {
    if( score != data.score ) return score < data.score;
    return id > data.id;
  }
};

const int MAX_N = 200000;
int sum[MAX_N],total_score[MAX_N];
int N,R,L;

int main(){
  cin >> N >> R >> L;
  vector<Event> buf(R);
  rep(i,R) cin >> buf[i].id >> buf[i].time >> buf[i].score;
  rep(i,R) --buf[i].id;
  buf.push_back((Event){0,0,0});
  buf.push_back((Event){0,L,0});
  sort(buf.begin(),buf.end());
  rep(i,N) sum[i] = total_score[i] = 0;
  
  priority_queue<Data> Q;
  int prev = 0,pre_id = 0;
  rep(i,(int)buf.size()){
    Event e = buf[i];
    sum[e.id] += e.score;
    Q.push((Data){e.id,sum[e.id]});
    while( !Q.empty() && sum[Q.top().id] != Q.top().score ) Q.pop();
    total_score[pre_id] += e.time - prev;
    prev = e.time;
    pre_id = Q.top().id;
  }
  int maxi = 0;
  rep(i,N) if( total_score[i] > total_score[maxi] ) maxi = i;
  cout << maxi + 1 << endl;
  return 0;
}

Measured memory_bytes: 24840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    string S; cin >> S;
    int Q; cin >> Q;
    bool r = false;
    string sf,sl;
    REP(_,Q){
        int t; cin >> t;
        if(t == 1){
            r = !r;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(r) sl += c;
                else sf += c;
            }else{
                if(r) sf += c;
                else sl += c;
            }
        }
    }
    string ans;
    if(!r){
        reverse(sf.begin(),sf.end());
        ans = sf + S + sl;
    }else{
        reverse(sl.begin(),sl.end());
        reverse(S.begin(),S.end());
        ans = sl + S + sf;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1300
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}
int main(void) {
	ll a, b;
	cin >> a >> b;
	ll ans = a * b / gcd(a, b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
}rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;
const int P(1e9 + 7);
int n, f[1 << 21];
std::vector<int> sta[22];
inline void inc(int &x, int y) { if ((x += y) >= P) x -= P; }
int main() {
	n = rd;
	const int st = (1 << n) - 1;
	REP(i, 0, st) sta[__builtin_popcount(i)].push_back(i);
	f[0] = 1;
	REP(i, 1, n){
		REP(j, 1, n) if(rd)
			for(auto u : sta[i - 1]) if(u >> j - 1 & 1 ^ 1)
				inc(f[u | 1 << j - 1], f[u]);
	}
	std::cout << f[st];
	return 0;
}



Measured memory_bytes: 17852
import java.util.*

fun main(args:Array<String>):Unit {
    val r = Array(10){0}
    val g = Array(10){0}
    val b = Array(10){0}
    repeat(readLine()!!.toInt()){
        readLine()!!.split(' ').map(String::toInt).zip(readLine()!!.split(' ')).forEach { (i, c) ->
            when(c){
                "R" -> r[i]++
                "G" -> g[i]++
                else -> b[i]++
            }
        }
        println(if (isSet(r) && isSet(g) && isSet(b)) 1 else 0)
        r.fill(0)
        g.fill(0)
        b.fill(0)
    }
}
fun isSet(array:Array<Int>):Boolean {
    for (i in 0 until 10){
        if (array[i] < 0){
            return false
        }else if (array[i] > 0){
            if (i < 8){
                (i .. (i + 2)).forEach{
                    array[it] -= 1
                }
                if (isSet(array)) return true
                (i .. (i + 2)).forEach {
                    array[it] += 1
                }
            }
            array[i] -= 3
            if (isSet(array)) return true
            array[i] += 3
            return false
        }
    }
    return true
}


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

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

    sort(v, v + n);
    double ans = v[0];
    for (int i = 1; i < n; i++) ans = (ans + v[i]) / 2;
    
    cout << ans << endl;
}


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

#[fastout]
fn main() {
    input! {
        s: String,
    }
    let week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    let mut index: usize = (0..7).find(|&i| week[i as usize].to_string() == s).unwrap();
    println!("{}", 7 - index);
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

signed main() {
    int A, B;
    cin >> A >> B;
    cout << max(max(A + B, A - B), A * B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
  	cin>>s;
  	
if((s.at(0)==s.at(1) && s.at(1)==s.at(2)) || (s.at(1)==s.at(2) && s.at(2)==s.at(3))){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

const int MAX = 510000;
//const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

long long int ext_gcd(long long int a, long long int b, long long int &x, long long int &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    long long int q = a / b;
    long long int g = ext_gcd(b, a - q * b, x, y);
    long long int z = x - q * y;
    x = y;
    y = z;
    return g;
}

//aとmは互いに素, a^(-1) mod m
long long int modinv(long long int a, long long int m)
{
    long long int x, y;
    ext_gcd(a, m, x, y);
    x %= m;
    if (x < 0)
        x += m;
    return x;
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N,a,b;
    string S;
    cin >> N>>a>>b;

    vector<ll> vec(200000+100);



    REPS(i,200000){
        ll tmp = modinv(i, MOD);
        if(i>1){
            vec.at(i) = ((vec.at(i - 1) * (N + 1 - i))%MOD) * tmp % MOD;
        }
        else{
            vec.at(i) = N * tmp % MOD;
        }
    }

    ll all = (modpow(2, N, MOD)-1) % MOD;

    ll na = vec.at(a);
    ll nb = vec.at(b);

    //cout << all << " " << na << " " << nb << endl;

    ll ans = all - na - nb;

    if(ans<0){
        while(ans<0){
            ans += MOD;
        }
    }
    else{
        ans % MOD;
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 4792
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;

ll ans=1e16,n,m,x;
vector<ll>c(12);
vector<vector<ll>>a(12,vector<ll>(12));

void func(ll cur,ll cost,set<ll>&taken)
{
	vector<ll>temp(m);
	for(auto z:taken)
	{
		for(ll j=0;j<m;j++)
		{
			temp[j]+=a[z][j];
		}
	}
	bool flag=true;
	for(auto z:temp)
	{
		if(z<x) {flag=false;break;}
	}
	if(flag) {ans=min(ans,cost);return;}
	for(ll i=cur+1;i<n;i++)
	{
		taken.insert(i);
		func(i,cost+c[i],taken);
		taken.erase(i);
	}
}

int main()
{
    
    // #ifndef ONLINE_JUDGE
    //     freopen ("data.in","r",stdin);
    //     freopen ("E.out","w",stdout);
    // #endif
    cin.sync_with_stdio( false );

    int tests=1;
    // cin>>tests;
    while(tests--)
    {
    	ll i,j,k;
    	cin>>n>>m>>x;
    	
    	for(i=0;i<n;i++)
    	{
    		cin>>c[i];
    		for(j=0;j<m;j++)
    		{
    			cin>>a[i][j];
    		}
    	}

    	set<ll>taken;
    	for(i=0;i<n;i++)
    	{
    		taken.insert(i);
    		func(i,c[i],taken);
    		taken.clear();
    	}
    	if(ans==1e16) cout<<-1;
    	else
    	cout<<ans;

   	}
    	return 0;
    
}

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

typedef pair<int, int> P;

int H,W;
int maze[51][51];
int d[51][51];
int sx,sy;
int gx,gy;
int way[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

int bfs(){
	queue<P> que;
	que.push(P(1,1));
	d[1][1] = 0;
	while(que.size()){
		P p = que.front(); que.pop();
		if(p.first==H&&p.second==W) break;
		for(int i=0;i<4;i++){
			int nx = p.first+way[i][0], ny = p.second+way[i][1];
			if(1<=nx&&nx<=H&&1<=ny&&ny<=W&&maze[nx][ny]!='#'&&d[nx][ny]==-1){
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[H][W];
}

int main() {
	// your code goes here
	char g;
	int whiteNum = 0;
	scanf("%d%d",&H,&W);
	scanf("%c",&g);
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			scanf("%c",&maze[i][j]);
			d[i][j] = -1;
			if(maze[i][j]=='.') whiteNum++;
		}
		scanf("%c",&g);
	}
	sx = 1; sy = 1; gx = H; gy = W;
	
	int ans = bfs();
	
	if(ans==-1) printf("-1");
	else printf("%d",whiteNum-ans-1);
	
	return 0;
}

Measured memory_bytes: 256
def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


D, N = readmap()

if D == 0:
    if N < 100:
        print(N)
    else:
        print(101)
elif D == 1:
    if N < 100:
        print(N * 100)
    else:
        print(10100)
else:
    if N < 100:
        print(N * 10000)
    else:
        print(1010000)



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

long long N;
int main() {
    cin >> N;
    cout << N * (N+1) / 2 << endl;
}















Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long int N;
	scanf("%lld",&N);
    
    int i;
    long long int A=0;
	for(i=0;i<=N;i++)
		if(i%3==0){
		}else if(i%5==0){
		}else{
			A+=i;
		}
		printf("%lld",A);

		return 0;
}


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

int main() {
  int N,K,i;
  cin >> N >> K;
  
  int R = 1;
  
  for (i = 0;i < N && R < K;i++) {
    R *= 2;
  }
  
  while (i < N) {
    R += K;
    i++;
  }
  
  cout << R << endl;
}

Measured memory_bytes: 3636
import numpy as np


N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << h2*60 + m2 - (h1 * 60 + m1) - k;
	return 0;
}


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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    int i = 0;
    string s, s1;
    cin >> s;

    for(i = 0; i < s.size(); i++){
        int j = i;
        while(s.at(j)=='A'||s.at(j)=='T'||s.at(j)=='C'||s.at(j)=='G'){
            j++;
            if(j==s.size()) break;
        }
        sum = max(j-i, sum);
    }
    cout << sum << endl;
}

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

int main() {
  string s;
  cin>>s;
  int a[800]={};
  bool yes=true;
  for(int i=0;i<s.size();i++){
    a[s[i]]++;
    if(a[s[i]]>1) yes=false;
  }
  if(yes) cout<<"yes";
  else cout <<"no";

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

ll func(ll h1, ll h2, ll res2) {
    return llabs(h1 - h2) + res2;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (auto& x: h) {
        cin >> x;
    }
    vector<ll> res(n);
    res[n - 1] = 0;
    for (ll i = n - 2; i >= 0; i--) {
        ll min_res = func(h[i], h[i + 1], res[i + 1]);
        for (ll j = 1; j <= k && i + j < n; j++) {
            ll tmp = func(h[i], h[i + j], res[i + j]);
            if (tmp < min_res) {
                min_res = tmp;
            }
        }
        res[i] = min_res;
    }
    cout << res[0] << endl;
    return 0;
}


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

int main() {
    
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int find12(int *a, int &fst, int &snd)
{
    if(a[0]<a[1])
    {
        snd = 0;
        fst = 1;
    }
    else
    {
        fst = 0;
        snd = 1;
    }
    for(int i=2; i<26; i++)
    {
        if(a[i]>a[snd])
        {
            if(a[i]>a[fst])
            {
                snd = fst;
                fst = i;
            }
            else
            {
                snd = i;
            }
        }
    }
    return a[fst] - a[snd];
}

int main()
{
    int n;
    while(cin >> n, n)
    {
        int a[26];
        fill(a, a+26, 0);
        int winner = -1;
        int timing = -1;
        for(int i=0; i<n; i++)
        {
            string v;
            cin >> v;
            a[v[0] - 'A']++;
            int fst, snd;
            if(winner == -1 && find12(a, fst, snd)>n-i-1)
            {
                winner = fst;
                timing = i+1;
            }
        }
        if(timing==-1)
        {
            cout << "TIE" << endl;
        }
        else
        {
            cout << char(winner+'A') << " " << timing << endl;
        }
    }
}

Measured memory_bytes: 3048
h,w,c,S,max,C,N,r;
int *_M;
D(x,y){
	_M[x+(w+2)*y]=N;
	if(_M[x-1+(w+2)*y]==C)r++,D(x-1,y);
	if(_M[x+1+(w+2)*y]==C)r++,D(x+1,y);
	if(_M[x+(w+2)*(y-1)]==C)r++,D(x,y-1);
	if(_M[x+(w+2)*(y+1)]==C)r++,D(x,y+1);
	return r;
}
E(int d,int *M){if(d<4||M[1+w+2]!=c){
	int *m=malloc(S);
	if(d==4){
		memcpy(_M=m,M,S);
		C=m[1+w+2],N=c;D(1,1);
		C=m[1+w+2],N=-1,r=1;D(1,1);
		if(max<r)max=r;
	}else{
		int i=1;
		for(;i<7;i++)if(M[1+w+2]!=i){
			memcpy(_M=m,M,S);
			C=m[1+w+2],N=i;D(1,1);
			E(d+1,m);
		}
	}
	free(m);
}}
a[100];
main(i,j){for(;scanf("%d%d%d",&h,&w,&c),c;printf("%d\n",max)){
	memset(a,0,S=4*(w+2)*(h+2));
	for(j=1;j<h+1;j++)for(i=1;i<w+1;i++)scanf("%d",a+i+(w+2)*j);
	E(max=0,a);
}}

Measured memory_bytes: 620
#include <stdio.h>

int main(void) {
	char s[20];
	int i;
	scanf("%s",s);
	for(i=1;i<=5;i++){
		printf("%c",s[i-1]);
		}
	printf(" ");
	for(i=1;i<=7;i++){
		printf("%c",s[i+5]);
		}
	printf(" ");
	for(i=1;i<=5;i++){
		printf("%c",s[i+13]);
		}
	return 0;
}

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

int main(){
    int n;
    map <int,int> mp;
    scanf("%d",&n);

    int x=n-1;
    for(int i=1; i<=x; i++){
        int a;
        scanf("%d",&a);
        mp[a]++;
    }

    for(int i=1; i<=n; i++){
        int len=mp[i];
        printf("%d\n",len);
    }
    return 0;
}


Measured memory_bytes: 13164
s = input()
n = 4

sum_val = 0
for i in range(1 << (n - 1)):
    val = int(s[0])
    expression = s[0]
    for j in range(n - 1):
        if (i >> j) & 1:
            val += int(s[j+1])
            expression += "+" + s[j+1]
        else:
            val -= int(s[j+1])
            expression += "-" + s[j+1]
    if val == 7:
        print(expression + "=7")
        quit()


Measured memory_bytes: 61844
#include <bits/stdc++.h>
#define REP(i, n, s) for (LL i = (s); i < (n); i++)
#define SIZE 200001
using namespace std;
typedef long long int LL;
typedef long double LD;

int N, K, L, _c[SIZE], _t[SIZE];
set<int> C[SIZE], T[SIZE], _C[SIZE], _T[SIZE];

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

	cin >> N >> K >> L;
	int p, q, r, s, res[SIZE];
	memset(res, 0, sizeof(res));
	memset(_c, 0, sizeof(_c));
	memset(_t, 0, sizeof(_t));
	while (K--) {
		cin >> p >> q;
		C[p].insert(q);
		C[q].insert(p);
	}
	while (L--) {
		cin >> r >> s;
		T[r].insert(s);
		T[s].insert(r);
	}

	REP(i, N+1, 1) {
		queue<int> que;
		set<int> chk;
		if (_c[i] == 0) {
			_c[i] = i;
			que.push(i);
			_C[i].clear();
			_C[i].insert(i);
			while (que.size()) {
				int a = que.front();
				que.pop();
				for (int c : C[a]) {
					if (_C[i].count(c) > 0) continue;
					_c[c] = i;
					_C[i].insert(c);
					que.push(c);
				}
			}
		}
		if (_t[i] == 0) {
			_t[i] = i;
			que.push(i);
			_T[i].clear();
			_T[i].insert(i);
			res[i]++;
			while (que.size()) {
				int a = que.front();
				que.pop();
				for (int t : T[a]) {
					if (_T[i].count(t) > 0) continue;
					if (_C[_c[i]].count(t) > 0) {
						res[i]++;
						chk.insert(t);
					}
					_t[t] = i;
					_T[i].insert(t);
					que.push(t);
				}
			}
		} else {
			if (res[i] == 0) {
				for (int c : _C[_c[i]]) {
					if (_T[_t[i]].count(c) > 0) {
						chk.insert(c);
						res[i]++;
					}
				}
			}
		}
		for (int c : chk) {
			res[c] = res[i];
		}
	}
	REP(i, N, 1) cout << res[i] << " ";
	cout << res[N] << endl;

	return 0;
}


Measured memory_bytes: 77312
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s;
  rep(z, n) {
    // zから
    string co = s.substr(z, n);
    ll A[n + 10] = {};
    A[0] = n - z;
    int i = 1, j = 0;
    while (i < n) {
      while (i + j < n && co[j] == co[i + j]) ++j;
      A[i] = j;
      if (j == 0) {
        i++;
        continue;
      }
      int k = 1;
      while (i + k < n && k + A[k] < j) A[i + k] = A[k], ++k;
      i += k;
      j -= k;
    }
    rrep(i, 0, n) ans = max(ans, min(A[i], i));
  }
  Cout(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ans = 0;
  rep(i,n) ans += a[i] - 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);
int a[200005],vis[200005];
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n,k,cur,tim,i,val,val1;
	cin>>n>>k;
	f(i,1,n+1){
		cin>>a[i];
	}
	cur=1;
	tim=1;
	while(1){
		if(tim>k){
			cout<<cur<<endl;
			return 0;
		}
		if(vis[cur]!=0){
			val=tim-vis[cur];
			val1=k+1-vis[cur];
			val1%=val;
			while(val1--){
				cur=a[cur];
			}
			cout<<cur<<endl;
			return 0;
		}
		else{
			vis[cur]=tim;
			tim++;
			cur=a[cur];
		}
	}
} 


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

int main() {
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else {
    int a = A.compare(B);
    if (a > 0) {
      cout << "GREATER" << endl;
    } else if (a < 0) {
      cout << "LESS" << endl;
    } else {
      cout << "EQUAL" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>

#define MAX_INPUT_SIZE  10240

using namespace std;

int
main(int argc, char* argv[])
{
    char input[MAX_INPUT_SIZE];

    int lines = atoi(fgets(input, sizeof(input), stdin));
    int *array = new int[lines];
    for (int i = 0; i < lines; i++) {
        array[i] = atoi(fgets(input, sizeof(input), stdin));
    }

    sort(array, array + lines);
    int max = array[lines-1];
#if 0
    for (int i = 0; i < lines; i++) {
        printf("%d\n", array[i]);
    }
#endif
    double sq = sqrt(max);
    
    for (int i = 0; i < lines; i++) {
        for (int j = 2; j < sq; j++) {
            if (array[i] != j && array[i] % j == 0) {
                array[i] = -1;
            }
        }
    }

    int num = 0;
    for (int i = 0; i < lines; i++) {
        if (array[i] > 0) {
            num++;
        }
    }
    
    printf("%d\n", num);

    return 0;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
#define double long double
using namespace std;
int main(){
	double A,B,AA,BB,H,M;
	cin >> A >> B >> H >> M;
	AA=A*A;
	BB=B*B;
	double hours=H*30+(M/60)*30;
	double minutes=M*6;
	if(hours>180)
		hours-=360;
	if(minutes>180)
		minutes-=360;
	double angle=fabs(hours-minutes)/180;
	angle*=M_PI;
	double ans=sqrt(AA+BB-(2*A*B*cos(angle)));
	printf("%.20Lf\n",ans);
}


Measured memory_bytes: 4104
#include <iostream>

using namespace std;
typedef long long LL;
const LL p = 1e9 + 7;

LL pow(LL a, LL b, LL p) {
    LL ans = 1;
    a %= p;
    while (b) {
        if (b & 1) {
            ans = (ans % p) * (a % p) % p;
        }
        b /= 2;
        a = (a % p) * (a % p) % p;
    }
    ans %= p;
    return ans;
}

LL inv(LL x, LL p) {
    return pow(x, p - 2, p);
}

LL C(LL n, LL m, LL p) {
    if (m > n) {
        return 0;
    }
    LL up = 1, down = 1;
    for (int i = n - m + 1; i <= n; i++) {
        up = up * i % p;
    }
    for (int i = 1; i <= m; i++) {
        down = down * i % p;
    }
    return up * inv(down, p) % p;
}

LL Lucas(LL n, LL m, LL p) {
    if (m == 0) {
        return 1;
    }
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

int main() {
    LL n, a, b, ans = 0;
    cin >> n >> a >> b;
    LL cnt = pow(2, n, p);
    ans = (cnt - 1 - Lucas(n, a, p) - Lucas(n, b, p) + (p << 1)) % p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N,num=1;
  int i;
  
  scanf("%d",&N);
  
  for(i=0;i<7;i++){
    num=num*2;
    if(num>N){
      printf("%d",num/2);break;
    }
    if(num==N){
      printf("%d",num);break;
    }
  }
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define pi              acos(-1)
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX             2005
#define MOD             1000000007

typedef long long ll;

ll w[MAX+1][MAX+1];
vector<ll>v(MAX);

int main()
{
    FastRead
    ll n,x,y;

    cin>>n>>x>>y;

    for(ll i=1;i<=n;i++)
        for(ll j=i+1;j<=n;j++)
                w[i][j] = min({j-i,abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)});

    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=n;j++)
            v[w[i][j]]++;

    for(ll i=1;i<n;i++)
        cout<<v[i]<<endl;
}


Measured memory_bytes: 31104
def win(hand):
        if hand == 'r':
            return 'p'
        elif hand == 'p':
            return 's'
        else:
            return 'r'

def get_best_hand(hand, last_hand):
    won_hand = win(hand)
    if won_hand == last_hand:
        return 'draw'
    else:
        return won_hand
    
def get_point(hand, R, S, P):
        if hand == 'r':
            return R
        elif hand == 'p':
            return P
        elif hand == 's':
            return S
        else:
            return 0

K = int(input().split()[1])
R, S, P = map(int, input().split())
T = input()

last_hand = ''
history = []
point = 0

for t in T:
    last_hand = history[0] if len(history) >= K else ''
    best_hand = get_best_hand(t, last_hand)
    point += get_point(best_hand, R, S, P)
    history.append(best_hand)
    if len(history) > K:
        del history[0]

print(point)

Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

lli ExGCD(lli a, lli b, lli &x, lli &y){
    lli d=a;
    x=1; y=0;
    if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
    return d;
}
lli inverse(lli a, lli mod){
	lli x,y;
	ExGCD(a, mod, x, y);
	return x>0? x: mod+x;
}

int main(){
	while(1){
		lli n,d,x;
		cin >> n >> d >> x;
		if(n==0) break;
		
		vector<lli> dp(n+1, 0), num(n+1, 0);
		dp[n] = 1;
		for(int i=1; i<=n; i++){
			vector<lli> ndp(n+1, 0);
			for(int j=n-1; j>=0; j--){
				ndp[j] = dp[j+1] +ndp[j+1];
				if(j+x < n+1){
					ndp[j] -= dp[j+x];
				}
				ndp[j] = (ndp[j] +mod)%mod;
			}
			num[i] = ndp[0];
			dp = ndp;
		}
		
		lli ans = 0;
		lli comb = 1;
		for(lli i=1; i<=n; i++){
			lli rate = (d-i+1)%mod *inverse(i, mod) %mod;
			comb = comb*rate %mod;
			ans += comb*num[i] %mod;
		}
		ans %= mod;
		cout << ans << endl;
	}
	return 0;
}


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

//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)

 
int main() {
  int N;
  cin >> N;
  VI d(N);
  REP(i,N) {
    cin >> d.at(i);
  }
  SORT(d);
  int M = N/2, a= d.at(M-1), b=d.at(M);
  int ans = b-a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
function Main(s) {
  var s = s.split("\n");
  var n = parseInt(s[0], 10);
  var a = s[1].split(" ").map(e => parseInt(e, 10));
  var acc1 = 0, cnt1 = 0, arr1 = [];
  var acc2 = 0, cnt2 = 0, arr2 = [];
  for (var i = 0; i < n; i++) {
    acc1 += a[i];
    if (i === 0) {
      if (acc1 <= 0) {
        cnt1 += Math.abs(acc1) + 1;
        acc1 += Math.abs(acc1) + 1;
      }
    } else {
      if (arr1[i - 1] > 0) {
        if (acc1 >= 0) {
          cnt1 += (acc1 + 1);
          acc1 -= (acc1 + 1);
        }
      } else {
        if (acc1 <= 0) {
          cnt1 += (Math.abs(acc1) + 1);
          acc1 += (Math.abs(acc1) + 1);
        }
      }
    }
    arr1.push(acc1);
  }

  for (var i = 0; i < n; i++) {
    acc2 += a[i];
    if (i === 0) {
      if (acc2 >= 0) {
        cnt2 += (acc2 + 1);
        acc2 -= (acc2 + 1);
      }
    } else {
      if (arr2[i - 1] > 0) {
        if (acc2 >= 0) {
          cnt2 += (acc2 + 1);
          acc2 -= (acc2 + 1);
        }
      } else {
        if (acc2 <= 0) {
          cnt2 += (Math.abs(acc2) + 1);
          acc2 += (Math.abs(acc2) + 1);
        }
      }
    }
    arr2.push(acc2);
  }
  console.log(Math.min(cnt1, cnt2));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> answers(10001);
vector<vector<int>> data(1000000);


int main(){
    int n;
    cin >> n;
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                ll a = (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x);
                if(a % 2 == 0){
                    if((a/2) <= n) answers.at(a/2)++;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << answers.at(i) << endl;
    }
}

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

template<typename T> T gcdraw(T a, T b)
{
    return a ? gcdraw(b%a, a) : b;
}

template<typename T> T gcd(T a, T b)
{
    const auto aa = abs(a), bb = abs(b);
    return aa > bb ? gcdraw(aa, bb) : gcdraw(bb, aa);
}

const int MAXN = 1000001;
int P[MAXN + 1];
bool B[MAXN + 1];

void makeLowestPrimeTable()
{
    for (int i=2;i*i<=MAXN;++i)
    {
        if (P[i]) { continue; }
        for (int j=i*2;j<=MAXN;j+=i) if(!P[j]) { P[j] = i; }
    }
}

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

    vector<int> A(N);
    for (auto& a : A) { cin >> a; }

    makeLowestPrimeTable();

    const auto isPairwise = [&]()
    {
        for (int i=0;i<N;++i)
        {
            int x = A[i];

            while (x != 1)
            {
                const auto p = P[x] ? P[x] : x;
                if (B[p]) { return false; }
                B[p] = true;

                while ((x % p) == 0) { x /= p; }
            }
        }

        return true;
    };

    if (isPairwise())
    {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int setwiseValue = A[0];
    for (int i=1;i<N;++i) { setwiseValue = gcd(setwiseValue, A[i]); }

    if (setwiseValue == 1)
    {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 11028