akhauriyash/Code-Regression huggingface dataset:
def main():
    N, M, X = [int(_n) for _n in input().split()]
    C = []
    books = []
    for i in range(N):
        l = [int(_n) for _n in input().split()]
        C.append(l[0])
        books.append(l[1:])
    ans = 10**8
    for i in range(0,2**N):
        res = [0]*M
        cost = 0
        a = 0
        # print(i)
        while True:
            if i % 2 == 1:
                cost += C[a]
                res = [res[i]+books[a][i] for i in range(M)]
            i//=2
            a+=1
            if i == 0:
                break
        # print(res)
        # print(cost)
        # print("-----")
        flag = True
        for j in range(M):
            if res[j] < X:
                # print("!!")
                flag = False
        if flag:
            ans = min(ans,cost)
    print(ans if ans != 10**8 else -1)

main()


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) (((x) > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}


inline int getlast(const int i){
    if (i<10) return i;
    return i%10;
}

int getfirst(int i){
    if (i<10) return i;
    return getfirst(i/10);
}

ll pow10(int i){
    ll ret=1;
    while(i){
        ret *= 10;
        --i;
    }
    return ret;
}

int main() {
    READ(0);
    int n;cin>>n;
    ll ret=0;

    if (n<1000){
        for(int a=1;a<=n;++a){
            int last=a%10;
            if (last==0) continue;
            int first=getfirst(a);
            for(int b=1;b<=n;++b){
                if (b%10==first && getfirst(b)==last) {
                    ++ret;
                }
            }
        }
        cout << ret << endl;
        return 0;
    }
    int nfirst=getfirst(n);
    int d=2;
    int limit=10;
    while (limit<=n) {
        limit *= 10;
        ++d;
    }
    --d;
    ret += 9;
    for(int da=2;da<d;++da){
        ret += 18LL * pow10(da-2);
    }
    for(int db=2;db<d;++db){
        for(int da=2;da<d;++da){
            ret += 81LL * pow10(da-2) * pow10(db-2);
        }
    }
    int p10=pow10(d-1);
    int start=p10+1;
    int inicio0=p10*nfirst;
    int cortar=min(n,p10*(nfirst+1)-1);
    for(;start<=n;++start){
        int last=start%10;
        if (last==0) continue;
        int first=getfirst(start);
        if (last==first){
            ret += 2;
        }
        int val=2;
        for(int dd=2;dd<d;++dd){
            ret += val;
            val *= 10;
        }
        if (last>nfirst) continue;
        if (last<nfirst){
            ret += pow10(d-2);
        }else{
            int inicio=inicio0+first;
            while(inicio<=cortar){
                ret++;
                inicio += 10;
            }
        }
    }
    cout << ret;

    return 0;
}

Measured memory_bytes: 256
import math

K = int(input())

sum_list = []
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            tmp = math.gcd(a,b)
            tmp = math.gcd(c,tmp)
            sum_list.append(tmp)


ans = sum(sum_list)
print(ans)

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

using namespace std;

const int N = 1e5 + 5 , M = 18;

struct edge {
    int to , color , cost;
};

struct q1 {
    int query_id , factor;
};

struct q2 {
    int query_id , color , factor;
};

struct q3 {
    int query_id , color , new_cost , factor;
};

vector<edge> adj[N];
vector<q1> t1[N]; // cum sum
vector<q2> t2[N]; // sum of edges of color
vector<q3> t3[N]; // count of edges of color * new_cost
int par[N] , lvl[N] , in[N];

void dfs(int node , int p = 0 , int l = 1) {
    par[node] = p;
    lvl[node] = l;
    for (auto &c : adj[node]) {
        if (c.to == p) continue;
        dfs (c.to , node , l + 1);
    }
}

int memo[N][M];
int solve (int u , int k) {
    if (!k) return par[u];
    int &ret = memo[u][k];
    if (~ret) return ret;
    return ret = solve(solve(u , k - 1) , k - 1);
}

int LCA(int u , int v) {
    if (lvl[u] < lvl[v])
        swap(u , v);

    for (int i = M ;i >= 0 ;i--)
        if (lvl[solve(u , i)] >= lvl[v])
            u = solve(u , i);

    if (u == v)
        return u;

    for (int i = M ;i >= 0 ;i--)
        if (solve(u , i) != solve(v , i))
            u = solve(u , i) , v = solve(v , i);

    return par[u];
}

int ans[N] , sum_with_color[N] , count_with_color[N];
void go(int node , int pre_sum = 0 , int par = -1) {
    for (auto &c : t2[node])
        ans[c.query_id] += sum_with_color[c.color] * c.factor;

    for (auto &c : t1[node])
        ans[c.query_id] += pre_sum * c.factor;

    for (auto &c : t3[node])
        ans[c.query_id] += count_with_color[c.color] * c.new_cost * c.factor;

    for (auto &c : adj[node]) {
        if (c.to == par) continue;
        sum_with_color[c.color] += c.cost;
        count_with_color[c.color]++;
        go(c.to , pre_sum + c.cost , node);
        sum_with_color[c.color] -= c.cost;
        count_with_color[c.color]--;
    }
}

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

    int n , q;
    cin >> n >> q;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v , color , cost;
        cin >> u >> v >> color >> cost;
        adj[u].push_back({v , color , cost});
        adj[v].push_back({u , color , cost});
    }

    dfs(1); // root
    memset(memo , -1 , sizeof memo);

    for (int i = 0 ;i < q ;i++) {
        int u , v , color , new_cost;
        cin >> color >> new_cost >> u >> v;
        int lca = LCA(u , v);

        t1[u].push_back({i , 1});
        t1[v].push_back({i , 1});
        t1[lca].push_back({i , -2});

        t2[u].push_back({i , color , -1});
        t2[v].push_back({i , color , -1});
        t2[lca].push_back({i , color , 2});

        t3[u].push_back({i , color , new_cost , 1});
        t3[v].push_back({i , color , new_cost , 1});
        t3[lca].push_back({i , color , new_cost , -2});
    }

    go(1);

    for (int i = 0 ;i < q ;i++)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 47120
float p=atan(1)*4/9,X[100],Y[100],x,y;main(n,i,j,k,a,b,c){for(;scanf("%d",&n),n;printf("%d\n",a)){
	for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
	for(a=i=0;i<n;a=a>b?a:b,i++)for(b=k=0;k<9;b=b>c?b:c,k++)for(x=X[i]+cos(p*k),y=Y[i]+sin(p*k),c=j=0;j<n;j++)if(hypot(X[j]-x,Y[j]-y)<1+1e-3)c++;
}exit(0);}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int main(){
  char sc[4];
  string s;
  cin>>s;
  for(int i=0;i<4;i++) sc[i]=s[i];
  sort(sc,sc+4);
  if(sc[0]==sc[1]&&sc[2]==sc[3]&&sc[0]!=sc[2]) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

int N;
vector<int> ve[100001];
bool flag[100001];
int d[2][100001];

void dfs(int pos, int num, int start) {
	for (int i = 0; i < ve[pos].size(); i++) {
		d[start][pos] = num;
		if (!flag[ve[pos][i]]) {
			flag[pos] = true;
			dfs(ve[pos][i], num + 1, start);
			flag[pos] = false;
		}
	}
}

void solve() {
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		ve[a].push_back(b);
		ve[b].push_back(a);
	}
	dfs(1, 0, 1);
	dfs(N, 0, 0);

	int fe = 0, su = 0;
	for (int i = 1; i <= N; i++) {
		if (d[1][i] <= d[0][i]) fe++;
		else su++;
	}
	cout << (fe > su ?  "Fennec" : "Snuke" )<< endl;
	
}

int main() {
	solve();
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;

    return 0;
}


Measured memory_bytes: 256
//===========================================================================
/* 
    "Some stories are unspoken"
     * But there is always a story that needs to be cure~
    A new chapter was going to open but she was not my girl ;)

    Even if we can't be together in the END, 
      I'm glad that you were a part of My life.
*/          
//===========================================================================
//   There are far more important things than A Girl. 
//		Prioritize them when the Time Comes ;)
//===========================================================================

#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;
#define inp_s ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TCI int Q4;cin>>Q4; while(Q4--)
#define FR(i,a,b) for(int i=a;i<b;i++)
#define r0 return 0;
#define pb push_back
#define mp make_pair
#define in insert
#define Nl cout<<"\n";
//===========================================================
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII>
#define VLL vector<PLL>
#define VS vector<string>
#define all(v) v.begin(),v.end()
#define l_b(v,n) lower_bound(all(v),n)
#define u_b(v,n) upper_bound(all(v),n) 
#define b_s(v,n) binary_search(all(v),n) 
#define sz(v) v.size()
//===========================================================
#define MST(a,d) memset(a,d,sizeof(a))
#define SP(n)  fixed<<setprecision(n)
#define SS(s,index,size) s.substr(index,size)
const int mod=1e9+7;
const int MAX=2e5+5;

int main()
{   
    // Fuck Ratings, I'm in love with Experience.
    
    inp_s
    string s;
    cin>>s;
    int ct=0,mx=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        ct++;
        else
        {
            mx=max(ct,mx);
            ct=0;
        }
    }
    if(ct)
    mx=max(ct,mx);
    cout<<mx;
    r0
}


Measured memory_bytes: 3644
open System

let rec getMaxLen input =
    let isACGT char = List.contains char ['A'; 'C'; 'G'; 'T']

    let rec inner = function
    | hd :: tl when isACGT hd -> 1 + (inner tl) 
    | _ :: _ -> 0
    | [] -> 0

    let rec outer = function 
    | hd :: tl -> max (inner <| hd :: tl) (outer tl)
    | [] -> 0

    outer <| Seq.toList input

let input = Console.ReadLine()
printfn "%d" <| getMaxLen input


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

int main() {
  long a,b,c,d;
  cin >> a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
  }
  else if(abs(a-b)<=d&&abs(b-c)<=d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}




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

int main() {
  int a, b, ab;
  string ans= "No";
  cin >> a >> b;
  if (b/10 == 0){ab = 10*a + b;}
  else if(b/100 == 0){ab=100*a+b;}
  else{ab=1000*a+b;}
  
  for(int i =0; i*i<=ab; i++){
    if(i*i==ab){ans = "Yes";}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    BigInteger x = in.nextBigInteger();
    BigInteger y = in.nextBigInteger();
    BigInteger sum = x;
    long count = 0;
    while(sum.compareTo(y) != 1) {
      sum = sum.multiply(BigInteger.valueOf(2));
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 35836
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll suf[maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vi a(n);
	REP(i, n) cin >> a[i];
	FORD(i, n - 1, 0) {
		suf[i] = (suf[i + 1] + a[i]) % MOD;
	}
	ll ans = 0;
	REP(i, n) {
		ans = (ans + suf[i + 1] * a[i]) % MOD;
	}
	cout << ans;
	return 0;
}
 


Measured memory_bytes: 5576
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a; cin >> a;
	cout << a*a*a << endl;
}

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main()
{
 int n;
  cin>>n;
  if(n<4)
  {
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0; i<=100; i++)
  {
    for(int j=0; j<=100; j++)
    {
      if(i*4+j*7==n)
      {
       cout<<"Yes"<<endl;
        return 0;
      }
    }

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

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

// 最大公約数
template <typename T>
T gcd(T n1, T n2) {
	return n1 ? gcd(n2 % n1, n1) : n2;
}

// 最小公倍数
template <typename T>
T lcm(T n1, T n2) {
	return n1 * n2 / gcd(n1, n2);
}

int main()
{
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll C_S = A % C == 0 ? A / C : A / C + 1;
	ll C_E = B % C == 0 ? B / C : B / C;
	ll C_SUM = C_E - C_S + 1;

	ll D_S = A % D == 0 ? A / D : A / D + 1;
	ll D_E = B % D == 0 ? B / D : B / D;
	ll D_SUM = D_E - D_S + 1;

	ll CD = lcm(C, D);
	ll CD_S = A % CD == 0 ? A / CD : A / CD + 1;
	ll CD_E = B % CD == 0 ? B / CD : B / CD;
	ll CD_SUM = CD_E - CD_S + 1;

	ll ans = (B - A + 1) - (C_SUM + D_SUM - CD_SUM);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<long long int >v;
set<long long int>stt;
set<long long int>::iterator set_it;
map<long long int,long long int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
long long int a[20007];
long long int i,j,k,l,m,n,flag=0,cnt=0,sum=0,mx=0,mn=0;
string s1,s2;
int main()
{
    long long  int tc,a,b,d,e,s,w;
    //char c;



        cin>>s>>w;
        if(s<=w)
        {
            cout<<"unsafe"<<endl;
        }
        else
        {
            cout<<"safe"<<endl;
        }


    return 0;

}






Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
void TollGates() {
	int n, m, x;
	cin >> n >> m >> x;
	int t[102];
	fill(t, t + 102, 0);
	for (size_t i = 0; i < m; i++)
	{
		int j;

		cin >> j;
		t[j] = 1;
	}
	int r1 = 0;
	for (size_t i = x + 1; i <= n; i++)
	{
		r1 += t[i];
	}
	int r2 = 0;
	for (int i = x - 1; i >= 0; i--)
	{
		r2 += t[i];
	}
	cout << min(r1, r2) << endl;
}
int main() {
	TollGates();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

int inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - (ll)inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = (ll)fac[i-1] * i % MOD;
		finv[i] = (ll)finv[i-1] * inv[i] % MOD;
	}
}

int comb(int a,int b)
{
	if(a<b){
		return 0;
	}
	return fac[a] * ((ll)finv[b] * finv[a-b] % MOD) % MOD;
}

inline int add(int x,int y)
{
    return (x+y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int dp[3005][2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,n;
    cin >> h >> w >> n;
    vp vec(n+2);
    vec[0] = P(0,0);
    rep(i,n){
        int r,c;
        cin >> r >> c;
        vec[i] = P(r-1,c-1);
    }
    vec[n+1] = P(h-1,w-1);
    sort(all(vec));
    make();
    dp[0][0] = 1;
    srep(i,1,n+2){
        rep(j,i){
            if(vec[j].se <= vec[i].se){
                int t = comb(vec[i].fi-vec[j].fi+vec[i].se-vec[j].se,vec[i].se-vec[j].se);
                dp[i][0] = add(dp[i][0], mul(dp[j][1], t));
                dp[i][1] = add(dp[i][1], mul(dp[j][0], t));
            }
        }
        // show(dp[i][0]), show(dp[i][1]);
    }
    cout << sub(dp[n+1][1], dp[n+1][0]) << "\n";
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
    int a,b,c, i, count;
    count = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; ++i)
    {
        if (c%i == 0)
        {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1164
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s0=gs
l=s0.length
putsend 0 if l==1

c=l/2
s=""
t=""
if l%2==0
  s=s0[0..c-1]
  t=s0[c..-1].reverse
else
  s=s0[0..c-1]
  t=s0[c+1..-1].reverse
end
l.times do |i|
  cnt+=1 if s[i]!=t[i]
end

puts cnt

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    string s;
    cin>>s;

    int ans=0,n=0;

    rep(i,3){
        if(s[i]=='R'){
            n++;
            cmax(ans,n);
        }else n=0;
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 3592
from sys import stdin
from collections import defaultdict
input = stdin.readline

n,m,k = map(int, input().split())
net = defaultdict(list)
for _ in range(m):
    a, b = map(int, input().split())
    net[a].append(b)
    net[b].append(a)

blocks = [ tuple(map(int, input().split())) for _ in range(k)]
id_to_group = {}
groups = []
num_candid = [0] * (n+1)

group_id = -1
for start in range(1, n+1):
    if start in id_to_group:
        continue
    group_id += 1
    # search connected component
    group = set()
    stack = [start]
    group.add(start)
    id_to_group[start] = group_id

    while stack:
        node = stack.pop()
        for nb in net[node]:
            if nb in id_to_group:
                continue
            group.add(nb)
            id_to_group[nb] = group_id
            stack.append(nb)
    for member in group:
        num_candid[member] = len(group) - 1 - len(net[member])

# deal with blcok
for a,b in blocks:
    if id_to_group[a] == id_to_group[b]:
        num_candid[a] -= 1
        num_candid[b] -= 1

for i in range(1, n+1):
    print(num_candid[i], end=' ')



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

int main()
{
	int values[10];

	for(int i= 0 ;i<10 ;i++)
	{
		cin >> values[i];
	}
	sort(values,values + 10);

	cout << values[9] << endl << values[8] << endl << values[7] << endl; 


	return 0;
}

Measured memory_bytes: 1176
from collections import deque

h, w = map(int, input().split())
si, sj = map(int, input().split())
ti, tj = map(int, input().split())
s = [input() for _ in range(h)]
si -= 1
sj -= 1
ti -= 1
tj -= 1

INF = 10**9
di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]
dist = [[INF] * w for _ in range(h)]
q = deque()
dist[si][sj] = 0
q.appendleft([si, sj])

while q:
    i, j = q.popleft()
    d = dist[i][j]
    for v in range(4):
        ni = i + di[v]
        nj = j + dj[v]
        if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
        if s[ni][nj] == '#': continue
        if dist[ni][nj] <= d: continue
        dist[ni][nj] = d
        q.appendleft([ni, nj])
    for ei in range(-2, 3):
        for ej in range(-2, 3):
            ni = i + ei
            nj = j + ej
            if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
            if s[ni][nj] == '#': continue
            if dist[ni][nj] <= d+1: continue
            dist[ni][nj] = d+1
            q.append([ni, nj])

ans = dist[ti][tj]
if ans == INF: ans = -1
print(ans)


Measured memory_bytes: 102640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll

int main() {
  ll n,q;
  cin>>n>>q;
  map<string,ll> task;
  vector<string> name(n);
  vec time(n); 
  loop(i,n){
    cin>>name[i]>>time[i];
    task[name[i]]=time[i];
  }
  queue<ll> round;
  queue<string> ROUND;
  loop(i,n){
    round.push(task[name[i]]);
    ROUND.push(name[i]);
  }
  map<string,ll> finishtime;
  queue<string> finishlist;
  ll timecount=0;
  while(!round.empty()){
    if(round.front()>q){
      timecount+=q;
      string s=ROUND.front();
      ROUND.pop();
      ROUND.push(s);
      ll z=round.front()-q;
      task[s]=z;
      round.pop();
      round.push(z);
    }
    else{
      timecount+=round.front();
      finishlist.push(ROUND.front());
      finishtime[ROUND.front()]=timecount;
      round.pop();
      ROUND.pop();
    }
  }
  loop(i,n){
   cout<<finishlist.front()<<" "<<finishtime[finishlist.front()]<<endl;
    finishlist.pop();
  }
  
  
  
  
  
  
  
  
  
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    ll n,k;
    cin >> n >> k;
    ll cnt[200001] = {};

    rep(i,0,n){
        ll a;
        cin >> a;
        cnt[a]++;
    }

    priority_queue<ll, VECLL> pq;

    rep(i,1,200001){
        if(cnt[i] != 0){
            pq.push(cnt[i]);
        }
    }

    ll memo = 0;
    rep(i,0,k){
        if(pq.empty()){
            cout << 0 << endl;
            return 0;
        }

        memo += pq.top();
        pq.pop();
    }

    cout << n - memo << endl;
    return 0;
}


Measured memory_bytes: 6728
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    uf.merge(a,b);
  }
  map<int,int> cnt;
  REP(i,n) {
    ++cnt[uf.root(i)];
  }
  int mx = 0;
  for(auto&&[id,sz] : cnt) {
    mx = max(mx, sz);
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 13332
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a<=c&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[10],all=1,bad=1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    all*=3;
    if(a[i]%2==0) {
      bad*=2;
    }
  }
  cout << all-bad << endl;
}

Measured memory_bytes: 256
#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;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    	
    	long double P = 100, X;
    	cin >> X;
    	long long ans = 0;
    	while (P < X) {
    		ans++;
    		P = floor(P * 1.01);
		}
    	cout << ans << "\n";
    	
	//code
	return 0;
}


Measured memory_bytes: 3728
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

int f(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n/=10;
    }
    return sum;
}

void Main(){
    int N, M;
    cin >> N >> M;
    vec<int> road(N);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        road[a]++;road[b]++;
    }
    REP(i, N){
        cout << road[i] << el;
    }
}



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    string ans = "No";
    if (a + b == c) ans = "Yes";
    if (a + c == b) ans = "Yes";
    if (b + c == a) ans = "Yes";

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B,flag=0;
  long long ans=0;
  cin>>N>>A>>B;
  if(A>B){
    cout<<0<<endl;

  }
  else if(N==1&&A==B)
    cout<<1<<endl;
  else{
    if(((B-A)*(N-2)+1)/90000000000000000000&&((B-A)*(N-2)+1)>0){
      ans=((B-A)*(N-2)+1)%90000000000000000000;
      flag=1;
    }
    else
      ans=(B-A)*(N-2)+1;
    if(ans<0)
      cout<<0<<endl;
    else if(flag==1)
      cout<<9<<ans<<endl;
    else
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int nax = 1e5+5;
vector<string>ans;

signed main(){
	int n;
	cin>>n;
	map<string,int>m;
	while(n--){
		string s;
		cin>>s;
		if(!m.count(s)){
			m[s]++;
		}
		else{
			m[s]++;
		}
	}
	int f=0;
	int mx=0;
	for(auto it:m){
		mx=max(mx,it.second);
	}
	if(mx>1){
		for(auto it:m){
			if(it.second==mx){
		//		cout<<mx<<endl;
				ans.push_back(it.first);
			}
		}
	}
	if(mx==1){
		//cout<<2<<endl;
		for(auto it:m){
			ans.push_back(it.first);
		}
	}
	sort(ans.begin(),ans.end());
	for(auto u:ans){
		
		cout<<u<<endl;
	}
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  string r = s;
  sort(r.begin(), r.end());
  int cnt = 0;
  rep(i, n)
  {
    if (s[i] != r[i])
      cnt++;
  }
  //cout << s << " " << r << endl;
  int ans = cnt / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define d7 1000000007
#define fori(n) for( ll i=0 ; i<n; i++)


long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){

ll n,k;
cin>>n>>k;
ll a[n];
fori(n) cin>>a[i];
ll dp[n];
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
fori(n-2){
dp[i+2]=dp[i+1]+abs(a[i+1]-a[i+2]);
for(ll j=0;j<k&&(i+1-j)>=0;j++){
dp[i+2]=min(dp[i+2], dp[i+1-j]+abs(a[i+1-j]-a[i+2]));
}
}
cout<<dp[n-1];

return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n, d;
  cin >> n >> d;
  int ans = (n / (2 * d + 1));
  if (n % (2 * d + 1) != 0) ans++;
  cout << ans << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

int main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  int k=upper_bound(A.begin(),A.end(),X)-A.begin();
  int an1=0,an2=0;
  for(int i=0;i<k;i++){
    an1++;
  }
  for(int i=k;i<M;i++){
    an2++;
  }
  cout<<min(an1,an2)<<endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007LL
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

long long modular(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

const int N = 1e5+10;
ll arr[N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    ll n, k; cin>>n>>k;
    arr[k] = 1;
    ll sum = k;
    for(i = k-1; i > 0; i--){
        arr[i] = modular(k/i,n,MOD);
        for(j = i * 2; j <= k; j+= i) arr[i] = (arr[i] + MOD - arr[j])%MOD;
        sum += arr[i]*i;
        sum %= MOD;
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	int maxi = n / 2 + (n % 2);
	cout << (k <= maxi? "YES" : "NO") << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] D = new int[K];
        for(int i=0;i<K;i++) D[i]=sc.nextInt();
        HashSet<Integer> dic = new HashSet<>();
        for(int w:D) dic.add(w);
        int cur = N;
        while(cur<=99999){
            if(valid(cur,dic)) break;
            cur++;
        }
        System.out.println(cur);
    }
    static boolean valid(int N, HashSet<Integer> dic){
        String cur = Integer.toString(N);
        for(int i=0;i<cur.length();i++){
            int w = cur.charAt(i)-'0';
            if(dic.contains(w)) return false;
        }
        return true;
    }
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(int base, int exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if(exp & 1 == 0) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b);

    return 0;
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

typedef long long ll;

long long P;

long long fac[300001];
long long ifac[300001];

long long mod_pow(long long a, long long p) {
	long long ans = 1;

	while (p != 0) {
		if (p & 1) {
			ans = ans * a % P;
		}
		a = a * a % P;
		p = p >> 1;
	}
	return ans;
}

void init_fac_table(void) {
	fac[0] = 1;
	ifac[0] = 1;
	for (int i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % P;
		ifac[i + 1] = ifac[i] * mod_pow(i + 1, P - 2) % P;
	}
}

long long nCr(long long n, long long r) {
	if (n == 0 && r == 0) {
		return 1;
	}
	if (n < r || n < 0) {
		return 0;
	}
	long long t = ifac[n - r] * ifac[r] % P;
	return t * fac[n] % P;
}

int main(int argc, char *argv[])
{
	int a[3005];
	int b[3005];
	
	cin >> P;

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

	init_fac_table();

	for (int i = 0; i < P; i++) {
		if (a[i]) {
			b[0] += 1;
			ll pw = 1;
			for (int j = P - 1; j >= 0; j--) {
				b[j] -= ((pw * nCr(P - 1, j)) % P + P) % P;
				b[j] = (b[j] % P + P) % P;
				pw *= -i;
				pw = (pw + P) % P;
			}
		}
	}

	for (int i = 0; i < P; i++) {
		printf("%d ", b[i]);
	}
	puts("");

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >>A>>B;
    if(A%3==0||B%3==0||(A+B)%3==0) cout << "Possible" <<endl;
    else cout <<"Impossible" <<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	int s = 0;
	int n;
	cin >> n;
	int w[102] = {};

	rep(i, n) {
		cin >> w[i];
		s += w[i];
	}

	int ans = 1000000;

	int sub = 0;
	rep(i, n) {
		sub += w[i];
		ans = min(ans, abs(s-2*sub));
		//cout << ans << endl;

	}

	cout << ans << endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int r,g;cin >>r>>g;
    int ans=2*g-r;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    int K;
    cin >> S >> K;

    map<string, bool> m;

    for(int i = 0; i < S.length(); i++) {
        string b = "";
        int c = 0;
        for(int j = i; j < S.length(); j++) {
            c++;
            b += S[j];
            m[b] = true;
            if(c == K) break;
        }
    }

    int c = 0;

    for(auto i = begin(m); i != end(m); i++) {
        c++;
        if(c == K) {
            cout << i -> first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println(a < b && b < c ? "Yes" : "No");
		} finally {
			sc.close();
		}
	}

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int pay = 0;
    while (pay < n) pay += 1000;
    cout << pay - n << endl;
    
    return 0;
}



Measured memory_bytes: 3556
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repe(i,n) for (int i = 1; i <= (n); ++i)
#define reps(i,start,end,step) for (int i = start; i <= end; i+=step)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
using namespace std;
typedef long long ll;
typedef string str;
const ll INF = 1e18;
const int MX = 2005;
const double pi = 3.141592653589793238;

string S;
int N;
int cnt;
int ans = 0;

int main() {

  cin >> N >> S;
  rep(i,1000){
    int c[3] = {i/100, i/10-(i/100)*10, i%10};
    
    cnt = 0;
    rep(j,N){
      if(('0'+c[cnt]) == S[j])  cnt += 1;
      if(cnt == 3) break;
    }
  if(cnt == 3) ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int k, s; cin >> k >> s;

    int ans = 0;
    for(int x = 0; x <= k; ++x){
        for(int y = 0; y <= k; ++y){
            int z = s - x - y;
            if(0 <= z && z <= k) ++ans;
        }
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3620