akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
    int n ; cin >> n;
	int cnt = 0;
	rep(i,0,n){
		int a, b; cin >> a >> b;
		cnt += (a == b);
		if(cnt == 3){
			cout << "Yes" << endl;
			return 0;
		}
		if(a != b)cnt = 0;
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3612
def digit_sum(x): 
    y = str(x) 
    y_len = len(y) 
    ans = 0
    for j in range(y_len):
        ans += int(y[j]) 

    return ans

answer=0
n,a,b = map(int,input().split()) 
for i in range(1, n+1):
    if a<= digit_sum(i) <= b:
        answer+=i

print(answer)

Measured memory_bytes: 9164
/* ****Ragnar7**** */
/* It's Going to be Hard, but hard does not mean Impossible. */
#include<bits/stdc++.h>
#define ll          long long
#define hell        1000000007
using namespace std;

ll n;
ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
vector<ll> fact(100005,0);
ll factorial(ll x)
{
	if(x==0)
		return 1;
	if(x<0)
		return 0;
	return fact[x];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll k;cin>>n>>k;
	vector<ll> v(n+1,0);

	fact[0]=1;
	for(ll i=1;i<100005;i++)
		fact[i]=(fact[i-1]*i)%hell;
	for(ll i=1;i<=n;i++)
		cin>>v[i];
	sort(v.begin()+1, v.end());
	
	if(k==1)
	{
		cout<<"0";
		return 0;
	}
	vector<ll> dp(n+5,0);
	ll N,R;
	for(ll i=1;i<=n;i++)
	{
		N=i-1;
		R=k-1;
		ll x=(factorial(N)*expo(factorial(N-R),hell-2,hell))%hell;
		x=(x*expo(factorial(R),hell-2,hell))%hell;
		N=n-i;
		ll y=(factorial(N)*expo(factorial(N-R),hell-2,hell))%hell;
		y=(y*expo(factorial(R),hell-2,hell))%hell;
		dp[i]=x-y;
		//cout<<x<<" "<<y<<endl;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ans=(ans+(dp[i]*v[i])%hell)%hell;
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int n; cin >> n;
  map<long long int, int> m;
  int ans = 0;

  for(int i = 0;i < n;i++) {
    long long int a; cin >> a;

    if(m[a] == 0) { m[a]++; }
    else { m[a] = 0; }
  }

  for(map<long long int, int>::iterator it = m.begin();it != m.end();it++) { if(it->second > 0) { ans++; } }

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

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll k,n,t_sum=0,ans,kind=0,v;
  cin >> n >> k;
  ll t[n],d[n];
  vector<P> sushi;
  vector<ll> vals[n];
  priority_queue<ll,vector<ll>,greater<ll>> que;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> t[i] >> d[i];
    t[i]--;
    sushi.push_back(P(d[i],t[i]));
    vals[t[i]].push_back(d[i]);
  }
  sort(sushi.begin(),sushi.end(),greater<P>());
  if(k==1){
    cout <<sushi[0].first+1<<endl;
    return 0;
  }
  for(int i=0;i<k;i++){
    t_sum += sushi[i].first;
    mp[sushi[i].second]++;
  }
  kind = mp.size();
  ans = kind*kind+t_sum;
  for(int i=0;i<n;i++){
    if(vals[i].size()==0) continue;
    sort(vals[i].begin(),vals[i].end(),greater<ll>());
    if(mp.find(i)!=mp.end()){
      v = mp[i];
    }else{
      continue;
    }
    for(int j=1;j<v;j++){
      que.push(vals[i][j]);
    }
  }
  for(int i=k;i<n;i++){
    if(mp.find(sushi[i].second)==mp.end()){
      if(que.empty()){
        break;
      }
      t_sum -= que.top();
      que.pop();
      t_sum += sushi[i].first;
      mp[sushi[i].second]++;
      kind++;
      ans = max(ans,kind*kind+t_sum);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12400
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(vector<long long> a, vector<long long> b){
  vector<long long> c(4, 0);
  for (int i = 0; i < 3; i++) {
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  for (int i = 0; i < 4; i++) {
    if (c[i] >= 3) {
      std::cout << "NO" << std::endl;
      return;
    }
  }
  std::cout << "YES" << std::endl;
  return;
}

int main(){
  vector<long long> a(3);
  vector<long long> b(3);
  for(int i = 0 ; i < 3 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  solve(a, b);
  return 0;
}


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

int main()
{
	int n,t,mx;
	while(cin >> n, n)
	{
		mx = -(1<<30);
		int dt[5000]={0};
		for(int i=0; i<n; i++)
		{
			cin >> t;
			for(int j=0; j<=i; j++)
			{
				dt[j]+=t;
				mx=max(mx,dt[j]);
			}
		}
		cout << mx << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <string.h>
#include <vector>




int main() {
	int A,B,C,X,Y;

	scanf("%d %d %d %d %d", &A,&B,&C,&X,&Y);
	
	int sum = 0;
	int sum2 = 0;
	int sum3 = 0;

	sum = A * X + B * Y;

	if (X > Y) {
		int tmp = X;
		X = Y;
		Y = tmp;
		tmp = A;
		A = B;
		B = tmp;
	}
	
	sum2 = C * 2*X + B * (Y - X);

	sum3 = C * 2 * Y;




	printf("%d", std::min(sum, std::min(sum2, sum3)));

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int>v, w;
	rep(i, 0, N) {
		int a, b, c; cin >> a >> b >> c;
		int j(0);
		while (c) {
			int x = min(c,(1 << j++));
			c -= x;
			v.push_back(a*x);
			w.push_back(b*x);
		}
	}
	vector<int>dp(W + 1, 0);
	rep(i, 0, v.size())rrep(j, w[i], W + 1)
		chmax(dp[j], dp[j - w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3228
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val s = next()
    val t = s.dropWhile { it != 'A' }.dropLastWhile { it != 'Z' }
    println(t.length)
}

Measured memory_bytes: 36252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n);
  rep(i, n) {
    cin >> A[i];
    A[i]--;
  }
  set<int> st;
  int tmp = 0;
  while(1) {
    if(tmp == 1) {
      cout << st.size() << endk;
      return 0;
    }
    if(st.count(tmp)) {
      cout << -1 << endk;
      return 0;
    }
    st.insert(tmp);
    tmp = A[tmp];
  }
  return 0;
}


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

template <typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    const T e;
    const F f;
    size_t sz;
    vector<T> tree;

    SegmentTree(size_t n, const F &f, const T &e = 0) : f(f), e(e) {
        sz = 1;
        while(sz < n) sz <<= 1;
        tree.assign(2*sz, e);
    }

    void set(typename vector<T>::iterator begin, typename vector<T>::iterator end) {
        copy(begin, end, tree.begin() + sz);
        for(size_t k=sz-1; k>0; k--)
            tree[k] = f(tree[2*k+0], tree[2*k+1]);
    }

    void update(size_t k, const T &x) {
        k += sz;
        tree[k] = x;
        while(k >>= 1)
            tree[k] = f(tree[2*k+0], tree[2*k+1]);
    }

    T query(size_t a, size_t b) const {
        T l = e, r = e;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) l = f(l, tree[a++]);
            if(b & 1) r = f(tree[--b], r);
        }
        return f(l, r);
    }

    T operator[](const size_t k) const {
        return tree[sz + k];
    }
};

int main(void) {
    long n, k;
    cin >> n >> k;

    vector<long> a(n);
    for(auto &e: a) cin >> e, e -= k;

    vector<long> b(n+1);
    for(long i=1; i<=n; i++)
        b[i] = b[i-1] + a[i-1];

    vector<pair<long,long>> c(n+1);
    for(long i=0; i<=n; i++)
        c[i] = make_pair(b[i], i);
    sort(c.begin(), c.end());

    SegmentTree<long> st(n+1, [&](long a, long b){return a+b;}, 0);

    long r = 0;
    for(long i=0; i<=n; i++) {
        long cc = c[i].second;
        r += st.query(0, cc);
        st.update(cc, 1);
    }
    cout << r << endl;

}


Measured memory_bytes: 10624
class dsu():
    n=1
    parent_or_size=[-1 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.parent_or_size=[-1 for i in range(N)]
    def merge(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        x=self.leader(a)
        y=self.leader(b)
        if x==y:
            return x
        if (-self.parent_or_size[x]<-self.parent_or_size[y]):
            x,y=y,x
        self.parent_or_size[x]+=self.parent_or_size[y]
        self.parent_or_size[y]=x
        return x
    def same(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        return self.leader(a)==self.leader(b)
    def leader(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        if (self.parent_or_size[a]<0):
            return a
        self.parent_or_size[a]=self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]
    def size(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        return -self.parent_or_size[self.leader(a)]
    def groups(self):
        leader_buf=[0 for i in range(self.n)]
        group_size=[0 for i in range(self.n)]
        for i in range(self.n):
            leader_buf[i]=self.leader(i)
            group_size[leader_buf[i]]+=1
        result=[[] for i in range(self.n)]
        for i in range(self.n):
            result[leader_buf[i]].append(i)
        result2=[]
        for i in range(self.n):
            if len(result[i])>0:
                result2.append(result[i])
        return result2

N,Q=map(int,input().split())
G=dsu(N)
for i in range(Q):
    t,u,v=map(int,input().split())
    if t==0:
        G.merge(u,v)
    else:
        if G.same(u,v):
            print(1)
        else:
            print(0)


Measured memory_bytes: 11716
#include <iostream>
#include <vector>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <string>

int main(){
    using namespace std;
    int S, W;
    cin >> S >> W;


    if(W>=S) cout << "unsafe"<< endl;
    else cout << "safe"<< endl;


    return 0;
}

Measured memory_bytes: 3636
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

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


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

int n;
ll k;
vector<ll>A(N),F(N);

bool check(ll mid) {
	ll sum = 0;
	for(int i = 0; i < n; i++) {
		ll req =  mid / F[i];
		if(req < A[i])sum += (A[i] - req);
	}
	debug(mid,sum);
	if(sum <= k)return true;
	return false;
}

int32_t main(){
	fast;

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	cin >> n >> k;

	FOR(i,0,n-1)cin >> A[i];
	FOR(i,0,n-1)cin >> F[i];

	sort(A.begin(),A.begin()+n);
	sort(F.begin(),F.begin()+n,greater<int>());

	ll l = 0, r = 1e18;
	while(l != r) {
		ll m = (l + r)/2;
		if(check(m))r = m;
		else l = m + 1;
	}
	cout << l << "\n";

	time_p=clock()-time_p;
	cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

	return 0;
}

Measured memory_bytes: 3584
use std::io;

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let iter = buf.trim().split_whitespace();
    let mut nums: Vec<i32> = Vec::new();
    for i in iter {
        let num = i.parse::<i32>().unwrap();
        nums.push(num);
    }
    println!("{}", if (nums[1] - nums[2]) % 2 == 0 { "Alice" } else { "Borys" });
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>

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

using namespace std;

typedef long long ll;

int main(){
	static char s[100001]; gets(s);
	int n=strlen(s);

	static int freq[100001];
	int sum=0;
	rep(i,n){
		sum+=(s[i]=='('?1:-1);
		freq[sum]++;
	}

	ll ans=-1;
	sum=0;
	rep(i,n){
		ans+=freq[sum];
		sum+=(s[i]=='('?1:-1);
		freq[sum]--;
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+50;
int n,c[N],m,f[N];
struct node{
	int l,r;
	bool friend operator <(node a,node b){
		return a.r<b.r;
	}
}a[N];
void cmax(int &x,int y){y>x?x=y:0;}
void add(int x,int y){for(;x<=m;x+=x&-x)cmax(f[x],y);}
int ask(int x){int y=0;for(;x;x-=x&-x)cmax(y,f[x]);return y;}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y);
		a[i].l=c[i]=x-y;
		a[i].r=c[i+n]=x+y;
	}
	sort(c+1,c+n*2+1);m=unique(c+1,c+n*2+1)-c-1;
	for(int i=1;i<=n;i++)
		a[i].l=lower_bound(c+1,c+m+1,a[i].l)-c,
		a[i].r=lower_bound(c+1,c+m+1,a[i].r)-c;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		add(a[i].r,ask(a[i].l)+1);
	printf("%d\n",ask(m));
}

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


int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    rep(i,S.size()){
        int num = (int)S[i]-65;
        if(25-num < N){
            char c = 'A';
            int j = 1;
            while(j<N-(25-num)){
                c++;
                j++;
            }
            S[i] = c;
        }
        else{
            int j = 0;
            while(j<N){
                S[i]++;
                j++;
            }
        }
    }
    cout << S << endl;
  }

Measured memory_bytes: 256
import numpy as np
import math
N = int(input())
X_k = list(map(int , input().split(" ")))

P = float(sum(X_k)/N)
P_ceil = int(math.ceil(P))
P_floor= int(math.floor(P))

ceil_sum = 0
floor_sum = 0

for X in X_k:
    ceil_sum = ceil_sum + (P_ceil-X)*(P_ceil-X)
    floor_sum = floor_sum + (P_floor-X)*(P_floor-X)


if (ceil_sum-floor_sum > 0):
    print(floor_sum)
else:
    print(ceil_sum)

Measured memory_bytes: 12504
/*
Author : N_o_o_B
Created : April 22 2020 22:09:07 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n;
    cin >> n;
    ll ans[n+1];
    ans[0] = 2;ans[1]=1;
    rep(i,2,n) ans[i]=ans[i-1]+ans[i-2];
    cout << ans[n] << endl;


    time_taken();
    return 0;
}

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

int main(int argc, char** argv) {

	stack<int> S;
	int a, b;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		} else if (s[0] == '-') {
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		} else if (s[0] == '*') {
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a * b);		
		} else {
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;
	return 0;
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

int x[2],y[2],w[2],h[2];
int R;
vector<vvi> zimu;

void dfs(int i, int x, int y, vvi& used, vector<pair<int,int>>& list){

  priority_queue< pair<int,pii>, vector<pair<int,pii> >,greater<pair<int,pii> > > que;
  que.push(pair<int,pii>(1,pii(x,y)));

  int auth = 0;
  int room = 0;
  while(que.size()){
    int corr_lev = que.top().first;
    int corr_x = que.top().second.first;
    int corr_y = que.top().second.second;
    //cout << "POP (" << corr_x << "," << corr_y <<") " << corr_lev << endl; 
    que.pop();
    if( used[corr_y][corr_x] == 1) continue;
    used[corr_y][corr_x] = 1;
    
    if(corr_lev > auth){
      list.push_back(pii(room,auth));
      auth = corr_lev;
    }
    room++;
    if( room == w[i]*h[i] ) break;


    for(int j=0; j<4; j++){
      int nx = corr_x + dx[j];
      int ny = corr_y + dy[j];
      if(nx >= w[i] || nx < 0 || ny >= h[i] || ny < 0) continue; // ????£?
      if(used[ny][nx] == 1) continue; // ??¢?´¢??????
      que.push( pair<int,pii>(zimu[i][ny][nx],pii(nx,ny)) );
      //cout << "  PUSH (" << nx << "," << ny << ") " << zimu[i][ny][nx] << endl; 
    }
  }
  list.push_back(pii(room,auth));
}

int main(){
  while(1){
  
    cin >> R; if(!R) break;
    zimu.clear();
    
    // ??\???
    for(int i=0; i<2; i++){
      cin >> w[i] >> h[i] >> x[i] >> y[i];
  
      zimu.push_back(vvi(h[i],vi(w[i])));

      for(int j=0; j<h[i]; j++)
	for(int k=0; k<w[i]; k++)
	  cin >> zimu[i][j][k];
    }

    // 
    vector<vector<pair<int,int> > > list(2); // ???????????¨?±???°???????¨???¬??????
    
    for(int i=0; i<2; i++){
      list[i].push_back(pii(0,0));
      vvi used(h[i],vi(w[i],0));
      dfs(i, x[i]-1, y[i]-1, used, list[i]);
    }
    /*
    for(int i=0; i<2; i++){
      for(int j=0; j<list[i].size(); j++)
	cout << "(" << list[i][j].first << "," << list[i][j].second << "), ";
      cout << endl;
      }*/
    

    int ans = 1e+9;
    for(int i=0; i<list[0].size(); i++){
      int rooma = list[0][i].first;
      int autha = list[0][i].second;
      pii tmp = *lower_bound(list[1].begin(),list[1].end(), pii(R-rooma,0));
      int roomb = tmp.first;
      int authb = tmp.second;
      if(rooma + roomb < R) continue;
      ans = min(ans,autha + authb);
    }
    cout << ans << endl;

  }
}

Measured memory_bytes: 9288
#include<stdio.h>
#include<stdlib.h>
  
#define N 26
  
typedef struct node{
  int p;
  int l;
  int r;
}Tree;
  
int Height(int);
  
int n;
Tree T[N];
  
int main(){
  int i, j, id, l, r;
  int s[N], deg[N], dep[N], h[N];
  
  scanf("%d", &n);
   
  for(i = 0; i < n; i++){
    T[i].p =-1;
    T[i].l =-1;
    T[i].r =-1;
    s[i] =-1;
    deg[i] =0;
    dep[i] =0;
    h[i] =0;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d%d", &id, &l, &r);
  
    if(l!=-1){
      T[l].p = id;
      deg[id]++;
    }
  
    if(r!=-1){
      T[r].p = id;
      deg[id]++;
    }
  
    T[id].l = l;
    T[id].r = r;
    s[l] = r;
    s[r] = l;
  }
  
  for(i = 0; i < n; i++){
    j = i;
      
    while(T[j].p!=-1){
      j = T[j].p;
      dep[i]++;
    }  
  
    h[i] = Height(i);
  }
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
       , i, T[i].p,s [i], deg[i], dep[i], h[i]);
  
    if(T[i].p == -1){
      printf("root\n");
    }else if(T[i].l == -1 && T[i].r ==- 1){
      printf("leaf\n");
    }else{
      printf("internal node\n");
    }
  }
  return 0;
}
  
int Height(int i){
  int j, count=0, max=0;
  
  for(j = 0; j < n; j++){
    if(T[j].p == i){
      count=Height(j)+1;
  
      if(count > max){
    max = count;
      }
    }
  }
  
  return max;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 3005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll n;
pair<ll, ll> arr[N];
ll dp[N][N];
ll T;
ll recur(ll pos, ll curr) {

  if (curr > T) {
    return -inf;
  }
  if (pos == n + 1)
    return 0;

  ll &ans = dp[pos][curr];
  if (ans != -1)
    return ans;

  if (curr < T)
    ans = arr[pos].second;
  else
    ans = 0;

  ans = max(ans, recur(pos + 1, curr));

  ans = max(ans, arr[pos].second + recur(pos + 1, curr + arr[pos].first));

  return ans;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(dp, -1, sizeof(dp));
  cin >> n >> T;
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i].first >> arr[i].second;
  }
  sort(arr + 1, arr + n + 1);

  cout << recur(1, 0) << en;

  return 0;
}

/*
5
1 2 3 1 2
1
1 5
 */

Measured memory_bytes: 71040
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        int size = input.nextInt();
        int[] heap = new int[size+1];
        for (int i = 1; i < size+1; i++) {
            heap[i] = input.nextInt();
        }
        for (int i = 1; i < size+1; i++) {
            StringBuilder sb = new StringBuilder();
            sb.append("node ").append(i).append(": ");
            sb.append("key = ").append(heap[i]).append(", ");
            if (i/2 > 0) {
                sb.append("parent key = ").append(heap[i/2]).append(", ");
            }
            if (i*2 < size+1) {
                sb.append("left key = ").append(heap[i*2]).append(", ");
            }
            if (i*2+1 < size+1) {
                sb.append("right key = ").append(heap[i*2+1]).append(", ");
            }
            System.out.println(sb.toString());
        }
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

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

int main() {
    int a, b, c, d, e, k;
    std::cin >>  a;
    std::cin >>  b;
    std::cin >>  c;
    std::cin >>  d;
    std::cin >>  e;
    std::cin >>  k;
    
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  ll ans = 0;
  ll i;
  for(i = 1;  i*i<n; i++){
    ll m = (n-i)/i;
    if((n-i)%i == 0 && i<m)
      ans += m;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}


const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};







int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W; cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    
    bool seen[H][W];
    memset( seen, false, sizeof(seen) );
    
    int countsharp = 0;
    
    rep(i,H){
        rep(j,W){
            if(field[i][j]=='#') {
                seen[i][j] = true;
                countsharp++;
            }
        }
    }
    seen[0][0] = true;
    
    queue<pair<int, int>> que{};
    int dist[H][W];
    memset( dist, -1, sizeof(dist));
    
    que.push(make_pair(0, 0));
    dist[0][0] = 0;
    
    while(!que.empty()){
        
        
        int nowh = que.front().first;
        int noww = que.front().second;
        
        que.pop();
        
        
        
        
        for (int i = 0; i < 4; i++) {
            
            int newh = nowh + dx4[i];
            int neww = noww + dy4[i];
            if( !(0<=newh&&newh<H && 0<=neww&&neww<W) ) continue;
            if( seen[newh][neww] ) continue;
            
            que.push(make_pair(newh,neww));
            dist[newh][neww] = dist[nowh][noww] + 1;
            seen[newh][neww] = true;
        }
        
        
        
        
    }
    
    if(seen[H-1][W-1]){
        cout << H*W - countsharp - dist[H-1][W-1] - 1 << endl;
    }else{
        cout << -1 << endl;
    }
    
    
    
    
    
}



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

typedef long long int ll;
const int maxn = 1e5 + 10;
int a[maxn];
void solved(){
	int n,k;cin>>n>>k;
	for(int i = 1; i <= k ;i++){
		int d;cin>>d;
		for(int j = 1; j <= d; j++){
			int x;cin>>x;
			a[x]++;
		}
	} 
	int cnt = 0;
	for(int i = 1; i <= n; i++)if(a[i] == 0)cnt++;
	cout<<cnt<<endl;
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 3636
using System;

class program
{
    public static void Main()
    {
        var s = Console.ReadLine();
        s += s;

        var p = Console.ReadLine();

        if (s.IndexOf(p) >= 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

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

 int n,x,y;
 cin >> n >> x >> y;
 vector<int> ans(n,0);
 for(int i=1; i<=n; i++){
 	for(int j=i+1; j<=n; j++){
 		int dis;
 		if(j<=x) ans[j-i]++;
 		else if(i>=y) ans[j-i]++;
 		else if(i<=x && j>=y) ans[x-i+j-y+1]++;
 		else if(i>=x && y>=j) {
 			dis = min(j-i, y-x+1-j+i);
 			ans[dis]++;
 		} else if(i>=x && j>=y) {
 			dis = min(j-i, j-y+1+i-x);
 			ans[dis]++;
 		} else if(j>=x && x>=i){
 			dis = min(j-i, y-j+1+x-i);
 			ans[dis]++;
 		}
 	}
 }
 for(int i=1; i<n; i++){
 	cout << ans[i] << "\n";
 }

}


Measured memory_bytes: 256
import bisect


def main():
    A, B, Q = map(int, input().split())
    INF = 10 ** 18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for q in range(Q):
        x = int(input())
        b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
        res = INF
        for S in [s[b-1], s[b]]:
            for T in [t[d-1], t[d]]:
                d1 = abs(S-x) + abs(T-S)
                d2 = abs(T-x) + abs(S-T)
                res = min(res, d1, d2)
        print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12800
from math import factorial
def comb(n,r):
    return (factorial(n) // (factorial(r) * factorial(n-r))) % (10**9 + 7)

N = int(input())

if N <= 2:
    print(0)
    exit()

m = 2
ans = 1

while 3*m <= N:
    ans += comb(N - 2*m - 1, m - 1) 
    ans %= (10**9 + 7)
    m += 1
print(ans)

Measured memory_bytes: 73668
#include <iostream>
using namespace std;
 
int main(void){
 
  int n,sum,point;
 
  while(1){
 
    sum = 0;
 
    cin >> n;
 
    if( n == 0 ) break;
 
    for( int i = 0 ; i < n/4 ; i++ ){
 
      cin >> point;
 
      sum += point;
 
    }
 cout << sum << endl;
 
  }
 
 
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace  std;
int main()
{
	int test;
	string s;
	int count_ac=0, count_wa=0, count_tle=0, count_re=0;
	
	cin >> test;
	
	while(test--)
	{
		cin >> s;
		
		if(s=="AC")
		{
			count_ac++;
		}
		else if(s=="WA")
		{
			count_wa++;
		}
		else if(s=="TLE")
		{
			count_tle++;
		}
		else if(s=="RE")
		{
			count_re++;
		}
	}
	
	cout << "AC x " << count_ac << endl;
	cout << "WA x " << count_wa << endl;
	cout << "TLE x " << count_tle << endl;
	cout << "RE x " << count_re << endl;
	
return 0;
}

Measured memory_bytes: 3608
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[]num=new int[n];
        for(int i=0;i<n;i++){
            num[i]=sc.nextInt();
        }
        	
        Arrays.sort(num);
        int sum=1000000000;
        for(int i=0;i+m-1<n;i++){
            int nsum=0;
            nsum+=num[i+m-1]-num[i];
            sum=Math.min(sum,nsum);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 51180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<(x-z)/(y+z)<<endl;
}

Measured memory_bytes: 256
/*
今回は、vectorでなく、普通に配列使う。
[ヒープを表す配列A、ヒープのサイズ（要素数）をheap_sizeとすれば、A[1...heap_size]にヒープの要素が格納される。木の根はA[1]であり、節点の添え字iが与えられたとき、その親parent(i)、左の子left(i)、右の子right(i)は以下の式で算出される： ]
と、問題文に書いてあるので、添え字０は使わず、獲得する領域も１大きくする。


MAXヒープを最初から作るのではなく、すでにあるヒープ（順序立てられてはいない）
をMAXヒープに直すプログラム。
（最初から作るのであれば、もっと違うやり方がある。）

親と子を比較して、　親が小さかったら、子と交換
再帰で、子になった小さいやつをさらに下げるか見る感じ。

これを　for(i=heap_size/2; i>=1; i--)
でやることによって、maxHeapifyのlargest には、常にその部分木の最大の値が入る。
（maxHeapify内で、二つの子のうち大きいほうを上にあげるのが、（当たり前だが）肝）

*/

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;


void maxHeapify(int *&heap, int i, int heap_size){
	int l,r, largest;

	l=i*2;
	r=i*2+1;

	if(l <= heap_size && heap[l] > heap[i]) largest = l;
	else largest = i;

	if(r <= heap_size && heap[r] > heap[largest]) largest = r;

	if(largest!=i){
		swap(heap[i], heap[largest]);
		maxHeapify(heap, largest, heap_size);
	}

}

void buildMaxHeap(int *&heap, int heap_size){
	int i;

	for(i=heap_size/2; i>=1; i--) maxHeapify(heap, i, heap_size);
}


int main() {
	int i,j;
	int heap_size;

	//input
	// 標準入力をファイルに変更////////////////////////////////////////////////////////
    //FILE* fp_in = freopen("\\\\k1300\\k1300\\s1350010\\.windows\\Desktop\\input_data.txt", "r", stdin);
	/////////////////////////////////////////////////////////////////////////////////////

	cin >> heap_size;
	int *heap = new int[heap_size+1]; //[1...heap_size]まで使うので

	for(i=1;i<=heap_size;i++){ cin >> heap[i]; }

	buildMaxHeap(heap, heap_size);

	for(i=1;i<=heap_size;i++){ printf(" %d", heap[i]); }
	printf("\n");
	
	// ファイルを閉じる//////////////////////////////////////////////////////////////////
    //fclose(fp_in);
	/////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,i;
    string b="No" ;
    cin>>n;
    for(i=1;i<=9;i++){
        if(n%i==0&&n/i<=9)a=a+1;
    }
    if(a!=0)b="Yes";
    cout<<b;
    return 0;
}

Measured memory_bytes: 256
/* vim: set st=2 sts=2 :*/
#include <cstdio>
#include <algorithm>
using namespace std;

int m,n,b[500],r[500];
bool c[500][500],V[500];
int P[500];

bool match(int i){
  if(i<0) return true;
  for(int j=0;j<n;j++){
    if((!c[i][j])||V[j]) continue;
    V[j]=true;
    if(match(P[j])){
      P[j]=i;
      return true;
    }
  }
  return false;
}

int main(){
  while(scanf("%d%d",&m,&n),m|n){
    for(int i=0;i<m;i++) scanf("%d",b+i);
    for(int i=0;i<n;i++) scanf("%d",r+i);
    fill(P,P+n,-1);
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
        c[i][j]=(__gcd(b[i],r[j])>=2);
    int cnt=0;
    for(int i=0;i<m;i++){
      fill(V,V+n,false);
      if(match(i)) ++cnt;
    }
    printf("%d\n",cnt);
  }
}

Measured memory_bytes: 1012
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

import math
def comb(n, r):
    if n<0 or r<0 or n<r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def comod(n,r):
    return comb(n,r)%mod

n,k=MI()
ans=[0 for i in range(k)]
b=k
r=n-k
for i in range(1,k+1):
    #ans[i-1]=2*comod(b-1,i-1)*comod(r-1,i-1)+comod(b-1,i-1)*comod(r-1,i)+comod(b-1,i-1)*comod(r-1,i-2)
    ans[i-1]=comod(n-k+1,i)*comod(k-1,i-1)

#print(ans)
for a in ans:
    print(a%mod)


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

#define int long long

main()
{
  int n, a, b;
  int h[100005];
  int nh[100005];
  
  int l = 0, r = 1LL << 32;
  
  cin >> n >> a >> b;

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

  //多分rのほうにくる
  while(l + 1 < r) {
    int m = (l + r) / 2;
    int cnt = 0;
    int val = a - b;
    
    for(int i = 0; i < n; i++) {
      nh[i] = h[i] - (m * b);
    }
    
    for(int i = 0; i < n; i++) {
      if(nh[i] > 0) cnt += (nh[i] + val - 1) / val;
    }

    if(cnt <= m) r = m;
    else l = m;
    
  }

  cout << r << endl;

  return (0);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] H, W;
        int i, j, k, count;

        H = new int[10000];
        W = new int[10000];

        i=0;
        while(true){
            if(i == 10000){break;}

            H[i] = sc.nextInt();
            W[i] = sc.nextInt();

            if(H[i] == 0 && W[i] == 0){break;}
            i++;
        }
        count = i;

        for(k=0;k<count;k++){

            for(j=0;j<W[k];j++){
                System.out.print("#");
            }

            System.out.println();

            for(i=1;i<H[k]-1;i++){

                System.out.print("#");
                for(j=1;j<W[k]-1;j++){
                    System.out.print(".");
                }
                System.out.print("#");
                System.out.println();

            }

            for(j=0;j<W[k];j++){
                System.out.print("#");
            }

            System.out.println();
            System.out.println();
        }
    }

}



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

using namespace std;

int main() {
  int N, M, C;
  vector<int> B;
  
  cin >> N >> M >> C;
  
  for (int i = 0; i < M; i++) {
    int in;
    
    cin >> in;
    
    B.push_back(in);
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    int sum = 0;
    
    for (int j = 0; j < M; j++) {
      int in;
      
      cin >> in;
      
      sum += in * B[j];
    }
    
    sum += C;
    
    if (sum > 0) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = arr[0];
            var m = arr[1];
            var l = arr[2];

            arr.Select(e => e.ToString());

            var res = new long[n][];
            for(var i = 0; i < res.Length; ++i)
            {
                res[i] = new long[l];
            }

            var a = Enumerable.Range(0, n).Select(e => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()).ToArray();
            var b = Enumerable.Range(0, m).Select(e => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()).ToArray();

            for(var i = 0; i < n; ++i)
            {
                for(var k = 0; k < l; ++k)
                {
                    for(var p = 0; p < m; ++p)
                    {
                        res[i][k] += a[i][p] * b[p][k];
                    }
                }
            }

            Console.WriteLine(string.Join("\n", res.Select(e => string.Join(" ", e))));
        }

        /*private static bool IsInput(out int[] arr)
        {
            var s = Console.ReadLine();
            if (s == "0 0") { arr = null; return false; }

            arr = s.Split(' ').Select(int.Parse).ToArray();
            return true;
        }
        // */
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;


int main() {

	ll n, a, b;
	cin >> n >> a >> b;

  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans  = 0;
  REP(i, 1, n){
    ans += min((x[i] - x[i - 1]) * a, b);
  }

  cout << ans << endl;

	return 0;

}

Measured memory_bytes: 1024
import numpy as np

K,N=list(map(int, input().split()))
a = np.array(list(map(int, input().split())))
diff_a=np.diff(a,n=1)
max_index=np.argmax(diff_a)
temp_max=diff_a[max_index]
last_first=K-(a[-1]-a[0])
if temp_max>last_first:
  print(int(K-temp_max))
else:
  print(int(K-last_first))

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

bool check(int n, vector<int> &b, int &N){
  for(int i=0; i<N; i++){
    if(b.at(i) == n) return true;
  }
  return false;
}

int main(){
  vector<vector<int>> A(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> A.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  vector<int> b(N);
  for(int i=0; i<N; i++){
    cin >> b.at(i); 
  }

  vector<int> ans(8);
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(check(A.at(i).at(j), b, N)){
        ans.at(i) += 1;
        ans.at(j+3) += 1;
        if(i==j) ans.at(6)+=1;
        if((i==2&&j==0)||(i==0&&j==2)||(i==1&&j==1)) ans.at(7)+=1;
      } 
    }
  }

  string a="No";
  for(int i=0; i<8; i++){
    if(ans.at(i)==3) a="Yes";
  }

  cout << a;
  
}

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

const int MAX_N = 300000;

int main() {
    int n;
    cin >> n;
    ll d[n];
    for (int i = 0; i < n; i++) cin >> d[i];
    ll md = 0;
    for (int i = 0; i < n; i++) {
        if (i <= md) md = max(md, i + (d[i] / 10));
    }
    if (md < n - 1) {
        cout << "no" << endl;
        return 0;
    }
    md = n - 1;
    for (int i = n - 1; i >= 0; i--) {
        if (md <= i) md = min(md, i - (d[i] / 10));
    }
    if (md > 0) cout << "no" << endl;
    else cout << "yes" << endl;
}


Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<int>a(A);
  vector<int>b(B);
  vector<int>x(M);
  vector<int>y(M);
  vector<int>c(M);
  for(int i=0;i<A;i++){
    cin>>a[i];
  }
  for(int i=0;i<B;i++){
    cin>>b[i];
  }
  for(int i=0;i<M;i++){
    cin>>x[i];
    cin>>y[i];
    cin>>c[i];
  }
  int cnt=0;
  int ans=0;
  for(int i=0;i<M;i++){
    cnt=0;
    cnt=a[x[i]-1]+b[y[i]-1]-c[i];
    if(i==0){
      ans=cnt;
    }
    if(i>0){
      if(cnt<ans){
        ans=cnt;
      }
    }
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(ans>a[0]+b[0]){
    ans=a[0]+b[0];
  }   
  cout<<ans<<endl;
}

Measured memory_bytes: 5060
//
// Created by Akifumi Ohata on 2017/09/29.
//

#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>

using namespace std;

int main(){

    int N;



    cin >> N ;

    std::vector<int> arrays(static_cast<unsigned long>(N), 0);

    for(int i=0;i<N;i++){

        cin >> arrays[i];

    }

    int sum = std::accumulate(arrays.begin(), arrays.end(), 0);

    double div=N;
    int avarage= static_cast<int>(std::lround(sum/div));

    //cout << avarage<< endl;
    std::vector<int> cost_array;

    for(const int a : arrays){

        int dis=(a-avarage);
        cost_array.push_back(dis*dis);
    }

    int costsum = std::accumulate(cost_array.begin(), cost_array.end(), 0);

    cout << costsum <<endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(m)]

PY.sort(key=lambda x: (x[0], x[1]))

prefec = 0
cnt = 1
for py in PY:
    if py[0] != prefec:
        prefec = py[0]
        cnt = 1
    py.append(cnt)
    cnt += 1

PY.sort(key=lambda x: x[2])

for py in PY:
    print('{0:06d}{1:06d}'.format(py[0], py[3]))


Measured memory_bytes: 35840
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

using P = pair<int, int>;
const int INF = 1e9;
const int NX[4] = {-1, 1, 0, 0};
const int NY[4] = {0, 0, -1, 1};

inline void Main() {
  // code
  int n, m;
  cin >> n >> m;
  vector<P> ab(m);
  rep(i, m) cin >> ab.at(i).second >> ab.at(i).first;
  sort(all(ab));

  P x, y;
  int res = 1;

  x = ab.at(0);

  repi(i, 1, m) {
    y = ab.at(i);
    if(x.first<=y.second) {
      res++;
      x = y;
    }
  }

  cout << res << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. 169A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 A          PIC 9(03).
01 B          PIC 9(03).
01 OUT        PIC*>
 ZZZZ9.
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B.
*>
  COMPUTE OUT = A * B.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3864