akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void) {
    int r,c,sheet[101][101]={{0}},i,j;
    scanf("%d %d",&r,&c);
    for (i=0; i<r; i++) {
        for (j=0; j<c; j++) {
            scanf("%d",&sheet[i][j]);
            sheet[i][c]+=sheet[i][j];
            sheet[r][j]+=sheet[i][j];
            sheet[r][c]+=sheet[i][j];
        }
    }
    for (i=0; i<r+1; i++) {
        for (j=0; j<c+1; j++) {
            if (j) printf(" ");
            printf("%d",sheet[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a==5&&b==5&&c==7) cout<<"YES";
	else if (a==5&&b==7&&c==5) cout<<"YES";
	else if (a==7&&b==5&&c==5) cout<<"YES";
	else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

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

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

// const int N = 1e5 + 1;
// vector<int > graph[N];

// void bfs(int n, int s, int ans[]) {
//     ans[s] = 1;
//     queue<int> q;
//     q.push(s);
//     while(!q.empty()) {
//         int v = q.front();
//         q.pop();
//         // cout<<v<<" source\n";
//         for(int b: graph[v]) {
//             if(ans[b] == 0) {
//                 ans[b] = 1;
//                 q.push(b);
//             }
//         }
//     }
// }


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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    // int a,b;
    // cin>>a>>b;

    // if(a >= 13)
    //     cout<<b;
    // else if(a >= 6)
    //     cout<<b/2;
    // else
    //     cout<<0;
    ll r,d,x0;
    cin>>r>>d>>x0;
    for(int i=0;i<10;++i) {
        x0 = r*x0 - d;
        cout<<x0<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i;
    int b[110];
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",b[i]);
        if(i>0){
            printf(" ");
        }
        else{
            printf("\n");

        }


    }




    return 0;
 }

Measured memory_bytes: 600
/*
* @Author: dnhirapara
* @Date: 2020-04-25 23:49
* @Name: dp_d
*/
//see this : https://github.com/Errichto/youtube/blob/master/atcoder-dp/d.cpp --> O(n) space code
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n, w, x, y;
    cin>>n>>w;
    std::vector< pair<ll,ll> > a(n+2);
    a[0]=  make_pair(0,0);
    for(ll i=1;i<=n;i++){
        cin>>x>>y;
        a[i]=make_pair(x,y);
    }
    // @first method
    // @space comp : O(n)
    // @time comp : O(n^2)
    ll dp[w+1]={0};
    for(ll i=1;i<=n;i++){
        for(ll weight=w;weight>=a[i].first;weight--){
            dp[weight] = max(dp[weight],dp[weight-a[i].first]+a[i].second);
        }

    }
    cout<<dp[w]<<endl;
    /*
    @second method
    @space comp : O(n^2)

    ll dp[n+2][w+2]={0};
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=w;j++){
            if(a[i].first<=j){
                dp[i][j] = max(dp[i-1][j-a[i].first]+a[i].second,dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
    */

    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

L,N=map(int,input().split())
X=[0]+[int(input()) for i in range(N)]

S=[]

for i in range(N):
    S.append(X[i+1]-X[i])
S.append(L-X[-1])

#print(S)

DIS=L-S[-1]
ANS=L-S[-1]
MINUS=0
PLUS=L-S[-1]

#print(DIS)

for i in range(N-1):
    if i%2==0:
        MINUS+=S[-i-2]
        PLUS+=S[-i//2-1]-S[-i-2]

    else:
        MINUS+=S[-i-2]-S[-i-1+i//2]
        PLUS-=S[-i-2]

    DIS+=PLUS-MINUS

    if ANS<DIS:
        ANS=DIS

    #print(DIS,PLUS,MINUS)

S=S[::-1]

DIS=L-S[-1]
MINUS=0
PLUS=L-S[-1]

#print(DIS)

for i in range(N-1):
    if i%2==0:
        MINUS+=S[-i-2]
        PLUS+=S[-i//2-1]-S[-i-2]

    else:
        MINUS+=S[-i-2]-S[-i-1+i//2]
        PLUS-=S[-i-2]

    DIS+=PLUS-MINUS

    if ANS<DIS:
        ANS=DIS

    #print(DIS,PLUS,MINUS)

print(ANS)


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

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main() {
    int n;
    vector<string> s(2);
    cin >> n >> s[0] >> s[1];

    vector<int> narabi;

    for (int i = 0; i < n;) {
        if (s[0][i] == s[1][i]) {
            narabi.push_back(0);
            i++;
        } else {
            narabi.push_back(1);
            i += 2;
        }
    }

    ll ans = 3;
    if (narabi[0] == 1) ans = 6;
    for (int i = 1; i < narabi.size(); ++i) {
        if (narabi[i] == 0) {
            if (narabi[i - 1] == 0) {
                ans *= 2;
            } else {
                ans *= 1;
            }
        } else {
            if (narabi[i - 1] == 0) {
                ans *= 2;
            } else {
                ans *= 3;
            }
        }
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] a=ir.nextIntArray(3);
		int[] ct=new int[a[1]];
		for(int i=1;i<=a[1];i++){
			if((a[0]*i)%a[1]==a[2]){
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 23380
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|
ans = 0
boder = s[i][0]+c[0]

  (0..25).each do |l|
    c[l] += C[l]
  end
  (1..25).each do |e|
    if s[i][e]+c[e] >= boder
      ans = e
      boder = s[i][e]+c[e]
    end
  end
c[ans] = 0
puts ans+1
last = boder
end


  



Measured memory_bytes: 14304
fun c81(args: Array<String>) {
    val (n, k) = args[0].split(" ").map { it.toInt() }
    val numList = args[1].split(" ").map { it.toInt() }
    var numMap = mutableMapOf<Int, Int>()
    numList.forEach {
        if (!numMap.containsKey(it)) {
            numMap.put(it, 0)
        }
        numMap.put(it, numMap[it]!! + 1)
    }
    println(numMap.values.sortedDescending().drop(k).sum())
}

fun main(args: Array<String>) {
    c81(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 93984
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;

	struct info {
		int C;
		int S;
		int F;
	};

	vector<struct info> v;
	for (int i = 0; i < N - 1; i++) {
		struct info Info;
		int c, s, f;
		cin >> c >> s >> f;
		//cout << c << s << f << endl;

		Info = { c,s,f };
		v.push_back(Info);
	}

	//for (int i = 0; i < N - 1; i++) {
	//	cout << v.at(i).C << ' ';
	//	cout << v.at(i).S << ' ';
	//	cout << v.at(i).F << endl;;
	//}

	vector<int> A(N);
	for (int i = 0; i < N - 1; i++) {
		int sum = 0;

		for (int j = i; j < N - 1; j++) {
			if (sum < v.at(j).S) sum = v.at(j).S;
			else if (!(sum % v.at(j).F == 0)) sum = sum + v.at(j).F - (sum % v.at(j).F);
			sum += v.at(j).C;
		}

		A.at(i) = sum;
	}

	for (int i = 0; i < N; i++) {
		cout << A.at(i) << endl;
	}
}

Measured memory_bytes: 3612
s = int(input())

b = s % 100
a = int((s-b)/100)

flaga = False
flagb = False

if a > 0 and a < 13:
    flaga = True
if b > 0 and b < 13:
    flagb = True

if flaga == True and flagb == True:
    print('AMBIGUOUS')
if flaga == False and flagb == True:
    print('YYMM')
if flaga == True and flagb == False:
    print('MMYY')
if flaga == False and flagb == False:
    print('NA')


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (1000)
#define MOD (998244353)

int a[MAXN][MAXN];
int sn[MAXN];
int last[MAXN];

int main(void)
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<n;i++)for(int j=0;j<n-1;j++)
    {
        scanf("%d",&(a[i][j]));
    }
    
    int siain = 0;
    int maxday = 0;
    while(1)
    {
        bool siai = false;
        for(int i=0;i<n;i++)
        {
            if(sn[i]==n-1) continue;
            // jと試合できるならする
            int j = a[i][sn[i]]-1;
            if(a[j][sn[j]]==i+1)
            {
                sn[i]++;
                sn[j]++;
                int day = max(last[i],last[j])+1;
                last[i] = day;
                last[j] = day;
                maxday = max(day, maxday);
                siai = true;
                siain++;
                i--;
            }
        }
        if(!siai)
        {
            printf("-1\n");
            return 0;
        }
        if(siain>=(n*(n-1)/2)) break;
    }
    printf("%d\n",maxday);

    return 0;
}







Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { rep(i, f.size())input(f[i]); input(r...); }

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
// g++ -std=c++11 prac.cpp 

int main(){
    ll x=0,y=0,z=0,n,m=0,k,h,w,ans=0,sum=0,Max=-1e9-1,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=false;
    cin >> n;
    VL a(n);
    rep(i,n){
        cin >> a[i];
    }
    x = 1;
    rep(i,n){
        if(a[i] == x){
            x++;
            ok = true;
        }
        else{
            ans++;
        }

    }
    if(!ok)
        cout << -1 << endl;
    else 
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
def modinv(a, m):
    b, u, v = m, 1, 0
    while(b):
        a, b, u, v = b, a%b, v, u-(a//b)*v
    return u % m

def modfac(n, m):
    res = [1] * (n+1)
    for i in range(2, n+1):
        res[i] = res[i-1] * i % m
    return res

def modc(n, r, m):
    lst = modfac(n, m)
    return lst[n] * modinv(lst[r], m) * modinv(lst[n-r], m) % m

x, y = map(int, input().split())
if (x+y)%3 == 0 and x >= (x+y)//3 and x <= 2*(x+y)//3:
    print(modc((x+y)//3, x-(x+y)//3, 1000000007))
else:
    print(0)

Measured memory_bytes: 29300
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<vector>
#define MN 200000
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
vector<int> v[MN+5],V[MN+5];
int n,head[MN+5],cnt=0,f[MN+5][3],dfn[MN+5],dn,dep[MN+5],top[MN+5],size[MN+5],mx[MN+5],fa[MN+5],tp,q[MN+5],pw[MN+5],ans;
struct edge{int to,next;}e[MN+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
void Pre(int x)
{
    size[x]=1;v[dep[x]].push_back(x);
    for(int i=head[x];i;i=e[i].next)
        dep[e[i].to]=dep[x]+1,Pre(e[i].to),
        size[x]+=size[e[i].to],size[e[i].to]>size[mx[x]]?mx[x]=e[i].to:0;
}
void Dfs(int x,int tp)
{
    top[x]=tp;dfn[x]=++dn;
    if(mx[x]) Dfs(mx[x],tp);
    for(int i=head[x];i;i=e[i].next) if(e[i].to!=mx[x]) Dfs(e[i].to,e[i].to);
}
inline int lca(int x,int y)
{
    for(;top[x]!=top[y];x=fa[top[x]]) if(dep[top[x]]<dep[top[y]]) swap(x,y);
    return dfn[x]<dfn[y]?x:y;
}
bool cmp(int x,int y){return dfn[x]<dfn[y];}
void Build(vector<int> v)
{
    v.push_back(1);sort(v.begin(),v.end(),cmp);tp=0;
    for(int i=0+(v[1]==1);i<v.size();++i)
    {
        if(tp)
        {
            int y=lca(v[i],q[tp]);
            while(tp>1&&dep[q[tp-1]]>=dep[y]) V[q[tp-1]].push_back(q[tp]),--tp;
            if(q[tp]!=y) V[y].push_back(q[tp]),q[tp]=y;
        }
        q[++tp]=v[i];
    }
    while(tp-->1) V[q[tp]].push_back(q[tp+1]);
}
void Dp(int x,int d)
{
    f[x][0]=1;f[x][1]=dep[x]==d;f[x][2]=0;
    for(int i=0;i<V[x].size();++i)
    {
        Dp(V[x][i],d);int a=f[V[x][i]][0],b=f[V[x][i]][1];
        f[x][2]=(1LL*f[x][2]*(a+b)%mod+1LL*f[x][1]*b)%mod;
        f[x][1]=(1LL*f[x][1]*a+1LL*f[x][0]*b)%mod;
        f[x][0]=1LL*f[x][0]*a%mod;
    }
    f[x][0]=(f[x][0]+f[x][2])%mod;V[x].clear();
}

int main()
{
    n=read()+1;pw[0]=1;
    for(int i=1;i<=n;++i) pw[i]=2*pw[i-1]%mod;
    for(int i=2;i<=n;++i) ins(fa[i]=read()+1,i);
    Pre(1);Dfs(1,1);
    for(int i=0;i<=n;++i) if(v[i].size())
    {
        Build(v[i]);Dp(1,i);
        ans=(ans+1LL*pw[n-v[i].size()]*f[1][1])%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 33024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];

  ll ans = 0;
  for (int i = 0; i < n-1; ++i) {
    ll d = x[i+1] - x[i];
    ll costA = d * a;
    if (costA < b) {
      ans += costA;
    } else {
      ans += b;
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 1152
import bisect
n = int(input())

A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

A.sort()
B.sort()
C.sort()

res = 0
for i in range(n):
    i1 = bisect.bisect_left(A,B[i])
    i2 = bisect.bisect_right(C,B[i])
    res += i1 * (n - i2)

print(res)

Measured memory_bytes: 23232
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val Array(a, b) = readBigDecimals
  println((a * b).setScale(0, scala.math.BigDecimal.RoundingMode.FLOOR))
}

trait StdInHelper {
  def readStrings = readLine.split(" ")
  def readInts = readStrings.map(_.toInt)
  def readLongs = readStrings.map(_.toLong)
  def readDoubles = readStrings.map(_.toDouble)
  def readBigInts = readStrings.map(BigInt.apply(_))
  def readBigDecimals = readStrings.map(BigDecimal.apply(_))
}


Measured memory_bytes: 54824
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  	int n;
  	std::cin >> n;
  	std::vector<long long> a(n);
  	int minus=0;
  	long long sum=0;
  	long long min=10000000000ll;
  	for(auto&e:a){
      	std::cin >> e;
      	sum+=std::abs(e);
      	min = std::min(std::abs(e), min);
      	if(e<0)minus++;
    }
  	if(minus%2==0) std::cout << sum << "\n";
  	else std::cout << sum-2*min << "\n";
  	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N = 1000010;
int a[N];
int cnt[N];
signed main()
{
	int ans1=0;
	int ans2=0;
	int ans3=0;
	ans1=ans2=ans3=0;
	int n ;ans1=ans2=ans3=0;
	cin >> n;ans1=ans2=ans3=0;
	rep(i , 1 , n) cin >> a[i];
	ans1=ans2=ans3=0;
	rep(i , 1 , n)
	{ans1=ans2=ans3=0;
		int x = a[i];ans1=ans2=ans3=0;
		for(int j = 2 ; j * j <= x ; j ++)
		{ans1=ans2=ans3=0;
			if(x % j == 0)
			{ans1=ans2=ans3=0;
				while(x % j == 0) x /= j;
				cnt[j] ++ ;ans1=ans2=ans3=0;
			}
		}
		if(x > 1) cnt[x] ++ ;
		ans1=ans2=ans3=0;
	}
	int g = a[1] , flag = 0;
	ans1=ans2=ans3=0;
	rep(i , 1 , N - 10) if(cnt[i] > 1) flag = 1;
	ans1=ans2=ans3=0;
	if(!flag) return cout << "pairwise coprime\n" , 0;
	ans1=ans2=ans3=0;
	rep(i , 2 , n) g = __gcd(g , a[i]);
	ans1=ans2=ans3=0;
	if(g +ans1+ans2+ans3== 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";
	return 0;
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    while (1) {
        int t;
        string num;
        cin >> t >> num;
        if (!t && num == "0") break;

        int len = num.length();
        int as = -1;
        int r = 0;
        vector<int> av;
        loop (1<<(len-1), i) {
            string s = num;
            vector<int> n;
            int idx = 0;
            loop (len-1, j) {
                if ((i>>j) & 1) {
                    string q = num.substr(idx, j+1-idx);
                    n.push_back(stoi(q));
                    idx = j+1;
                }
            }
            n.push_back(stoi(num.substr(idx)));
            int sum = 0;
            for (int v : n) sum += v;
            if (t >= sum && sum > as) {
                as = sum;
                av = n;
                r = 0;
            } else if (sum == as) {
                r = 1;
            }
        }
        if (as == -1) {
            cout << "error" << endl;
        } else if (r) {
            cout << "rejected" << endl;
        } else {
            cout << as;
            for (int v : av) cout << " " << v;
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<P> drink(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> drink[i].first >> drink[i].second;
    }
    sort(ALL(drink));
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        if (m - drink[i].second >= 0)
        {
            m -= drink[i].second;
            ans += drink[i].first * drink[i].second;
        }
        else
        {
            ans += drink[i].first * m;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

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

#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    int N;
    cin >> S >> T >> N;
    vector<int> ls, lt;
    int sum = 0;
    for(auto t : S)
        if(t == 'A')
            ls.push_back(sum += 1);
        else
            ls.push_back(sum += 2);
    sum = 0;
    for(auto t : T)
        if(t == 'A')
            lt.push_back(sum += 1);
        else
            lt.push_back(sum += 2);


    for (int i = 0; i < N; i++) {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        int pa = (ls[b] - ls[a] + 1 + S[a] - 'A') % 3;
        int qa = (lt[d] - lt[c] + 1 + T[c] - 'A') % 3;
        // cerr << "i" << i  <<  " -> " << pa << ',' << qa << '\n';
        cout << (pa == qa? "YES\n" : "NO\n");
    }
}



Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    int m = INF;
    for(int i = 0 ; i <= n-k; i++){
        m = min(m, abs(a[i] - a[i-1 + k]));
    }
    cout << m;
}

Measured memory_bytes: 640
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
floatSub(s::SubString{String})=parse(Float64,s)
intLine()=map(intSub,split(input()))
function main()
    N,M,X,Y=intLine()
    x=zeros(Int32,N+1)
    for (i,v)=enumerate(intLine());x[i]=v;end
    x[end]=X
    y=zeros(Int32,M+1)
    for (i,v)=enumerate(intLine());y[i]=v;end
    y[end]=Y
    println("No "^(maximum(x)<minimum(y)),"War")
end
main()

Measured memory_bytes: 117912
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; cin >> n;
    int k = 0; while(k*(k-1)/2 < n) k++;
    if(k*(k-1)/2 > n){ cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    cout << k << endl;
    int ans[k][k-1];
    int count = 1;
    rep(i,k) rep(j,k-1){
        if(i <= j){
            ans[i][j] = count;
            ans[j+1][i] = count;
            count++;
        }
    }
    rep(i,k) rep(j,k-1){
        if(j == 0) cout << k-1 << " ";
        cout << ans[i][j] << " ";
        if(j == k-2) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4188
def d_crossing(N):
    # N = k(k-1)/2 となる正整数kが存在するなら、求めるものが作れる
    k = 2
    while True:
        tmp = k * (k - 1)
        if tmp > 2 * N:
            return 'No'
        elif tmp == 2 * N:
            ans = ['Yes']
            break
        k += 1

    ans.append(str(k))
    matrix = [[0] * (k - 1) for _ in range(k - 1)]
    cnt = 1
    for r in range(k - 1):
        for c in range(r + 1):
            matrix[c][r] = matrix[r][c] = cnt
            cnt += 1
    for r in matrix:
        ans.append('{0} {1}'.format(k - 1, ' '.join(map(str, r))))
    tmp = []
    for j in range(k - 1):
        tmp.append(matrix[j][j])
    ans.append('{0} {1}'.format(k - 1, ' '.join(map(str, tmp))))
    ans = '\n'.join(ans)
    return ans

N = int(input())
print(d_crossing(N))

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


def read():
    H, W = map(int, input().strip().split())
    CH, CW = map(int, input().strip().split())
    DH, DW = map(int, input().strip().split())
    S = [[0 for j in range(W)] for i in range(H)]
    for i in range(H):
        s = list(input().strip())
        for j in range(W):
            if s[j] == "#":
                S[i][j] = -2
            else:
                S[i][j] = -1
    return H, W, CH, CW, DH, DW, S


def solve(H, W, CH, CW, DH, DW, S, INF=10**7):
    DIR = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    # 島を作る
    id = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == -1:
                id += 1
                S[i][j] = id
                q = deque()
                q.append((i, j))
                while q:
                    y, x = q.popleft()
                    for dy, dx in DIR:
                        ny, nx = y+dy, x+dx
                        if 0 <= ny < H and 0 <= nx < W and S[ny][nx] == -1:
                            S[ny][nx] = id
                            q.append((ny, nx))

    start_id = S[CH-1][CW-1]
    goal_id = S[DH-1][DW-1]
    if start_id == goal_id:
        return 0

    # id: 島の数
    N = id
    G = [dict() for i in range(N)]

    # 島を連結する
    for i in range(H):
        for j in range(W):
            source_id = S[i][j]
            if source_id > 0:
                for k in range(i-2, i+3):
                    for l in range(j-2, j+3):
                        if 0 <= k < H and 0 <= l < W:
                            target_id = S[k][l]
                            if target_id > 0 and source_id != target_id:
                                G[source_id-1][target_id-1] = 1
                                G[target_id-1][source_id-1] = 1
    
    visited = [-1 for i in range(N)]
    q = deque()
    visited[start_id-1] = 0
    q.append(start_id-1)
    while q:
        u = q.popleft()
        if u == goal_id-1:
            break
        for v in G[u].keys():
            if visited[v] == -1:
                visited[v] = visited[u] + 1
                q.append(v)
    return visited[goal_id-1]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

vector<vector<int>> to(100005);
vector<int> dist(100005,-1);
vector<int> pre(100005,-1);

void bfs(){
    queue<int> q;
    dist[0] = 0;
    q.push(0);
    while (!q.empty()){
        int u = q.front();q.pop();
        for (auto v : to[u]){
            if (dist[v] != -1) continue;
            dist[v] = dist[u] + 1;
            pre[v] = u;
            q.push(v);
        }
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    for (int i=0;i<M;i++){
        int A, B;
        cin >> A >> B;
        A--;B--;
        to[A].push_back(B);
        to[B].push_back(A);
    }
    bfs();
    cout << "Yes" << "\n";
    for (int i=1;i<N;i++){
        cout << pre[i]+1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 10648
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

int n, m, k;
ll a[N], b[N], s[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m >> k;
	ll res = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
		if (s[i + 1] <= k)
			res = i + 1;
	}
	ll cur = 0;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		cur += b[i];
		if (cur > k)
			break;
		ll rem = k - cur;
		int st = 0, en = n;
		while (st < en) {
			int mid = st + (en - st + 1) / 2;
			if (s[mid] <= rem)
				st = mid;
			else
				en = mid - 1;
		}
		res = max(res, i + 1LL + st);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 8300
#include<stdio.h>
#include<iostream>
typedef long long ll;
using namespace std;
int main(){
    unsigned long long ans,a,b;
    cin>>a>>b;
    ans=a*b;
    if(a==1||b==1) ans=1;
    else if(ans%2==0) ans/=2;
    else ans=ans/2+1;
    cout<<ans;
}


Measured memory_bytes: 256
M[100],i,j,h,s;char N[100][9],B[9];main(n,m){for(;scanf("%d%d",&n,&m)*n;printf("%d\n",s)){for(i=n;i--;)scanf("%s%d",N[i],M+i);for(s=0;m--;)for(scanf("%s",B),i=n;i--;s+=M[i]*h)for(h=1,j=8;j--;)h&=N[i][j]<43|N[i][j]==B[j];}}

Measured memory_bytes: 0
#include<cstdio>
#define N 100005
int n,k,a[105];
bool dp[N][2];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=k;++i)for(int j=0;j<2;++j){
		for(int l=0;l<n;++l)if(i>=a[l]&&!dp[i-a[l]][j^1])dp[i][j]=1;
	}
	puts(dp[k][0]?"First":"Second");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=1e5+5;
char s[N];
int n,a[N];
signed main(){
	//freopen("a","r",stdin);
	scanf("%s",s+1);n=strlen(s+1);rep(i,1,n)a[i]=(s[i]=='1');
	rep(i,1,n)if(a[i]&&!a[n-i])return cout<<-1,signed();
	if(!a[1])return cout<<-1,signed();
	int now=1;
	rep(i,2,n/2)if(a[i]){rep(j,now,i-1)cout<<i<<' '<<j<<'\n';now=i;}
	rep(i,now,n-1)cout<<n<<' '<<i<<'\n';
	return signed();
}

Measured memory_bytes: 4240
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	T := make([]int64, 0)
	for i := 0; i < N; i++ {
		T = append(T, fsc.NextInt64())
	}
	var res int64
	res = 1
	for _, val := range T {
		res = res / Int64Gcd(res, int64(val)) * int64(val)
	}
	fmt.Println(res)
}
 
//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}
 
func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}
 
func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
 
//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}
 
func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}
 
func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}
 
func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}
 
//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}
 
func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 
func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

class union_find:
	def __init__(self, num_node):
		self.parent = list(range(num_node))
		self.siz = [1] * num_node
		
	def root(self, node):
		if self.parent[node] == node:
			return node
		else:
			self.parent[node] = self.root(self.parent[node])
			return self.parent[node]
			
	def size(self, node):
		return self.siz[self.root(node)]
		
	def same(self, node1, node2):
		if self.root(node1) == self.root(node2):
			return True
		else:
			return False
			
	def unite(self, node1, node2):
		if self.same(node1, node2):
			return False
		else:
			siz1 = self.size(node1)
			siz2 = self.size(node2)
			if siz1 < siz2:
				self.siz[self.root(node2)] += siz1
				self.parent[self.root(node1)] = self.root(node2)
			else:
				self.siz[self.root(node1)] += siz2
				self.parent[self.root(node2)] = self.root(node1)
			return True
	
def main():
	N, M = map(int, input().split())
	A = [0] * M
	B = [0] * M
	uf = union_find(N)
	
	for i in range(M):
		A[i], B[i] = map(int, input().split())
		A[i] -= 1
		B[i] -= 1
		
	unco = [0] * M
	unco[M - 1] = (N * (N - 1)) // 2
	
	for i in range(M - 1, 0, -1):
		tmp1 = uf.size(A[i])
		if uf.unite(A[i], B[i]):
			tmp2 = uf.size(A[i])
			unco[i - 1] = unco[i] - (tmp2 - tmp1) * tmp1
		else:
			unco[i - 1] = unco[i]
	
	for i in range(M):
		print(unco[i])
		
main()

Measured memory_bytes: 106076
class Set(): #BinaryIndexedTree
    def __init__(self, valuelist, INF=10**18+1):
        self.n = len(valuelist) + 1
        self.value = sorted(valuelist) + [INF]
        self.comp = {v : k for k, v in enumerate(self.value, 1)}
        self.bit = BinaryIndexedTree(self.n)

    def insert(self, x, k=1):
        self.bit.add(self.comp[x], k)

    def delete(self, x, k=1):
        self.bit.add(self.comp[x], -k)

    def count(self, x):
        return self.bit.get(self.comp[x])

    def sum(self, x):
        return self.bit.sum(self.comp[x])

    def get(self, k): #k個以下のときはINFを返す
        return self.value[self.bit.bisect_left(k) - 1]

class BinaryIndexedTree(): #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, index):
        res = 0
        while index:
            res += self.tree[index]
            index -= index & -index
        return res

    def get(self, index):
        return self.sum(index) - self.sum(index - 1)

    def add(self, index, x):
        while index <= self.n:
            self.tree[index] += x
            index += index & -index

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        return res + 1

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

MOD = 10**9 + 7

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

S = Set(list(range(N * M + 1)))
T = Set(list(range(N * M + 1)))

res = 1

for i in range(N):
    if S.count(A[i]):
        res = 0
    S.insert(A[i])

for i in range(M):
    if T.count(B[i]):
        res = 0
    T.insert(B[i])

for i in range(N * M):
    k = N * M - i
    if S.count(k) and T.count(k):
        res *= 1
    elif S.count(k):
        res *= T.sum(N * M) - T.sum(k)
    elif T.count(k):
        res *= S.sum(N * M) - S.sum(k)
    else:
        res *= (S.sum(N * M) - S.sum(k)) * (T.sum(N * M) - T.sum(k)) - i
    res %= MOD

print(res)

Measured memory_bytes: 268512
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1, 0), b(m + 1, 0);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    int ans = 0;
    for(int i = 0; i <= n; i++) {
        if(a[i] > k) {
            break;
        }
        auto it = upper_bound(ALL(b), k - a[i]);
        it--;
        chmax(ans, i + (int)(it - b.begin()));
    }
    cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)
#define H(x) cout << #x << " " << x << endl;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);

vi par;
vi maxedge, vertsum, maxsize, sz;
int find (int u) {
    return par[u] = par[u] == u ? u : find(par[u]);
}

void comb(int u, int v, int w) {
    u = find(u); v = find(v);
    if(u != v) {
        par[v] = u;
        maxedge[u] = max(maxedge[u], maxedge[v]);
        vertsum[u] += vertsum[v];
        sz[u] += sz[v];
        maxsize[u] += maxsize[v];
    }
    sz[u] ++;
    maxedge[u] = max(maxedge[u], w);
    if(maxedge[u] <= vertsum[u]) maxsize[u] = sz[u];
}

struct edge {
    int u, v, l;
};

bool lt (const edge &e1, const edge &e2){
    return e1.l < e2.l;
}

vector<edge> edges;

signed main(){
    int N, M;
    cin >> N >> M;
    vertsum.resize(N);
    par.resize(N);
    maxedge.assign(N, 0);
    maxsize.assign(N, 0);
    sz.assign(N, 0);
    FOR(i, 0, N) par[i] = i;
    FOR(i, 0, N) {
        int x;
        cin >> x;
        vertsum[i] = x;
    }  
    FOR(i, 0, M){  
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        edges.pb({u,v,w});
    }
    sort(edges.begin(), edges.end(), lt);
    for(edge e : edges){
        comb(e.u, e.v, e.l);
    }
    int tot = 0;
    FOR(i, 0, N) if(find(i) == i) tot += maxsize[i];
    cout << M-tot << endl; 
}

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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int a, b;
	read(a), read(b);
	printf("%d\n", max(0, a - 2 * b));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,A,B;
  cin>>N>>A>>B;
  vector<int64_t>h(N);
  for(int64_t i=0;i<N;i++)
    cin>>h.at(i);
  int64_t left=0;
  int64_t right=10000000000;
  while(1<right-left){
  int64_t mid=left+(right-left)/2;
    int64_t a=0;
    for(int i=0;i<N;i++){
    if(h.at(i)-B*mid<=0)
      continue;
      else
        a+=(h.at(i)-B*mid+A-B-1)/(A-B);
    }if(a<=mid)
      right=mid;
    else
      left=mid;
  }cout<<right<<endl;
   return 0;
}

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

const int MAX = 1e5 + 111;

int n, c, k;

int t[MAX];

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> c >> k;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t, t + n);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool f = false;
        for (int j = i; j < min(i + c, n); ++j) {
            if (j == n - 1 || t[j + 1] - t[i] > k) {
                ans++;
                i = j;
                f = true;
                break;
            }
        }
        if (!f) {
            ans++;
            i = i + c - 1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int d;
  cin>>d;
  if(d==25) cout<<"Christmas"<<endl;
  else if(d==24) cout<<"Christmas Eve"<<endl;
  else if(d==23) cout<<"Christmas Eve Eve"<<endl;
  else if(d==22) cout<<"Christmas Eve Eve Eve"<<endl;
}


Measured memory_bytes: 256