akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include<cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pii> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

bool warp[5][5];
int maze[3010][3010];
int cnt[3010][3010];
int h,w;
vector<string> s;
int c;
void dfs(int y,int x){
    cnt[y][x]=c;
    for(int i=0;i<4;++i){
        int ny=y+dy[i],nx=x+dx[i];
        if(!(ny>=0&&ny<h&&nx>=0&&ny<w)) continue;
        if(s[ny][nx]=='#') continue;
        if(cnt[y][x]>0) continue;
        dfs(ny,nx);
    }
}
int main(){
    string s,t;cin>>s>>t;
    int ans=1e9;
    int n=s.size(),m=t.size();
    for(int i=0;i<=n-m;++i){
        int cnt=0;
        for(int j=0;j<m;++j){
            if(t[j]!=s[i+j]) cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


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

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

using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> d; // (d.at(i) >= 0): index of the parent of the element i, (-d.at(i) > 0): size of the set whose root is element i.

    UnionFind(int size = 0) : d(size, -1) {}

    // Return the root of element i.
    int find(int i) {
        return d.at(i) < 0 ? i : d.at(i) = find(d.at(i));
    }

    // Unite the set element i belongs to to the set element j does.
    bool unite(int i, int j) {
        i = find(i);
        j = find(j);

        if(i == j) return false;
        if(d.at(i) > d.at(j)) swap(i, j);
        d.at(i) += d.at(j);
        d.at(j) = i;
        return true;
    }

    // Return true if element i belongs to the set element j does.
    bool same(int i, int j) {
        return find(i) == find(j);
    }

    // Return the size of the set element i belongs to.
    int size(int i) {
        return -d.at(find(i));
    }
};

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

    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;

    rep(i, n) ans = max(ans, uf.size(i));

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, C;
    cin >> N >> C;
    int p[C];
    for (int i = 0; i < C; i++) {
        cin >> p[i];
    }
    int s = 0;
    for (int i : p) {
        s += i;
    }
    int ans = s / (N + 1);
    s -= ans * (N + 1);
    if (s != 0) ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define input(arr, s, n) for (int i = s; i < n; i++) cin >> arr[i]
using namespace std;

int main()
{
    int n;
    cin >> n;
    double v[n];
    input(v, 0, n);
    sort(v, v + n);

    double a = v[0];
    for (int i = 1; i < n; i++) {
        a = (a + v[i]) / 2.0;
    }
    cout << setprecision(16) << a << "\n";
}


Measured memory_bytes: 256
import numpy as np
Q = int(input())
N = 10**5
c_sum = [0 for i in range(N+2)]
#c_sum[i+1]:iまでの2017-likeな奇数の数
#エラトステネスの篩
primes = [1 for i in range(N+1)]
primes[0], primes[1] = 0, 0
for i in range(N+1):
    if primes[i] == 1:
        for j in range(2*i, N+1, i):
            primes[j] = 0
for i in range(3, N+1):
    if primes[i] == 1 and primes[int((i+1)/2)] == 1:
        c_sum[i+1] = c_sum[i] + 1
    else:
        c_sum[i+1] = c_sum[i]
for i in range(Q):
    l, r = map(int, input().split())
    r += 1
    print(c_sum[r] - c_sum[l])

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

int main(){
  int n, q;
  cin >> n >> q;
  queue<int> s[n];
  while(q--){
    long a, b, c;
    cin >> a >> b;
    if(!a){
      cin >> c;
      s[b].push(c);
    }
    else if(a == 1){
      if(!s[b].empty())cout << s[b].front() << endl;
    }
    else{
      if(!s[b].empty()) s[b].pop();
    }
  }
}


Measured memory_bytes: 4180
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000000
using namespace std;
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}



void solve()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            ans=1;
            break;
        }
    }
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE

    solve();
    return 0;
}


Measured memory_bytes: 3624
A = int(input())
B = int(input())
C = int(input())
X = int(input())
tmp = 0
for a in range(0,(A+1)):
    for b in range(0,(B+1)):
        for c in range(0,(C+1)):
            total = 500*a + 100*b + 50*c
            if total == X:
                tmp += 1    
print(tmp)

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

int prv[N][26];
int f[N];

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

    string S;
    cin >> S;   f[0] = 1;

    reverse(all(S));

    for(int i = 1 ; i <= sz(S) ; ++i)   {
        for(int j = 0 ; j < 26 ; ++j)
            prv[i][j] = prv[i - 1][j];
        
        prv[i][S[i - 1] - 'a'] = i;

        for(int j = 0 ; j < 26 ; ++j)
            if (prv[i][j] == 0) {
                f[i] = 1;
                break;
            }
        if (f[i])   continue;

        f[i] = 1e9;

        for(int j = 0 ; j < 26 ; ++j)
            if (f[i] > f[prv[i][j] - 1] + 1)
                f[i] = f[prv[i][j] - 1] + 1;
    }
    string res = "";

    for(int i = sz(S) ;;)
    for(int j = 0 ; j < 26 ; ++j)   {
        if (prv[i][j] == 0) {
            res += (char)(j + 'a');

            cout << res;
            return  0;            
        }
        if (f[i] == f[prv[i][j] - 1] + 1)   {
            res += (char)(j + 'a');
            i = prv[i][j] - 1;
            break;
        }
    }
}

Measured memory_bytes: 24772
d=[0j,100+0j]
for _ in[0]*int(input()):
 p=[d[0]]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a+r,a+r+r*(1+3**.5*1j)/2,b-r,b]
 d=p
for e in d:print(e.real,e.imag)


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


int main() {
  int n;
  cin >> n;
  int cnt=0;
  char pre = ' ';
  rep(i,n){
    char c;
    cin >> c;
    if(pre != c) cnt++;
    pre = c;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          int[] n = ReadLine().Split(' ').Select(int.Parse).ToArray();
          int[] b = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

          for(int i = 0; i < 10; i++){
              b[i] += n[1] * 10;
          }
          int ans = check(b,n[0]);
          WriteLine(ans);
      }

      static int check(int[] b, int a){
          for(int i = 0; i < 10; i++){
              double s = b[i] * 0.08;
              if(Math.Floor(s) == a){
                  return b[i];
              }
          }
          return -1;
      }
   }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pdd = pair<double, double>;

int main()
{
    int n;
    cin >> n;
    vector<pdd> points;
    for (int i=0; i<n; ++i)
    {
        int x, y;
        cin >> x >> y;
        points.emplace_back(x, y);
    }

    double res = 0;
    rep(i, 0, n)
        rep(j, 0, n)
        {
            double d1 = points[i].first - points[j].first;
            double d2 = points[i].second - points[j].second;
            res += sqrt(d1*d1 + d2*d2);
        }
    
    res /= n;

    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 256
//Educational DP Contest S-Digit Sum
#include<bits/stdc++.h>
#include<cstring>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;

int D;
string K;
ll dp[10005][2][105];

int main(){
    cin >> K >> D;
    int l = K.size();

    dp[0][0][0] = 1;

    for(int i = 0; i < l; i++){
        int ni = K[i] - '0';
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < D; k++){
                for(int x = 0; x <= ( j ? 9 : ni ); x++){
                    dp[i+1][j || ( x < ni )][ (x + k) % D ] += dp[i][j][k];
                    dp[i+1][j || ( x < ni )][ (x + k) % D ] %= MOD;
                }
            }
        }
    }
    
    ll ans = dp[l][0][0] + dp[l][1][0] - 1;
    cout << ( ans<0 ? ans+MOD : ans ) <<endl;
    
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ans[101];
vector<ll> b;

int main(){
	cin >> n;
	b.resize(n);
	
	for(ll i = 0; i < n; i++){cin >> b[i];}
	
	//memset(ans, 0, sizeof(ans));
	bool flag = true;
	for(ll j = n-1; j >= 0; j--){
		for(ll i = j; i >= 0; i--){
			//cout << i << j << endl;
			if(b[i] == i+1){
				ans[j] = i+1;
				b.erase(b.begin()+i);
				break;
			}
		}
		if(b.size() != j){flag = false; break;}
	}
	
	if(flag){for(ll j = 0; j < n; j++){cout << ans[j] << endl;}}
	else{cout << -1 << endl;}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

S = [[x - l, x + l] for x, l in X]
S.sort(key=lambda x: x[1])

ans = 0
tmp = -10 ** 12
for x, y in S:
    if tmp <= x:
        ans += 1
        tmp = y
        
print(ans)


Measured memory_bytes: 75864
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    char al[110];
    int i,j,k;
    int flag=0;
    scanf("%s",al);
    for(i=1;i<=strlen(al);i++)
    {
        if(i%2!=0)
        {
            if(!(al[i-1]=='R'||al[i-1]=='U'||al[i-1]=='D'))
            {
                flag=1;
                break;
            }
        }
        else
        {
            if(!(al[i-1]=='L'||al[i-1]=='U'||al[i-1]=='D'))
            {
                flag=1;
                break;
            }
        }
    }
    if(flag==0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

// 最大公約数を求める
template<typename T>
T gcd(T a, T b)
{
  if (a == 0)
    return b;
  return gcd(b % a, a);
}

// 最小公倍数を求める
template<typename T>
T lcm(T a, T b)
{
  return (a * b) / gcd(a, b);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll CD;
  CD = lcm(C, D);

  ll divC, divD, divCD;
  divC = (B / C) - ((A - 1) / C);
  // dump(B / C);
  // dump(A / C);
  divD = (B / D) - ((A - 1) / D);
  divCD = (B / CD) - ((A - 1) / CD);
  // dump(divC, divD, divCD);
  if (A == B) {
    if (A % C == 0 || A % D == 0) {
      cout << 0 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  if (C == D) {
    cout << (B - A + 1 - divC) << endl;
    return 0;
  }
  cout << (B - A + 1 - divC - divD + divCD) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

class Program{
    static void Main(string[] args){
        int S=int.Parse(Console.ReadLine());
        int h,m,s;
        m=S/60;
        s=S%60;
        h=m/60;
        m%=60;
        Console.WriteLine("{0}:{1}:{2}",h,m,s);
    } 
}


Measured memory_bytes: 19996
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

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



    

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>
#include<iostream>
using namespace std;
char * cp=(char *)malloc(50000000);
typedef long long LL;
inline void in(LL &x)
{
	while(*cp<'0'||*cp>'9')++cp;
	for(x=0;*cp>='0'&&*cp<='9';)x=x*10+(*cp++^'0');
}
LL gcd(LL a,LL b)
{
	return b?gcd(b,a%b):a;
}
int main()
{
	int n;
	scanf("%d",&n);
	fread(cp,1,50000000,stdin);
	LL a=1,b=1,x,y,g,k;
	while(n--)
	{
		in(x),in(y);
		g=gcd(x,y);
		x/=g,y/=g;
		k=max((a+x-1)/x,(b+y-1)/y);
		a=x*k,b=y*k;
		
		//printf("%I64d/%I64d=%I64d/%I64d\n",a,b,x,y);
	}
	cout<<a+b<<endl;
}

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


int main() {
  int p,q,r;
  
  cin >> p >> q >> r;
  
  vector<int> val = {p,q,r};
  
  sort(val.begin(),val.end());
  
  cout << val.at(0)+val.at(1);
  
  
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int score[105];
	for(int i = 1;i<=n;i++){
		scanf("%d",&score[i]);
	}
	sort(score+1,score+1+n);
	int flag;
	for(int i = 1;i<=n;i++){
		if(score[i]%10!=0)
		{
			flag=i;
			break;
		}
		else flag=0;
	}
	int sum=0;
	for(int i = 1;i<=n;i++){
		sum+=score[i];
	}
	if(sum%10!=0) printf("%d\n",sum);
	else if(sum%10==0&&flag!=0) printf("%d\n",sum-score[flag]);
	else printf("0\n");
}

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

#include <algorithm>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(A.rbegin(), A.rend());

    ll minA = A[1];
    ll tot = A[0];

    int cnt = 0;
    for (int i = 0; i < N - 2; i++) {
        if (i % 2 == 0) {
            cnt++;
            minA = A[cnt];
        }
        tot += minA;
    }
    cout << tot << endl;

    return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;//first=point second=num||first=time second=num
int N,r,l;
int d,t,x;
int n;
P team[100005];
P Seg[100005*2];
P Ttime[100005];
int top=0;
int btop=0;
int smin=-1;
int btime=0;
P Pmax(P a,P b);
void init(int n_);
void update(int k,int a);
P query(int a,int b,int k,int l,int r);
main(){
  cin>>N>>r>>l;
  for(int i=0;i<100005;i++){
    team[i].F=0;
    team[i].S=i+1;
    Ttime[i].F=0;
    Ttime[i].S=-(i+1);
  }
  init(N);
  for(int i=0;i<r;i++){
    cin>>d>>t>>x;
    Ttime[top].F+=t-btop;
    update(d-1,x);
    /*
    for(int i=n-1;i<2*n-1;i++){
      cout<<"|"<<Seg[i].F<<"|"<<Seg[i].S<<"| ";
    }
    */
    //cout<<endl;
    P tops;
    tops=query(0,n-1,0,0,n);
    top=tops.S;
    btop=t;
    int a=1;
  }
  Ttime[top].F+=l-btop;
  sort(Ttime,Ttime+N);
  /*
  for(int i=0;i<N;i++){
    cout<<Ttime[i].F<<"|"<<Ttime[i].S<<" ";
  }
  */
  //cout<<endl;
  cout<<-Ttime[N-1].second<<endl;
}
void init(int n_){
  n=1;
  while(n<n_){
    n*=2;
  }
  for(int i=0;i<2*n-1;i++){
    Seg[i]=P(0,0);
  }
  for(int i=n-1;i<2*n-1;i++){
    Seg[i].S=i-(n-1);
  }
  return;
}
void update(int k,int a){
  k+=n-1;
  Seg[k].F+=a;
  if(Seg[k].F<smin){
    smin=Seg[k].F;
  }
  while(k>0){
    k=(k-1)/2;
    Seg[k]=Pmax(Seg[k*2+1],Seg[k*2+2]);
  }

  return;
}
P Pmax(P a,P b){
  if(a.F>b.F||(a.F==b.F&&a.S<b.S)){
    return a;
  }
  else{
    return b;
  }
}
P query(int a,int b,int k,int l,int r){
  if(r<=a||b<=l){
    return P(smin,100010);
  }
  if(a<=l&&r<=b){
    return Seg[k];
  }
  else{
    P vl=query(a,b,k*2+1,l,(l+r)/2);
    P vr=query(a,b,k*2+2,(l+r)/2,r);
    return Pmax(vl,vr);
  }
}

Measured memory_bytes: 4288
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        String b = scanner.next();
        scanner.close();

        boolean isLiar = a.equals("H") && b.equals("H") || a.equals("D") && b.equals("D");

        System.out.println(isLiar ? "H" : "D");
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>
#include<stack>
#include <cstdlib>


using namespace std;
int main() {
	int n, m, x;
	int c[12], a[12][12];
	int sum[12];
	int anscost= 99999999;
	int tmp;

	cin >> n >> m >> x;

	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> tmp;
			a[i][j]=tmp;
		}
	}

	for (int bit = 0; bit < (1 << n); bit++) {
		//init
		for (int i = 0; i < m; i++) {
			sum[i] = 0;
		}
		int cost = 0;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				for (int k = 0; k < m; k++) {
					sum[k] += a[i][k];
				}
				cost += c[i];
		
			}
			
			
		}
		for (int j = 0; j < m; j++) {
			if (sum[j] < x) {
				cost = 99999999;
			}
		}anscost = min(cost, anscost);


	}
	if (anscost == 99999999) {
		anscost = -1;
	}
	cout << anscost;


	return 0;
}

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

int main(){
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if(u==s) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

main = do
  n <- readLn :: IO Int
  xs <- input n (map read . words) :: IO [[Int]]
  mapM_ putStrLn $ solve xs

solve :: [[Int]] -> [String]
solve zs = map (f [] []) zs
  where 
    f _ _ [] = "YES"
    f [] [] (x:xs) = f [x] [] xs
    f [] (r:rs) (x:xs) = if r < x then f [] (x:r:rs) xs else f [x] (r:rs) xs
    f (l:ls) [] (x:xs) = if l < x then f (x:l:ls) [] xs else f (l:ls) [x] xs
    f (l:ls) (r:rs) (x:xs) | l > x && r > x = "NO"
                           | l < x && x < r = f (x:l:ls) (r:rs) xs
                           | r < x && x < l = f (l:ls) (x:r:rs) xs
                           | l < r && r < x = f (l:ls) (x:r:rs) xs
                           | otherwise = f (x:l:ls) (r:rs) xs

input :: Int -> (String -> a) -> IO [a]
input n f = map f <$> replicateM n getLine

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

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

    int n; cin >> n;
    priority_queue<double, vector<double>, greater<double>> pq;
    
    for(int i=0; i<n; ++i){
        double a; cin >> a;
        pq.push(a);
    }

    double ans = 0;

    for(int i=0; i<n-1; ++i){
        double a, b;
        a = pq.top(); pq.pop();
        b = pq.top(); pq.pop();
        ans = (a+b)/2;
        pq.push(ans);
    }

    printf("%.10lf\n", ans);

    
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        if(a<b && b<c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
    
}



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

const int N = 100005;;
int n, a[N], b[N];
int main() {
  cin >> n;
  for(int i=0; i<=n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  
  int64_t ans = 0;
  for(int i=0; i<n; i++) {
  	ans += min(a[i],b[i]);
    b[i]=max(0,b[i]-a[i]);
    ans += min(a[i+1], b[i]);
    a[i+1]=max(0,a[i+1]-b[i]);
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)

{

   int a,b,d,r;

   double f=0;

   scanf("%d ",&a);

   scanf("%d ",&b);


   d=a/b;

   r=a%b;

   f=(double)a/(double)b;

   printf("%d %d %lf\n",d,r,f);

   return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
def print_ans(ar):
    """Test Case
    >>> print_ans([5, 7, 9])
    win
    >>> print_ans([13, 7, 2])
    bust
    """
    if sum(ar) >= 22:
        print("bust")
    else:
        print("win")

if __name__ == '__main__':
    ar = list(map(int, input().rstrip().split()))
    print_ans(ar)




Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    vector<stack<long long>> S(n);
    for(int i = 0; i < q; i++){
        long long x, y, z;
        cin >> x;
        if(x == 0){
            cin >> y >> z;
            S[y].push(z);
        }else if(x == 1){
            cin >> y;
            if(S[y].empty()) continue;
            cout << S[y].top() << "\n";
        }else{
            cin >> y;
            if(S[y].empty()) continue;
            S[y].pop();
        }
    }

    return 0;
}


Measured memory_bytes: 5044
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	string S;
	cin >> S;
	
	for (int i = 0; i<S.size(); i++) cout << 'x';
	cout <<endl;
	
	
	
	
	
	
	return 0;
}



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

using namespace std;

struct box {
    int w, s, v;
};
int n;
box arr[1010];
long long D[20010];

int main() {
    int i, j;

    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d%d%d",&arr[i].w,&arr[i].s,&arr[i].v);
    sort(arr,arr+n,[](box &a, box &b) {return a.w+a.s<b.w+b.s;});
    for (i=0;i<n;i++) {
        for (j=arr[i].w+arr[i].s;j>=arr[i].w;j--) D[j] = max(D[j],D[j-arr[i].w]+arr[i].v);
        for (j=1;j<=20001;j++) D[j] = max(D[j],D[j-1]);
    }
    printf("%lld\n",D[20001]);

    return 0;
}


Measured memory_bytes: 384
// C - たくさんの数式

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

string S;
ll ans = 0;

vector<string> split(string s, string c)
{
	vector<string> ret;
	for(int i = 0, n; i <= s.length(); i = n + 1){

		n = s.find_first_of(c, i);
		if(n == string::npos) n = s.length();
		string tmp = s.substr(i, n - i);
		ret.push_back(tmp);
	}
	return ret;
}

ll calc(string s) {
	//cout << s << endl; // **** debug ****
	ll res = 0;
	vector<string> vals = split(s, "+");
	for (string v : vals) {
		res += stoll(v);
	}
	return res;
}

void dfs(string& s, int i) {
	if (i == S.size()) {
		ans += calc(s);
		return;
	}

	s.push_back(S[i]);
	dfs(s, i+1);
	s.pop_back();

	s.push_back('+');
	s.push_back(S[i]);
	dfs(s, i+1);
	s.pop_back();
	s.pop_back();
}

int main() {
	cin >> S;

	string s;
	s.push_back(S[0]);

	dfs(s, 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j;
    ll N, M;
    cin >> N >> M;
    ll b, d;
    if(N % 2 == 1) {
        b = N / 2;
        for(i = 1; i <= M; i++) {
            d = i * 2 - 1;
            cout << b << " " << b + d << endl;
            b--;
        }
    }
    if(N % 2 == 0) {
        b = N / 2;
        for(i = 1; i <= M; i++) {
            d = i * 2 - 1;
            if(i > (M + 1) / 2)
                d++;
            cout << b << " " << b + d << endl;
            b--;
        }
    }

    return 0;
}

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

int GCD( int a, int b )
{
    if( a % b == 0 )
        return b;
    return GCD( b, a % b );
}

int main()
{
    int a, b;

    while( cin >> a >> b )
        cout << GCD( a, b ) << endl;

    return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    sort(begin(d), end(d));
    ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
data = int(input())

F = [list(map(int, input().split())) for _ in range(data)]
P = [list(map(int, input().split())) for _ in range(data)]

max_score = -float('inf')
for pattern_i in range(1, 2**10):
  op_num = [0]*data
  for pos_i in range(10):
    if pattern_i & 1<<pos_i:
      for n_i in range(data):
        op_num[n_i] += F[n_i][pos_i]
  max_score = max(max_score, sum([p_i[op_num_i] for p_i, op_num_i in zip(P, op_num)]))

print(max_score)

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(((a + b) % 3) == 0 || a%3 == 0 || b%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
int memo[200100], v[200200];

int lis(int pos, int last, int n){
    if (pos == n - 1 and v[pos] <= last) return 1;
    if (pos == n - 1) return 0;
    if (memo[pos] != -1) return memo[pos];
    if (v[pos] > last) return memo[pos] = lis(pos+1, last, n);
    return memo[pos] = max(lis(pos+1, last, n), lis(pos+1, v[pos], n) + 1);
}

void init(int n){
    for (int i=0; i<n; i++){
        memo[i] = -1;
    }
}
 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;

    cin >> n;
    init(n);
    for (int i=0; i<n; i++){
        cin >> v[i];
    }


    cout << lis(0, oo, n) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
using namespace std;
using ll = long long;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int r; cin >> r;

  cout << r*r << endl;


  return 0;
}


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

const int N = 1e5 + 10;

int n, a, b, na, nb;
vector <int> v;

int main() {
	ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	set <int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.insert(a);
		v.push_back(a);
	}
	if (s.size() > 2)
		cout << "No";
	else if (s.size() == 2) {
		vector <int> l;
		for (auto x: s)
			l.push_back(x);
		a = l[0];
		b = l[1];
		if (b - a != 1)
			cout << "No";
		else {
			na = 0, nb = 0;
			for (auto x: v) {
				if (x == a)
					na++;
				else
					nb++;
			}
			int k = b;
			k -= na;
			if (nb >= 2 * k && k > 0)
				cout << "Yes";
			else
				cout << "No";
		}
	}
	else {
		vector <int> l;
		for (auto x: s)
			l.push_back(x);
		a = l[0];
		if (n == a + 1 || n >= a * 2)
			cout << "Yes";
		else
			cout << "No";
	}
	return 0;
}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int h, n;
    cin >> h >> n;
    rep (i, n) {
        int a;
        cin >> a;
        h -= a;
    }

    if (h <= 0)yn
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] line = scan.nextLine().split(" ");

        int[] inputs = new int[2];
        int input;

        // -1,000 ≤ a, b ≤ 1,000
        for (int i = 0; i < line.length; i++) {
            input = Integer.parseInt(line[i]);
            if (input < -1000 || 1000 < input ) System.exit(-1);
            inputs[i] = input;
        }

        int a = inputs[0];
        int b = inputs[1];

        System.out.println("a " + (a < b ? "<": a > b ? ">" : "==") + " b" );

        scan.close();
    }

}


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

int main()
{
    int n;
    cin >> n;
    
    set<int> S;
    
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        
        if(S.find(t) == S.end())
        {
            S.insert(t);
        }
        else
        {
            S.erase(S.find(t));
        }
    }
    
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    sort(ALL(A),greater<ll>());
    vector<ll> B(N);
    rep(i,N) B[i]=A[i];
    SORT(B);
    map<ll,ll> mp;
    /*bis*/ ll low= -1 , high= INF2 ; // min-1, max+1
    while( abs(high-low)>1 ){ ll mid=(high+low)/2;
        bool ok=false;
        // mid以上の組で握手
        ll ct=0;
        vector<ll> sum(N+1,0);
        vector<ll> summ(N+1,0);
        rep(i,N) if(A[i]*2>=mid) {++ct; summ[i]+=2;}
        rep(i,N){
            ll x=mid-A[i];
            ll ind=lower_bound(ALL(B), x)-B.begin();
            ind=N-1-ind;
            if(ind<=i) break;
            sum[i+1]+=2;
            sum[ind+1]-=2;
            summ[i]+=2*(ind-i);
            ct+=2*(ind-i);
        }
        rep(i,N) sum[i+1]+=sum[i];
        rep(i,N) sum[i]+=summ[i];
        ll ans=0;
        rep(i,N) ans+=A[i]*sum[i];
        ans-=(ct-M)*mid;
        mp[mid]=ans;
        if(ct>=M) ok=true;
        ( ok ? low : high ) = mid;
    }// if ok, okdir = mid
    
    cout<< mp[low] <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.length(); i++) {
    char c = s[i];
    c += n;
    if (c > 'Z') {
      c = 'A' + c - 'Z' - 1;
    }
    cout << c;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,m;
    cin>>n>>m;
    int a[n];
    float s=0,c=0;
    for(int i =0; i<n; i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    float ss = s/(4*m);
    //cout<<ss<<endl;
    for(int i=0; i<n; i++)
    {
        if(a[i]>=s/(4*m))
        {
            c++;
        }
    }
    if(c<m)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }

}


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

int main() {
    int n, result = 0;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    if (p[0] == 1) {
        swap(p[0], p[1]);
        result++;
    }
    for (int i = 1; i < n; i++) {
        if (p[i] == i + 1) {
            if (i + 1 < n && p[i + 1] == i + 2) {
                swap(p[i], p[i + 1]);
            }
            result++;
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
#define end system("PAUSE");return 0
using namespace std;
signed main() {
	int n, ans = 0;
	map<int, int> mp;
	cin >> n;
	rep(i, n) {
		int in;
		cin >> in;
		++mp[in];
	}
	for (auto it : mp) {
		if (it.second % 2 == 1)ans++;
	}
	cout << ans << endl;
	end;
}


Measured memory_bytes: 6776
#include <stdio.h>

struct DICE {
	int num[7];
};

void throwdice(char, struct DICE *);
int judge(struct DICE *, struct DICE *);
int issame(struct DICE *, struct DICE *);

int main(void)
{
	struct DICE dice1, dice2;
	int i;
	
	for(i=1; i<=6; i++) {
		scanf("%d",&dice1.num[i]);
	}
	for(i=1; i<=6; i++) {
		scanf("%d",&dice2.num[i]);
	}
	if( issame(&dice1, &dice2) ) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

void throwdice(char ch, struct DICE *dice)
{
	int temp;
	switch (ch) {
	case 'N':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[5] ;
		dice->num[5] = dice->num[1] ;
		dice->num[1] = dice->num[2] ;
		dice->num[2] = temp;
		break;
	case 'S':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[2] ;
		dice->num[2] = dice->num[1] ;
		dice->num[1] = dice->num[5] ;
		dice->num[5] = temp;
		break;
	case 'E':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[3] ;
		dice->num[3] = dice->num[1] ;
		dice->num[1] = dice->num[4] ;
		dice->num[4] = temp;
		break;
	case 'W':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[4] ;
		dice->num[4] = dice->num[1] ;
		dice->num[1] = dice->num[3] ;
		dice->num[3] = temp;
		break;
	}
}

int judge(struct DICE *dice1, struct DICE *dice2)
{
	int i, j, flag=0, cnt;
	for (i=0; i<4; i++) {
		cnt = 0;
		for (j=1; j<=6; j++) {
			if(dice1->num[j] == dice2->num[j]) {
				cnt++;
			}
		}
		if(cnt == 6) {
			flag = 1;
		}
		throwdice('E',dice1);
	}
	return flag;
}

int issame(struct DICE *dice1, struct DICE *dice2)
{
	int i;
	
	if ( judge(dice1,dice2) ) {
		return 1;
	}
	
	throwdice('S',dice1);
	if ( judge(dice1,dice2) ) {
		return 1;
	}
	
	throwdice('W',dice1);
	throwdice('S',dice1);
	if ( judge(dice1,dice2) ) {
		return 1;
	}
	
	throwdice('S',dice1);
	throwdice('S',dice1);
	if ( judge(dice1,dice2) ) {
		return 1;
	}
	
	throwdice('E',dice1);
	throwdice('S',dice1);
	if ( judge(dice1,dice2) ) {
		return 1;
	}
	
	throwdice('E',dice1);
	throwdice('S',dice1);
	if ( judge(dice1,dice2) ) {
		return 1;
	}
	return 0;
}

Measured memory_bytes: 580
x, y= map(int, input().split())
mod=10**9+7
import math
a=(2*y-x)//3
b=(2*x-y)//3

if (2*x-y)%3!=0 or (2*y-x)%3!=0 or a<0 or b<0:
	print(0)

else:
	L=[1]*(a+b+1)
	for i in range(1,a+b+1):
		L[i]=L[i-1]*i
		L[i]=L[i]%mod
	p=pow(L[a], mod-2, mod)
	q=pow(L[b], mod-2, mod)
	ans=(L[a+b]*p*q)%mod
	print(ans)

Measured memory_bytes: 29428
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

//#define DEBUG

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cins(s);
    cinll(k);

/* Cases
 * 1. sames within string: change n/2; 3:1, 4,2
 * 2. sames at begin/end
 * on first k nbegin/2, last k nend/2
 * other (nbegin+nend)/2
 * 3. all same: (n*k)/2
 */

    int nbegin=1;
    for(size_t i=1; i<s.size(); i++) {
        if(s[i]==s[0])
            nbegin++;
        else
            break;
    }

    int nend=1;
    for(int i=s.size()-2; i>=0; i--) {
        if(s[i]==s[s.size()-1])
            nend++;
        else
            break;
    }
    if(nbegin+nend>s.size()) {     // case 3
        ll ans=(k*s.size())/2;
        cout<<ans<<endl;
        return 0;
    }

    vector<pii> sames;
    sames.push_back({ 0, nbegin});

    int idx=nbegin+1;
    int cnt=1;
    while(idx<s.size()) {
        while(idx<s.size() && s[idx]==s[idx-1]) {
            cnt++;
            idx++;
        }

        sames.push_back({idx-cnt, cnt});
        idx++;
        cnt=1;
    }

#ifdef DEBUG
cout<<"dump sames"<<endl;
for(auto p : sames)
    cout<<"first="<<p.first<<" second="<<p.second<<endl;
#endif

    ll ans=0;
    if(s[sames[0].first]==s[sames.back().first]) { /* case 2 */
        ans+=sames[0].second/2;
        ans+=sames.back().second/2;
        if(k>1)
            ans+=(k-1)*((sames[0].second+sames.back().second)/2);

        for(int i=1; i<sames.size()-1; i++) 
            ans+=k*(sames[i].second/2);

    } else {
        for(int i=0; i<sames.size(); i++) 
            ans+=k*(sames[i].second/2);
    }

    cout<<ans<<endl;
    

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  map<int, int64_t> m; vector<int> A(N); for (auto &a: A) {cin >> a; ++m[a];}
  int64_t s{}; for (auto [_, c] : m) s += c * (c - 1) / 2;
  for (int k = 0; k < N; ++k) {auto c{m[A[k]]}; cout << s - c * (c - 1) / 2 + (c - 1) * (c - 2) / 2 << "\n";}}

Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
// define #Asukaminato ha kawaii
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.

 
int main(){
 int N;int ans = inf;cin >>N;
 vector<int> X(N);
 for (size_t i = 0; i < N; i++)
 {
   cin>>X[i];
 }
 
 for(int i = 1; i <= 100; i++) {
 int cost = 0;
 rep(j, N) cost += (X[j] - i) * (X[j] - i);
 ans = min(ans, cost);}
 cout <<ans<<endl;
 return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int MAX = 110000;
int dp[MAX];

int main(){
    int n; cin >> n;
    for(int i = 0; i < MAX; ++i) dp[i] = n;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int pow6 = 1; pow6 + i <= n; pow6 *= 6) dp[pow6 + i] = min(dp[pow6 + i], dp[i] + 1);
        for(int pow9 = 1; pow9 + i <= n; pow9 *= 9) dp[pow9 + i] = min(dp[pow9 + i], dp[i] + 1);
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static ll n,x;
	static ll b[100010],l[100010],u[100010];
	scanf("%lld%lld",&n,&x);
	rep1(i,n){
		scanf("%lld%lld%lld",&b[i],&l[i],&u[i]);
	}
	
	ll X = x;
	
	vector<P> vec;
	rep1(i,n){
		vec.pb(P(X*u[i]-b[i]*(u[i]-l[i]),i));
	}
	sor(vec); rev(vec);
	static ll sum[100010];
	sum[0] = vec[0].fr;
	for(int i = 1 ; i < n ; i ++){
		sum[i] = sum[i-1]+vec[i].fr;
		//sum[i] = sum[i-1]+(X-b[vec[i].sc])*u[vec[i].sc];
	}
	static ll loc[100010];
	rep(i,vec.size()){
		loc[vec[i].sc] = i;
	}
	
	ll SUM = 0;
	for(int i = 1 ; i <= n ; i ++){
		SUM += -b[i]*l[i];
	}
	
	if(SUM == 0){
		cout << 0 << endl;
		return 0;
	}
	
	ll S = 0;
	ll _sum = SUM;
	for(int i = 0 ; i < n ; i ++){
		_sum += vec[i].fr;
		if(_sum >= 0)break;
		else S = i+1;
	}
	
	ll ret = n*X;
	rep1(i,n){
		//cout << i << endl;
		ll L = S*X+1, R = (S+1)*X;
		while(L < R){
			ll M = (L+R)/2;
			ll s = M/X, t = M%X;
			if(t == 0){
				s --;
				t = X;
			}
			if(loc[i] < s)s ++;
			ll sum_ = SUM;
			if(s == 0)sum_ += 0;
			else sum_ += sum[s-1];
			if(loc[i] < s){
				sum_ -= vec[loc[i]].fr;
			}
			//cout << sum_ << endl;
			sum_ += l[i]*min(t,b[i]);
			sum_ += u[i]*max(t-b[i],(ll)0);
			if(sum_ >= 0)R = M;
			else L = M+1;
			//cout << L << " " << R << " " << M <<" " << sum_ << endl;
		}
		ret = min( ret , L );
	}
	cout << ret << endl;
}
	
	

Measured memory_bytes: 5872
#include<bits/stdc++.h>
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
using namespace std;

int main(){
    int N; cin>>N;
    int a;
    int ans=0;
    for(int i=0; i<N; i++){
        cin>>a;
        if((i+1)%2 != 0 && a%2 != 0) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3560
import java.util.Scanner;
public class Main{
    int a;   
    int b;
    int n;
    int x;
    int y;
    int kin=0;
    int wari;
    public void solve(){
        Scanner sc=new Scanner(System.in);
        n = sc.nextInt();
        for(int i=0;i<n;i++){
          a = sc.nextInt();
          b = sc.nextInt();
          x = sc.nextInt();
          y = sc.nextInt();
          kin =a*x + b*y;
            
        if(x>=5 && y>=2){
          kin =(a*x + b*y)*4/5;
            
        } else if(x<5){
                x=5;
                }
                if(y<2){
                y=2;
                }
                int wari = (a*x + b*y)*4/5;
                 
                if(kin>wari){
                    kin = wari;
                }
        
            
        System.out.println(kin);
        }
    }
    public static void main(String[] args){
      Main obj=new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23436
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int K = intArray[0];
            int X = intArray[1];
            if(500 * K >= X)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28028