akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ss second
#define ff first
#define mit map<ll,ll>::iterator
#define it(x,type) x<type>::iterator
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define printf __mingw_printf
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vec2d(nam,type,row,col,fix) vector<vector<type>> nam(row,vector<type>(col,fix))
#define vec4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
int main()
{
     io;
    //string hudai(1000000,'a');
    int T=1;
   // cin>>T;
     for(int cas=1;cas<=T;cas++)
    {
       ll h,w;
       cin>>h>>w;
       vector<string> v(h);
       for(int i=0;i<h;i++)
        cin>>v[i];
       vec2d(dp,ll,h+1,w+1,0);
       dp[0][1]=1;
       for(ll i=1;i<=h;i++)
       {
           for(ll j=1;j<=w;j++)
           {
               if(v[i-1][j-1]=='.')dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
           }
       }
       cout<<dp[h][w];

    }
    return 0;
}


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

int g[10][10];
int ans;
int v[10];
int N,M;
void dfs(int start,int score){
	if(N==score)ans++;
	for(int i=0;i<N;i++){
		if(g[start][i] && !v[i]){
			v[i]=1;
			dfs(i,score+1);
			v[i]=0;
		}
	}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a][b]=1;
		g[b][a]=1;
	}
	v[0] = 1;
	dfs(0,1);
	v[0] = 0;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <cctype>
using namespace std;
#define swap(x,y) int (temp)=int (x);(x)=int (y);(y)=(temp);
#define swapS(x,y) string (tukar)=x;x=y;y=tukar;
#define swapC(x,y) char (pindah)=x;x=y;y=pindah;
#define ll long long
#define S string
#define len(a)	string (a).length()
#define arn 100000
#define forn(a,b) for(int (a)=1;a<=int (b);a++)
#define for3(a,b,c) for(int (a)=int (b); a<=int(c);a++)
int gcd(int a, int b) {
    return (a == 0 ? b : gcd(b % a, a));
}
int lcm(int a, int b)
{
    int temp = gcd(a, b);

    return ((a*b)/temp);
}
int main()
{
	long long total;
	int n,m;
	int x,y;
	int max=0;
	string s[10000],t[10000];
	cin>>n;
	for(x=1;x<=n;x++)
	{
		cin>>s[x];
	}
	cin>>m;
	for(x=1;x<=m;x++)
	{
		cin>>t[x];
	}
	y=1;
	while(y!=n+1)
	{
	total=0;
	for(x=1;x<=n+m;x++)
	{
		if(s[y]==s[x])
		{
			total++;
		}
		if(s[y]==t[x])
		{
			total--;
		}
	
	}
		if(total>max)
		{
			max=total;
		}
	y++;
	}
	cout<<max<<endl;
	return 0;
}

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

ll count_mon=1;
ll hp_mon;
ll count_attack=0;

int main(){
	cin>>hp_mon;

	while(hp_mon){
		count_attack*=2;
		count_attack++;
		hp_mon/=2;
			}

	cout<<count_attack<<endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long

int main() {
    
    ll n ;
    cin >> n;
    map<string,ll> mp;
    for(ll i=0;i<n;i++){
        char s[10];
        string t="";
        for(ll j=0;j<10;j++){
            cin >> s[j];
        }
        sort(s,s+10);
        for(ll j=0;j<10;j++) t+=s[j];
        if(mp.find(t)==mp.end()) mp[t]=1;
        else mp[t]++;
    }
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        ans+=(itr->second)*(itr->second-1)/2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int N,K;
	scanf("%d %d",&N,&K);
	int *matrix=malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){
		scanf("%d",&matrix[i]);
	}
	int cursor=0;
	for(int i=0;i<K;i++){
		cursor+=matrix[i];
	}
	int max=cursor;
	int max_point=K-1;
	for(int j=K;j<N;j++){
		int next=cursor-matrix[j-K]+matrix[j];
		if(next>max){
			max=next;
			max_point=j;
		}
		cursor=next;
	}
	double sum;
	for(int i=0;i<K;i++){
		sum+=(1+matrix[max_point-i])/2.0;
	}
	printf("%lf",sum);
	return 0;
}





Measured memory_bytes: 896
#include <bits/stdc++.h>
#define x first
#define y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
 
ll po(ll a, ll n) {
    if (!n) return 1;
    ll t = po(a,n/2);
    return t*t%MOD*(n%2?a:1)%MOD;
}
 
int n;
int D[4010][4010];
int A[200100], B[200100];
ll fac[8030], fnv[8030];
int bias = 2005;
 
ll comb (ll n, ll r) {return fac[n]*fnv[r]%MOD*fnv[n-r]%MOD;}
 
int main() {
    int i, j;
 
    scanf("%d",&n);
    for (i=0;i<n;i++) {
        scanf("%d%d",&A[i],&B[i]);
        D[bias-A[i]][bias-B[i]]++;
    }
    fac[0] = 1;
    for (i=1;i<bias*4;i++) fac[i]=fac[i-1]*i%MOD;
    for (i=0;i<bias*4;i++) fnv[i]=po(fac[i],MOD-2);
    for (i=1;i<bias*2;i++) for (j=1;j<bias*2;j++) D[i][j] = ((D[i-1][j]+D[i][j-1])%MOD+D[i][j])%MOD;
    ll sum = 0;
    for (i=0;i<n;i++) sum = (sum+D[bias+A[i]][bias+B[i]])%MOD;
    for (i=0;i<n;i++) sum = (sum-comb(2*(A[i]+B[i]),2*A[i]))%MOD;
    sum = sum*(MOD+1)/2%MOD;
    printf("%lld\n",(sum+MOD)%MOD);
 
    return 0;
}

Measured memory_bytes: 64768
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> f(n+1,0);
    f[0]=1;
    f[1]=1;

    for (int i = 2; i < n+1; i++)
    {
        f[i]=f[i-1]+f[i-2];
    }
    cout<<f[n]<<endl;

    return 0;
}



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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define reunique(a) (a).resize(unique(all(a)) - (a).begin())
#define ld long double
#define int long long
const int mod = (int)1e9 + 7;

int binpow(int a, int b){
    int ret = 1;
    while (b){
        if (b & 1){
            ret *= a;
            ret %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}

int mul(int x, int y){
    return (x * y) % mod;
}
int add(int x, int y){
    return (x + y) % mod;
}
int sub(int x, int y){
    return (x - y + mod) % mod;
}

int inv(int x){
    int ret = binpow(x, mod - 2);
    return ret;
}

void SOLVE(){
    int n, a, b;
    cin >> n >> a >> b;
    int t1 = 1;

    int rem = 1;
    for (int i = n - a + 1, j = 1; i <= n; i++, j++){
        t1 = mul(t1, i);
        rem = mul(rem, j);
    }
    t1 = mul(t1, inv(rem));

    rem = 1;
    int t2 = 1;
    for (int i = n - b + 1, j = 1; i <= n; i++, j++){
        t2 = mul(t2, i);
        rem = mul(rem, j);
    }
    t2 = mul(t2, inv(rem));

    int ans = binpow(2, n);
    ans = sub(ans, 1);

    ans = sub(ans, t1);
    ans = sub(ans, t2);

    cout << ans << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}


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

struct guide {
    int id;
    string name;
    int point;
};

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

    int N, L;
    cin >> N >> L;

    int sum = (L - 1) * N + (N + 1) * N / 2;

    if (L > 0 && (L + N - 1) > 0) {
        cout << sum - L << '\n';
    } else if (L < 0 && (L + N - 1) < 0) {
        cout << sum - (L + N - 1) << '\n';
    } else {
        cout << sum << '\n';
    }

    return 0;
}


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

long long pw[20];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	pw[0] = 1;
	for (int i = 1; i < 20; i++) pw[i] = pw[i - 1] * 10;
	
	int K; cin >> K;
	long long now = 0;
	while (K--) {
		now++;
		auto nxt = now, nxt_sum = 0LL;
		{
			auto buf = now;
			while (buf) nxt_sum += buf % 10, buf /= 10;
		}
		for (int i = 1; i < 18; i++) if (now >= pw[i]) {
			auto cur = now / pw[i] * pw[i] + pw[i] - 1;
			auto sum = 0LL, buf = cur;
			while (buf) sum += buf % 10, buf /= 10;
			if ((long long)cur * nxt_sum < (long long)nxt * sum) {
				nxt = cur, nxt_sum = sum;
			}
		}
		now = nxt;
		cout << now << "\n";
	}
	
	return 0;
}


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

int main() {

    int N,cnt=1,tmp;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; i++) { cin >> A.at(i); }
  tmp=A[0];
    for (int i = 1; i < N; i++) { if(tmp>=A[i]){cnt++;tmp=A[i]; }}

    cout<<cnt<<endl;
}
    


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int N = cin.Int();
			int C = cin.Int();
			var st = new Tuple<int, int>[N];
			int[] c = new int[N];
			for (int i = 0; i < N; i++) {
				int s = cin.Int();
				int t = cin.Int();
				int ct = cin.Int();
				st[i] = new Tuple<int, int>(s, t);
				c[i] = ct - 1;
			}

			int m = 2 * 100000 + 1;
			int[] nums = new int[m];
			int[] temp = new int[m];
			for (int i = 0; i < C; i++) {
				for (int j = 0; j < m; j++) {
					temp[j] = 0;
				}

				for (int j = 0; j < N; j++) {
					if (c[j] == i) {
						temp[st[j].Item1 * 2 - 1]++;
						temp[st[j].Item2 * 2]--;
					}
				}

				for (int j = 1; j < m; j++) {
					temp[j] += temp[j - 1];
				}

				for (int j = 0; j < m; j++) {
					if (temp[j] > 0) {
						nums[j]++;
					}
				}
			}

			int ans = nums.Max();
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 22084
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

ll N;

ll calc(ll x){
  if(x > N) return 0;
  ll ans = 0;
  bool has3 = false;
  bool has5 = false;
  bool has7 = false;
  ll x_org = x;
  while(x > 0){
    if(x%10 == 3) has3 = true;
    else if(x%10 == 5) has5 = true;
    else if(x%10 == 7) has7 = true;
    else return 0;
    x/=10;
  }
  if(has3 && has5 && has7) ans++;
  ll cnd[3] = {3, 5, 7};
  for(int i = 0; i < 3; i++){
    ans += calc(x_org * 10 + cnd[i]);
  }
  return ans;
}


int main(){
  cin >> N;

  cout << calc(0) << endl;

  return 0;
}


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

vector<int> d;
bool ok(int i){
	while(i>0){
		if(find(d.begin(),d.end(),i%10)!=d.end()) return false;
		i/=10;
	}
	return true;
}

int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<k;i++) {
		int x;
		cin >> x;
		d.push_back(x);
	}
	int ans;
	for(int i=n;i<=10*n;i++) if(ok(i)){ans=i;break;}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7,MAX=1e6;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
typedef struct{int SPF[1000001],Primes[168],sz;}Template;
Template P;
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}if(x*x>MAX)break;
    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}
  }
}
const char common[]="not coprime",disjoint[]="pairwise coprime",partial[]="setwise coprime";
int vol=0,esc[100][2];
static inline int Divise(int x)
{
  if(!x)return 0;
  rep(i,168)
  {
    if(x%P.Primes[i])continue;
    rep(j,vol){if(esc[j][0]==P.Primes[i]&&esc[j][1])return 0;}
    esc[vol][0]=P.Primes[i],esc[vol++][1]=1;
    while(x%P.Primes[i]==0){x/=P.Primes[i];}
  }
  if(x!=1)
  {
    rep(j,vol){if(esc[j][0]==x&&esc[j][1])return 0;}
    esc[vol][0]=x,esc[vol++][1]=1;
    return 1;
  }
  return 1;
}
int main(void)
{
  int N=IN(),A=0,g=0,flag=0;
  ready();
  rep(i,N){A=IN();g=GCD(g,A);if(!Divise(A)){flag=1;}}
  if(g>1)return puts(common),0;
  if(flag)return puts(partial),0;
  return puts(disjoint),0;
}

Measured memory_bytes: 5416
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}


signed main()
{
    Start();
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({b * c * (a % 2), a * c * (b % 2), a * b * (c % 2)});
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = nab[0];
            int a = nab[1];
            int b = nab[2];
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                int t = int.Parse(Console.ReadLine());
                if (t < a || b <= t) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 2776
import java.util.Scanner;

/**
 * https://abc058.contest.atcoder.jp/tasks/arc071_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] s = new int[26][N];
		for(int i = 0; i<N; i++){
			for(char c: sc.next().toCharArray()){
				s[c-'a'][i]++;
			}
		}
		sc.close();
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<26; i++){
			char target = (char)('a'+i);
			int min = Integer.MAX_VALUE;
			for(int j=0; j<N; j++){
				min = Math.min(min, s[i][j]);
			}
			for(int j=0; j<min; j++){
				ans.append(target);
			}
		}
 
		System.out.println(ans.toString());
		
	}

}

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

int64_t MOD = 998244353;

int64_t N_MAX = 3010;

int64_t dp[3010][3010];

//modの割り算
// a/bをa*modint(b,MOD) %MODに変換
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

//繰り返し二乗法
int64_t powmod(int64_t x, int64_t n) { 
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= MOD;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= MOD;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans;
}

int main(){
  int64_t N, S;
  cin >> N >> S;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  for(int i=0; i<N; i++){
    int64_t x = vec[i];
    dp[i+1][x] = powmod(2,N-1);
    for(int j=0; j<N_MAX; j++){
      dp[i+1][j] += dp[i][j]; //加えない
      if(j + x < N_MAX){ //加える
        int64_t y = dp[i][j];
        y %= MOD;
        y = y*modinv((int64_t)2,MOD) %MOD;
        dp[i+1][j+x] += y;
        dp[i+1][j+x] %= MOD;
      }
      dp[i+1][j] %= MOD;
    }
  }
  cout << (dp[N][S]) %MOD << endl;
}

Measured memory_bytes: 74144
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

int main() {
    int K;
    cin >> K;
    int res = 0;
    int Mod = 0;
    int Max = 10000000;
    while (Max--) {
        Mod = (10 * Mod + 7) % K;
        ++res;
        if (Mod == 0) {
            cout << res << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    cout << S[i] << flush;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

vector<vector<int>> dp1(1005,vector<int>(1005,1));
vector<vector<int>> dp2(1005,vector<int>(1005,0));

bool solve() {
	int a,b,c; cin >> a >> b >> c;
  	cout << a + b + c - max({a,b,c}) << endl;
}

signed main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 16128
MOD=10**9+7
p=100009
fact=[0]*p 
fact[0]=1 
for i in range(1,p):
    fact[i]=(fact[i-1]*i)%MOD
def MI(a,MOD):
    return pow(a,MOD-2,MOD)
def nck(n, k,MOD):
    if k<0:
        return 0 
    if n==k or k==0:
        return 1 
    if n<k:
        return 0 
    return (fact[n]*MI(fact[k],MOD)%MOD*MI(fact[n-k],MOD)%MOD)%MOD

n=int(input())
l=[int(i) for i in input().split()]
from collections import Counter
c=Counter(l)
for i  in c:
    if c[i]>=2:
        ans=i 
        break 
ind1=-1 
ind2=-1 
for i in range(n+1):
    if l[i]==ans:
        if ind1==-1:
            ind1= i 
        else: 
            ind2=i 
MOD=10**9+7 
for i in range(1,n+2):
    a=nck(n+1,i,MOD)
    b=nck(n-(ind2-ind1),i-1,MOD)
    print((a-b+MOD)%MOD)

Measured memory_bytes: 65512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int lim[100009],n,m,c,sum,cnt[100009],X;
int main(){
  cin>>n>>m>>c;
  priority_queue<P>q;
  for(int i=0;i<c;i++)scanf("%d",&lim[i]);
  for(int i=0;i<n;i++){
    int a1,a2;
    scanf("%d%d",&a1,&a2); a1--;
    q.push(P(a2,a1));
  }
  while(!q.empty()){
    P p=q.top();q.pop();
    if(lim[p.second]==cnt[p.second])continue;
    sum+=p.first;
    cnt[p.second]++;
    if(++X==m)break;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 4548
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s.at(k-1) = tolower(s.at(k - 1));
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

	int n, k;
	scanf("%d %d", &n, &k);

	int count = 0;
	double num = (double) n;

	while(num >= 1){
		num = num / (double)k;
		count++;
	}

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

	return 0;


}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop();

int sum[1000];
int top;

int main(){
  int x;
  int top=0;
  int po1,po2;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      po1=pop();
      po2=pop();
      push(po1+po2);
    }
    else if ( s[0] == '-' ){
      po2=pop();
      po1=pop();
      push(po1-po2);
    }
    else if ( s[0] == '*' ){
      po1=pop();
      po2=pop();
      push(po1*po2);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  top++;
  sum[top]=x;
}

int pop(){
  top--;
  return sum[top+1];
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( A + B > C + D ) {
    cout << "Left" << endl;
  } else if ( A + B < C + D ) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


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

int main()
{

  int N, M;
  vector<int> A;
  cin >> N;
  cin >> M;
  int selected_items = 0;

  int vote = 0;
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> vote;
    sum += vote;
    A.push_back(vote);
  }

  double condition = (1.0 / (4 * M)) * sum;

  for (int i = 0; i < N; i++)
  {
    if (A[i] >= condition)
    {
      selected_items++;
    }
  }

  if (selected_items >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    pas = [-1 for _ in range(N)]
    pas[S] = 's'
    frag = set([S])
    que = deque([S])

    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:
            if i in frag:  # 処理済みか否か
                continue
            pas[i]=q
            que.append(i)
            frag.add(i)
    return pas


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

near = [[] for _ in range(n)]
for a, b in ab:
    near[a - 1].append(b - 1)
    near[b - 1].append(a - 1)
pas = bfs(near, 0, n)

if all(pas[i] != -1 for i in range(n)):
    print('Yes')
    for i in range(1, n):
        print(pas[i] + 1)
else:
    print('No')


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main() {
    int n;
    cin>>n;
    int mod=pow(10,9)+7;
    map<int,int> d;
    vector<int> l;
    rep(i,n+1){
        if (IsPrime(i)){
            d[i]=0;
            append(l,i);
        }
    }
    int num;
    for (int x:l){
        num=x;
        while (num<=n){
            d[x]+=n/num;
            num*=x;
        }
    }
    long ans=1;
    for (int x:l){
        ans*=d[x]+1;
        ans%=mod;
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
def main():
    import heapq
    n,m=map(int,input().split())
    a=sorted(list(map(int, input().split())))
    bc=[list(map(int, input().split())) for _ in range(m)]
    bc.sort(key=lambda x:-x[1])
    heapq.heapify(a)
    for b,c in bc:
      for j in range(b):
        amin=heapq.heappop(a)
        if amin<c:
          heapq.heappush(a,c)
        else:
          heapq.heappush(a,amin)
          break
    print(sum(a))
main()

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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];

void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int n, x, y;
map<int, int> m;
vector<int> v[MAXN];
int dis[MAXN];
bool vis[MAXN];

void bfs(int x) {
    queue<int> q;
    q.push(x);
    dis[x] = 0;
    vis[x] = 1;
    while (!q.empty()) {
        int top = q.front();
        q.pop();
        for (int i = 0; i < v[top].size(); i++) {
            if (!vis[v[top][i]]) {
                vis[v[top][i]] = 1;
                dis[v[top][i]] = dis[top] + 1;
                m[dis[v[top][i]]]++;
                q.push(v[top][i]);
            }
        }
    }
}


int main() {
    FAST

    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        v[i].push_back(i + 1);
        v[i + 1].push_back(i);
    }
    v[x].push_back(y);
    v[y].push_back(x);
for(int i=1;i<=n;i++)
{
    memset(vis,0, sizeof(vis));
    memset(dis,-1, sizeof(dis));
    bfs(i);
}
for(int i=1;i<n;i++)
{
    cout<<m[i]/2<<endl;
}
    return 0;
}

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

using namespace std;

const long long MOD = 1000000000 + 7;
const string abc = "abacaba";

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // int t;
    // cin >> t;
    // for (int tt = 0; tt < t; tt++) {
        solve();
    // }
    return 0;
}

Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// input
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int L = A + B;
		int R = C + D;

		if(L>R){
			System.out.println("Left");
		}else if (L == R){
			System.out.println("Balanced");
		}else{
			System.out.print("Right");
		}
	}
}



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

using namespace std;

int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> c(N), t(N);
    for (int i = 0; i < N; i++){
        cin >> c.at(i) >> t.at(i);
    }

    vector<int> ansc(N);
    
    for (int i = 0; i < N; i++){
        if (t.at(i) <= T){
            ansc.push_back(c.at(i));
        }
    }
    bool check = false;
    for (int c: ansc){
        if (c > 0){
            check = true;
            break;
        }
    }
    
    if (check){
        sort(ansc.begin(), ansc.end());
        ansc.erase(remove(ansc.begin(), ansc.end(), 0));
        cout << ansc.front() << endl;
    }else{
        cout << "TLE" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int LEN = 10001;
const double EPS = 1e-8;

main(){
  int N, K, T, U, V, L;
  bool D[LEN];
  fill(D, D+LEN, false);
  cin >> N >> K >> T >> U >> V >> L;
  for(int i=0;i<N;i++){
    int in;
    cin >> in;
    D[in] = true;
  }
  double ans = 0.0, rem;
  bool f = false;
  int c = 0;
  for(int i=0;i<L;i++){
    if(D[i]) c++;
    if(c > K || !f && c){
      c--;
      f = true;
      rem = T;
    }
    if(f){
      if(rem - 1.0 / V < 0.0 + EPS){
        ans += rem + (1.0 - rem * V) / U;
        f = false;
        rem = 0.0;
      }else{
        rem -= 1.0 / V;
        ans += 1.0 / V;
      }
    }else ans += 1.0 / U;
  }
  printf("%.9f\n", ans);
}

Measured memory_bytes: 1204
#include<iostream>
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b) {
		if (b < c) {
			std::cout << "Yes" << std::endl;
		}
		else {
			std::cout << "No" << std::endl;
		}
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<list>
#include<stack>
#include<sstream>
#define lli long long int
#define h 100
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL) ;
  lli t, k, i, n, m, sum, flag, j;
  	string x, y, z;
  	cin>>x>>y>>z;
  	cout<<x[0]<<y[1]<<z[2]<<endl;
  return 0;
} 


Measured memory_bytes: 3608
N = int(input())
AB = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    AB[i] = [a,b]

AB = sorted(AB, key=lambda x:x[1])

totalt = 0
for ab in AB:
    totalt += ab[0]
    if totalt > ab[1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 41076
#include <stdio.h>
int main(void)
{
    int h,w;
    scanf("%d %d\n",&h,&w);
    char str[53][53]={"$"};
    for(int p=1;p<h+1;p++)
    {
        for(int q=1;q<w+1;q++)
        {
            scanf("%c",&str[p][q]);
        }
        scanf("\n");
    }
    int up[5]={1,0,-1,0};
    int side[5]={0,1,0,-1};
    int ans=1;
    int check=0;
    for(int r=1;r<h+1;r++)
    {
        for(int s=1;s<w+1;s++)
        {
            if(str[r][s]=='#')
            {
                check=0;
                for(int t=0;t<4;t++)
                {
                    if(str[r+up[t]][s+side[t]]=='#')check=1;
                }
                if(check==0)
                {
                    printf("No");
                    return 0;
                }
            }
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

long long int N, C, s, t, d, ans = 0;
bool flag[31][100001] = {};

int main() {
	cin >> N >> C;
	for (int i = 1; i <= N; i++) {
		cin >> s >> t >> d;
		for (int j = s; j <= t; j++)flag[d][j] = true;
	}
	for (int i = 1; i <= 100000; i++) {
		long long int num = 0;
		for (int j = 1; j <= C; j++) {
			if (flag[j][i])num++;
		}
		ans = max(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main(void)
{
    int a,b,c,s[100],i,j;

    scanf("%d%d%d",&a,&b,&c);

    j=0;
    for(i=a;i>=1;i--){
       if((a%i==0)&&(b%i==0)){
       s[j]=i;
       j=j+1;
       }
    }
    printf("%d\n",s[c-1]);

    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3e5 + 10, MOD = 1e9+7;
const ll OO = 2e18;
int n, m;
int val[N][32];
int main() {
	multiset<int> mt;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		mt.insert(x);
	}
	if (n == 1) {
		cout << *mt.rbegin() / (1 << min(m, 31)) << endl;
		return 0;
	}
	ll ans = 0;
	while (m!=0) {
		int x = *mt.rbegin();
		mt.erase(--mt.end());
		int y = *mt.rbegin();
		for (int j = 0; j <= 31; ++j) {
			int tobe = x / (1 << j);
			if (j == m || tobe < y) {
				m -= j;
				mt.insert(tobe);
				break;
			}
		}
	}
	while (!mt.empty()) {
		ans += *mt.rbegin();
		mt.erase(--mt.end());
	}
	cout << ans << endl;

}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, k;
	cin >> n >> k;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	long long ans = 0;
	long long z = 0;
	for (long long i = k + 1; i <= n; i++) {
		ans += n / i * (i - k);
		ans += max(z, (n % i) - k + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3568
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
const int MaxN=1005000;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int f[MaxN];
signed main(void)
{
	memset(f,0x3f,sizeof f);f[0]=0;
	int h,n;
	cin>>h>>n;
	reg int a,b;
	for(int i=1;i<=n;++i)
	{
		scanf("%lld %lld",&a,&b);
		for(int j=a;j<=h+10000;++j)
			f[j]=min(f[j],f[j-a]+b);
	}
	reg int ans=0x3f3f3f3f3f3f3f3f;
	for(int i=h;i<MaxN;++i)
		ans=min(ans,f[i]);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 8064
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e11;
const int mod = 998244353;
const int maxN = 10000003;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int kj[maxN], kji[maxN];
int rwa[maxN];
int modpow(int a, int x, int mod) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		x >>= 1;
		a = a*a%mod;
	}
	return res;
}
void setkj(int n) {
	kj[0] = 1;
	rep(i, n)kj[i + 1] = kj[i] * (i + 1) % mod;
	rep(i, n + 1)kji[i] = modpow(kj[i], mod - 2, mod);
}
int comb(int r,int c) {
	if (c<0 || r<c)return 0;
	return kj[r] * kji[c] % mod*kji[r - c] % mod;
}
void expr(int n) {
	int sum = 0;
	rep(a1, n + 1) {
		rep(b1, n + 1) {
			rep(a2, n + 1) {
				rep(b2, n + 1) {
					if (a1 + b1 <= n&&a2 + b2 <= n&&a1 + b2 <= n&&a2 + b1 <= n) {
						int c1 = n - a1 - b1, c2 = n - a2 - b2;
						sum += kj[n] * kj[n] % mod*kji[a1] % mod*kji[a2] % mod*kji[b1] % mod*kji[b2] % mod*kji[c1] % mod*kji[c2] % mod;
						cout << a1 << b1 << a2 << b2 << endl;
					}
				}
			}
		}
	}
	cout << sum << endl;
}
signed main() {
	int n; cin >> n;
	setkj(n);
	n /= 2;
	int sum = 0;
	for (int j = 1; j <= n; j++)rwa[j] = comb(n, j)*modpow(2, mod - 1 - j, mod) % mod;
	for (int j = 0; j <= n; j++)rwa[j + 1] += rwa[j];

	for (int i = 1; i <= n; i++) {
		int lj = n + 1 - i, rj = n;
		int res1 = rwa[rj] - rwa[lj - 1] + mod;
		res1 %= mod;
		sum += comb(n, i)*modpow(2, n + n - i, mod) % mod*res1%mod;
		sum %= mod;
	}
	/*
	rep(i, n + 1) {
		rep(j, n + 1) {
			if (i + j > n) {
				sum += comb(n, i)*comb(n, j) % mod*modpow(2, n*2 - i-j, mod);
			}
		}
	}*/
	sum = modpow(3, 2 * n, mod) - sum * 2 % mod;
	sum = (sum + mod) % mod;
	cout << sum << endl; 
}

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

int main(){
  int K;
  cin >> K;
  long long t = 7, s = 0;
  for(int i = 1; i <= K; ++i){
    s += t;
    s %= K;
    if(!s){
      cout << i << endl;
      return 0;
    }
    t *= 10;
    t %= K;
  }
  cout << -1 << endl;
}


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

int main(){
  int i,q1,q2,c1,c2,b;

  while(1){
    cin >> q1;
    if(!q1)break;
    cin >> b >> c1 >> c2 >> q2;

    int k1,k2;

    k1 = b/c1;
      if(k1>q2)k1 = q2;
      for(i=k1;i>0;i--){
	k2 = (b-c1*i)/c2;
	if(i+k2>=q1){
	  cout << i << " " << k2 << endl;
	  break;
	}
      }
      if(!i)cout << "NA" << endl;
  }
}

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

int main(){
	int N;
	cin>>N;
	vector<int> W(N);
	int S= 0;
	for (int i = 0;i<N;i++){
		cin>>W.at(i);
		S+=W.at(i);
	}
	int ans=1000000;
	int S2=0;
	for (int i = 0;i<N;i++){
		S2+=W.at(i);
		if (ans>=abs(S-2*S2)){
			ans = abs(S-2*S2);
		}
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;

void sort(ll a[],ll b[],ll N) {
	ll a1[N / 2];
	ll a2[N / 2 + N % 2];
	ll b1[N / 2];
	ll b2[N / 2 + N % 2];
	for (int i = 0; i < N; i++) {
		if (i < N / 2) {
			a1[i] = a[i];
			b1[i] = b[i];
		}
		else {
			a2[i - N / 2] = a[i];
			b2[i - N / 2] = b[i];

		}
	}
	if(N/2>1)sort(a1,b1,N/2);
	if(N/2+N%2>1)sort(a2,b2,N/2+N%2);
	int A1 = 0;
	int A2 = 0;
	for (int i = 0; i < N; i++) {
		if ((a1[A1]+b1[A1] <= a2[A2]+b2[A2]||A2==N/2+N%2)&&A1< N / 2) {
			a[i] = a1[A1];
			b[i] = b1[A1];
			A1++;
		}
		else {
			a[i] = a2[A2];
			b[i] = b2[A2];
			A2++;
		}
	}
}
int main() {
	ll N;
	cin >> N;
	ll X[N];
	ll L[N];
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> L[i];
	}
	sort(X,L, N);
	ll now = X[0]+L[0];
	int ans = 1;
	//cout << now << endl;
	for (int i = 1; i < N; i++) {
		//cout << X[i] + L[i] << endl;
		if (now <= X[i] - L[i]) {
			ans++;
			now = X[i] + L[i];
			//cout << now << endl;
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int Order(int *, int);
int T[101][101];

int main(){
  int n, i;
  int p[101];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &p[i], &p[i+1]);
  }

  printf("%d\n", Order(p, n));

  return 0;
}


int Order(int *p, int n){
  int i, j, k, l, q;

  for(i = 1; i <= n; i++){
    T[i][i] = 0;
  }

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;

      T[i][j] = 20000000;

      for(k = i; k <= j - 1; k++){
        q = T[i][k] + T[k + 1][j] + p[i - 1] * p[k] * p[j];
        T[i][j] = ((T[i][j] <= q) ? T[i][j] : q);
      }

    }
  }

  return T[1][n];
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 vector<int> v(5);
	 cin>>v[0]>>v[1]>>v[2]>>v[3]>>v[4];
	 for(int i=0;i<5;i++)
	 {
		 if(v[i]==0)
		 {
			 cout<<i+1<<'\n';
			 return 0;
		 }
	 }
	 return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

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

    string s;
    cin >> s;
    for (auto&c : s) {
        if (c == '1') {
            c = '9';
        } else if (c == '9') {
            c = '1';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();
        sc.close();
        int ans = (int) (Math.pow(100, D) * N);
        if(N == 100) ans += Math.pow(100, D);
        System.out.println(ans);

    }

}


Measured memory_bytes: 21844
N = int(input())
S = input()
lists = list(S)
#print(lists)
count = N
num = 0
while count>1:
    if lists[0] == lists[1]:
        count -= 1
        del lists[0]
    else:
        num += 1
        count -= 1
        del lists[0]    
ans = num+1
print(ans)


Measured memory_bytes: 4084
#include <stdio.h>
#include <math.h>

int main(void){
  double a,b,h,m,t1,t2,ans;
  scanf("%lf",&a);
  scanf("%lf",&b);
  scanf("%lf",&h);
  scanf("%lf",&m);
  t2=M_PI*m/30.0;
  t1=M_PI*h/6.0+t2/12.0;
  ans=(a*sin(t1)-b*sin(t2))*(a*sin(t1)-b*sin(t2))+(a*cos(t1)-b*cos(t2))*(a*cos(t1)-b*cos(t2));
  ans=sqrt(ans);
  printf("%.9lf",ans);
  return 0;
}
  

Measured memory_bytes: 2492
n = int(input())
a = list(map(int,input().split()))
syo = min(a)
dai = max(a)
ans = []
if abs(syo) >= abs(dai):
  ind = a.index(syo)
  ind += 1
  for i in range(n):
    ans.append([ind,i+1])
  for i in range(n,1,-1):
    ans.append([i,i-1])
  print(len(ans))
  for i in ans:
    print(*i)
else:
  ind = a.index(dai)
  ind += 1
  for i in range(n):
    ans.append([ind,i+1])
  for i in range(1,n):
    ans.append([i,i+1])
  print(len(ans))
  for i in ans:
    print(*i)  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int n,q,answer = 0;
vector<long> s(10005),t(505);
int main(){
 cin >> n;
 for(int i = 0;i < n;i++)scanf("%ld",&s[i]);
 cin >> q;
 for(int i = 0;i < q;i++)scanf("%ld",&t[i]);

 for(int i = 0;i < q;i++){
  for(int j = 0;j < n;j++){
         if(t[i] == s[j]){
         answer++;
         break;
         }
        }
 }
 printf("%d\n",answer);
 return 0;
}



Measured memory_bytes: 3308
import sys
from operator import itemgetter
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
ab = [tuple(map(int, i.split())) for i in readlines()]

ab.sort(key=itemgetter(1))
right_island = ab[0][1]
answer = 1

for i, j in ab:
    if i >= right_island:
        answer += 1
        right_island = j

print(answer)

Measured memory_bytes: 23732
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N, C, K = map(int, input().split())
    t_list = list(sorted([int(input()) for _ in range(N)]))

    ans = 0
    left = 0
    while left < N:
        a = t_list[left] + K
        for i in range(left, min(left + C, N)):
            if t_list[i] > a:
                left = i
                break
        else:
            left += C

        ans += 1


    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,a,b;cin >> n >> a >>b;
    a-=b;
    vl h(n);
    rep(i,n)cin >> h[i];
    ll ok=MOD;
    ll ng=0;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll k=0;
        rep(i,n){
            ll x=h[i]-mid*b;
            if(x>0){
                k+=(x+a-1)/a;
            }
        }
        if(k<=mid)ok=mid;
        else ng=mid;
    }
    cout << ok <<endl;
}

Measured memory_bytes: 1152