akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
#define N 500000
#define S 1000000000
 
int merge(int *, int, int, int);
void mergeSort(int *, int, int);
 
int n, s[N], tmp[N], x[N];
int  count = 0;
 
int main(){
    int i, x;
 
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &s[i]);
    }
    
    mergeSort(s, 0, n-1);

    for(i = 0; i < n-1; i++){
        printf("%d ", s[i]);
    }
    printf("%d\n", s[n-1]);
    printf("%d\n", count);

    return 0;

}
 
void mergeSort(int A[], int left, int right){
    int mid, i, j, k;
    
    if(left >= right) return;

    mid = (left + right) / 2;

    mergeSort(A, left, mid);
    mergeSort(A, mid + 1, right);
    
    for(i = left; i <= mid; i++){
        tmp[i] = A[i];
        }
 
    for(i = mid + 1, j = right; i <= right; i++, j--){
        tmp[i] = A[j];
        }
        
    i = left;
    j = right;
 
    for(k = left; k <= right; k++){
      if(tmp[i] <= tmp[j]) A[k] = tmp[i++];
      else A[k] = tmp[j--];
      count++;
    }
}

Measured memory_bytes: 4504
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    s = input()
    if s == 'AAA' or s == 'BBB':
        print("No")
    else:
        print('Yes')


if __name__ == '__main__':
    main()


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed Gcd(long m, long n)
{
	int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    std::vector<int> SPF( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    SPF.at(1) = 1;
//    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                                if(is_prime[j]!=false){
                is_prime[ j ] = false;
                SPF.at(j) = i;
                                }
            }
            SPF.at(i) = 1; //prime number
//            P.emplace_back( i );
        }
    }
    return SPF;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    int max_A=0;
    rep(i,N){
        cin>>A.at(i);
        if(max_A<A.at(i))max_A=A.at(i);
    }
    //まずsetwiseかどうかをチェックする
    int current_val = A.at(0);
    for(int i=1;i<N;i++){
        current_val = Gcd(current_val, A.at(i));
    }
    if(current_val!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }

    // pairwiseかは素因数分解してチェックできるが, N sqrt(N)になって間に合わない
    // SPFを利用した素因数分解で行ける
    vec_int SPF = Eratosthenes(max_A);
    vec_int check(max_A+1,0);

    for(int i=0;i<N;i++){
        set<int> soinsuu;
        int num = A.at(i);
        while(true){
            if(SPF.at(num)==1){
                soinsuu.insert(num);
                break;
            }
            soinsuu.insert(SPF.at(num));
            num = num/SPF.at(num);
        }
        for(auto num : soinsuu){
            if(check.at(num)==1 && num!=1){
                cout<<"setwise coprime"<<endl;
                return 0;
            }else{
                check.at(num)=1;
            }
        }
    }


                cout<<"pairwise coprime"<<endl;
 





    return 0;
}

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

int n, h[101010];

int main(){
  cin >> n;
  rep(i, n) cin >> h[i];
  h[n] = 1e9 + 100;
  int res = 0, cnt = 0;
  rep(i, n){
    if(h[i + 1] <= h[i]){
      cnt++;
    }else{
      res = max(res, cnt);
      cnt = 0;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
N,K=map(int,input().split())
A=[int(x)-1 for x in input().split()]

t,i,dist=0,0,{0:0}
while K>0:
    K-=1
    i+=1
    t=A[t]
    if t in dist:
        K%=i-dist[t]
    else:
        dist[t]=i

print(t+1)


Measured memory_bytes: 110700
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Maze Master
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 20;
const int MAX_W = 20;
const int dxs[] = { 1, 0, -1, 0 }, dys[] = { 0, -1, 0, 1 };

/* typedef */

typedef pair<int,int> pii;

/* global variables */

char fs[MAX_H][MAX_W + 4];
int ds[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);
  for (int y = 0; y < h; y++) scanf("%s", fs[y]);

  int maxd = 0;
  for (int sy = 0; sy < h; sy++)
    for (int sx = 0; sx < w; sx++)
      if (fs[sy][sx] == '.') {
	memset(ds, -1, sizeof(ds));
	ds[sy][sx] = 0;

	queue<pii> q;
	q.push(pii(sx, sy));

	while (! q.empty()) {
	  pii u = q.front(); q.pop();
	  int ux = u.first, uy = u.second, ud = ds[uy][ux];
	  if (maxd < ud) maxd = ud;

	  int vd = ud + 1;
	  for (int di = 0; di < 4; di++) {
	    int vx = ux + dxs[di], vy = uy + dys[di];
	    if (vx >= 0 && vx < w && vy >= 0 && vy < h &&
		fs[vy][vx] == '.' && ds[vy][vx] < 0) {
	      ds[vy][vx] = vd;
	      q.push(pii(vx, vy));
	    }
	  }
	}
      }

  printf("%d\n", maxd);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define pf push_front
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,a;
  deque<ll> dq;
  cin>>n;
  fr(i,n){
    cin>>a;
    if(i%2) dq.pf(a);
    else dq.pb(a);
  }
  if(n%2) for(auto it=dq.end();(it--)!=dq.begin();) cout<<*it<<" ";
  else for(auto it=dq.begin();it!=dq.end();it++) cout<<*it<<" ";
  cout<<endl;
}

Measured memory_bytes: 3840
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
cnt=0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            cnt += 1
if cnt == h+w-1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 38384
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

signed main() {
	int n,k,q; cin >> n >> k >> q;
	int a[n];
	REP (i,n) {
		cin >> a[i];
	}
	int ans = INF;
	REP (i,n) {
		vector<int> P;
		vector<int> V;
		REP (j,n) {
			if (a[j] < a[i]) {
				if ((int)V.size() >= k) {
					sort(V.begin(),V.end());
					REP (l,min((int)V.size()-k+1,(int)q)) P.push_back(V[l]);
				}
				V.clear();
			}
			else V.push_back(a[j]);
		}
		if ((int)V.size() >= k) {
			sort(V.begin(),V.end());
			REP (l,min((int)V.size()-k+1,(int)q)) P.push_back(V[l]);
		}
		sort(P.begin(),P.end());
		if (P.size() >= q) ans = min(ans,P[q-1]-P[0]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int N;
int a[1000];

int is_ok(int num) {
	int prev = 99;
	while (num > 0) {
		if (prev != 99 && num % 10 != prev - 1) return 0;
		prev = num % 10;
		num /= 10;
	}
	return 1;
}

int main(void) {
	int i, j;
	int answer = -1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			int mul = a[i] * a[j];
			if (is_ok(mul) && mul > answer) answer = mul;
		}
	}
	printf("%d\n", answer);
	return 0;
}

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MAX = 410;
using pint = pair<int,int>;

int H, W;
vector<string> fi;

long long cnt = 0;
bool seen[MAX][MAX];
int flg;
void dfs(int x, int y) {
    
    flg=0;
    for (int dir = 0; dir < 4; ++dir) {
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        if (fi[nx][ny]=='#'){
        	flg=1;
        	break;
        }
    }
}

int main() {
    cin >> H;
    cin >> W;
    
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];
    
    long long res = 0;
    for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
            //printf("%c",fi[x][y]);
            
            if (fi[x][y] == '.') continue;
            dfs(x, y);
            if(flg==0){
				puts("No");
				return 0;
			}
        }
    }
    puts("Yes");
}

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

using namespace std;

typedef long long ll;

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> cs(n);
    for (int i = 0; i < n; i++) {
        cin >> cs[i];
        for (int k = 0; k < m; k++) {
            cin >> a[i][k];
        }
    }
    ll ans = 1e10;
    for (int i = 0; i < (1 << n); i++) {
        ll c = 0;
        vector<int> un(m);
        for (int k = 0; k < n; k++) {
            if (i >> k & 1) {
                c += cs[k];
                for (int l = 0; l < m; l++) {
                    un[l] += a[k][l];
                }
            }
        }
        bool clear = true;
        for (int k = 0; k < m; k++) {
            if (un[k] < x) {
                clear = false;
                break;
            }
        }
        if (clear) {
            ans = min(ans, c);
        }
    }
    if (ans == 1e10) {
        cout << -1;
    } else {
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int digit[15] = {}, ans = 0;
    while (1)
    {
        int x = 0, p = 1;
        vector<bool> use(4, false);
        digit[0]++;
        rep(i, 14) if (digit[i] == 4) digit[i] = 0, digit[i + 1]++;
        bool f = false;
        rep(i, 15)
        {
            if (digit[i] == 0)
                f = true;
            if (digit[i] == 1)
                x += 3 * p, use[1] = true;
            if (digit[i] == 2)
                x += 5 * p, use[2] = true;
            if (digit[i] == 3)
                x += 7 * p, use[3] = true;
            if (f && digit[i] != 0)
                use[0] = true;
            p *= 10;
        }
        if (x > n)
            break;
        if (!use[0] && use[1] && use[2] && use[3])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int sum = 0;
        while(scan.hasNext()){
        	int x = scan.nextInt();
        	int h = scan.nextInt();
        	if(x == 0 && h == 0){
        		break;
        	}
        	System.out.printf("%.6f\n",(double)x*x + (double)x*Math.sqrt(4*h*h+x*x));
        }
    }
}

Measured memory_bytes: 17192
#include <cstdio>
#include <cstring>
#include <algorithm>

int Max[550000], cMax[550000]; 
int n, a[550000], Ans[550000];
int o[4];

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < (1 << n); i++) scanf("%d", &a[i]);
	memset(Max, -1, sizeof(Max));
	memset(cMax, -1, sizeof(cMax));
	Max[0] = a[0];
	if(a[1] > a[0]) Max[1] = a[1], cMax[1] = a[0];
	else Max[1] = a[0], cMax[1] = a[1];
	Ans[1] = a[0] + a[1];
	printf("%d\n", a[0] + a[1]);
	for(int i = 2; i < (1 << n); i++)
	{
		int S = 0, b;
		for(int j = 17; j >= 0; j--)
		{
			if((i >> j) & 1)
			{
				S = i ^ (1 << j);
				b = j;
				break;
			}
		}
		b = 1 << b;
		for(int j = S; ; j = ((j - 1) & S))
		{
			int u = a[b ^ j];
			if(u > Max[i]) cMax[i] = Max[i], Max[i] = u;
			else if(u > cMax[i]) cMax[i] = u;
			if(j == 0) break;
		}
		o[0] = Max[i]; o[1] = cMax[i]; o[2] = Max[S]; o[3] = cMax[S];
		std::sort(o, o + 4);
		Max[i] = o[3]; cMax[i] = o[2];
		if(cMax[i] == -1)
		{
			Ans[i] = Ans[i - 1];
			printf("%d\n", Ans[i]);
		}
		else
		{
			Ans[i] = std::max(Max[i] + cMax[i], Ans[i - 1]);
			printf("%d\n", Ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, i;
  map<string, i64> S;
  cin >> N;
  getchar();
  i64 M = 0;
  REP(0, N, i) {
    string s;
    getline(cin, s);
    if(S.find(s) == S.end())
      S[s] = 1;
    else
      S[s]++;

    M = max(M, S[s]);
  }

  for(auto p: S) {
    if(p.second == M)
      cout << p.first << endl;
  }

  
  
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N;
     cin >> N;
     vector<int> A(N);
     for(int i = 0; i < N; i++) cin >> A[i];
     int M = 0;
     for(int i = 0; i < N; i++){
          for(int j = i + 1; j < N; j++){
               int t = abs(A[i] - A[j]);
               M = max(M,t);
          }
     }
     cout << M << endl;
}

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

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

  vector<int> a(N);
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  int min = a.at(N-1)-a.at(0);

  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

string S;
bool Sf= false;
bool small = true;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int count = 0;
    cin >> S;
    if(S[0] == 0x41){
         Sf = true;
         S[0] = S[0] + 0x20;
        if(S[2] == 0x43 && S[S.size()-3] == 0x43){ 
        }else{
            REPP(i,2,S.size()-1)
            if(S[i] == 0x43 ){ 
                count++;
                S[i] += 0x20;
            }
        }
        REP(i,S.size()){
            if(!(S[i] > 0x60 && S[i] < 0x7b)) small = false;
        }
    }

    if(Sf && count==1 && small) cout << "AC" << endl;
    else cout << "WA" << endl;
       


    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

ll A, B, C, X, Y;

int main()
{
	cin >> A >> B >> C >> X >> Y;
	ll ans = 1e10;
	for (ll i = 0; i<=200000; i += 2)
	{
		ans = min(ans, i*C + max(0LL,(X - i / 2))*A + max(0LL,(Y - i / 2))*B);
	}
	cout << ans;
}

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

int main(){
    int A,B,C;
    cin >> A >> B;
    int tmp;
    tmp=max(A,B);
    A=min(A,B);
    B=tmp;
    if(A==1 && B==2) C=3;
    if(A==2 && B==3) C=1;
    if(A==1 && B==3) C=2;

    cout << C << endl;

    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int mn = n+1, cnt = 0;
    for(int i=0; i<n; i++){
        int p;
        cin >> p;
        if(p < mn){
            mn = p;
            cnt++;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:usize, c:i64, k:i64, t:[i64;n]};
    let mut t = t;
    t.sort();

    let mut ans = 1i64;
    let mut cnt = 0i64;
    let mut crt = t[0];
    for i in 0..n {
        if crt+k < t[i] || cnt==c {
            crt = t[i];
            cnt = 0;
            ans += 1;
        }
        cnt += 1;
        //debug!(i,t[i],crt,cnt,ans);
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	int A, B;
	cin >> A >> B;
	A--;
	B--;

	int h = 100, w = 100;

	vector<string> s(h);

	for (int i = 0; i < h; i++) {
		s[i].resize(w);
		for (int j = 0; j < w; j++) {
			if (i < h / 2) s[i][j] = '#';
			else s[i][j] = '.';
		}
	}
	int x, y;
	for (int i = 0; i < A; i++) {
		x = i % 50 * 2;
		y = i / 50 * 2;
		s[y][x] = '.';
	}

	for (int i = 0; i < B; i++) {
		x = i % 50 * 2;
		y = h - 1 - i / 50 * 2;
		s[y][x] = '#';
	}

	cout << h << " " << w << endl;
	for (int i = 0; i < h; i++) cout << s[i] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()

def s(x):
    return x * (x + 1) // 2

print(s(n) - s(n//3)*3 - s(n//5)*5 + s(n//15)*15)


Measured memory_bytes: 9188
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;

     if((a+b+c)==17)
     {
         if(a!=5  && a!=7)
            goto jump;
         else if(b!=5 && b!=7)
            goto jump;
                else if(c!=5 && c!=7)
                goto jump;
     else
        cout<<"YES\n";
        return 0;
     }
    else {
            cout<<"NO\n";
            return 0;
    }
    jump:
        cout<<"NO\n";

}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl '\n'
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
const int maxn = 2e5 + 10; 
int n;
int x[maxn],y[maxn];

int main()
{
	fastIO;
	cin >> n;
	rep(i,0,n) {
		cin >> x[i] >> y[i];
	}
	sort(x, x + n);
	sort(y, y + n);
	if(n & 1) {
		cout << y[n / 2] - x[n / 2] + 1;
	}
	else {
		cout << y[n / 2] + y[n / 2 - 1] - x[n / 2] - x[n / 2 - 1] + 1;
	}
	return 0;
}

Measured memory_bytes: 5256
import java.util.Scanner;

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

	String s1 = scan.next();
	String s2 = scan.next();
	String s3 = scan.next();

	System.out.println((char)(s1.charAt(0)-32)+""+
			   (char)(s2.charAt(0)-32)+""+
			   (char)(s3.charAt(0)-32));
    }
}


Measured memory_bytes: 23124
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  13 - 6 - 2020 +   13 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int, int>
#define pb push_back
#define pi acos(-1.0)
#define eps 1e-12
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int scala;
    int php;
    scanf("%d%d", &scala,&php);
    if (php >= scala){
        puts("unsafe\n");
    }
    else{
        puts("safe\n");
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 100228;
vector<int> e[N];

void nein() {
    cout << "No\n";
    exit(0);
}

void ja() {
    cout << "Yes\n";
    exit(0);
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif  
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    for (int i = 1; i <= n; ++i) {
        if (e[i].size() % 2) {
            nein();
        }
    }

    int cn = 0;

    for (int i = 1; i <= n; ++i) {
        if (e[i].size() >= 6) {
            ja();
        }

        cn += e[i].size() > 2;
    }

    if (cn < 2) {
        nein();
    }

    if (cn > 2) {
        ja();
    }

    for (int i = 1; i <= n; ++i) {
        if (e[i].size() > 2) {
           for (int cur: e[i]) {
               int pv = i;
               int v = cur;
               while (e[v].size() == 2) {
                   int u = e[v][0] ^ e[v][1] ^ pv;
                   pv = v;
                   v = u;
               }

               if (v == i) {
                   ja();
               }
           }
        }
    }

    nein();
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,t,x,y,t1,t2,x1,x2,y1,y2,dst;
	bool can=true;
	t1=x1=y1=0;
	cin>>n;
	while(n--){
		cin>>t2>>x2>>y2;
		t=t2-t1;	x=x2-x1;	y=y2-y1;
		dst=abs(x)+abs(y);
		if(dst==0)	dst=2;
		if(t%dst!=0)	can=false;
		t1=t2;	x1=x2;	y1=y2;
	}
	if(can)	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 3000 + 5;
const ll oo = 1e17;

ll dp[maxn][maxn][4], a[maxn][maxn];
bool f[maxn][maxn];
int n, m, k;

ll solve(int x, int y, int h){
	if(x > n || y > m || h > 3)
		return -oo;

	if(x == n && y == m){
		if(h < 3 && f[x][y])
			return a[x][y];
		return 0;
	}

	if(dp[x][y][h] != -1)
		return dp[x][y][h];

	ll ans = -oo;
	ans = max(ans, solve(x, y + 1, h));
	ans = max(ans, solve(x + 1, y, 0));

	if(f[x][y] && h < 3){
		ans = max(ans, solve(x, y + 1, h + 1) + a[x][y]);
		ans = max(ans, solve(x + 1, y, 0) + a[x][y]);
	}

	return dp[x][y][h] = ans;
}
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
		
	cin >> n >> m >> k;
	for(int i = 0, x, y; i < k; i++){
		ll v;
		cin >> x >> y >> v;
		f[x][y] = true;
		a[x][y] = v;
	}

	memset(dp, -1, sizeof(dp));

	cout << solve(1, 1, 0) << endl;

	return 0;
}

Measured memory_bytes: 365488
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ld long double

using namespace std;

const int MIN = 1e3 + 2;
const int MXN = 1e5 + 3;
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 15;
const double EPS = 1e-9;

string st[27][27];
int h, w;

int main(){
	cin >> h >> w;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> st[i][j];
			if (st[i][j] == "snuke"){
				cout << char (j + 64) << i;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

const int MOD = 1e9 + 7;

i64 mod_pow(i64 x, i64 n = MOD - 2, i64 mod = MOD) {
	i64 ret = 1;
	
	while(n) {
		if(n & 1) (ret *= x) %= mod;
		(x *= x) %= mod;
		n >>= 1;
	}
	
	return ret;
}

std::vector<i64> fact(2e5 + 1, 1);
i64 comb(int a, int b) {
	if(a < b) return 0;
	
	return fact[a] * mod_pow(fact[b]) % MOD * mod_pow(fact[a - b]) % MOD;
}

int main() {
	for(i64 i = 0; i < 2e5; i++) (fact[i + 1] = fact[i] * (i + 1)) %= MOD;
	int n; cin >> n; n++; std::vector<int> a(n);
	std::vector<bool> used(n + 1, false); int tmp = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		
		if(used[a[i]]) tmp = a[i];
		used[a[i]] = true;
	}
	assert(tmp);
	
	int A = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] == tmp) {
			A = i;
			break;
		}
	}
	
	int B = 0;
	for(int i = n - 1; i >= 0; i--) {
		if(a[i] == tmp) {
			B = n - i - 1;
			break;
		}
	}
	
	for(int k = 1; k <= n; k++) {
		cout << (comb(n, k) - comb(A + B, k - 1) + MOD) % MOD << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    go(i,0,n)
    {
        cin>>a[i];
    }
    ll max1=INT_MIN,max2=INT_MIN,max_index;
    go(i,0,n)
    {
        if(max1<a[i])
        {
            max1=a[i];
            max_index=i;
        }
        else if(max2<a[i])
        {
            max2=a[i];
        }
    }
    go(i,0,n)
    {
        if(i==max_index) show(max2);
        else show(max1);
    }
    return 0;
}


Measured memory_bytes: 3200
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
from copy import deepcopy, copy

import queue
from collections import deque



def main():
    box_num, kagi_num = map(int, input().split())

    kagi_data = defaultdict(lambda: 10 ** 10)
    for i in range(kagi_num):
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        money = a[0]
        ind = 0
        for ele in b:
            ind += 2 ** (ele - 1)
        kagi_data[ind] = min(kagi_data[ind], money)

        for key, value in list(kagi_data.items()):
            kari = ind | key
            kagi_data[kari] = min(money + value, kagi_data[kari])

    ans = kagi_data[2 ** (box_num) - 1]
    if ans == 10 ** 10:
        print(-1)
    else:
        print(ans)



if __name__ == '__main__':
    main()



Measured memory_bytes: 48344
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K;
  cin >> N >> K;
  vector<vector<long>> data(N, vector<long> (3));
  vector<long> A(N), F(N);
  for(int i = 0; i < N; i++)cin >> A.at(i);
  for(int i = 0; i < N; i++)cin >> F.at(i);
  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  for(int i = 0; i < N; i++){
    data.at(i).at(1) = A.at(i);
    data.at(i).at(2) = F.at(i);
    data.at(i).at(0) = A.at(i) * F.at(i);
  }
  sort(data.begin(), data.end());
  long left = -1, right = data.at(N - 1).at(0), mid, count;
  while(right - left > 1){
    mid = left + (right - left) / 2;
    count = 0;
    for(int i = 0; i < N; i++){
      if(data.at(i).at(0) > mid){
        count += data.at(i).at(1) - mid / data.at(i).at(2);
      }
    }
    if(count <= K)right = mid;
    else left = mid;
  }
  cout << right << endl;
  return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int n,w; cin >> n >> w;
    vector <vector <ll> > item(n+1, vector <ll> (2,0)), dp(n+1,vector <ll> (w+1,0));
    for(int i = 1; i<=n; i++)
		cin>>item[i][0]>>item[i][1];
	
	dp[1][item[1][0]] = item[1][1];
	for(int i = 2; i <= n ; i++)
	{	for(int j = 0; j <= w; j++ )
		{	dp[i][j] = dp[i-1][j];
			if(item[i][0] <= j)	
				dp[i][j] = max(dp[i][j], dp[i-1][j-item[i][0]] + item[i][1]);
		}
	}	
	cout<< *max_element(dp[n].begin() ,dp[n].end()) ;
    return 0;
}

 


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    char now=s[0];
    int ans=0;
    rep(i,len(s)){
      if(s[i]!=now){
        now=s[i];
        ans++;
      }
    }
    cout<<ans<<endl;
}

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

int main(){
  int H, W; cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W)), B(H, vector<int>(W)), F(H, vector<int>(W));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> A[i][j];
    }
  }
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> B[i][j];
    }
  }
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      F[i][j] = abs(A[i][j] - B[i][j]);
    }
  }
  vector<vector<vector<int>>> score(H, vector<vector<int>>(W, vector<int>(30000,0)));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      for (int k=F[i][j]; k<30000-F[i][j]; k++){
        if (i==0&&j==0){
          if (abs(k-15000) == F[i][j]) score[i][j][k] = 1;
        }
        else if (i==0){
          if (score[i][j-1][k-F[i][j]] == 1 || score[i][j-1][k+F[i][j]] == 1) score[i][j][k] = 1;
        }
        else if (j==0){
          if (score[i-1][j][k-F[i][j]] == 1 || score[i-1][j][k+F[i][j]] == 1) score[i][j][k] = 1;
        }
        else{
          if (score[i][j-1][k-F[i][j]] == 1 || score[i][j-1][k+F[i][j]] == 1) score[i][j][k] = 1;
          if (score[i-1][j][k-F[i][j]] == 1 || score[i-1][j][k+F[i][j]] == 1) score[i][j][k] = 1;
        }
      }
    }
  }
  int ans = 30000;
  for (int i=0; i<30000; i++){
    if (score[H-1][W-1][i]==1) ans = min(ans, abs(i-15000));
  }
  cout << ans << endl;
}


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

int main() {
  int n,r;
  cin >> n >> r;
  if(n>=10) cout << r << endl;
  else cout << r+100*(10-n) << endl;
  
  return 0;
}

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

int main(){
    int N, T, i, j, k, ans = 0;
    scanf("%d %d", &N, &T);

    int t_i[N];
    for(i = 0; i < N; i++){
        scanf("%d", &t_i[i]);
    }

    for(i = 0, j = 0, k = 0; i < (t_i[N - 1] + T); i++, k--){
        if(t_i[j] == i){
            k = T;
            j++;
        }
        if(k > 0) ans++;
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
ll raise(ll a, ll b){
	ll ans = 1;
	while(b){
		if(b & 1){
			ans = (ans * a) % MOD;
		}
		b /= 2;
		a = (a * a) % MOD;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin >> n >> k;
	vector<ll> dp(k + 1);
	ll ans = 0;
	for(int i = k; i >= 1; i--){
		ll cur = raise(k / i, n);
		for(int j = 2 * i; j <= k; j += i){
			cur = (cur - dp[j] + MOD) % MOD;
		}
		dp[i] = cur;
		ans = (ans + (i * cur) % MOD) % MOD;
	}
	cout << ans << '\n';

}

Measured memory_bytes: 3988
let () =
    let s = read_line () |> Str.split (Str.regexp "") in
    let ans = List.fold_left (fun (a, b, c) elt ->
            match elt with
            | "a" -> (a + 1, b, c)
            | "b" -> (a, b + 1, c)
            |  _  -> (a, b, c + 1)
        ) (0, 0, 0) s
    in
    if ans = (1, 1, 1) then print_endline "Yes"
    else print_endline "No"


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,k;
  int data[55];
  cin>>n>>k;
  rep(i,n)cin>>data[i];
  sort(data,data+n);
  reverse(data,data+n);
  int ans=0;
  rep(i,k)ans+=data[i];
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
const int maxn = 10 + 2;
int n, arr[maxn], sum = 0;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i], sum += arr[i];
	sort(arr, arr + n);
	if (2 * arr[n - 1] >= sum)
		cout << "No\n";
	else
		cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($R,$G,$B,$N) =  explode(" ",trim(fgets(STDIN)));

$ret=0;
for($i=0;$i<=$N;$i++) {
  for($j=0;$j<=$N;$j++) {
    //この時点でわかりそう
    $left = $N - ($i*$R+$j*$G);
    if ($left < 0) continue;
    if (($left % $B)==0) {
      $ret++;
    }
  }
}
printf("%d\n",$ret);


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> v = {0}, index = {0};
    map<int,vector<int>> mp;
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        if(a > v.back()) {
            v.emplace_back(a);
            index.emplace_back(i);
        }
        mp[*lower_bound(v.begin(), v.end(), a)].emplace_back(a);
    }

    int64_t cnt = 0;
    vector<int64_t> ans(N);
    reverse(v.begin(), v.end());
    reverse(index.begin(), index.end());
    for(int i=0; i+1<v.size(); i++) {
        ans[index[i]] += cnt * (v[i] - v[i+1]);
        for(auto e: mp[v[i]]) {
            ans[index[i]] += e - v[i+1];
            ++cnt;
        }
    }

    for(auto e: ans) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 13424
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n; cin >> n;
	long long dp[n+10][5];

	int a[n][5];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			int m;cin >> m;
			if(i == 0){
				dp[i][j] = m;
			}
			a[i][j] = m;
		}
	}
	for(int i = 1; i < n; i++){	
			dp[i][0] = max(dp[i-1][1] + a[i][0],dp[i-1][2] + a[i][0]);
			dp[i][1] = max(dp[i-1][2] + a[i][1],dp[i-1][0] + a[i][1]);
			dp[i][2] = max(dp[i-1][0] + a[i][2],dp[i-1][1] + a[i][2]);
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<< endl;
}

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

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

using namespace std;

typedef long long ll;
const ll LLINF = LLONG_MAX;

struct Edge { int dst; ll w; };
struct Data {
  int cur,v; ll w;
  bool operator < ( const Data &e ) const {
    if( w != e.w ) return w > e.w;
    if( v != e.v ) return v > e.v;
    return cur > e.cur;
  }
};

#define MAX_V 510

int V,E;
ll v0,a,b,c;
ll mini[MAX_V][51][2];
vector<Edge> G[MAX_V];

ll cost1;
ll adhoc = LLINF;
void dijkstra(int sp,int v0) {
  rep(i,V) rep(j,c) mini[i][j][sp==(V-1)] = LLINF;
  priority_queue<Data> Q;
  Q.push((Data){sp,v0,0});
  mini[sp][v0][sp==(V-1)] = 0;
  while( !Q.empty() ) {
    Data data = Q.top(); Q.pop();
    if( data.w + cost1 >= adhoc ) return;
    rep(i,(int)G[data.cur].size()) {
      Edge &e = G[data.cur][i];
      int nv = ( a * data.v + b ) % c;
      ll nw = data.w + e.w * data.v;
      if( adhoc != LLINF && cost1 + nw >= adhoc ) continue;
      if( nw < mini[e.dst][nv][sp==(V-1)] ) {
        mini[e.dst][nv][sp==(V-1)] = nw;
        Q.push((Data){e.dst,nv,nw});
      }
    }
  }
}

void compute() {
  dijkstra(0,v0);
  ll ans = LLINF;
  rep(i,c) {
    if( mini[V-1][i][0] != LLINF ) {
      ll cost = mini[V-1][i][0];
      if( cost >= ans ) continue;
      cost1 = cost;
      dijkstra(V-1,i);
      ll tmp = LLINF;
      rep(j,c) tmp = min(tmp,mini[0][j][1]);
      if( tmp == LLINF ) continue;
      ans = min(ans,cost+tmp);
      adhoc = ans;
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> V >> E;
  rep(i,E) {
    int x,y,t;
    cin >> x >> y >> t;
    --x,--y;
    G[x].push_back((Edge){y,t});
    G[y].push_back((Edge){x,t});
  } 
  cin >> v0 >> a >> b >> c;
  compute();
  return 0;
}

Measured memory_bytes: 6940
import math
from sys import stdin
input = stdin.readline


class Eratos:
  def __init__(self, n):

    self.is_prime = [True]*(n+1)
    self.is_prime[0] = False
    self.is_prime[1] = False
    self.primes = []

    # for i in range(2, int(math.sqrt(n))+1):
    for i in range(2, n):
      if self.is_prime[i]:
        self.primes.append(i)
        j = i + i
        while j <= n:
          self.is_prime[j] = False
          j += i

  def all(self):
    return self.primes


def main():
  N = int(input())

  MAX = 10**6
  primes = Eratos(MAX).all()

  cnt = 0
  for p in primes:
    if N < p: break
    e = 1
    while not(N % p**e):
      N //= (p**e)
      cnt += 1
      e += 1

  if N > MAX:
    for p in primes:
      while N % p == 0:
        N //= p
    if N > MAX:
      print(cnt+1)
    else:
      print(cnt)
  else:
    print(cnt)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 85444
import math

a,b = map(lambda x: int(x), input().split())


hati_s = a/0.08
hati_l = (a+1)/0.08

ten_s = b/0.1
ten_l = (b+1)/0.1

#print(hati_s,hati_l,ten_s,ten_l)


def intersec(a_min,a_max,b_min,b_max):
    if a_min < b_min:
        if a_max < b_min:
            return [0,0]
        else:
            if a_max < b_max:
                return [b_min,b_max]
            else:
                return [b_min,a_max]
    else:
        if b_max < a_min:
            return [0,0]
        else:
            if b_max < a_max:
                return [a_min,a_max]
            else:
                return [a_min,a_max]


def min_int(pair):
    if pair == [0,0]:
        return -1
    else:
        return math.ceil(pair[0])



tmp = intersec(hati_s,hati_l,ten_s,ten_l)

if math.ceil(tmp[0]) == math.ceil(tmp[1]):
    print(-1)
else:
    tst = min_int(tmp)
    if math.floor(tst*0.08) == a and math.floor(tst*0.1) == b:
        print(tst)
    else:
        print(-1)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(int i=p;i<n;i++)
#define fr1(i,p,n) for(int i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (int)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        ll sum=0;
        map<ll,ll> mp;
        fr(i,0,n)
        {
            cin>>a[i];
            mp[a[i]]++;
            sum+=a[i];
        }
        ll q;
        cin>>q;
        while(q--)
        {
            ll b,c;
            cin>>b>>c;
            sum-=(mp[b]*b-mp[b]*c);
            cout<<sum<<endl;
            mp[c]+=mp[b];
            mp[b]=0;
        }
    }
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

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

    vector<long long> l(n);

    rep(i,n)cin>>l[i];

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

    long long ans=0;
    for(int i=0;i<n-2;i++){
        long long start=l[i];
        for(int k=i+1;k<n-1;k++){
            if(start==l[k])continue;
            for(int p=k+1;p<n;p++){
                if(l[k]==l[p])continue;
                if(start+l[k]>l[p]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3608