akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import math
import fractions

class KyoPro:
    AtCoder_Mod = 1000 * 1000 * 1000 + 7

    @staticmethod
    def ReadNumbers():
        return list(map(int, input().split()))

    @staticmethod
    def MakeStringFromNumbers(a):
        if len(a) == 0:
            return
        s = str(a[0])

        for i in range(1, len(a)):
            s += ' ' + str(a[i])
        
        return s


def main():
    n = int(input())
    a = KyoPro.ReadNumbers()

    mx = max(a)
    count = list(range(mx + 1))

    for i in range(len(count)):
        count[i] = 0
    
    for i in a:
        count[i] += 1
    
    sum = 0
    for i in range(len(count)):
        if(count[i] > 1):
            sum += count[i] - 1
    
    if(sum % 2 == 1):
        sum += 1
    
    print(n - sum)
        
    

main()

Measured memory_bytes: 24248
#include"bits/stdc++.h"
using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0;i < s.size();i += 2) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n;
    cin >> n;
    ll resenje = (ll)(n - 1LL) * (ll)n / 2LL;
    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> edge(n + 1);
	queue<int> bfs;
	vector<int> root(n + 1, -1);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
	}

	//for (int i = 1; i <= n; i++) {
	//	printf("%d->", i);
	//	for (int v : edge[i]) {
	//		printf("%d ", v);
	//	}
	//	printf("\n");
	//}

	bfs.push(1);
	root[1] = 1;

	while (!bfs.empty()) {
		int now = bfs.front();
		bfs.pop();
		for (int v : edge[now]) {
			if (root[v] != -1)continue;
			root[v] = now;
			bfs.push(v);
		}
	}

	for (int i = 1; i <= n; i++) {
		if (root[i] == -1) {
			printf("No");
			return 0;
		}
	}

	printf("Yes\n");
	for (int i = 2; i <= n; i++) {
		printf("%d\n", root[i]);
	}

}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	ll s;
	cin>>s;
	ll lb=0, ub=1e9;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(mid*mid>s){
			ub=mid;
		}
		else{
			lb=mid;
		}
	}
	if(abs(s-ub*ub)>abs(s-(ub+1)*(ub+1))){
		++ub;
	}
	ll a=abs(s-ub*ub);
	cout<<0<<' '<<0<<' ';
	cout<<ub<<' '<<1<<' ';
	cout<<a<<' '<<ub<<'\n';
	// DEBUG(ub*ub-a-s);
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
x = list(map(int, input().split()))

sameNum = 0
diffNum = 0

for n in x:
    for m in x:
        if n == m:
            sameNum += 1
        else:
            diffNum += 1

if sameNum == 5:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  vector<int> A(26);
  for(int i=0;i<S.size();i++){
    A[S[i]-'a']++;
  }
  bool f=false;
  for(int i=0;i<26;i++){
    if(A[i]==0){
      cout<<char(i+'a')<<endl;
      f=true;
      break;
    }
  }
  if(!f){
    cout<<"None"<<endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1e9,MOD=1e9+7;

int main(){
	int n,k; cin>>n>>k;
	if(n<3){
		cout<<0<<endl; return 0;
	}
	int a[11][11];
	rep(i,11)rep(j,11) a[i][j]=0;
	a[0][0]=1,a[0][2]=1,a[0][4]=1,a[0][7]=1,a[0][9]=1;
	int b[11][5]={4,2,0,9,7};
	rep(i,10)rep(j,5){
		b[i+1][j]=(b[i][j]+8)%11;
		a[i+1][b[i+1][j]]++;
	}
	rep(i,10)rep(j,11) a[i+1][j]+=a[i][j];

	// rep(i,11){
	// 	rep(j,11){
	// 		cout<<a[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<<5*((n-3)/11)+a[(n-3)%11][k]<<endl;
	return 0;
}


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

int main(void)
{
    int n;
    cin >> n;

    string s, t, ans;
    cin >> s >> t;
    
    for (size_t i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int di[] = {0, -1, 0, 1};
int dj[] = {-1, 0, 1, 0};

int main() {
	for (;;) {
		int w, h; cin >> w >> h;
		if (w == 0) break;
		vector<string> a(h);
		for (int i = 0; i < h; i++) cin >> a[i];
		vector< vector<bool> > b(h, vector<bool>(w)), c(h, vector<bool>(w));
		for (int t = 0; t < h * w; t++)
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					if (a[i][j] == '.')
						for (int k = 0; k < 4; k++) {
							int _i = i + di[k], _j = j + dj[k];
							if (_i >= 0 && _i < h && _j >= 0 && _j < w) {
								if (a[_i][_j] == 'B' || b[_i][_j]) b[i][j] = true;
								if (a[_i][_j] == 'W' || c[_i][_j]) c[i][j] = true;
							}
						}
		int cnt1 = 0, cnt2 = 0;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++) {
				if (b[i][j] && !c[i][j]) cnt1++;
				if (!b[i][j] && c[i][j]) cnt2++;
			}
		cout << cnt1 << ' ' << cnt2 << endl;
	}
}

Measured memory_bytes: 1228
#include <stdio.h>
 
int main(void){
    int i,dice[7];
    char order[101];
     
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
     
    scanf("%s", order);
     
    for(i=0;order[i]!='\0';i++){
         
        dice[0] = dice[1];
         
        switch(order[i]){
                 
            case 'E':
                dice[1] = dice[4];
                dice[4] = dice[6];
                dice[6] = dice[3];
                dice[3] = dice[0]; 
                break;
             
            case 'N':
                dice[1] = dice[2];
                dice[2] = dice[6];
                dice[6] = dice[5];
                dice[5] = dice[0]; 
                break;
             
            case 'S':
                dice[1] = dice[5];
                dice[5] = dice[6];
                dice[6] = dice[2];
                dice[2] = dice[0]; 
                break;
                 
            case 'W':
                dice[1] = dice[3];
                dice[3] = dice[6];
                dice[6] = dice[4];
                dice[4] = dice[0]; 
                break;
 
        }
    }
     
    printf("%d\n", dice[1]);
     
    return 0;
}



Measured memory_bytes: 2148
def check(x0, y0, x1, y1, s):
  dist = abs(x1 - x0) + abs(y1 - y0)
  if dist > s:
    return False
  if (dist + s) % 2 == 0:
    return True
  return False

N = int(input())
s0, x0, y0 = 0, 0, 0
ret = True
for i in range(N):
  s1, x1, y1 = map(int, input().split())
  if not check(x0, y0, x1, y1, s1 - s0):
    ret = False
    break
  s0, x0, y0 = s1, x1, y1
if ret:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 46568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  string s;
  cin >> s;

  int cnt = 0;
  rep(i, 4) if (s[i] == '2') cnt++;
  cout << cnt << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n * n * n << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    if a[i] != a[minj]:
        cnt += 1
    a[i], a[minj] = a[minj], a[i]
print(' '.join(map(str, a)))
print(cnt)


Measured memory_bytes: 5596
n, m = map(int, input().split())
a = list(map(int, input().split()))

total = sum(a)
b = []

for i in range(n):
    if a[i] >= total/(4*m):
        b.append(a[i])
        
if len(b) >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#define boido void
#define innto int
#define suitti switch
#define keesu case
#define bureeku break
#define meinn main
#define chaa char
#define foa for
#define ifu if
#define ritaann return
#define sukyannefu scanf
#define purinntoefu printf

boido kaitenn(innto daisu[6], innto komanndo) {
	innto tennpu;
	suitti (komanndo) {
		keesu 'E':
			tennpu = daisu[0];
			daisu[0] = daisu[3];
			daisu[3] = daisu[5];
			daisu[5] = daisu[2];
			daisu[2] = tennpu;
			bureeku;
		keesu 'N':
			tennpu = daisu[0];
			daisu[0] = daisu[1];
			daisu[1] = daisu[5];
			daisu[5] = daisu[4];
			daisu[4] = tennpu;
			bureeku;
		keesu 'S':
			tennpu = daisu[0];
			daisu[0] = daisu[4];
			daisu[4] = daisu[5];
			daisu[5] = daisu[1];
			daisu[1] = tennpu;
			bureeku;
		keesu 'W':
			tennpu = daisu[0];
			daisu[0] = daisu[2];
			daisu[2] = daisu[5];
			daisu[5] = daisu[3];
			daisu[3] = tennpu;
			bureeku;
	}
}

innto meinn(boido) {
	innto daisu[6];
	chaa komanndo[128];
	innto ai;
	foa (ai = 0; ai < 6; ai++) {
		ifu (sukyannefu("%d", &daisu[ai]) != 1) ritaann 1;
	}
	ifu (sukyannefu("%127s", komanndo) != 1) ritaann 1;
	foa (ai = 0; komanndo[ai] != '\0'; ai++) {
		kaitenn(daisu, komanndo[ai]);
	}
	purinntoefu("%d\n", daisu[0]);
	ritaann 0;
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		//????????¶????????\???
		if(a < b && b < c){ //??????????¨???°????????????
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26220
N, K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))

h.sort()

ans = 10 ** 9
for i in range(N-(K-1)):
    tmp = h[i+(K-1)] - h[i]
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 7388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, X, Y;
  cin >> N >> X >> Y;

  vector<int> ans(N - 1, 0);
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      int posi = i + 1;
      int posj = j + 1;
      int dist1 = posj - posi;
      int dist2 = abs(X - posi) + abs(Y - posj) + 1;
      int dist3 = abs(Y - posi) + abs(X - posj) + 1;
      int dist = min({dist1, dist2, dist3});
     // cout << i << "->" << j << ":" << dist1 << ", " << dist2 << ", " << dist3 << endl;
      ans[dist - 1]++;
    }
  }

  printlnVector(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less_equal<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 300+7;
const ll MOD = 1e9+123;
const ll M1 = 1e9+7;
const ll INF = 1E17;
const ld eps = 0.00000000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
	static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution <int> (a, b)(rng);
}
const ll MAXN = 1E9;
ld dp[DIM][DIM][DIM];
ll vis[DIM][DIM][DIM];
struct node{
    ll fi,sc,th;
};
const bool operator==(const node &a,const node &b){
    return a.fi==b.fi && a.sc==b.sc && a.th==b.th;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    ll cnt[3];
    cnt[0] = cnt[1] = cnt[2] = 0;
    forn(i,n){
        ll x;
        cin>>x;
        cnt[x-1]++;
    }
    dp[cnt[0]][cnt[1]][cnt[2]] = 1;
    queue<node> Q;
    Q.push({cnt[0],cnt[1],cnt[2]});
    ld res = 0.0;
    while(!Q.empty()){
        node t = Q.front();
        Q.pop();
        if (t==node{0,0,0})break;
        ld prob = dp[t.fi][t.sc][t.th];
        ld mprb = ld(n-t.fi-t.sc-t.th)/n;
        ld bp = prob;
        while(prob>eps){
            res+=prob;
            prob*=mprb;
        }
        ll su = t.fi+t.sc+t.th;

        prob = ld(t.fi)*bp/su;

        if (t.fi>0){
            dp[t.fi-1][t.sc][t.th]+=prob;
            if (vis[t.fi-1][t.sc][t.th]==0){
                vis[t.fi-1][t.sc][t.th] = 1;
                Q.push({t.fi-1,t.sc,t.th});
            }
        }
        prob = ld(t.sc)*bp/su;
        if (t.sc>0){
            dp[t.fi+1][t.sc-1][t.th]+=prob;
            if (vis[t.fi+1][t.sc-1][t.th]==0){
                Q.push({t.fi+1,t.sc-1,t.th});
                vis[t.fi+1][t.sc-1][t.th] = 1;
            }
        }
        prob = ld(t.th)*bp/su;
        if (t.th>0){
            dp[t.fi][t.sc+1][t.th-1]+=prob;
            if (vis[t.fi][t.sc+1][t.th-1]==0){
                vis[t.fi][t.sc+1][t.th-1] = 1;
                Q.push({t.fi,t.sc+1,t.th-1});
            }
        }
    }
    cout<<fixed<<setprecision(10)<<res<<endl;
    return 0;
}


Measured memory_bytes: 325676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
typedef struct{
    ll S;
    ll T;
    ll X;
} P;

bool comp(P p1, P p2){
    return p1.X > p2.X;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,Q;
    cin >> N >> Q;
    ll S[200010], T[200010], X[200010];
    ll D[200010];
    rep(i,0,N){
        cin >> S[i] >> T[i] >> X[i];
        T[i]--;
    }
    rep(i,0,Q){
        cin >> D[i];
    }
    ll pos[200010];
    memset(pos, -1, sizeof(pos));
    vector<P> lp;
    rep(i,0,N){
        P tmp = {S[i], T[i], X[i]};
        lp.push_back(tmp);
    }
    sort(lp.begin(), lp.end(), comp);
    vector<lpair> ans;
    rep(i,0,N){
        ll s = lp[i].S;
        ll t = lp[i].T;
        ll x = lp[i].X;
        if(s < x) s = x;
        if(t < x) t = x;
        ll ss = max(0LL, s - x);
        ll tt = max(0LL, t - x);
        ll p1 = lower_bound(D, D+Q, ss) - D;
        ll p2 = upper_bound(D, D+Q, tt) - D;
        ans.push_back(make_pair(p1,p2));
    }
    reverse(ans.begin(), ans.end());
    set<ll> st;
    rep(i,0,Q) st.insert(i);
    rep(i,0,N){
        auto it1 = st.lower_bound(ans[i].first);
        auto it2 = st.upper_bound(ans[i].second-1);
        while(it1 != it2){
            auto it_tmp = it1;
            ll v = *it_tmp;
            pos[v] = lp[N-1-i].X;
            it_tmp++;
            st.erase(it1);
            it1 = it_tmp;
        }

    }
    rep(i,0,Q) print(pos[i]);
}

Measured memory_bytes: 28140
N, K = map(int, input().split())

def main():
  a = N//K
  if K%2 == 1:
    print(a**3)
  else:
    if N%K >= K//2:
      print(a**3 + (a + 1)**3)
    else:
      print(a**3*2)
    
main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>string join(const v(T)&v){stringstream s;rep(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<class T>inline ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int L, R;
  cin >> L >> R;
  R = min(R, L+2019);
  int ans = inf;
  rep(i, L, R+1) rep(j, i+1, R+1) {
    chmin(ans, ((i%2019)*(j%2019)) % 2019);
  }
  cout << ans << endl;
}

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

int N,K;
int snuke[100];

signed main() {
  cin >> N >> K;
  for(int i=0; i<K; i++) {
    int d;
    cin >> d;
    for(int j=0; j<d; j++) {
      int a;
      cin >> a;
      snuke[a-1]++; 
    }
  }
  int ans = 0;
  for(int i=0;i<N; i++) {
    if(snuke[i] == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define INF 2147483647

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(m);
	vector<int> d(m);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cin >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i];
		cin >> d[i];
	}

	for (int i = 0; i < n; i++) {
		int min_dis = INF;
		int res = -1;
		for (int j = 0; j < m; j++) {
			int dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (dis < min_dis) {
				min_dis = dis;
				res = j + 1;
			}
		}
		cout << res << endl;
	}

	return (0);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc130/tasks/abc130_b

n, x = [int(x) for x in input().split()]
li = [int(x) for x in input().split()]
li2 = [0] + [sum(li[:i + 1]) for i, n in enumerate(li)]
li2 = [n for n in li2 if n <= x]
print(len(li2))


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGridComponents solver = new DGridComponents();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGridComponents {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt() - 1, b = in.nextInt() - 1;
            System.out.println("100 100");
            for (int y = 0; y < 49; y++) {
                for (int x = 0; x < 100; x++) {
                    if (b > 0 && x % 2 == 0 && y % 2 == 0) {
                        System.out.print('#');
                        b--;
                    } else {
                        System.out.print('.');
                    }
                }
                System.out.println();
            }
            for (int i = 0; i < 100; i++) {
                System.out.print('.');
            }
            System.out.println();
            for (int i = 0; i < 100; i++) {
                System.out.print('#');
            }
            System.out.println();
            for (int y = 51; y < 100; y++) {
                for (int x = 0; x < 100; x++) {
                    if (a > 0 && x % 2 == 0 && y % 2 == 0) {
                        System.out.print('.');
                        a--;
                    } else {
                        System.out.print('#');
                    }
                }
                System.out.println();
            }
        }

    }
}



Measured memory_bytes: 27348
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToList();
		int k = h[0], n = h[1];
		var a = Console.ReadLine().Split().Select(int.Parse).ToList();
		a.Add(k + a[0]);
		Console.WriteLine(k - Enumerable.Range(0, n).Max(i => a[i + 1] - a[i]));
	}
}


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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  int costA[A] = {0};
  int costB[B] = {0};
  int minA = 100000;
  int minB = 100000;
  for (int i=0; i<A; i++) {
    cin >> costA[i];
    minA = min(costA[i], minA);
  }
  for (int i=0; i<B; i++){
    cin >> costB[i];
    minB = min(costB[i], minB);
  }

  int res = minA + minB;
  int tmp = 0;

  int tmpI, tmpJ, tmpDiscount;
  for (int i=0; i<M; i++) {
    cin >> tmpI >> tmpJ >> tmpDiscount;
    tmpI--;
    tmpJ--;
    tmp = costA[tmpI] + costB[tmpJ] - tmpDiscount;
    res = min(res, tmp);
  }
    
  cout << res << endl;
}

Measured memory_bytes: 1024
def solve():
    n = int(input())

    ans = n * (n+1) - 1

    r = int(n // 2)
    for i in range(2, r+1):
        d = (n // i) * i
        sigma = (d * (d+i))//(2*i) - i
        ans += sigma

    return ans


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9140
use strict;
use warnings;

sub main {
    chomp(my $sc = <STDIN>);
    my($A,$B) = split(/ /,$sc);
    print solver($A,$B);
}
main() unless caller;

sub solver {
    my ($A,$B) = @_;
    if($A==$B){ return "Draw" }
    if($A==1){ return "Alice" }
    if($B==1){ return "Bob" }
    if($A > $B){
        return "Alice";
    }else {
        return "Bob";
    }
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//目標
      	double x = sc.nextDouble();//一回あたり
      	double t = sc.nextDouble();//時間
   
    	System.out.println((int)(Math.ceil(n/x)*t));
    } 
}



















Measured memory_bytes: 37472
#include <cstdio>

int n, A[50];

int solve(int i, int m) {
	if (!m) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M;

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &M);
		if (solve(0, M)) printf("yes\n");
		else printf("no\n");
	}
}


Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	

int main() {
	int n;
	cin >> n;
	bool a = false;
	for (int i = 1; i <= 9; i++) {
		if ((n / i) <= 9&&(n%i)==0) {
			a = true;
			break;
		}
	}
	if (a==true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
		return 0;
}









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

typedef long long ll;

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)

const int MAXN = 1e5+10;
int A[MAXN], B[MAXN], C[MAXN];  // upper, middle, lower parts
ll preB[MAXN];                 // prefix sum of middle parts

int main() {
    int N;
    ri(N);
    FOR(i,0,N) ri(A[i]);
    FOR(i,0,N) ri(B[i]);
    FOR(i,0,N) ri(C[i]);
    // sort parts
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    ll ans=0;   // answer

    /*
        for each middle part, find number of lower parts that
        can be put below
    */
    FOR(i,0,N) {
        int b = B[i];
        auto itr = upper_bound(C, C+N, b);

        /*
            prefix_sum(i) = (# valid lower parts below B[i]) + prefix_sum(i-1)
            prefix_sum(0) = (# valid lower parts below B[0])
        */
        preB[i] = distance(itr, C+N);
        if (i) preB[i] += preB[i-1];
    }

    /*
        for each upper part, find middle parts that can be put below
    */
    FOR(i,0,N) {
        int a = A[i];
        auto itr = upper_bound(B, B+N, a);
        int idx = distance(B, itr);
        ans += preB[N-1];
        if (idx != 0) ans -= preB[idx-1];
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 502, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

int n, dist[N][N], p[N*N], vis[N][N], gone[N][N];
vector< pii > v;
void rec(int i, int j, int d, bool st=0)
{
    if(i<0 || i>=n || j<0 || j>=n) return;
    if(vis[i][j]) return;
    if(!st && d>=dist[i][j]) return;
    vis[i][j]=1;
    v.pb({i, j});
    dist[i][j]=d;
    int add = 1 - gone[i][j];
    int dn = d + add;
    rec(i-1, j, dn);
    rec(i+1, j, dn);
    rec(i, j-1, dn);
    rec(i, j+1, dn);
}
void solve(int i, int j, int d)
{
    rec(i, j, d, 1);
    for(auto u: v)
    {
        vis[u.F][u.S]=0;
    }
    v.clear();
}
pii getij(int x)
{
    return {x/n, x%n};
}
signed main()
{
    int ans = 0;
    cin >> n;
    for(int i = 0; i < n*n; i++)
    {
        cin >> p[i];
        p[i]-=1;
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            dist[i][j] = min(i, j);
            dist[i][j] = min(dist[i][j], min(n-i-1, n-j-1));
        }
    }
    for(int it = 0; it < n*n; it++)
    {
        pii ij = getij(p[it]);
        int i = ij.F, j = ij.S;
        ans += dist[i][j];
        gone[i][j]=1;
        solve(i, j, dist[i][j]);
    }
    cout << ans;
}

Measured memory_bytes: 28140
n, m = gets.split.map!(& :to_i)
a_array = Array.new(n).map{ Array.new(m,0) }
n.times do |i|
  inputs = gets.split.map!(& :to_i)
  inputs.each.with_index do |val, ind|
  	a_array[i][ind] = val
  end
end

b_array = Array.new(m)
m.times do |ind|
  b_array[ind] = gets.to_i
end

n.times do |i|
  result = 0
  m.times do |j|
  	result += a_array[i][j] * b_array[j]  	
  end
  puts result
end

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

int main(){
    int n; cin>>n;
    set<int> s;

    for(int i=0; i<n; i++){
        int a; cin>>a;
        if(!s.count(a)) s.insert(a);
        else if(s.count(a)) s.erase(a);
    }

    cout<<s.size()<<endl;

    return 0;
}

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

int main() {
  double N,K;
  cin >> N >> K;
  vector<double> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<double> c(N);
  for(int i = 0; i < N; i++) {
    c.at(i) = (a.at(i)+1)/2;
  }
  vector<double> b(N+1);
  b.at(0) = 0;
  for (int i = 1; i < N+1; i++) {
    b.at(i) = b.at(i-1)+c.at(i-1);
  }
  double sum = 0;
  for (int i = K; i < N+1; i++) {
    if (sum < b.at(i)-b.at(i-K)) {
      sum = b.at(i)-b.at(i-K);
    }
  }
  cout << fixed <<setprecision(10);
  cout << sum <<endl;
}


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

int main(){
  int num1,num2;
  char x;
  cin>>num1>>x>>num2;
  if(x=='+'){
    cout<<num1+num2<<endl;
  }
  else if(x=='-'){
    cout<<num1-num2<<endl;
  }
}

Measured memory_bytes: 256
import math

def main():
    _, k = map(int, input().split())
    arr = list(map(int, input().split()))
    l, r = 1, 1000000000
    while l < r:
        m = (l + r) // 2
        cnt = 0
        for val in arr:
            cnt += math.ceil(val / m) - 1
        if cnt > k:
            l = m + 1
        else:
            r = m
    print(l)
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 31032
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ln length()
#define mod 1000000007
#define MAX 1000000
#define umap unordered_map
#define uset unordered_set
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define V(x) vector<x>
#define deci(n) cout<<fixed<<setprecision(n)
#define pq priority_queue
#define dbg(x)      cout << #x << " = " << x << '\n'
#define FOR(i,s,e)    for(ll i=(ll)s;i<(ll)e;i++)

typedef long long int ll;
typedef long double ldb;

ll gcd(ll a, ll b){
    ll mi=min(a, b), mx=max(a, b), temp;
    while(mi){
        temp=mi;
        mi=mx%mi;
        mx=temp;
    }
    return mx;
}

ll pw(ll x, ll n){
    ll ans=1;
    while(n){
        if(n&1ll){
            ans*=x;
            // ans%=mod;
        }
        x*=x;
        // x%=mod;
        n>>=1ll;
    }
    return ans;
}


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    int dp[n],arr[n];
    memset(dp,0,sizeof(dp));
    FOR(i,0,n)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    FOR(i,1,n)
    {
        if(i==1)    dp[i]=(abs(arr[i]-arr[i-1]));
        else
        {
            dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N , K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i< N; i++) cin >> A.at(i);
  int count[200200] = {0};
  for(int i = 0; i < A.size(); i++){
    count[A.at(i)] ++;
  }
  sort(count, count + A.size());
  reverse(count, count + A.size());

int sum = 0;
for(int i = 0; i < K; i++){
  sum+= count[i];
}
cout << N - sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s;
  cin >> s;
  bool cflag = false;
  bool fflag = false;
  rep(i,s.size()){
    if(s.at(i) == 'C'){
      cflag = true;
    }
    if(cflag && s.at(i) == 'F'){
      fflag = true;
    }
  }
  if(fflag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    string SA,SB,SC;
    cin >> SA >> SB >> SC;
    int a=1,b=0,c=0;
    char next;
    next = SA[0];
    while(true){
        //cout << next;
        if (SA.length() < a)
        {
            fin("A");return 0;
        }
        else if (SB.length() < b)
        {
            fin("B");return 0;
        }
        else if (SC.length() < c)
        {
            fin("C");return 0;
        }
        if(next == 'a'){
            next = SA[a]; a++;
        }else if(next == 'b'){
            next = SB[b]; b++;
        }else{
            next = SC[c]; c++;
        }
    }
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
using namespace std;
 
int main() {
	int k;
	string s;
	cin >> k >> s;
 
	for(int i = 0; i < s.length(); i++){
		cout << char ((s[i] - 'A' + k) % 26 + 'A'); 
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e6+9,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*ret*x%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}
	int fac[N],ifac[N];
	inline int C(int n,int m){
		if(n<0 || m<0 || n<m) return 0;
		return 1LL*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
	}
	int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
	inline int get(int _x,int _y,int x,int y){return C(abs(x-_x)+abs(y-_y),abs(x-_x));}
	inline int calc1(int x,int y){
		int ret1=add(get(x1-1,y1-1,x,y),get(x2,y2,x,y));
		ret1=sub(ret1,add(get(x1-1,y2,x,y),get(x2,y1-1,x,y)));
		return ret1;
	}
	inline int calc2(int x,int y){
		int ret2=add(get(x,y,x6+1,y6+1),get(x,y,x5,y5));
		ret2=sub(ret2,add(get(x,y,x5,y6+1),get(x,y,x6+1,y5)));
		return ret2;
	}
	int main(){
		x1=read<int>(),x2=read<int>(),x3=read<int>(),x4=read<int>(),x5=read<int>(),x6=read<int>();
		y1=read<int>(),y2=read<int>(),y3=read<int>(),y4=read<int>(),y5=read<int>(),y6=read<int>();
		fac[0]=ifac[0]=1;
		for(int i=1;i<=x6+y6+4;i++) fac[i]=1LL*fac[i-1]*i%mod;
		ifac[x6+y6+4]=qpow(fac[x6+y6+4],mod-2);
		for(int i=x6+y6+3;i>=1;i--) ifac[i]=1LL*ifac[i+1]*(i+1)%mod;

		int ans=0;
		for(int i=y3;i<=y4;i++) ans=(1LL*calc1(x3-1,i)*calc2(x3,i)%mod*(mod-x3-i)+ans)%mod;
		for(int i=x3;i<=x4;i++) ans=(1LL*calc1(i,y3-1)*calc2(i,y3)%mod*(mod-y3-i)+ans)%mod;
		for(int i=y3;i<=y4;i++) ans=(1LL*calc1(x4,i)*calc2(x4+1,i)%mod*(x4+i+1)+ans)%mod;
		for(int i=x3;i<=x4;i++) ans=(1LL*calc1(i,y4)*calc2(i,y4+1)%mod*(y4+i+1)+ans)%mod;
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 19336
#include<iostream>
using namespace std;
int main(){
    int n, m, x, total, i, j;
    cin >> n >> m;
    int A[100][100]={{}};
    int b[100],c[100];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    for(i=0;i<m;i++) cin >> b[i];
    for(i=0;i<n;i++){
        c[i] = 0;
        for(j=0;j<m;j++){
            c[i] += A[i][j]*b[j];
        }
    }
    for(i=0;i<n;i++) cout << c[i] << endl;
    return 0; 
}


Measured memory_bytes: 3144
n,m=map(int,input().split())
h1=list(map(int,input().split()))
h2=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if h1[a-1] == h1[b-1]:
        h2[a-1]=1
        h2[b-1]=1
    elif h1[a-1] < h1[b-1]:
        h2[a-1]=1
    else:
        h2[b-1]=1
print(h2.count(0))

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200)
        cout << s << "\n";
    else
        cout << "red\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

void alpha_count(int *count, char *cstr) 
{
	switch(*cstr) {
		case 'a':
		case 'A':
				 count[0]++;
			 	 break;
		case 'b':
		case 'B':
				 count[1]++;
			 	 break;
		case 'c':
		case 'C':	
				 count[2]++;
			 	 break;
		case 'd':
		case 'D':
				 count[3]++;
			 	 break;
		case 'e':
		case 'E':
				 count[4]++;
			 	 break;
		case 'f':
		case 'F':
				 count[5]++;
			     break;
		case 'g':
		case 'G':
				 count[6]++;
				 break;
		case 'h':
		case 'H':
				 count[7]++;
			 	 break;
		case 'i':
		case 'I':
				 count[8]++;
			 	 break;
		case 'j':
		case 'J':	
				 count[9]++;
			 	 break;
		case 'k':
		case 'K':
				 count[10]++;
			 	 break;
		case 'l':
		case 'L':
				 count[11]++;
			 	 break;
		case 'm':
		case 'M':
				 count[12]++;
			     break;
		case 'n':
		case 'N':
				 count[13]++;
				 break;
		case 'o':
		case 'O':
				 count[14]++;
			 	 break;
		case 'p':
		case 'P':
				 count[15]++;
			 	 break;
		case 'q':
		case 'Q':	
				 count[16]++;
			 	 break;
		case 'r':
		case 'R':
				 count[17]++;
			 	 break;
		case 's':
		case 'S':
				 count[18]++;
			 	 break;
		case 't':
		case 'T':
				 count[19]++;
			     break;
		case 'u':
		case 'U':
				 count[20]++;
				 break;
		case 'v':
		case 'V':	
				 count[21]++;
			 	 break;
		case 'w':
		case 'W':
				 count[22]++;
			 	 break;
		case 'x':
		case 'X':
				 count[23]++;
			 	 break;
		case 'y':
		case 'Y':
				 count[24]++;
			     break;
		case 'z':
		case 'Z':
				 count[25]++;
				 break;
			}

}

int main()
{
	vector<string> words;
	char *cstr;
	int count[26] = {0};

	//単語を読み込む
	for (string temp; cin >> temp; )
		words.push_back(temp);

	for (int i = 0; i < words.size(); i++) {
		cstr = (char*)words[i].c_str();
		for (int j = 0; j < words[i].length(); j++) {
			//cout << "test1" <<  "+++" << words[i] << "+++" << '\n';
			//cout << "test2" << "***" << *cstr  << "***" << '\n';
			if ('A' <= *cstr && *cstr <= 'z') {
				//printf("test3\n");
				alpha_count(count, cstr);
			}
			cstr++;
		}
	}
	
	printf("a : %d\n",count[0]);
	printf("b : %d\n",count[1]);
	printf("c : %d\n",count[2]);
	printf("d : %d\n",count[3]);
	printf("e : %d\n",count[4]);
	printf("f : %d\n",count[5]);
	printf("g : %d\n",count[6]);
	printf("h : %d\n",count[7]);
	printf("i : %d\n",count[8]);
	printf("j : %d\n",count[9]);
	printf("k : %d\n",count[10]);
	printf("l : %d\n",count[11]);
	printf("m : %d\n",count[12]);
	printf("n : %d\n",count[13]);
	printf("o : %d\n",count[14]);
	printf("p : %d\n",count[15]);
	printf("q : %d\n",count[16]);
	printf("r : %d\n",count[17]);
	printf("s : %d\n",count[18]);
	printf("t : %d\n",count[19]);
	printf("u : %d\n",count[20]);
	printf("v : %d\n",count[21]);
	printf("w : %d\n",count[22]);
	printf("x : %d\n",count[23]);
	printf("y : %d\n",count[24]);
	printf("z : %d\n",count[25]);


	return 0;
}


Measured memory_bytes: 3152
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
G = [list(map(int, input().split())) for _ in range(N)]
GC = []
GC.append([0]*C)
GC.append([0]*C)
GC.append([0]*C)
for y in range(N):
  for x in range(N):
    GC[(y+x)%3][G[y][x]-1] += 1
ans = 1000000000
for a in range(C):
  for b in range(C):
    if a == b:
      continue
    for c in range(C):
      if a == c or b == c:
        continue
      cost = 0
      for i in range(C):
        cost += GC[0][i]*D[i][a]
        cost += GC[1][i]*D[i][b]
        cost += GC[2][i]*D[i][c]
      ans = min(ans, cost)
print(ans)



Measured memory_bytes: 7540
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    int m; cin >> m;
    vector<pair<int,int>> x(m);
    rep(i,m) {
        cin >> x[i].first >> x[i].second;
        x[i].first--;
    }
    rep(i,m) {
        int sum = 0;
        rep(j,n) {
            if (x[i].first == j)
            {
                sum += x[i].second;
            } else {
                sum += t[j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

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

int M(char a)
{
  if(a=='T')return 10;
  if(a=='J')return 11;
  if(a=='Q')return 12;
  if(a=='K')return 13;
  if(a=='A')return 14;
  return (a-'2');
}
int main()
{
  string s;
  int Card_N[4][13];
  char Card_S[4][13],Trump;

  while(1){
    cin>>Trump;
    if(Trump=='#')break;
    for(int k=0;k<4;k++){
      for(int i=0;i<13;i++){
	cin>>s;
	Card_N[k][i]=M(s[0]);
	Card_S[k][i]=s[1];
	if(Card_S[k][i]==Trump)Card_N[k][i]+=20;
      }
    }

    int start=0,NS=0,EW=0;
    for(int i=0;i<13;i++){
      int ma=Card_N[start][i],b=start;
      for(int j=1;j<4;j++){
	int a=((b+j)%4);
	if(Card_S[a][i]==Card_S[b][i] || Card_S[a][i]==Trump){
	  if(Card_N[a][i]>ma){
	    ma=Card_N[a][i];
	    start=a;
	  }
	}
      }
      if(start%2==0)NS++;
      else EW++;
    }/*
    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++)cout<<Card_N[i][j]<<" ";
      cout<<endl;
    }*/
    if(NS>EW)cout<<"NS "<<NS-6<<endl;
    else cout<<"EW "<<EW-6<<endl;
  } 
  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(){

    int h, A[251];

    scanf("%d",&h);

    int i;
    for(i=1; i<=h;i++){
        scanf("%d", &A[i]);
    }

    for(i=1;i<=h;i++){
        printf("node %d: key = %d, ", i, A[i]);
        if(i != 1) printf("parent key = %d, ", A[(int)i/2]);
        if((i*2) <= h) printf("left key = %d, ", A[(i*2)]);
        if((i*2)+1 <= h) printf("right key = %d, ", A[(i*2)+1]);
        printf("\n");
    }

    return 0;

}



Measured memory_bytes: 2036
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N, A, B; cin >> N >> A >> B;

    cout << min(A*N, B) << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve() {
    int ans = 0;
    
    bool V[MAX];
    for (int i=0; i<n; i++) {
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B+n);
    for (int i=0; i<n; i++) T[B[i]] = i;
    for (int i=0; i<n; i++) {
        if (V[i]) continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while(1) {
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur]) break;
        }
        ans += min(S + (an-2) * m, m + S + (an+1) * s);
    }
    
    return ans;
}

int main() {
    cin >> n;
    s = VMAX;
    for (int i=0; i<n; i++) {
        cin >> A[i];
        s = min(s, A[i]);
    }
    
    int ans = solve();
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3176