akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

/*int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    ll len = 0;
    rep(i, n) {
        len += a[i];
    }

    ll num = 0;
    ll num2 = len;
    ll diff = 0 - len;
    ll diff2;
    rep(i, n) {
        num += a[i];
        num2 -= a[i];
        diff = abs(num - num2);
        diff2 = diff;
        if (diff > diff2)
            break;
    }

    ans = abs(num - num2);
    cout << ans << endl;
    return 0;
}*/

int main() {
    int x, y;
    cin >> x >> y;
    if (x == 1 && y == 1) {
        cout << 1000000;
        return 0;
    }
    int ans = 0;
    switch (x) {
    case 1:
        ans += 300000;
        break;
    case 2:
        ans += 200000;
        break;
    case 3:
        ans += 100000;
        break;
    }
    switch (y) {
    case 1:
        ans += 300000;
        break;
    case 2:
        ans += 200000;
        break;
    case 3:
        ans += 100000;
        break;
    }
    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

    int ans = 0;
    if(A+B >= 2*C){
        ans += 2*C*min(X,Y);
        if(X < Y){
            Y -= X;
            if(B >= 2*C) ans += 2*C*Y;
            else ans += B*Y;
        }
        else{
            X -= Y;
            if(A >= 2*C) ans += 2*C*X;
            else ans += A*X;
        }
    }
    else{
        ans += A*X + B*Y;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long n,k,p,sum=0;
	vector<long long> v;
	cin >> n >> k;
	
	while(n--){
		cin >> p;
		v.push_back(p);
	}
	sort(v.begin(), v.end());
	for(long long i=0; i<k; i++){
		sum+=v[i];
	}
	
	cout << sum << endl;
	
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>


using namespace std;

const int N = 50001;

vector<int> prime;

bool data[N];

void Solution()
{
    /*the way to get prime number also can check the problems which i did before
     ex: 9, 44, 53*/
 
    /*this function is for getting prime numbers and save them to vector*/
    for (int i = 0; i < N; i++)
    {
        data[i] = true;
    }
    
    data[0] = data[1] = false;
    
    for (int i = 2; i * i < N; i++)
    {
        for (int j = 2 * i; j < N; j += i)
        {
            data[j] = false;
        }
    }
    
    for (int i = 2; i < N; i++)
    {
        if (data[i])
        {
            prime.push_back(i);
        }
    }
}

void Cal()
{
    int n;
    
    Solution();

    while (cin>>n)
    {
        int count = 0;
        
        if (n == 0)
        {
            break;
        }
        
        for (int i = 0; 2 * prime[i] <= n; i++) // two prime[i] are the largest prime numbers if n is an even number
        {
            if (n - prime[i] > 0 && data[n - prime[i]])
            {
                count++;
            }
        }
        cout<<count<<endl;
    }
}

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

Measured memory_bytes: 1320
// 問題URL
//

import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer a = Integer.parseInt(scanner.next());
        Integer b = Integer.parseInt(scanner.next());
        int result =  -1;
        if (a < 10 && b < 10) {
            result = a * b;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n, b, f, r, v;
	int a[10] = { 0 };
	cin >> n;
	int college[4][3][10] = { 0 };
	for (int i = 1; i <= n; i++){
		cin >> b >> f >> r >> v;
		college[b - 1][f - 1][r - 1] += v;
	}
	for (int j = 0; j < 4; j++){
		for (int k = 0; k < 3; k++){
			for (int l = 0; l < 10; l++){
				if (college[j][k][l]>0||college[j][k][l]<0){
					cout << " " <<0 + college[j][k][l];
				}
				else{
					cout << " " << 0;
				}
			}
			cout << endl;
		}
		if (j < 3){
			cout << "####################" << endl;
		}
	}
	return 0;
	}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long n,m,ans=1; 
int main() 
{
	cin>>n>>m;
    if(abs(m-n)>1) 
	{
		cout<<0<<endl; 
		return 0;
	}
    for(int i=1;i<=n;i++) 
		ans=ans*i,ans=ans%mod; 
    for(int i=1;i<=m;i++) 
		ans=ans*i,ans=ans%mod; 
    cout<<(n!=m?ans:ans*2%mod)<<endl;
    return 0;
}

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

struct cake {
    ll x;
    ll y;
    ll z;
};

int main() {
    ll N, M; cin >> N >> M;
    vector<cake> V(N);
    rep(i, N){
        cin >> V[i].x >> V[i].y >> V[i].z;
    }

    ll ans = 0;
    for (int i = 0; i < 8; i++){
        vector<ll> A;
        for (int j = 0; j < N; j++){
            ll now = 0;
            if(i>>0&1){
                now += V[j].x;
            } else {
                now -= V[j].x;
            }
            if(i>>1&1){
                now += V[j].y;
            } else {
                now -= V[j].y;
            }
            if(i>>2&1){
                now += V[j].z;
            } else {
                now -= V[j].z;
            }
            A.push_back(now);
        }
        sort(A.begin(), A.end());
        reverse(A.begin(), A.end());

        ll total = 0;
        for (int k = 0; k < M; k++){
            total += A[k];
        }

        ans = max(ans, total);

    }

    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int n;
struct ac{
	int x,y,z;
}a[100010];
int bcj[100010];

int cmp(ac v,ac r){
	return v.x<r.x;
}

int cmp2(ac v,ac r){
	return v.y<r.y;
}

set<pair<int,pii> > v;

int father(int b){
	if(bcj[b]==b)
		return b;
	bcj[b]=father(bcj[b]);
	return bcj[b];
}

int main(){
	//my name is Veex
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
		a[i].z=i;
		bcj[i]=i;
	}
	
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<n;i++)
		v.insert(mer(a[i+1].x-a[i].x,mer(a[i].z,a[i+1].z)));
	
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<n;i++)
		v.insert(mer(a[i+1].y-a[i].y,mer(a[i].z,a[i+1].z)));
	
	int sum=0;
	while(!v.empty()){
		pair<int,pii> pij=*v.begin();
		v.erase(v.begin());
		if(father(pij.se.fi)!=father(pij.se.se)){
			bcj[father(pij.se.fi)]=father(pij.se.se);
			sum+=pij.fi;
		}
	}
	cout<<sum;
	return 0;
}
/*
6
8 3
4 9
12 19
18 1
13 5
7 6
*/

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> l(m),r(m);
    for(int i=0;i<m;i++){
        cin>>l.at(i)>>r.at(i);
    }
    cout<<max(0,*min_element(r.begin(),r.end()) - *max_element(l.begin(),l.end()) + 1);
}

Measured memory_bytes: 1024
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn print_vec(vec: &Vec<i32>) {
    print!("{}", vec[0]);
    for i in 1..vec.len() {
        print!(" {}", vec[i]);
    }
}

fn main() {
    let N: i32 = read_line().parse().unwrap();
    let A = read_vec();
    let mut ans = vec![0; N as usize];
    for (i, &a) in A.iter().enumerate() {
        ans[(a-1) as usize] = (i+1) as i32;
    }
    print_vec(&ans);
}


Measured memory_bytes: 4860
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  x = LI()
  for i in range(5):
    if x[i] == 0:
      print(i+1)

  
if __name__ == '__main__':
  main()

Measured memory_bytes: 9108
#include <iostream>

using namespace std;

int main() {
		int N, M;
		cin >> N >> M;
		int L[M], R[M];
		for (int i = 0; i < M; i++) cin >> L[i] >> R[i];

		int minR = N, maxL = 1;
		for (int i = 0; i < M; i++) {
				minR = min(R[i], minR);
				maxL = max(L[i], maxL);
		}

		int ans = minR - maxL + 1;

		if (ans < 0) cout << "0" << endl;
		else cout << ans << endl;
		return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		if(k*500 >= x) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if( a * b < c * d ) cout << c * d;
    else cout << a * b;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;

#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n; cin >> n;
    vi v(n);
    forn(i, n) cin >> v[i];
    sort(all(v));
    ll res = 0ll;
    forn(i, n-1) {
        forab(j, i+1, n-1) {
            int lo = lower_bound(all(v), v[i] + v[j])  - v.begin();
            res += lo - (j+1);
        }
    }
    cout << res << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

typedef struct _node {
	int key;
	struct _node **parent;
	struct _node *left;
	struct _node *right;
} node;

typedef void(*FUNCP)(node *);

node *allocNode(int key) {
	node *p = (node *)malloc(sizeof(node));
	p->key = key;
	p->parent = NULL;
	p->left = NULL;
	p->right = NULL;

	return p;
}

void terminate(node *p) {
	if (p == NULL) return;
	terminate(p->left);
	terminate(p->right);
	free(p);
}

node *insert(node *p, node *c) {
	if (p == NULL) return c;
	if (c->key < p->key) {
		p->left = insert(p->left, c);
		p->left->parent = &(p->left);
	}
	else {
		p->right = insert(p->right, c);
		p->right->parent = &(p->right);
	}
	return p;
}

node *find(node *p, int key) {
	if (p != NULL && p->key != key) {
		if (key < p->key) p = find(p->left, key);
		else p = find(p->right, key);
	}
	return p;
}

void delete(node **root, int key) {
	node *next, *p;
	node **right, **pp;

	p = find(*root, key);
	if (p == NULL) return;
	pp = p->parent;
	if (p->right == NULL)	next = p->left;
	else if (p->left == NULL)	next = p->right;
	else {
		right = p->right->parent;
		while ((*right)->left != NULL)
			right = (*right)->left->parent;
		next = *right;
		*right = next->right;
		next->left = p->left;
		next->right = p->right;
	}
	if (pp != NULL)	*pp = next; else *root = next;
	if (next != NULL) next->parent = pp;
	free(p);
}

void inParse(node *p) {
	if (p == NULL) return;
	inParse(p->left);
	printf(" %d", p->key);
	inParse(p->right);
}

void preParse(node *p) {
	if (p == NULL) return;
	printf(" %d", p->key);
	preParse(p->left);
	preParse(p->right);
}

void dump(node *p, FUNCP funcp) {
	(funcp)(p);
	printf("\n");
}

int main() {
	int n, i, key;
	char order[7];
	node *p;
	node *root = NULL;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", order);
		switch (order[0])
		{
		case 'i':
			scanf("%d", &key);
			p = allocNode(key);
			root = insert(root, p);
			break;
		case 'p':
			dump(root, &inParse);
			dump(root, &preParse);
			break;
		case 'f':
			scanf("%d", &key);
			if (find(root, key) != NULL) printf("yes\n");
			else printf("no\n");
			break;
		case 'd':
			scanf("%d", &key);
			delete(&root,key);
			break;
		}
	}
	terminate(root);

	return 0;
}



Measured memory_bytes: 20480
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = []
for i in range(n):
    a.append(inn())
b = [0]*(n+1)
for i in range(n):
    b[a[i]] = b[a[i]-1]+1
print(n-max(b))


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

char s[100005];
int len;


int main()
{
	scanf("%s", s + 1);
	len = strlen(s + 1);
	int ans1 = 0;
	for(int i = len; i; i--)
	{
		if(i == len || s[i] != s[i + 1])
		{
			ans1++;
		}
	}
	ans1--;
	int ans2 = 0;
	for(int i = 1; i <= len; i++)
	{
		if(i == 1 || s[i] != s[i - 1])
		{
			ans2++;
		}
	}
	ans2--;
	printf("%d\n", min(ans1, ans2));
	
	return 0;
}

Measured memory_bytes: 384
using System;
class Program{
    static void Main(string[] args){
        string oneStr = Console.ReadLine();
        string twoStr = Console.ReadLine();
        char[] oneLine = new char[3];
        char[] twoLine = new char[3];
        for(int i=0;i<oneLine.Length;i++){
            oneLine[i] = oneStr[i];
        }
        for(int i=0;i<twoLine.Length;i++){
            twoLine[i] = twoStr[i];
        }
        Console.WriteLine(oneLine[0] == twoLine[2] && oneLine[1] == twoLine[1] && oneLine[2] == twoLine[0] ? "YES" : "NO");
    }
}

Measured memory_bytes: 11092
def Z_algo(s):
    n=len(s)
    a=[0]*n
    a[0]=n
    i,j=1,0
    while i<n:
        while i+j<n and s[j]==s[i+j]:
            j+=1
        a[i]=j
        if j==0:
            i+=1
            continue
        k=1
        while i+k<n and k+a[k]<j:
            a[i+k]=a[k]
            k+=1
        i+=k
        j-=k
    return a

n=int(input())
s=input()
ans=0
for i in range(n-1):
    z=Z_algo(s[i:])
    ans=max(ans,max(z[j] for j in range(1,n-i) if z[j]-1<j))
print(ans)

Measured memory_bytes: 55132
def g(a,b):
	return a if b==0 else g(b,a%b)

while 1:
	n=input()
	if n==0:break
	s=[map(int,raw_input().split()) for i in [1]*n]
	t=c=1
	for i in s:t*=i[1]/g(t,i[1])
	for i in range(n):
		s[i]=t*s[i][0]/s[i][1]
		c*=s[i]/g(c,s[i])
	for i in s:print c/i

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> str(H);
  int kabe = 0;
  for(int i = 0; i < H; i++){
    cin >> str.at(i);
    for(int j = 0; j < W; j++){
      if(str.at(i).at(j) == '#') kabe++;
    }
  }

  queue<P> que;
  que.push(P(0, 0));
  vvi num(H, vi(W, -1));
  num.at(0).at(0) = 1;
  vi dx = {1, -1, 0, 0};
  vi dy = {0, 0, 1, -1};
  while(!que.empty()){
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    for(int i = 0; i < 4; i++){
      int xx = x + dx.at(i);
      int yy = y + dy.at(i);
      if(xx < 0 || xx >= W || yy < 0 || yy >= H) continue;
      if(num.at(yy).at(xx) == -1 && str.at(yy).at(xx) == '.'){
        num.at(yy).at(xx) = num.at(y).at(x) + 1;
        que.push(P(xx, yy));
      }
    }
  }
  if(num.at(H-1).at(W-1) == -1) cout << -1 << endl;
  else cout << H * W - num.at(H-1).at(W-1) - kabe << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		int[] a=sc.Ia;
		int m1=0,m2=int.MaxValue;
		int[] h=new int[n+1];
		for(int i = 0;i<n;i++) {
			m1=Math.Max(m1,a[i]);
			m2=Math.Min(m2,a[i]);
			h[a[i]]++;
		}
		if(m1==m2){Console.WriteLine("{0}",(m1==n-1||m1*2<=n)?"Yes":"No");}
		else if(m1-m2==1){
			if(m2==h[m2]&&h[m1]>1){Console.WriteLine("Yes");}
			else if(m2>h[m2]&&(m1-h[m2])*2<=h[m1]){Console.WriteLine("Yes");}
			else{Console.WriteLine("No");}
		}
		else{Console.WriteLine("No");}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 18144
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  long a,b,c,d;
  string abcd;
  cin >> abcd;
  a=abcd[0]-'0';
  b=abcd[1]-'0';
  c=abcd[2]-'0';
  d=abcd[3]-'0';
  
  vector<int> p(3); 
  p[0] = b;
  p[1] = c;
  p[2] = d;
  
  for(ll bit = 0; bit < (1<<3); ++bit){
    int sum;
    sum = a;
    
    for(int i = 0; i < 3; i++){
    if(bit & (1<<i)){
      sum = sum + p[i];
    }
    else{
      sum = sum - p[i];
    }
    }
    
    if(sum == 7){
      string x, y, z;
      if(bit & (1<<0)){
      x = '+';
      }
      else{
      x = '-';
      }
      if(bit & (1<<1)){
      y = '+';
      }
      else{
      y = '-';
      }
      if(bit & (1<<2)){
      z = '+';
      }
      else{
      z = '-';
      }
      cout << a << x << p[0] << y << p[1] << z << p[2] << '=' << 7;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3604
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (3e5);
    static List<Integer>[] edges;
    static int n;
    static double[] p;
    static Double[][] dp;
    
    
	public static void main(String[] args) {
		n = sc.nextInt();
		p = new double[n+1];
		for(int i=1;i<=n;++i) p[i] = sc.nextDouble();
		dp = new Double[n+1][2*n+1];
		out.print(f(1,0));
		out.close();
   }


	private static double f(int i, int j) {
		if(i > n) {
			if(j > 0) return 1;
			else return 0;
		}
		if(dp[i][j+n] != null) return dp[i][j+n];
		double o1 = 0,o2 = 0;
		o1 = p[i]*f(i+1,j+1);
		o2 = (1-p[i])*f(i+1,j-1);
		return dp[i][j+n] = o1 + o2;
	}

}

Measured memory_bytes: 233180
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let B: i64 = sc.get();
    println!("{}", max(0, A - B * 2));
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long L,R;
  in(L,R);
  if(R-L>=2019){out(0);return;}
  long ans=L*R%2019;
  up(i,L,R-1){
    up(j,L+1,R){
      chmin(ans,i*j%2019);
    }
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Di = Sarray();
            var dct = new Dictionary<long, long>();
            if (Di[0] != 0 || Di.Count(d => d == 0) != 1)
            {
                WriteLine(0);
                return;
            }
            for (var i = 0; i < N; ++i)
            {
                if (!dct.ContainsKey(Di[i])) dct[Di[i]] = 0;
                ++dct[Di[i]];
            }
            var max = Di.Max();
            var ans = 1L;
            for (var i = 1; i <= max; ++i)
            {
                if (!dct.ContainsKey(i))
                {
                    WriteLine(0);
                    return;
                }
                var t = ModPow(dct[i - 1], dct[i], Mod);
                ans = (ans * t) % Mod;
            }
            WriteLine(ans);
            //Out.Flush();
        }
        static long ModPow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
    }
}

Measured memory_bytes: 27488
#include <bits/stdc++.h>
 
using namespace std;
 
#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000
 
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
 
int main()
{
    string str;
    cin >> str;
    int i = 0;
    while(i < sz(str)){
        int R_C = 0, L_C = 0;
        while((str[i] - 'R') == 0){
            ++R_C;
            ++i;
        }
        while((i < sz(str)) && ((str[i] - 'L') == 0)){
            ++L_C;
            ++i;
        }
        lpi(j, 1, R_C)
            cout << "0 ";
        if((R_C + L_C) % 2 == 0){
            lp(j, 2)
                cout << (R_C+L_C)/2 << ' ';
        }
        else if((R_C > L_C && (R_C%2)) || (R_C < L_C && (L_C%2)))
            cout << (R_C+L_C)/2 + (R_C > L_C)  << ' ' << (R_C+L_C)/2 + (R_C < L_C)  << ' ';
        else
            cout << (R_C+L_C)/2 + (R_C < L_C)  << ' ' << (R_C+L_C)/2 + (R_C > L_C)  << ' ';
        lpi(j, 1, L_C)
            cout << "0 ";
    }
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
   
    char b, r;
    scanf("%c", &b);
    
    switch (b) {
        case 'A':
            r = 'T';
            break;
            
        case 'C':
            r = 'G';
            break;
        
        case 'G':
            r = 'C';
            break;
        
        case 'T':
            r = 'A';
            break;
    }
    
    printf("%c", r);
    
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
  val N = Integer.parseInt(readLine())
  val line = readLine()
  if (line != null) {
    val list = line.split(" ")
    var sum = 0
    for (i in 1..N) {
      if (Integer.parseInt(list[i-1]) != i) {
        sum += 1
      }
    }
    if (sum <= 2) {
      println("YES")
    } else {
      println("NO")
    }
  }
}

Measured memory_bytes: 38000
#include <cstdio>

typedef struct node {
        int key;
        struct node *left;
        struct node *right;

        node();
} node;

node::node()
        : left(nullptr), right(nullptr)
        {
        }

void inOrder(node *p)
{
        if (p == nullptr) {
                return;
        }
        inOrder(p->left);
        printf(" %d", p->key);
        inOrder(p->right);
}

void preOrder(node *p)
{
        if (p == nullptr) {
                return;
        }
        printf(" %d", p->key);
        preOrder(p->left);
        preOrder(p->right);
}

class BinaryTree {
public:
        node *root;
        BinaryTree();
        void insert(int newKey);
        void print();
};

BinaryTree::BinaryTree()
        : root(nullptr)
        {
        }

void BinaryTree::insert(int newKey)
{
        node **p, *newNode;

        for (p = &root; *p != nullptr;) {
                if (newKey == (*p)->key) {
                        return;
                }
                p = (newKey < (*p)->key) ? &(*p)->left : &(*p)->right;
        }
        newNode = new node();
        newNode->key = newKey;
        *p = newNode;
}

void BinaryTree::print()
{
        inOrder(root);
        putchar('\n');
        preOrder(root);
        putchar('\n');
}

int main()
{
        BinaryTree tree;
        int m;
        char com[10];

        scanf("%d", &m);
        for (int i = 0; i < m; i++) {
                scanf("%s", com);
                if (com[0] == 'i') {
                        int key;
                        scanf("%d", &key);
                        tree.insert(key);
                }
                else {
                        tree.print();
                }
        }

        return 0;
}

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

class P
{
    static void Main()
    {
        int[] NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int> from1Ship = new List<int>();
        List<int> toNShip = new List<int>();
        for (int i = 0; i < NM[1]; i++)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] == 1) from1Ship.Add(a[1]);
            if (a[1] == NM[0]) toNShip.Add(a[0]);
        }
        int[] f1 = from1Ship.OrderBy(x => x).ToArray();
        int[] tN = toNShip.OrderBy(x => x).ToArray();
        int f1index = 0;
        int tnindex = 0;
        while (f1index < f1.Length && tnindex < tN.Length)
        {
            if (f1[f1index] < tN[tnindex]) f1index++;
            else if (f1[f1index] > tN[tnindex]) tnindex++;
            else
            {
                Console.WriteLine("POSSIBLE");
                return;
            }
        }
        Console.WriteLine("IMPOSSIBLE");
    }
}

Measured memory_bytes: 22680
#include <cstdio>
int main() {
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
if(a>b)a+=b,b=a-b,a-=b;
scanf("%d",&c);
if(b>c)b+=c,c=b-c,b-=c;
if(a>b)a+=b,b=a-b,a-=b;
printf("%d %d %d\n",a,b,c);
}

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

long long Bubble(int arr[], int n)
{
    int i, j;
    long long cnt = 0;

    for(i = 0; i < n-1; i++)
    {
        for(j = 0; j < n-i-1; j++)
        {
            if(arr[j] > arr[j+1])
            {
                swap(arr[j], arr[j+1]);
                cnt++;
            }
        }
    }
    for(i = 0; i < n; i++)
        cout << arr[i] << (i == n-1 ? '\n' : ' ');
    //cout << endl;
    return cnt;
}

int main()
{
    int n, i;
    cin >> n;
    int arr[n];
    for(i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int p = Bubble(arr, n);
    cout << p << endl;
}



Measured memory_bytes: 3104
#include <stdio.h>
int main(void)
{
  int n,i;
  long int l[87]={};
  scanf("%d",&n);
  l[0]=2;
  l[1]=1;
  for(i=2;i<=n;i++)
  {
    l[i]=l[i-1]+l[i-2];
  }
  printf("%ld\n",l[n]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K){
        cout << S << endl;
    }else{
        for(int i = 0; i < K; i++){
            cout << S.at(i);    
        }
        cout << "..." << endl;
    }
    
}


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

int n,b[10000],c[10000],a[2][10000],ans;

int main(){
	cin>>n;
	for(int i=1;i<=2;++i)
		for(int j=1;j<=n;++j)
			cin>>a[i][j];
	for(int i=1;i<=n;++i)
		b[i]=b[i-1]+a[1][i];
	for(int i=n;i;--i)
		c[i]=c[i+1]+a[2][i];
	for(int i=1;i<=n;++i)
		ans=max(ans,b[i]+c[i]);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n, ans = -1;
  long ansx, ansy;

  cin >> n;

  vector<int> x(n), y(n);
  vector<pair<long, long>> p;

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      p.push_back(make_pair(x[i] - x[j], y[i] - y[j]));
    }
  }

  for (int i = 0; i < p.size(); i++) {
    int cnt = 0;
    for (int j = 0; j < p.size(); j++) {
      if (j == i) continue;
      if (p[j].first == p[i].first && p[j].second == p[i].second) cnt++;
    }
    if (cnt > ans) ans = cnt;
  }

  cout << n - ans - 1;

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int> a(N);
  for(int i = 0; i< N; i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int longest = a.at(0);
  int ans = 0;
  for(int i = 1; i < N; i++)
    ans += a.at(i);
  
  if(longest < ans)
    cout << "Yes" <<endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll parent[N];
ll GroupSize[N];


ll FindLeader(ll i)
{
    if(parent[i] == i)  return i;

    return parent[i] = FindLeader(parent[i]);
}

bool SameGroup(int x, int y)
{
    int leader1 = FindLeader(x);
    int leader2 = FindLeader(y);

    return leader1 == leader2;
}


void MergeGroups(int x, int y)
{
    int leader1 = FindLeader(x);
    int leader2 = FindLeader(y);

    if(leader1 == leader2)  return;

    if(GroupSize[leader1] > GroupSize[leader2])
    {
        parent[leader2] =  leader1;
        GroupSize[leader1] += GroupSize[leader2];
    }

    else
    {
        parent[leader1] =  leader2;
        GroupSize[leader2] += GroupSize[leader1];
    }
}

ll GetSize(int x)
{
    ll leader = FindLeader(x);
    return GroupSize[leader];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    for(int i = 0; i < N; i++)
    {
        parent[i] = i;
        GroupSize[i] = 1;
    }
    vector<pair<int, int>> vec;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        vec.push_back({a, b});
    }
    reverse(vec.begin(), vec.end());
    vector<ll> res;
    ll curr = (n * (n - 1)) / 2;
    res.push_back((n * (n - 1)) / 2);
    for (int i = 0; i < m - 1; i++) {
        if (GetSize(vec[i].first) == n) {
            res.push_back(0);
            continue;
        }
        if (SameGroup(vec[i].first, vec[i].second)) {
            res.push_back(curr);
            continue;
        }
        curr -= GetSize(vec[i].first) * GetSize(vec[i].second);
        res.push_back(curr);
        MergeGroups(vec[i].first, vec[i].second);
    }
    for (int i = res.size() - 1; i >= 0; i--)
        cout << res[i] << '\n';
    return 0;
}


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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  vector<int> s(n + 1);
  rep(i, n) s[i + 1] = (s[i] + a[i]) % mod;

  ll ans = 0;
  rep(i, n - 1) {
    ans = (ans + (ll)a[i] * (s[n] - s[i + 1] + mod) % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int x = in.nextInt();
        if(k * 500 >= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21972
import java.util.*;

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

        int cnt = 0;
        while((cnt + 1) * cnt < n * 2) {
            cnt++;
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 23764
N = int(input())

F = [[int(i) for i in input().split()] for i in range(N)]
P = [[int(i) for i in input().split()] for i in range(N)]

ans = - 10 ** 16
for i in range(1 << 10):
    output = [0] * 10
    for j in range(10):
        if (i>>j) & 1:
            output[j] = 1
    if output.count(0) == 10:
        continue
    tmp_sum = 0
    for n in range(N):
        cnt = 0
        for m in range(10):
            if F[n][m] == output[m] == 1:
                cnt += 1
        tmp_sum += P[n][cnt]
    ans = max(ans, tmp_sum)
print(ans)

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

#define ll long long

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll sum = a+b;

    if(n%sum == 0){
        cout << n/sum * a;
        return 0;
    }
    else{
        ll ans=0;
        ans = n/sum * a;
        n = n%sum;
        ans += min(a, n);
        cout << ans;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3596
N, H = map(int, input().split())

w = []
for i in range(N):
  a, b = map(int, input().split())
  w.append((a, 0))
  w.append((b, 1))

w.sort(reverse=True)
ans = 0
for v, t in w:
  if t == 1:
    H -= v
    ans += 1
  else:
    ans += -(-H//v)
    H = 0
  
  if H <= 0:
    break

print(ans)

Measured memory_bytes: 24328
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

string g[10];
inline void work() {
    int h, w, k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        cin >> g[i];
    }
    int cnt = 0;
    for (int i = 0; i < (1 << h); ++i) {
        for (int j = 0; j < (1 << w); ++j) {
            int cur = 0;
            for (int x = 0; x < h; ++x) {
                for (int y = 0; y < w; ++y) {
                    if (!((i >> x) & 1) && !((j >> y) & 1)) {
                        if (g[x][y] == '#') {
                            cur++;
                        }
                    }
                }
            }
            // cout << cur << endl;
            if (k == cur) cnt++;
        }
    }
    cout << cnt;
}

int main() {
    // freopen(".txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3648
# coding: utf-8
# Your code here!

n=int(input())
c = [int(input()) for i in range(n)]

r = [-1]*n
d=dict()
for i, cc in enumerate(c):
    if cc in d:
        r[i] = d[cc]
        d[cc] = i
    else:
        d[cc] = i

#print(c)
#print(r)
dp=[1]*n
dp[0]=1
for i in range(1,n):
    if r[i] == -1:
        dp[i] = dp[i-1]
    elif r[i] == i-1:
        dp[i] = dp[i-1]
    else:
        dp[i] = (dp[i-1] + dp[r[i]])%(10**9+7)

#print(dp)
print(dp[n-1])

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

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

    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (D2 == 1) << '\n';

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = ""
while N != 0 :
    if N % (-2) == 0 :
        S = "0"+S
    else :
        S = "1"+S
        N -= 1
    N = N / (-2)
if len(S) != 0 :
    print(S)
else :
    print(0)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define MAX 1000010

using namespace std;
typedef unsigned long long ull;

const ull MOD = 1000000007;
/*
vector<ull> fac(1000010); //n!(mod M)
vector<ull> ifac(1000010); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ull mpow(ull x, ull n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ull ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ull comb(ull a, ull b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ull tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/

ull fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ull COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
  COMinit();
  int x, y, u, r;//u:上方向の回数、r:右方向の回数
  cin >> x >> y;
  if(x<y)swap(x,y);//x>=y
  r=x-y;
  x-=2*r;y-=r;//x=y
  if(x%3!=0){
    puts("0");
    return 0;
  }
  u=x/3;r+=x/3;
  /*
  fac[0] = 1;
    ifac[0] = 1;
    for(ull i = 0; i<u+r+1; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
  */
  /*
  ull ans=1;
  queue<ull> s;
  rep(i, u){
    s.push(i+1);
  }
  ull tp=s.top();s.pop();
  for(ull i=r+1;i<=u+r; i++){
    ans*=i;
    while(ans%tp==0 && !s.empty()){
      ans/=tp;
      tp=s.top();s.pop();
    }
  }
  */

  cout << COM(u+r,r) << endl;
  return 0;
}


Measured memory_bytes: 23680
n=int(input())
pl=list(map(int, input().split()))
dl=[]
m=int(input())
for i in range(m):
  dl.append(list(map(int, input().split())))

for i in range(m):
  ans=0
  for j in range(1,n+1):
    if j==dl[i][0]:
      ans+=dl[i][1]
    else:
      ans+=pl[j-1]
  print(ans)

Measured memory_bytes: 3064