akhauriyash/Code-Regression huggingface dataset:
class P_UnionFind:
    def __init__(self, n):
        self.p=[i for i in range(n)]
        self.r=[0 for i in range(n)]
        self.d=[0 for i in range(n)]
    def root(self,x):
        if self.p[x]==x:
            return x
        else:
            tmp = self.root(self.p[x])
            self.d[x] += self.d[self.p[x]]
            self.p[x] = tmp
            return self.p[x]
    
    def weight(self,x):
        self.root(x)
        return self.d[x]

    def diff(self,x,y):
        if self.root(x)==self.root(y):
            return self.weight(y)-self.weight(x)
        else:
            return '?'

    def uni(self,x,y,w):
        w+=self.weight(x)
        w-=self.weight(y)
        x=self.root(x)
        y=self.root(y)
        if(x==y):
            return
        if self.r[x]<self.r[y]:
            self.p[x]=y
            self.d[x]=-w
        else:
            self.p[y]=x
            self.d[y]=w
            if self.r[x]==self.r[y]:
                self.r[x]+=1
    
    def same(self,x,y):
        return self.root(x)==self.root(y)

n,q=map(int,input().split())
uf=P_UnionFind(n)
ans=[]
for i in range(q):
    d=list(map(int,input().split()))
    if d[0]==0:
        c,x,y,z=d
        uf.uni(x,y,z)
    else:
        c,x,y=d
        ans.append(uf.diff(x,y))
print(*ans,sep='\n')


Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, X, Y;
  cin >> X >> Y;
  int ans = INF2;
  REP(i, 4) {
    A = X, B = Y;
    int tmp = 0;
    if (i & BIT(0)) {

        A *= -1;
        tmp++;

    }

    if (i & BIT(1)) {

        B *= -1;
        tmp++;

    }
    if (B - A >= 0) {
      chmin(ans, tmp + B - A);
    }
  }
  print(ans);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn is_good(s: &str) -> bool {
    let mut s = String::from(s);

    while s.len() > 0 {
        if s.len() >= 5 && &s[..5] == "dream" {
            if s.len() >= 7 && &s[..7] == "dreamer" {
                if s.len() >= 10 && &s[5..10] == "erase" {
                    s = s[5..].to_string();
                } else {
                    s = s[7..].to_string();
                }
            } else {
                s = s[5..].to_string();
            }
        } else if s.len() >= 6 && &s[..6] == "eraser" {
            s = s[6..].to_string();
        } else if s.len() >= 5 && &s[..5] == "erase" {
            s = s[5..].to_string();
        } else {
            return false;
        }
    }

    return true;
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let s: String = read(&mut stdin).unwrap();

    if is_good(&s) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i=0;i<n;i++){
        ll A;
        cin>>A;
        a[i+1]=a[i]+A;
    }
    ll ans=INF;
    for(int i=1;i<n;i++){
        ll x=a[i];
        ll y=a[n]-a[i];
        ans=min(ans,llabs(x-y));
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

const ll MAX_N = 100002;
const ll MOD = 1000000007;

vector<ll> fac(MAX_N), finv(MAX_N), inv(MAX_N);

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

ll combi(int n, int k) {
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

ll solve() {
  int N, K;
  cin >> N >> K;

  init(N);

  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());

  ll s_min = 0;
  ll s_max = 0;
  for (int i = 0; i < (N - K + 1); i++) {
    ll c = combi(N - i - 1, K - 1);
    s_min = (s_min + (c * A[i] % MOD)) % MOD;
  }
  for (int i = K - 1; i < N; i++) {
    ll c = combi(i, K - 1);
    s_max = (s_max + (c * A[i] % MOD)) % MOD;
  }

  return (s_max - s_min + MOD) % MOD;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3328
/*
  AOJ 2084
  Title:Hit and Blow
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
int  N;
char valid[10000];

int decide(char secret[4],char attempt[4])
{
  int i,j,h,b;
  h=b=0;
  for(i=0;i<4;i++)
    for(j=0;j<4;j++)
      {
	if(secret[i]==attempt[j])
	  {
	    if(i==j)
	      h++;
	    else
	      b++;
	  }
      }
  return(h*10+b);
}

int decide2(int secret,int attempt)
{
  char s[4],a[4];
  int i,j;

  for(i=0;i<4;i++)
    {
      s[3-i] = secret % 10;
      a[3-i] = attempt % 10;
      secret /= 10;
      attempt /= 10;
    }
  for(i=0;i<4;i++)
    for(j=0;j<4;j++)
      if(i != j && a[i]==a[j])
	return(-1);
  return(decide(s,a));
}
int critical(int c[],int cnt)
{
  int i,j,k,l,wk[6];

  for(i=123;i<=9876;i++)
    {
      for(j=0;j<cnt;j++)
	wk[j]=decide2(c[j],i);
      for(k=0;k<cnt;k++)
	for(l=0;l<cnt;l++)
	  if(k!=l && wk[k]==wk[l])
	    goto NEXT;
      return(i);
    NEXT:
      ;
    }
  return(-1);
}
int print_all()
{
  int i,cnt,cand[6],ret;

  cnt=0;
  for(i=0,cnt=0;i<10000;i++)
    if(valid[i]==N)
      {
	if(cnt<6)
	  cand[cnt]=i;
	cnt++;
      }
#ifdef COUNT
  printf("%d:",cnt);
  if(cnt>2)
    for(i=0;i<cnt;i++)
      printf("%04d:",cand[i]);
  printf("\n");
#endif
  if(cnt==1)
    printf("%04d\n",cand[0]);
  else if(cnt<7)
    {
      ret=critical(cand,cnt);
      if(ret>0)
	printf("%04d\n" ,ret);
      else
	printf("????\n");
    }
  else
    printf("????\n");
  return(cnt);
}


main()
{
  int i,j,hb,cnt,res;
  char d[4],secr[4];
  char h,b,ret;
  while(scanf("%d ",&N) && N)
    {
      memset(valid,0,10000);
      for(i=0;i<N;i++)
	{
	  scanf("%c%c%c%c %c %c ",&d[0],&d[1],&d[2],&d[3],&h,&b);
	  for(j=0;j<4;j++)
	    d[j] -= '0';
	  h-='0';b-='0';hb=h*10+b;
	  //printf("d:=%d%d%d%d hb=%02d\n",d[0],d[1],d[2],d[3],hb);
	  
	  for(secr[0]=0;secr[0]<=9;secr[0]++)
	    for(secr[1]=0;secr[1]<=9;secr[1]++)
	      {
		if(secr[0]==secr[1])
		  continue;
		for(secr[2]=0;secr[2]<=9;secr[2]++)
		  {
		    if(secr[0]==secr[2] || secr[1]==secr[2])
		      continue;
		    for(secr[3]=0;secr[3]<=9;secr[3]++)
		      {
			if(secr[0]==secr[3] || secr[1]==secr[3] || secr[2]==secr[3])
			  continue;
			res=decide(&secr[0],&d[0]);
			if(hb==res)
			  {
			    //printf("%d%d%d%d",secr[0],secr[1],secr[2],secr[3]);
			    //printf(":%d%d%d%d",d[0],d[1],d[2],d[3]);
			    //printf(":%02d\n",res);
			    
			    valid[secr[0]*1000+secr[1]*100+secr[2]*10+secr[3]]++;
			  }
		      }
		  }
	      }
	}
      ret=print_all();

    }
  return(0);
}

Measured memory_bytes: 636
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){

	ll n,m;
	cin>>n>>m;

	vector<ll> h(n,0);
	for(ll i=0;i<n;i++){
		cin>>h[i];
	}

	vector<vector<ll>> gra(n);
	for(ll i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		gra[a].push_back(b);
		gra[b].push_back(a);
	}

	ll ans=0;

	for(ll j=0;j<n;j++){
		bool check=true;
		for(ll i=0;i<gra[j].size();i++){

			if(h[j]<=h[gra[j][i]]){
				check=false;
				break;
			}
		}
		if(check){
			ans++;
		}
	}

	cout<<ans<<endl;

}


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


Measured memory_bytes: 9856
#include <iostream>
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int main()
{
    IO;
    int n ;
    cin>>n;
    double arr[n+2];
    for(int i = 0; i< n ; i ++) cin>>arr[i];
    double dp[n+2][n+2];
    dp[0][0]=1-arr[0];
    dp[0][1]=arr[0];
    for(int i = 1 ; i< n ; i ++)
    {
        for(int j = 0 ; j <=i+1 ; j ++)
        {
             if(j==0)
                dp[i][j]=(1-arr[i])*dp[i-1][j];
             else if(j==i+1)
                dp[i][j]=arr[i]*dp[i-1][j-1];
            else
                dp[i][j]=(1-arr[i])*dp[i-1][j]+(arr[i]*dp[i-1][j-1]);
        }
    }
    double ans=0;
    for(int i = n; i>n/2;i--){
        ans+=dp[n-1][i];
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 49900
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  while(str[0]!='0'){
    int i,o=0;
    for(i=0;i<str.size();i++){
      o+=str[i]-'0';//文字コードよくわかんない
    }
    cout << o << endl;
    cin >> str; //なんでこの行にcin >> str;もう1回出てくるの？
  }
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;

int main(){
    int n,q;
    cin >> n >> q;
    dsu d(n);

    rep(i,q){
        int t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            d.merge(u,v);
        }else{
            cout << (d.same(u,v)?1:0) << endl;
        }
    }
}

Measured memory_bytes: 3852
N, X = map(int, input().split())
l_list = list(map(int, input().split()))
l_list = [0] + l_list
d = 0
for i, l in enumerate(l_list):
    if d + l > X:
        break
    d += l
if sum(l_list) <= X:
    i = N + 1
print(i)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 20;
char a[(1<<N+1)+3];
int f[(1<<N+1)+3][N+3];
int bitcnt[(1<<N+1)+3],lg2[(1<<N+1)+3];
int nxt[(1<<N+1)+3][2],cnt[(1<<N+1)+3];
int n,m;

int main()
{
	for(int i=1; i<(1<<N+1); i++) bitcnt[i] = bitcnt[i>>1]+(i&1);
	lg2[1] = 0; for(int i=2; i<(1<<N+1); i++) lg2[i] = lg2[i>>1]+1;
	scanf("%d%d",&n,&m);
	for(int i=0; i<=n; i++)
	{
		scanf("%s",a); for(int j=0; j<(1<<i); j++) f[j|(1<<i)][0] = a[j]-48;
	}
	for(int i=1; i<(1<<n+1); i++)
	{
		int len = lg2[i]; int sta = i^(1<<len);
		for(int x=0; x<2; x++)
		{
			nxt[i][x] = -1;
			for(int j=len-1; j>=0; j--)
			{
				if(((i>>j)&1)==x) {nxt[i][x] = (i&((1<<j)-1))|(1<<j); break;}
			}
//			printf("nxt[%d][%d]=%d\n",i,x,nxt[i][x]);
		}
	}
	for(int j=0; j<=n; j++)
	{
		for(int i=(1<<j); i<(1<<n+1); i++)
		{
			int len = lg2[i]; int sta = i^(1<<len);
			if(f[i][j]==0) continue;
			cnt[i>>len-j] += f[i][j];
			for(int x=0; x<2; x++)
			{
				if(nxt[(sta&((1<<len-j)-1))|(1<<len-j)][x]==-1) continue;
				int sta2 = nxt[(sta&((1<<len-j)-1))|(1<<len-j)][x],len2 = lg2[sta2]; sta2 ^= (1<<len2);
				sta2 |= (((i>>len-j)<<1|x)<<len2);
//				printf("(%d,%d)+%d->(%d,%d)\n",i,j,x,sta2,j+1);
				f[sta2][j+1] += f[i][j];
			}
		}
	}
	int ans = 0;
	for(int i=1; i<(1<<n+1); i++)
	{
//		printf("cnt[%d]=%d\n",i,cnt[i]);
		if(cnt[i]>=m)
		{
			if(lg2[i]>lg2[ans]||(lg2[i]==lg2[ans]&&i<ans)) {ans = i;}
		}
	}
	int len = lg2[ans]; for(int i=len-1; i>=0; i--) printf("%d",(ans>>i)&1); puts("");
	return 0;
}

Measured memory_bytes: 231680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, w, p;
string s[15];
vector<vector<int>> vec;
vector<vector<int>> vect;
vector<int> ve;
set<vector<char>> st;
vector<char> v;
bool bl[15];

void dfs(int x, int k) {
	ve.push_back(x);
	if (k == p - 1)vec.push_back(ve);
	if (k < p - 1 && x + 1 < h)dfs(x + 1, k + 1);
	ve.pop_back();
	if (k == p)vec.push_back(ve);
	if (k < p&&x + 1 < h)dfs(x + 1, k);
}

signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)cin >> s[i];
	p = (h + 1) / 2;
	dfs(0, 0);
	int t = (int)vec.size();
	for (int i = 0; i < t; i++) {
		do {
			vect.push_back(vec[i]);
		} while (next_permutation(all(vec[i])));
	}
	for (int i = 0; i < (int)vect.size(); i++) {
		fill(bl, bl + h, false);
		for (int j = 0; j < (int)vect[i].size(); j++)bl[vect[i][j]] = true;
		for (int j = 0; j < h; j++)if (!bl[j])vect[i].push_back(j);
		st.clear();
		for (int k = 0; k < w; k++) {
			v.clear();
			for (int j = 0; j < h; j++)v.push_back(s[vect[i][j]][k]);
			reverse(all(v));
			auto p = st.find(v);
			if (p != st.end())st.erase(v);
			else {
				reverse(all(v));
				st.insert(v);
			}
		}
		if ((int)st.size() <= 1) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 90404
while True:
    try:
        x1, y1, x2, y2, xp, yp = map(float, input().split(','))

        dx = x2 - x1
        dy = y2 - y1
        
        xr = (2*dx*dy*yp + (dx**2 - dy**2)*xp + 2*dy*(x1*y2 - x2*y1))/(dx**2 + dy**2)
        yr = (2*dx*dy*xp - (dx**2 - dy**2)*yp - 2*dx*(x1*y2 - x2*y1))/(dx**2 + dy**2)

        print(xr, yr)

    except EOFError:
        break


Measured memory_bytes: 5592
MOD = 10 ** 9 + 7
from math import gcd
from collections import defaultdict

n = int(input())
plus = defaultdict(int)
minus = defaultdict(int)
zero = [0, 0, 0]
for _ in range(n):
    a, b = map(int, input().split())
    if a * b == 0:
        if a == b == 0:
            zero[0] += 1
        elif a == 0:
            zero[1] += 1
        else:
            zero[2] += 1
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        a *= -1
        b *= -1
    if b >= 0:
        s = str(a) + "-" + str(b)
        plus[s] += 1
    else:
        s = str(-b) + "-" + str(a)
        minus[s] += 1

pm = [[zero[1], zero[2]]]
cnt = sum(zero)
for key, value in plus.items():
    if minus[key] != 0:
        pm.append([value, minus[key]])
        cnt += value + minus[key]
        
ans = pow(2, n - cnt, MOD)

for p, m in pm:
    ans *= (pow(2, p, MOD) + pow(2, m, MOD) - 1)
    ans %= MOD
ans += zero[0] - 1
ans %= MOD
print(ans)


Measured memory_bytes: 158816
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (a < b) {
		if ((b - a) % 2 == 1) {
			cout << "Borys" << endl;
		} else {
			cout << "Alice" << endl;
		}
	} else {
		if ((a - b) % 2 == 1) {
			cout << "Borys" << endl;
		} else {
			cout << "Alice" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
int friends[100000];
int N;
int ans=0;
int main(void){
	std::cin>>N;
	for(int i=0;i<N;i++){
		std::cin>>friends[i];
	}
	for(int i=0;i<N;i++){
		if(friends[ friends[i]-1 ]==i+1)ans++;
	}
	ans/=2;
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if (N == 1){
    cout << "Hello World" << endl;
  }
  if(N == 2){
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int n;
    cin >> n;
    int Max = -1;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        Max = max(Max,a[i]);
    }
    vector<int> mps(Max+1);
    for(int i = 0; i <= Max; i++) mps[i] = i;
    for(ll i = 2; i*i <= Max; i++){
        if(mps[i] == i){
            for(ll j = i*i; j <= Max; j += i){
                if(mps[j] == j) mps[j] = i;
            }
        }
    }

    vector<int> seen(Max,0);
    bool pc = true;

    for(int i = 0; i < n; i++){
        if(a[i] == 1) continue;
        vector<int> fp;
        int n = a[i];
        while(mps[n] != n){
            if(fp.size() != 0 && fp.back() == mps[n]){
                n /= mps[n];
            } else {
                fp.push_back(mps[n]);
                n /= mps[n];
            }
        }
        if(fp.size() == 0 || fp.back() != mps[n]) fp.push_back(mps[n]);
        for(auto p:fp){
            if(seen[p]) pc = false;
            seen[p] = true;
        }
    }

    

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

    int g = __gcd(a[0],a[1]);
    for(int i = 0; i < n; i++) g = __gcd(g,a[i]);

    if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 15072
#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>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int A, B, T;

int main()
{
	cin >> A >> B >> T;

	int tmp = T / A;
	int ans = tmp * B;

	cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int n, k;

int Ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  scanf("%d%d", &n, &k);
  printf("%d\n", 1 + Ceil(n - k, k - 1));
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    List<Character> rem = new ArrayList<>();
    for (char ch : s) if (ch != 'x') rem.add(ch);
    if (palindrome(rem)) {
      int i = 0;
      int j = s.length - 1;
      int count = 0;
      while (i < j) {
        while (i < j && s[i] == s[j]) {
          i++;
          j--;
        }
        while (i < j && s[i] == 'x') {
          i++;
          count++;
        }
        while (i < j && s[j] == 'x') {
          j--;
          count++;
        }
      }
      System.out.println(count);
    } else {
      System.out.println(-1);
    }
  }

  private static boolean palindrome(List<Character> list) {
    int i = 0;
    int j = list.size() - 1;
    while (i < j && list.get(i).equals(list.get(j))) {
      i++;
      j--;
    }
    return i >= j;
  }
}


Measured memory_bytes: 27832
a = input()
S = list(a)

count = 0
if S[0] == "A":
    count += 1
    # print("OK")

vaa = 0
num=[0]
for j in range(2, len(S)-1):
    # print(j)
    if S[j] == "C":
        vaa += 1
        num.append(j)

if vaa == 1:
    count += 1
    # print("OK")

# val = 0
# for i in range(len(S)):
#     for j in range(len(S)):
#         if j == 0 or j == num:
#             print(j)
#             continue
#         else:
#             if S[i] == S_low[j]:
#                 print(S[i])
#                 print(S[j])
#                 val += 1
#             else:
#                 continue
# print("val", val)
# if val == len(S)-2:
#     count +=1
# print(num)
num = reversed(num)
S_pop = [S.pop(i) for i in num]
S_low = [i.lower() for i in S]

# print("S", S)
# print("S_low", S_low)

if S == S_low:
    count += 1

if count == 3:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int n,k,l[50]={0},ll,tmp;
    int ans = 0;
    scanf("%d %d",&n,&k);
    for(int i=0; i<n; i++){
        scanf("%d",&l[i]);
        //l[ll]++;
    }
    //printf("%d",l[1]);
    /*for(int j=0; j<k; j++){
        if(l[j] > l[j+1]){
            x = l[j];
            l[j] = l[j+1];
            l[j+1] = x;
        }

    }*/
    for (int j=0; j<n; ++j) {
        for (int m=j+1; m<n; ++m) {
            if (l[j] > l[m]) {
                tmp =  l[j];
                l[j] = l[m];
                l[m] = tmp;
            }
        }
    }

    //printf("%d",x);
    for(int a = 1; a <= k; a++){
        ans += l[n-a];
    }
        printf("%d",ans);
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
dist = 1000
for i, a in enumerate(A):
	if abs(a - ave) < dist:
		ans = i
		dist = abs(a - ave)
	if dist < 0.5:
		break
print(ans)
	

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double
int main(){
  string s;
  cin >> s;
  int n=s.length();
  int ans=0;
  rep(i,n-1){
    if(s[i]!=s[i+1]) ans++;
  }

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


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int days;
    if (s == "SUN")
        days = 7;
    else if (s == "MON")
        days = 6;
    else if (s == "TUE")
        days = 5;
    else if (s == "WED")
        days = 4;
    else if (s == "THU")
        days = 3;
    else if (s == "FRI")
        days = 2;
    else if (s == "SAT")
        days = 1;
    cout << days << endl;
}

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

#define reg register

using namespace std;

int n,arr[10],used[11]={1,0};

inline void dfs(const int &dep,const int &n) {
	if(dep==n) {
		for(reg int i=0; i<n; ++i) putchar(arr[i]+96);
		putchar('\n');
		return ;
	}
	for(reg int i=1; i<=n; ++i) {
		if(!used[i-1]) break;
		arr[dep]=i;
		++used[i];
		dfs(dep+1,n);
		--used[i];
	}
	return ;
}

int main() {
	scanf("%d",&n);
	dfs(0,n);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> t(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> t.at(i);
        sum += t.at(i);
    }
    int m;
    cin >> m;
    vector<int> p(m), x(m);
    for (int i = 0; i < m; i++) {
        cin >> p.at(i) >> x.at(i);
        p.at(i)--;
    }

    for (int i = 0; i < m; i++) {
        int new_sum = sum + (x.at(i) - t.at(p.at(i)));
        cout << new_sum << endl;
    }
}   

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;
static const ll INF = 1e18;

vector<ll> dx = {0, -1, 0, 1};
vector<ll> dy = {-1, 0, 1, 0};


void Main(){
    ll H, W, K;
    cin >> H >> W >> K;

    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    -- sx;
    -- sy;
    -- tx;
    -- ty;

    
    vector<string> field(H);
    rep(i, H){
        cin >> field[i];
    }
    vector<ll> dist(H*W*4, INF);

    priority_queue<pll, vector<pll>, greater<pll>> PQ;

    auto toid = [&](ll x, ll y, ll nd){
        return x * W * 4 + y * 4 + nd;
    };

    auto push = [&](int x, int y, int nd, ll d){
        ll id = toid(x, y, nd);
        if(dist[id]<= d){
            return;
        }
        dist[id] = d;
        PQ.emplace(d, id);
    };

    auto mod_ceil = [&](ll d){
        return (d + K - 1) / K * K;
    };

    rep(v, 4) push(sx, sy, v, 0);

    while(!PQ.empty()){
        ll d = PQ.top().first;
        ll id = PQ.top().second;
        PQ.pop();
        if(d!=dist[id]) continue;
        ll i = id / W / 4;
        ll j = id / 4 % W;
        ll v = id % 4;
        rep(nv, 4) push(i, j, nv, mod_ceil(d));
        ll next_i = i + dx[v];
        ll next_j = j + dy[v];
        if(next_i >= 0 && next_i < H && next_j >= 0 && next_j < W){
            if(field[next_i][next_j] == '.'){
                push(next_i, next_j, v, d+1);
            }
        }

    }

    ll ans = INF;
    rep(v, 4){
        ans = min(ans, dist[toid(tx, ty, v)]);
    }

    if(ans == INF){
        cout << "-1"<<endl;
    }else{
        cout << mod_ceil(ans) / K <<endl;
    }




}

int main(){
    Main();
}

Measured memory_bytes: 43576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    string a,b; cin >> a >> b;
    int A = a.size(),B = b.size();
    if(A == B){
        if(a > b){
            cout << "GREATER" << endl;
        }else if(a < b){
            cout << "LESS" << endl;
        }
    }else{
        if(A < B){
            cout << "LESS" << endl;
        }else{
            cout << "GREATER" << endl;
        }
    }
    if(a == b){
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> A(N);for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end());
  
  vector<int> memo(N);
  //ijは, iから見たjのすがた(<i/2) ただし, j<=i
  
  int id=0;
  int M=0;
  for(int i=0;i<N-1;i++){
    //r,n-rの小さい方をtmpにする(左側のどこなのか)
    //rを変化させた時のtmpの最大値
    int tmp=min(A[i],A[N-1]-A[i]);
    if(tmp>M){id=i;M=tmp;}
    
    //cout<<tmp<<" "<<A[i]<<" "<<A[N-1]-A[i]<<" "<<id<<endl;
  }
  
  cout<<A[N-1]<<" "<<A[id];
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    vl parent;  //親ノード
    vl Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1LL) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {

        x = root(x);
        y = root(y);

        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};

int main() {
    ll n, m;
    cin >> n >> m;

    vl a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
    }

    UnionFind Uni(n);

    ll bridge = 0;
    rep(i, m) {
        Uni.init(n);
        rep(j, m) {
            if(j == i) {
                continue;
            }
            Uni.unite(a[j], b[j]);
        }
        if(Uni.size(0) != n) {
            bridge++;
        }
    }
    
    out(bridge);
    re0;
}

Measured memory_bytes: 256
n = list(map(int, list(input())))
k = int(input())
ln = len(n)

if ln < k:
    print(0)
    exit()

#comb(n,r) = nCr
def comb(n, r):
    m = 1
    for i in range(n-r+1, n+1):
        m *= i
    for i in range(1, r+1):
        m //= i
    return m

ans = 0

#ln-1桁以下を処理
if ln > k:
    ans += comb(ln-1, k) * (9 ** k)

#ln桁を処理
ans += comb(ln-1, k-1) * (9**(k-1)) * (n[0]-1)

if k == 1:
    ans += 1

elif k == 2:
    for i in range(1, ln):
        if n[i] != 0:
            ans += comb(ln-i-1, k-1) * (9**(k-1))
            ans += comb(ln-i-1, k-2) * (9**(k-2)) * (n[i]-1)
            ans += 1
            break

else:
    for i in range(1, ln):
        if n[i] != 0:
            ans += comb(ln-i-1, k-1) * (9**(k-1))
            ans += comb(ln-i-1, k-2) * (9**(k-2)) * (n[i]-1)
            for j in range(i+1, ln):
                if n[j] != 0:
                    ans += comb(ln-j-1, k-2) * (9**(k-2))
                    ans += comb(ln-j-1, k-3) * (9**(k-3)) * (n[j]-1)
                    ans += 1
                    break
            break

print(ans)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] s = Console.ReadLine().Split(' ');
		int A = int.Parse(s[0]);
		int B = int.Parse(s[1]);
		int c = 0;
		if(B>=A){
			c = A;
		} else {
			c = A-1;
		}
		Console.WriteLine(c);
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <limits.h>
#include <algorithm>
using namespace std;

int main(void){
    long long ai, ao, at, aj, al, as, az, b[3], ai_c, aj_c, al_c;
    long long ans = 0;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;
    
    ai_c = ai;  aj_c = aj;  al_c = al;
    
    ans += ao;
    
    b[0] = ai;  b[1] = aj;  b[2] = al;
    sort(b, b + 3);
    
    ans += b[0] * 3;
    ai -= b[0];  aj -= b[0];  al -= b[0];
    
    ans += (ai / 2) * 2;
    if (ai % 2 == 0) ai = 0; else ai = 1;
    
    ans += (aj / 2) * 2;
    if (aj % 2 == 0) aj = 0; else aj = 1;
    
    ans += (al / 2) * 2;
    if (al % 2 == 0) al = 0; else al = 1;
    
    if (ai == 1 && aj == 1) {
        if (ai_c > 2 && aj_c > 2) ans++;
    }
    else if (ai == 1 && al == 1) {
        if (ai_c > 2 && al_c > 2) ans++;
    }
    else if (aj == 1 && al == 1) {
        if (ai_c > 1) ans++;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1): B.extend([i]*bin[i-n_min])
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    # output
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

Measured memory_bytes: 105512
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
cin>>n;
ll a[n];
f(i,0,n)
cin>>a[i];
ll ma=0,x=0,i=0;
while(i<n-1)
{
   if(a[i]>=a[i+1])
        x++;
   else
   {   ma=max(ma,x);
       x=0;

   }
   i++;
}
 ma=max(ma,x);
c(ma);
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 1024
from statistics import median

n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
x = median(A)
y = median(B)

if n % 2 == 0:
    print(int((y - x) * 2 + 1))
else:
    print(y - x + 1)


Measured memory_bytes: 28864
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

long long N;

void func(long long cur, int use, long long &counter) {
	if (cur > N) return;
	if (use == 0b111) ++counter;

	func(cur * 10 + 7, use | 0b001, counter);
	func(cur * 10 + 5, use | 0b010, counter);
	func(cur * 10 + 3, use | 0b100, counter);
}

int main() {
	cin >> N;
	long long res = 0;
	func(0, 0, res);
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;
const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k, q;
//vector <i64> a;


i64 x;


vector<vector<i64>> books;

bool next_combination(vector<i64> & a, int n) {
    int k = (int)a.size();
    for (int i = k - 1; i >= 0; --i)
        if (a[i] < n - k + i + 1) {
            ++a[i];
            for (int j = i + 1; j<k; ++j)
                a[j] = a[j - 1] + 1;
            return true;
        }
    return false;
}

i64 price(vector<i64> &x) {
    i64 sum = 0;
    for (int i = 0; i <= x.size()-1; ++i) {
        sum += books[x[i]][0];
    }
    return sum;
}

bool check(vector<i64> &y) {
    for (int i = 1; i <= m; ++i) {
        i64 s = 0;
        for (int j = 0; j < y.size(); ++j) {
            s += books[y[j]][i];
        }
        if (s < x) {
            return false;
        }
    }
    return true;
}

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


    cin >> n >> m >> x;

    books.resize(n + 1, vector<i64>(m + 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            cin >> books[i][j];
        }
    }

    bool fl = true;
    for (int i = 1; i <= m; ++i) {
        i64 sum = 0;
        for (int j = 1; j <= n; ++j) {
            sum += books[j][i];
        }
        if (sum < x) {
            fl = false;
            break;
        }
    }


    if (!fl) {
        cout << -1 << endl;
    }

    else {
        i64 res = 0;
        for (int i = 1; i <= n; ++i) {
            res += books[i][0];
        }

        vector <i64>d = { 1 };
        i64 n0 = 1;
        for (int i = 1; i <= n; ) {
            if (check(d)) {
                i64 g = price(d);
                if (g < res) {
                    res = g;
                }
            }
            if (next_combination(d, n)) {
                continue;
            }
            else {
                i += 1;
                d.clear();
                for (int j = 1; j <= i;++j) {
                    d.push_back(j);
                }
            }

        }

        cout << res << endl;

    }


    return 0;
}

Measured memory_bytes: 3172
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000

using namespace std;
typedef long long ll;

int main(){
	int sum[2];
	sum[0]=sum[1]=0;
	for(int i=0;i<2;i++){
		for(int j=0;j<4;j++){
			int a;
			cin>>a;
			sum[i]+=a;
		}
	}
	cout<<max(sum[0],sum[1])<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
ll sum(ll x,ll b){
	ll add=0;
	while(x>=b){
		add+=x%b;
		x/=b;
	}
	return add+x;
}
int main(){
	ll n,s;
	scanf("%lld %lld",&n,&s);
	if(n==s){
		printf("%lld\n",n+1);
		exit(0);
	}
	for(ll i=2;i*i<=n;++i){
		if(sum(n,i)==s){
			printf("%lld\n",i);
			exit(0);
		}
	}
	for(ll i=(ll)sqrtl(n-s);i>=1;--i){
		if((n-s)%i==0 and sum(n,(n-s)/i+1)==s){
			printf("%lld\n",((n-s)/i+1));
			exit(0);
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[200009];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      cout<<"NO"<<endl;
      return(0);
    }
  }
  cout<<"YES"<<endl;
  return(0);
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab=sorted(ab)
ans = 0
for i in range(len(ab)):
    if m >= ab[i][1]:
        ans += ab[i][1]*ab[i][0]
        m -= ab[i][1]
    else:
        ans += m*ab[i][0]
        break
print(ans)

Measured memory_bytes: 28656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        for (int i = 0; i < String.valueOf(N).length(); i++) {
            int a = Integer.parseInt(String.valueOf(N).substring(i, i + 1));
            count += a;
        }
        System.out.println(N % count == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	int k;
	cin >> s;
	cin >> k;
	
	vector<string> x;
	for(int i = 0; i < s.size(); i++)
	{
		for(int j = 1; j <= 5; j++)
		{
			if(i + j - 1 < s.size())
			{
				x.push_back(s.substr(i, j));
			}
		}
	}
	sort(x.begin(), x.end());
	int tmp = 0;
	if(k == 1)
	{
		cout << x[0] << endl;
	}
	else
	{
		for(int i = 0; i < x.size(); i++)
		{
			if(i == x.size() - 1)
			{
				cout << x[i] << endl;
				return 0;
			}
			
			if(x[i] != x[i + 1])
			{
				tmp++;
			}
			
			if(tmp == k)
			{
				cout << x[i] << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1660
using DataStructures
parseline(str) = parse.(Int, split(str))
function ChartinaCircle()
    data = readlines()
    N = parse(Int, data[1])
    A = sort(parseline(data[2]), rev=true)
    res = sum([A[(n+1)÷2] for n in 1:N]) - A[1]
    return println(res)
end
ChartinaCircle()

Measured memory_bytes: 229140
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


// double c(double x)
// {
//   double X = x;
//   X = int(X) % 10;
//   return X;
// }

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i = 0;i < n;i++)
  {
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  int count = 1;
  int max = 1;
  vector<int> ans(n);
  ans[0] = count;
  for(int i = 1;i < n;i++)
  {
    if(s[i-1] == s[i])
    {
      count++;
      if(max < count)
      {
        max = count;
      }
    }
    else
    {
      count = 1;
    }
    ans[i] = count;
  }
  vector<string> S;
  for(int i = 0;i < n;i++)
  {
    if(ans[i] == max)
    {
      S.push_back(s[i]);
    }
  }
  sort(S.begin(),S.end());
  for(int i = 0;i < S.size();i++)
  {
    cout << S[i] << endl;
  }
}


Measured memory_bytes: 16756
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char campus[][] = new char[h][w];
        for (int i=0; i<h; i++){
            campus[i] = sc.next().toCharArray();
        }
        if (check(h, w, campus)){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }

    }

    private static boolean check(int h, int w, char[][] campus) {
        for (int i=0; i<h; i++){
            for (int j=0; j<w; j++){
                if (campus[i][j]=='#'){
                    if (i>0 && campus[i-1][j]=='#'){
                        continue;
                    }else if (j>0 && campus[i][j-1]=='#'){
                        continue;
                    }else if (i<h-1 && campus[i+1][j]=='#'){
                        continue;
                    }else if (j<w-1 && campus[i][j+1]=='#'){
                        continue;
                    }else {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int a = Integer.parseInt(scan.next());
	int b = Integer.parseInt(scan.next());
	int c = Integer.parseInt(scan.next());

	if(a > b) {
	    int tmp = b;
	    b = a;
	    a = tmp;
	}
	if(b > c) {
	    int tmp = c;
	    c = b;
	    b = tmp;
	}
	if(a > b) {
	    int tmp = b;
	    b = a;
	    a = tmp;
	}

	int count = (a == b ? 1 : 2);
	if(b != c) count++;

	System.out.println(count);
	scan.close();
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<stdio.h>
#include<vector>
#include<iomanip>

using namespace std;
int main(void) {
	int K, X;
	scanf("%d %d", &K, &X);
	int begin = X - (K - 1);
	int end	  = X + (K - 1);
	for (int i = begin; i <= end; i++) {
		printf("%d", i);
		if (i != end) printf(" ");
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=300003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;
        getline(cin,S);
        stack<char> ST;
        bool ok=true;
        if(S.size()==1&&S[0]=='.'){
            //cout<<"yes"<<endl;
            break;
        }
        
        for(int i=0;i<S.size();i++){
            if(S[i]=='('||S[i]=='['){
                ST.push(S[i]);
            }else if(S[i]==')'){
                if(ST.size()>=1&&ST.top()=='('){
                    ST.pop();
                }else ok=false;
            }else if(S[i]==']'){
                if(ST.size()>=1&&ST.top()=='['){
                    ST.pop();
                }else ok=false;
            }
        }
        
        if(ok&&ST.empty()) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}



Measured memory_bytes: 3196