akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

int main(){

  int n, m;
  std::cin >> n >> m;
  int a[n][m];
  int b[m];
  int c[n];

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      std::cin >> a[i][j];
    }
  }

  for(int i = 0; i < m; i++){
    std::cin >> b[i];
  }

  for(int i = 0; i < n; i++){
    c[i] = 0;
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
  }

  for(int i = 0; i < n; i++){
    std::cout << c[i] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#define TASK "C-large"
#pragma comment(linker, "/STACK:1710886400")
#include <stdio.h>
#include <iostream>
#include <iomanip> 
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000007;
const long double EPS = 1e-6;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(1);

double workTime()
{
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code)
{
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int n, m;
struct town
{
	int x, y, id;
} p[100010];

struct edge
{
	int u, v, cost;
} q[200010];

int par[100010], sz[100010];

int find_parent(int v)
{
	if (par[v] == v)
		return v;
	return par[v] = find_parent(par[v]);
}

bool unite(int u, int v)
{
	u = find_parent(u);
	v = find_parent(v);
	if (u == v)
		return false;
	if (sz[u] < sz[v])
		swap(u, v);
	sz[u] += sz[v];
	par[v] = u;
	return true;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		p[i].id = i;
		scanf("%d %d", &p[i].x, &p[i].y);
	}

	sort(p + 1, p + n + 1, [](town a, town b) {
		return a.x < b.x || a.x == b.x && a.id < b.id;
	});
	for (int i = 2; i <= n; ++i)
	{
		q[m].u = p[i - 1].id;
		q[m].v = p[i].id;
		q[m].cost = p[i].x - p[i - 1].x;
		++m;
	}
	sort(p + 1, p + n + 1, [](town a, town b) {
		return a.y < b.y || a.y == b.y && a.id < b.id;
	});
	for (int i = 2; i <= n; ++i)
	{
		q[m].u = p[i - 1].id;
		q[m].v = p[i].id;
		q[m].cost = p[i].y - p[i - 1].y;
		++m;
	}

	sort(q, q + m, [](edge a, edge b) {
		return a.cost < b.cost;
	});
	for (int i = 1; i <= n; ++i)
	{
		par[i] = i;
		sz[i] = 1;
	}
	int ans = 0;
	for (int i = 0; i < m; ++i)
	{
		if (unite(q[i].u, q[i].v))
			ans += q[i].cost;
	}
	printf("%d\n", ans);
	
	my_return(0);
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int ans = 0;
    rep(i, N) {
        int a;
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
A, B, C, D, E, F = tuple(map(int, input().split()))
A, B = 100*A, 100*B
waters = set([a+b for b in range(0, F+1, B) for a in range(0, F+1, A) if a+b <= F])

res_water = min(A, B)
res_sugar = 0
max_ratio = 0

for w in sorted(waters):
    sugars = [c+d for c in range(0, int(w//100)*E+1, C)
                         for d in range(0, int(w//100)*E+1, D) 
                             if (c+d+w <= F) and (c+d <= int(w/100)*E)]
    sugar = max(sugars)
    #print(sugars)
    if w+sugar==0:
        continue
    if 100*sugar / (w+sugar) > max_ratio:
        max_ratio = 100*sugar / (w+sugar)
        res_water = w
        res_sugar = sugar
print("{} {}".format(res_water+res_sugar, res_sugar))


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

int main(){

    double w,h,x,y;
    cin >> w >> h >> x >> y;

    bool f=false;

    double ans=w*h/2.;

    cout << setprecision(12) << ans << " ";

    if(w/2.==x&&h/2.==y){
        f=true;
    }

    if(f){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    if (B == 1) 
    {
        cout << 0;
    } else if (B <= A) {
        cout << 1;
    } else {
        int N = 1;
        int S = A;
        while (S < B)
        {
            N++;
            S += A - 1;
        }
        
        cout << N;
    }
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 12 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;

double dist(vector<int> &a , vector<int> &b){
    double distance =0.0;
    for(int i=0;  i<a.size(); ++i){
        distance += pow(abs(a[i]-b[i]) , 2);
    }
    return (float)sqrt(distance);
}


auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    ivv(n);
    ivv(d);

    vector<int> v[n];

    for(int x=0; x<n; ++x){
        v[x].resize(d);
        iv(v[x]);
    }
    int counter =0; 
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n;  ++j){
            double distance = dist(v[i] , v[j]);
            if(distance-(int)distance == 0){
                counter++;
            }
        }
    }

    cout<<counter<<endl;

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}

int n;
int l[2000];
int ll[2000*2001+1];

const int inf = 1<<30;

bool isOK(int mid, int key){
    if(l[mid]>key)return true;
    else return false;
}

int binary_search(int key, int ng, int ok){
    while(ok-ng>1){    
        int mid=(ng+ok)/2;
        if(isOK(mid, key)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    //cout<<"ng="<<ng<<" ok="<<ok<<endl;
    return ok;
}

void solve(){
    for(int i=0; i<2000*2001+1; i++){
        ll[i]=inf;
    }
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>l[i];
    }
    sort(l,l+n);
    long long int ans=0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            //cout<<"key="<<l[j]-l[i]<<endl;
            int mid=binary_search(l[j]-l[i], i, j);
            ans+=j-mid;
            //cout<<"i="<<i<<" j="<<j<<endl;
            //cout<<"mid="<<mid<<endl;
        }
    }
    cout<<ans<<endl;
}

signed main(){
    //while(1)
    solve();
}


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

n = int(input())
ans = ''

for i in range(1, 99):
    if n <= 26**i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a') + n%26)
            n //= 26
        break
    else:
        n -= 26**i

print(ans[::-1])

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

int main () {
    string N;
    cin >> N;
    if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]) {
            cout << "Yes" <<endl;
    }
    else {
        cout << "No" <<endl;
    }
}

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

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    char str[5];
    int map[4] = {0,0,0,0};
    while(n--){
        scanf("%s",str);
        if(!strcmp(str,"AC")){
            map[0]++;
        }else if(!strcmp(str,"WA")){
            map[1]++;
        }else if(!strcmp(str,"TLE")){
            map[2]++;
        }else if(!strcmp(str,"RE")){
            map[3]++;
        }
    }

    printf("AC x %d\n",map[0]);
    printf("WA x %d\n",map[1]);
    printf("TLE x %d\n",map[2]);
    printf("RE x %d\n",map[3]);
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int n, m, s, g;

struct edge {
	int from, to;
	string w;
};

void solve(){
	int in1, in2;
	string in;
	cin >> m >> s >> g;
	vector<edge> e(m);
	vs dist(n, "A");
	string ans;
	rep(i, m) {
		cin >> in1 >> in2;
		cin >> in;
		e[i].from = in1;
		e[i].to = in2;
		e[i].w = in;
		//cout << e[i].w << endl;
	}
	dist[g] = "";
	bool ok = true;
	rep(i,  6* n) {
		rep(j, m) {
			if (dist[e[j].to] != "A" && (dist[e[j].from] == "A" ||(dist[e[j].from] >  e[j].w+ dist[e[j].to]))) {
				dist[e[j].from] = e[j].w + dist[e[j].to];
				//if (e[j].from == s)cout << i <<" "+ dist[s] << endl;
			}
		}
		if (i == n - 1)ans = dist[s];
		rep(j, n) {
			//cout << j << " " << dist[j] << endl;
		}
	}
	rep(i, n) {
		//cout << dist[i] << endl;
	}
	if (dist[s] != ans||dist[s]=="A") {
		cout << "NO" << endl;
	}
	else {
		cout << dist[s] << endl;
	}
}

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

	while (cin >> n,n) {
		solve();
	}
}



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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int v[5];

int main(){
  REP(i,5)cin>>v[i];
  sort(v,v+5);
  int ans = 1<<30;
  do{
    int t = 0;
    REP(i,5){
      t = ((t+9)/10)*10;
      t += v[i];
    }
    CHMIN(ans,t);
  }while(next_permutation(v,v+5));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def bb083():
    n,a,b = list(map(int, input().split()))

    s = 0
    for i in range(1, n+1):
        t = 0
        for j in list(map(int, str(i))):
            t += j
        if a <= t and t <= b:
            s += i

    print(s)

bb083()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll n,k,i;
cin>>n>>k;
ll a[n];
for(i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n,greater<int>());
ll sum=0;
for(i=k;i<n;i++)
    sum+=a[i];
cout<<sum<<endl;
}


Measured memory_bytes: 1792
n, k = [int(_) for _ in input().split()]
r_s, s_s, p_s = [int(_) for _ in input().split()]
t = input()

s = ''
for i in range(k):
    s += t[i]

for start in range(k):
    c = 0
    for i in range(start + k, n, k):
        if t[i] == t[i - k]:
            c += 1
            if c % 2 == 0:
                s += t[i]
        else:
            s += t[i]
            c = 0

ans = 0
for i in range(len(s)):
    if s[i] == 'r':
        ans += p_s
    elif s[i] == 's':
        ans += r_s
    else:
        ans += s_s
print(ans)

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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	vector<int> harr(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> harr[i];
	}

	vector<int> dp(N, 0);
	for (int j = 0; j < N; j++) {
		if (j == 0) {
			dp[0] = 0;   // はじめの足場なので、コストは0
		} else if (j == 1) {
			dp[1] = abs(harr[1] - harr[0]);
		} else {
			dp[j] = min(
				dp[j - 2] + abs(harr[j] - harr[j - 2]),
				dp[j - 1] + abs(harr[j] - harr[j - 1])
			);
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}


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

#define int long long

using namespace std;

signed main() {
    int n;
    int div = 1;
    vector<pair<int, int> > p;

    cin >> n;

    for(int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        p.push_back(make_pair(x, y));
        div *= (i + 1);
    }

    sort(p.begin(), p.end());

    double sum = 0.0;
    do {
        double dist = 0.0;
        for(int i = 1; i < n; ++i) {
            int x0 = p[i - 1].first;
            int y0 = p[i - 1].second;
            int x1 = p[i].first;
            int y1 = p[i].second;
            dist += sqrt((double)((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)));
        }
        sum += dist;
    } while(next_permutation(p.begin(), p.end()));

    printf("%.16lf\n", sum / div);

    return 0;
}

Measured memory_bytes: 256
_ = int(input())
A = [int(a) for a in input().split()]
selector = 0
count = 1
pre_a = A[0]
for a in A[1:]:
    if selector == 0:
        selector = a - pre_a
    elif selector * (a - pre_a) < 0:
        count += 1
        selector = 0
    pre_a = a
print(count)

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, k;
  cin >> n >> k;
  int ans = 0, l = -1;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    ans += (t + k) - max(t, l);
    l = t + k;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3656
def isSquare(n):
        if n==0 or n==1:
            return True
        for i in range(1,int(n/2)+1):
            x = i*i;
            if x==n:
                return True
            elif n<x:
                return False
            else:
                continue
        
        return False
l=list(map(int,input().split()))
a=str(l[0])
b=str(l[1])
c=a+b
d=int(c)
if isSquare(d)==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
int pos[30];
int Nxt[MAX][30];
void pr(ll res){
    cout<<res<<"\n";
    exit(0);
}
int main ()
{
    string S,T;cin >> S >> T;
    int sz = S.size();
    for(int i=0;i<26;i++)pos[i]=sz+1;
    for(int i=sz;i>=0;i--){
        for(int j=0;j<26;j++)Nxt[i][j]=pos[j];
        if(i)pos[S[i-1]-'a']=i;
    }/*for(int i=0;i<sz;i++){
        for(int j=0;j<26;j++)cout<<Nxt[i][j]<<' ';
        cout<<endl;
    }*/
    ll res = 0,curr=0,prev=0;
    for(int i=0;i<T.size();i++){
            curr = Nxt[prev][T[i]-'a'];
            //cout<<prev<<" "<<curr<<endl;
            if(curr>sz){res+=sz;curr = Nxt[0][T[i]-'a'];}
            if(curr>sz){pr(-1);}
            prev = curr;
    }
    pr(res+prev);
    return 0;
}


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

int	main() {
	int N;
	long A, B;
	cin >>N >>A >>B;
	long X0, X1;
	cin >>X0;
	long S=0;
	for (int i=1; i<N; i++) {
		cin >>X1;
		if (B<(X1-X0)*A)
			S +=B;
		else
			S +=(X1-X0)*A;
		X0=X1;
	}
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	ll n,m;
	ll x=0;
	ll y=0;
	ll z=0;
	
	cin>>n>>m;
	m/=1000;
	x=m/10;
	m-=10*x;
	y=m/5;
	m-=5*y;
	z=m;
	//cerr<<x<<" "<<y<<" "<<z<<endl;
	if(x+y+z>n)
	{
		cout<<-1<<" "<<-1<<" "<<-1<<endl;
	}else{
		while(x>0 && x+y+z<n)
		{
			x--;
			y+=2;
			if(x+y+z+8<n)
			{
				y-=2;
				z+=10;
			}else if(x+y+z+4<n){
				y--;
				z+=5;
			}
		}
		while(y>0 && x+y+z<n){
			y--;
			z+=5;
		}
		if(x+y+z==n)
		{
			cout<<x<<" "<<y<<" "<<z<<endl;
		}else{
			cout<<-1<<" "<<-1<<" "<<-1<<endl;
		}
	}
	return 0;
}

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

const int MAXN = 2e5 + 5;

char s[MAXN];

int main() {
	scanf("%s", s);
	
	long long ans = 0, cnt = 0;
	for (int i = 0; s[i]; i++)
		if (s[i] == 'W') {
			ans += i - cnt;
			cnt++;
		}
	
	printf("%lld\n", ans);
	
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
const int mod = 1e9 + 7;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	ll n , m ;
	cin  >> n >> m;
	vector<int> a(m);
	rep(i,m) cin >> a[i];
	if(n >= m) 
	{
		cout << 0 << endl;
		return 0;
	}
	
	SORT(a);
	vector<int> b(m-1);
	For(i,1,m){
		b[i-1] = a[i] - a[i-1];
	}
	SORT(b);
//	for(auto x : b ){
//		cout << x << " ";
//	}
	ll ans = 0;
	int r = m - n  ;
	rep(i,r){
		ans += b[i];
	}
	cout << ans << endl;	
}


Measured memory_bytes: 1024
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	
	v := make([]int, 0)
	l := make([]int, 0)
	k := make([]int, 0)
	
	for i := 0; i < n; i++ {
		v = append(v, nextInt())
	}
	for i := 0; i < n; i++ {
		l = append(l, nextInt())
	}
	for i := 0; i < n-1; i++ {
		k = append(k, nextInt())
	}
	
	last := -2
	answer := 0
	for i := 0; i < n; i++ {
		answer += l[v[i]-1]
		if( last == v[i]-1 ){
			answer += k[v[i]-2]
		}
		last = v[i]
	} 	
	Println(answer)
}
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int last = 1000000001;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int x = ri();
		if (x > last) res++;
		last = x;
	}
	std::cout << res << std::endl;
	return 0;
}




Measured memory_bytes: 3244
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
vector<vector<int> > edge(100000);
int color[100000];
bool used[100000];

bool dfs(int ver, int clr) {
  color[ver] = clr;
  used[ver] = true;
  for (int e : edge[ver]) {
    if (color[e] == clr) return true;
    else if (color[e] == 0 && dfs(e, -clr)) return true;
  }
  return false;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n, m; cin >> n >> m;
  REP(i, m) {
    int a, b; cin >> a >> b;
    --a;
    --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  REP(i, n) if (!used[i]) {
    if (dfs(i, 1)) {
      cout << n * (n - 1) / 2 - m  << '\n';
      return 0;
    }
  }
  long long black = 0, white = 0;
  REP(i, n) {
    if (color[i] == 1) ++black;
    else ++white;
  }
  cout << black * white - m << '\n';
  return 0;
}


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

const int MAX = 1e5+10;
const int INF = 1e9+10;

int n, k;
vector<int> vet[MAX];
int memo[MAX][3];

int pd(int i, int x) {
    if(i == n) return 0;
    if(x != -1 && memo[i][x] != -1) return memo[i][x];
    int ans = 0;
    for(int j = 0; j < 3; ++j) {
        if(j == x) continue;
        //cout<<"usando o j = "<<j<<endl;
        ans = max(ans, vet[i][j] + pd(i+1, j));
    }

    if(x == -1) return ans;
    return memo[i][x] = ans;
}
int main() {
    memset(memo, -1, sizeof memo);
    cin>>n;
    for(int i = 0; i < n; ++i) {
        int a, b, c;
        cin>>a>>b>>c;
        vet[i].push_back(a);
        vet[i].push_back(b);
        vet[i].push_back(c);
    }
    int ans = pd(0, -1);
    cout<<ans<<"\n";
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
template<typename T>inline void read(T&x)
{
	T f;register char ch;x=0;f=1;
	for(ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x*10)+(ch^48);
	x*=f;
}

const int MAXN=2e5+7;

static int n,a[MAXN],b[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]),b[i]=a[i];
}

inline void solve()
{
	sort(b+1,b+n+1);
	b[0]=-1e9;
	int ps=lower_bound(b+1,b+n+1,b[n]/2)-b;
	if(b[n]-2*b[ps-1]>2*b[ps]-b[n])
	printf("%d %d\n",b[n],b[ps]);
	else printf("%d %d\n",b[n],b[ps-1]);
}

int main()
{
	init();
	solve();
	return 0;
}

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

#define ll long long int
#define tinput int t; cin>>t; while(t--)
#define rep(i,n,s) for((i)=(s); (i)<(n); (i)++)

int main(){
 //   freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll x=a*c;
	if(x<(a*d))
		x=a*d;
	if(x<(b*c))
		x=b*c;
	if(x<(b*d))
		x=b*d;
	cout<<x;

	return 0;
}

Measured memory_bytes: 3596
import math

N = int(input())
P = input().split()
Q = input().split()
X = [i+1 for i in range(N)]
Y = [i+1 for i in range(N)]

n = 1
m = 1
for i in range(N):
    for j in range(N-i):
        if int(P[i]) == X[j]:
            l = j
        if int(Q[i]) == Y[j]:
            k = j
    X.remove(int(P[i]))
    Y.remove(int(Q[i]))
    n += l*math.factorial(N-i-1)
    m += k*math.factorial(N-i-1)
    
print(abs(m-n))

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

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

    vll As(N);
    rep(i, N) {
        cin >> As[i];
    }

    ll sum = 0;
    rep(i, N) {
        sum += As[i] / 2;
        As[i] %= 2;

        if (i != N - 1) {
            if (As[i] == 1 && As[i+1] > 0) {
                sum++;
                As[i]--;
                As[i+1]--;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

map <string, int> votes;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int n, max = 0;
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        
        ++votes[s];
        
        if (votes[s] > max) 
            max = votes[s];
    }
    
    map <string, int> :: iterator it;
    for (it = votes.begin(); it != votes.end(); it++)
    {
        if (it->second == max)
            cout << it->first << endl;
    }
    return 0;
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a;
	cin >> n;
	for(int i=11;n;i+=10){
		a=0;
		for(int j=2;j*j<=i;j++){
		    if(i%j==0){a++;
		    
		    }
		}
		if(a==0)cout << i << ' ',n--;
	}
	cout << endl;
	return 0;
}

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

using namespace std;

#define MAX_N 2010
#define prev(x) ((x-1+N)%N)
#define next(x) ((x+1)%N)
typedef long long ll;

ll N,A[MAX_N];
ll dp[MAX_N][MAX_N];

ll solve(int L,int R,int P){
  if(L == R){
    return (P == 0 ? A[L] : 0);
  }
  if(dp[L][R] >= 0){ return dp[L][R]; }
  ll res = 0;
  if(P == 0){
    res = max(res,solve(prev(L),R,1)+A[L]);
    res = max(res,solve(L,next(R),1)+A[R]);
  }else{
    if(A[L] < A[R]){
      res = solve(L,next(R),0);
    }else{
      res = solve(prev(L),R,0);
    }
  }
  return dp[L][R] = res;
}

int main(){
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> A[i];
  }
  memset(dp,-1,sizeof(dp));
  ll res = 0;
  for(int i = 0 ; i < N ; i++){
    res = max(res,solve(prev(i),next(i),1)+A[i]);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 32836
N=int(input())
s=["".join(sorted(input())) for i in range(N)]
s.sort()
X=[1]
for i in range(1,N):
    if s[i-1]==s[i]:
        X[-1]+=1
    else:
        X.append(1)
#print(X)
ans=0
for k in X:
    ans+=(k*(k-1))//2
print(ans)

Measured memory_bytes: 63064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9+7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<P> lr;
	int mx = -INF, mi = INF;
	rep(i,n){
		int l, r;
		cin >> l >> r;
		--l;
		chmax(mx, l);
		chmin(mi, r);
		lr.emplace_back(l, r);
	}
	int ans = 0;
	for(auto p : lr){
		chmax(ans, max(mi - mx, 0) + p.second - p.first);
	}
	vector<P> t;
	rep(i,n){
		int a = max(mi - lr[i].first, 0);
		int b = max(lr[i].second - mx, 0);
		t.emplace_back(b, -a);
	}
	sort(t.begin(), t.end());
	int w = INF;
	rep(i,n){
		auto z = t[i];
		z.second = -z.second;
		if(i) chmax(ans, w + z.first);
		chmin(w, z.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5548
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    r=sum(B)
    for i in range(N-1):
        if A[i+1]-A[i]==1:
            r+=C[A[i]-1]
    return r


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    print(solve(N, A, B, C))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(A*N,B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int bit[11234567], bit_n;

int bit_sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

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

    int n, p[112345], q[112345];

    cin >> n;
    REP(i, n)
    {
        cin >> p[i];
        q[p[i]] = i;
    }

    V v;

    ll res = 0;

    v.push_back(-1);
    v.push_back(q[n]);
    v.push_back(n);

    for (int i = n - 1; i > 0; i--)
    {
        int pos = q[i];

        int vPos = lower_bound(v.begin(), v.end(), pos) - v.begin();

        v.insert(v.begin() + vPos, pos);

        if (vPos + 2 < v.size())
        {
            int large = v[vPos + 1];

            int l = v[vPos - 1];

            int r = v[vPos + 2];

            res += (ll)(pos - l) * (r - large) * i;
        }

        if (vPos - 2 >= 0)
        {
            int large = v[vPos - 1];

            int l = v[vPos - 2];

            int r = v[vPos + 1];

            res += (ll)(r - pos) * (large - l) * i;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;

int main(){
        string str,k="keyence";
        bool flag = true;
        cin >> str;
        for(int i=0;i<k.size();i++){
                if(str[i]!=k[i]){
                        int z = str.size()-1;
                        for(int j=k.size()-1;j>=i;j--,z--){
                                if(str[z]!=k[j]) flag=false;
                        }
                }
        }
        if(flag==true){
                        cout << "YES";
                        return 0;
                }   
        cout << "NO";
        return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int d, t, s;
	cin >> d >> t >> s;

	if (d <= s * t) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m;
	cin>>n>>m;
	using data=tuple<int,int,int>;
	vector<data> ans;
	vector<vector<pii>> d(n+1);
	rep(i,m){
	    int p,y;
	    cin>>p>>y;
	    d[p].emplace_back(y,i);
	}
	rep(i,n+1){
	    sort(all(d[i]));
	    rep(j,d[i].size()){
	        ans.emplace_back(d[i][j].second,i,j+1);
	    }
	}
	sort(all(ans));
	for(auto&ln:ans){
	    int p,l,r;
	    tie(p,l,r)=ln;
	    cout<<to_string(l+1000000).substr(1)<<to_string(r+1000000).substr(1)<<endl;
	}
}


Measured memory_bytes: 8308
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    int ans = 0;
    REP(i,n){
        VI a(26), b(26);
        REP(j,n){
            if (j < i){
                a[s[j] - 'a'] = 1;
            }else{
                b[s[j] - 'a'] = 1;
            }
        }
        int tmp = 0;
        REP(j,26) tmp += (a[j] & b[j]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
M,D = map(int, input().split())
c = 0
if 10 <= D:
  for i in range(2,M+1):
    for j in range(10,D+1):
      J = list(map(int, str(j)))
      if i == J[0] * J[1] and J[0] >= 2 and J[1] >= 2:
        c += 1
  print(c)
else:
  print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h;
  cin >> n >> h;
  int max=0;
  vector<pair<int, int> > a(n);
  for(int i=0;i<n;i++){
    cin >> a[i].second >> a[i].first;
    if(a[i].second>max)max=a[i].second;
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int cnt=0,sum=0;
  for(int i=0;i<n;i++){
    if(a[i].first>max&&sum<h){
      cnt++;
      sum+=a[i].first;
      //printf("%d %d\n",cnt,sum);
    }else break;
    if(sum>=h)break;
  }
  if(sum<h){
    cnt+=(h-sum+max-1)/max;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	
	for(int i=0 ; i<n ; ++i){
		int a[3];
		scanf("%d%d%d", &a[0], &a[1], &a[2]);
		sort(a, a+3);
		puts((a[0]*a[0] + a[1]*a[1] == a[2]*a[2]) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 0
n,k = map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


limit = min(k,n-k+1)
temp = n-k+1


for i in range(1,k+1):
    if i > limit:
        print(0)
    else:
        first = cmb(temp,i,mod)
        second = cmb(k-1,i-1,mod)
        ans = first*second
        ans = ans%mod
        print(ans)

Measured memory_bytes: 4584
#include<bits/stdc++.h>
using namespace std;
int n, x, l, a, d;

int main(){
    scanf("%d%d", &n, &x);
    for(a = 1; a <= n; a++){
        scanf("%d", &l);
        d += l;
        if(d > x) break;
    }
    printf("%d\n", a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define ll long long
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 100000000
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mk(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)              (x>y)?x:y
#define min2(x,y)              (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define en cout<<"\n";

int main()
{
    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    vector <ll> v;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        // v.push_back(a[i]);
    }
    v.push_back(-a[0]);
    for(ll i=1;i<n;i++)
    {
        if(upper_bound(v.begin(),v.end(),-a[i])==v.end())
        {
            v.push_back(-a[i]);
        }
        else
        {
            *upper_bound(v.begin(),v.end(),-a[i])=-a[i];;
            // *itr=-a[i];
        }
    }
    cout<<v.size()<<endl;
}

Measured memory_bytes: 2168
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t f(const int32_t n) {
  return (n % 2 == 0) ? n / 2 : 3 * n + 1;
}

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

  int32_t X;
  cin >> X;
  const int32_t max_search = max(100, 2 * X);
  vector<bool> is_prime(max_search + 1, true);
  int32_t result = -1;
  for (int32_t i = 2; i <= max_search; ++i) {
    if (is_prime[i]) {
      if (i >= X) {
        result = i;
        break;
      }
      int32_t j = 2 * i;
      while (j <= max_search) {
        is_prime[j] = false;
        j += i;
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int h,w;
	while(cin>>h>>w,h+w){
		FOR(i,0,h){
			FOR(j,0,w){
				cout << ((i+j)%2?'.':'#');
			}
			cout << '\n';
		}
		cout << '\n';
	}
}



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> a.at(i).at(j);
    }
  }

  vector<vector<bool>> vec_b(h, vector<bool>(w, true));
  
  for(int i=0; i<h; i++){
    bool b = false;
    for(int j=0; j<w; j++){
      if(a.at(i).at(j) == '#') b = true; 
    }
    if(!b) vec_b.at(i) = vector<bool> (w, false);
  }

  for(int i=0; i<w; i++){
    bool b = false;
    for(int j=0; j<h; j++){
      if(a.at(j).at(i) == '#') b = true; 
    }
    if(!b){
      for (int j=0; j<h; j++)
	  vec_b.at(j).at(i) = false;
    } 
  }  

  for(int i=0; i<h; i++){
    int f = 0;
    for(int j=0; j<w; j++){
      if(vec_b.at(i).at(j) == true){
        cout << a.at(i).at(j);
        f = 1;
      }
    }
	if(f == 1) cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    cumsum = [0] * (N+1)
    for i in range(N):
        cumsum[i+1] = cumsum[i] + A[i]
    cnt = Counter(cumsum)
    ans = 0
    for x in cnt:
        ans += cnt[x] * (cnt[x]-1) // 2
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 112976
#include <iostream>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  l64 a, b;
  cin >> a >> b;
  if (a<=0 && 0<=b) {cout << "Zero" << endl; return 0;}
  if (a>0) {cout << "Positive" << endl; return 0;}
  if (b>0) b=0;
  cout << ((b-a)%2 != 0 ? "Positive" : "Negative") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

s = input()
if s[-1] == 's':
    print(s+'es')
else:
    print(s+'s')

Measured memory_bytes: 9520
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007

void solve()
{
 ll n,m;
 cin>>n>>m;
 char a[n][m];
 fr(n){ 
    rep(j,0,m)
    {
      cin>>a[i][j];
    } 
 }
ll dp[n][m];
fr(n){
  rep(j,0,m)
  {
    dp[i][j]=0;
  }
}
dp[0][0]=1;
fr(n)
{
  
  rep(j,0,m)
  {
    if(i==0)
  {
    if(j==0)
      continue;
    if(a[i][j]=='#')
      continue;
    else
    dp[i][j]=dp[i][j-1];
  }
    else if(j==0)
    {
      if(a[i][j]=='#')
      continue;
    else
    dp[i][j]=dp[i-1][j];
    }
    else
    {
      if(a[i][j]=='#')
        continue;
      else
      {
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
          
      }

    }
    //cout<<dp[i][j]<<" ";
  }
}
cout<<dp[n-1][m-1];
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 12416
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

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

using namespace std;

const int MAX = 1024;

int ans;
int limit;

void recurse(long long num, int mask) {
    if (num > limit)
        return;
    if ((mask & 7) == 7)
        ans++;
    recurse(num * 10 + 3, mask | 1);
    recurse(num * 10 + 5, mask | 2);
    recurse(num * 10 + 7, mask | 4);
}

int main(void) {
	// in = fopen("C.in", "rt");
	
	scanf("%d", &limit);
	
	recurse(0, 0);
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 128
//#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; cin >> N;
    map<Int, Int> m;
    vector<Int> d(N);
    rep(i, 0, N) {
        cin >> d[i];
        m[d[i]]++;
    }

    sort(d.begin(), d.end());
    Int medL = d[N/2-1];
    Int medR = d[N/2];
    cout << (medR-medL) << endl;
}


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

int main() {
  int N;
  cin >> N;
  int64_t A[N+1], B[N];
  for(int i = 0;i< N+1;i++) {
    cin >> A[i];
  }
  for(int i = 0;i< N;i++) {
    cin >> B[i];
  }
  int64_t ans = 0;
  for(int i = 0; i < N; i++) {
    if(A[i] > B[i]) {
      ans += B[i];
    }
    else {
      ans += A[i];
      B[i] = B[i] - A[i];
      if(A[i+1] > B[i]) {
        ans += B[i];
        A[i+1] = A[i+1] - B[i];
      }
      else {
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792