akhauriyash/Code-Regression huggingface dataset:
N = int(input())
As = list(sorted(list(map(int, input().split()))))

max_num = max(As)
tfs = [0 for _ in range(max_num+1)]

for A in As:
    if tfs[A] != 0:
        tfs[A] = 2
        continue
    for j in range(A, max_num+1, A):
        tfs[j]+=1

result = 0
for A in As:
    if tfs[A] == 1:
        result+=1
print(result)


Measured memory_bytes: 32236
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<set>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[100001];
char C[1200100];

ll num[524300];
int kazu[524300];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 % 524287;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 % 524287;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

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


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	set<pair<int, char*>> ST;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			ST.insert(mp(n, s[i]));
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 100000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	for (auto p : ST) {
		auto S = p.second;
		int k[26] = {};
		ll are = 0;
		for (int i = p.first - 1; i >= 1; i--) {
			int tmp = query(are);
			rep(j, 26) if ((tmp >> j & 1)) {
				k[j]++;
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 12672
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 5050;
int n,k;
int p[MAXN],c[MAXN],vis[MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    cin >> p[i];
  }
  for(int i=1;i<=n;i++){
    cin >> c[i];
  }
  int ans = -1e18;
  for(int i=1;i<=n;i++){
    if(!vis[i]){
      vi v;
      v.pb(i);
      vis[i]=1;
      int nxt = p[i];
      while(!vis[nxt]){
        v.pb(nxt);
        vis[nxt]=1;
        nxt = p[nxt];
      }
      int sum = 0;
      for(auto t:v){
        sum+=c[t];
      }
      // cerr << sum << endl;
      int s = v.size();
      for(int i=0;i<v.size();i++){
        int cur = 0;
        int rem = k;
        int idx = i+1;
        cur += c[v[i]];
        idx = (i+1)%s;
        int cnt = 1;
        while(idx!=i){
          ans = max(ans,cur);
          ans = max(ans,cur+((k-cnt)/s)*sum);
          if(cnt>=rem)break;
          cur += c[v[idx]];
          idx = (idx+1)%s;
          ans = max(ans,cur);
          cnt++;
          ans = max(ans,cur+((k-cnt)/s)*sum);
        }
      }
    }
  }
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
int main(){int a=1;
  string s,t; cin>>s>>t;
  for(int i=97;i<123;i++){
    char p=i;if(s+p==t){a=0;break;}}
         if(a)cout<<"No"<<endl;
          else cout<<"Yes"<<endl;}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

vector<P> cal(vector<P> &v,double a,double b){
  vector<P> res;
  for(int i=0;i<v.size();i++){
    double l=v[i].real(),r=v[i].imag();
    if(l<=a&&b<=r)res.push_back(P(l,a)),res.push_back(P(b,r));
    else if(l<=a&&a<=r)res.push_back(P(l,a));
    else if(l<=b&&b<=r)res.push_back(P(b,r));
    else if(a>l||r>b)res.push_back(v[i]);
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  double x,y;
  P p[100];
  for(int i=0;i<n;i++)cin>>x>>y,p[i]=P(x,y);
  for(int i=0;i<n;i++){
    vector<P> v;
    v.push_back(P(-M_PI,M_PI));
    for(int j=0;j<n;j++){
      if(i==j)continue;
      P a=P(0,-1)*(p[j]-p[i]);
      double d=arg(a);
      if(d>0)v=cal(v,d,M_PI),v=cal(v,-M_PI,d-M_PI);
      else v=cal(v,d,d+M_PI);
    }
    double ans=0;
    for(int j=0;j<(int)v.size();j++)ans+=v[j].imag()-v[j].real();
    cout<<ans/2/M_PI<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"(n,m),*a=[list(map(int,s.split()))for s in open(0).readlines(0)]\n"
"for i,j in a[:n]:l=[abs(x-i)+abs(y-j)for x,y in a[n:]];print(1+l.index(min(l)))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
def solve():
  K = list(map(int,list(input())))
  digit = len(K)
  D = int(input())
  dp = [[[0]*D for _ in range(2)] for _ in range(digit+1)]
  dp[0][1][0] = 1
  mod = 10**9+7
  for k in range(1,digit+1):
    for d in range(D):
      dp[k][1][d] = dp[k-1][1][(d-K[k-1])%D]
      for p in range(10):
        dp[k][0][d] += dp[k-1][0][(d-p)%D] 
      for p in range(K[k-1]):
        dp[k][0][d] += dp[k-1][1][(d-p)%D]
      dp[k][0][d] %= mod
  ans = (dp[-1][0][0]+dp[-1][1][0]-1)%mod
  return ans
print(solve())

Measured memory_bytes: 92176
import sys
import os

def file_input():
    f = open('ABC160/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,X,Y=map(int, input().split())

    out=[0]*(N-1)

    for i in range(1,N):
        for j in range(i+1,N+1):
            out[min(j-i,abs(j-Y)+1+abs(X-i),abs(j-X)+1+abs(i-Y))-1]+=1

    [print(x) for x in out]

if __name__ == '__main__':
    main()


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

// 119**5 = 23863536599
// 120**5 = 24883200000 ここで初めて1少ない数の5乗との差が10**9を超える
#define MAX 119

int main()
{
    ll x; cin >> x;

    for (ll a = -MAX+1; a <= MAX; a++) {
        for (ll b = -MAX; b <= MAX-1; b++) {
            if (a == b) continue;
            ll a2 = a * a;
            ll a5 = a2 * a2 * a;
            ll b2 = b * b;
            ll b5 = b2 * b2 * b;
            if (a5 - b5 == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        } 
    }
}


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

int main(){

	int n, imp;

	cin >> n;

	if (n % 2 == 1)
	{
		imp = (n+1)/2;
	}else
		imp = n/2;

	printf("%.6f\n" ,(1.0*imp/n));

	return 0;
}

Measured memory_bytes: 256
n,m,k = map(int, input().split())
l1 = list(map(int, input().split()))
ans = 0
sc = 0

for i in range(n):
  sc = 0
  lt = list(map(int,input().split()))
  for j in range(m):
    sc += l1[j]*lt[j]

  if sc + k> 0:
    ans += 1
print(ans)

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

using namespace std;

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

    vector<int> a(n + 5, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    vector<int> l(n + 5, 0);
    l[1] = a[1];
    for (int i = 2; i <= n; ++i) {
        l[i] = __gcd(l[i - 1], a[i]);
    }

    vector<int> r(n + 5, 0);
    r[n] = a[n];
    for (int i = n - 1; i >= 1; --i) {
        r[i] = __gcd(r[i + 1], a[i]);
    }


    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, __gcd(l[i - 1], r[i + 1]));
    }
    cout << ans << endl;
    return 0;
}


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


#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

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

    int r,s,p;
    cin >> r >> s >> p;
    string str;
    cin >> str;

    int score=0;
    bool s_flag,p_flag,r_flag;
    s_flag = p_flag = r_flag = false;
    
    rep(i,k){
        int sub_score = 0;
        s_flag = p_flag = r_flag = false;
        
        for(int j = i; j < n; j += k){
            if(str[j]=='s'){
                if(!s_flag){ sub_score += r;}
                s_flag = !s_flag;

                r_flag = false;
                p_flag = false;
            }else if(str[j]=='p'){
                if(!p_flag){ sub_score += s;}
                p_flag = !p_flag;

                r_flag = false;
                s_flag = false;
            }else if(str[j]=='r'){
                if(!r_flag){sub_score += p;}
                r_flag = !r_flag;

                s_flag = false;
                p_flag = false;
            }
        }
        score += sub_score;
    }

    cout << score << endl;

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

ll N,Q,H,S,D;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> Q >> H >> S >> D >> N;
	N *= 4;
	esc(N / 8 * min({Q * 8,H * 4,S * 2,D}) + N % 8 / 4 * min({Q * 4,H * 2,S}) + N % 4 / 2 * min(Q * 2,H) + N % 2 * Q);
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod1 = 1e9 + 7;
const int mod2 = 1e9 + 9;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
const ll b1 = 1123456122;
const ll b2 = 1122541422;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int p = 0;
	ll answer = 0;
	int now = 0;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (i > 0) {
			--cnt;
			now ^= a[i - 1];
		}
		while (p < n && (a[p] & now) == 0) {
			now ^= a[p];
			++p;
			++cnt;
		}	
		answer += cnt;
	}
	
	cout << answer << '\n';
}


Measured memory_bytes: 1024
// 文字列大好きいろはちゃんイージー
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N, L;
    string S[110];
    string su = "";
    cin >> N >> L;
    for (int i = 0; i < N; ++i) cin >> S[i];
    sort(S, S+N);
    for (int i = 0; i < N; ++i) su += S[i];
    cout << su << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = (1..n).map { sc.nextInt() }
    var ans = Int.MAX_VALUE
    for (p in 1..100) {
        ans = Math.min(ans, x.map { (it - p) * (it - p) }.sum())
    }
    println(ans)
}


Measured memory_bytes: 29716
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = 0, mini = 9999, counter = 0, s = 0, endp = 0, checker = 0;
long long int one = 0, two = 0, four = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001],sec[100001],pointx[100001],pointy[100001];
long long int iremono2[100001],check[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input,input2;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> a;
	cout << 48-a << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Di = Sarray();
            for(var i=N; ;++i)
            {
                var k = i.ToString();
                var isAns = true;
                foreach(var d in Di)
                {
                    if (k.Contains(d.ToString()))
                    {
                        isAns = false;
                        break;
                    }
                }
                if (isAns)
                {
                    WriteLine(i);
                    return;
                }
            }
            //Out.Flush();
        }
    }
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define let const auto
#define USE1(T) template <typename T>
#define USE2(T, U) template <typename T, typename U>
#define I_ inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

USE1(T) using duo = std::pair<T, T>;
USE1(T) using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE2(T,U) I_ bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U) I_ bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int) I_ T in(){T x;std::cin>>x;return x;}
USE1(T=int) I_ vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T) vec<T> ndvec(T v,int n){return vec<T>(n, v);}
USE2(T,...Ts) auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T) I_ void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts) I_ void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
I_ int rd(){int x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
I_ void wr(int x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
struct IoSetup {
  IoSetup(){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = LLONG_MAX;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  ll N = in(), x = in();
  auto A = in<ll>(N);
  auto dp = ndvec(infll, N, N);
  rep(i, N) {
    dp[i][0] = A[i];
    rep(j, 1, N) { dp[i][j] = min(A[(i + N - j % N) % N], dp[i][j - 1]); }
  }

  ll mini = infll;
  rep(slide, N) {
    ll cost = 0;
    rep(i, N) cost += dp[i][slide];
    chmin(mini, cost + slide * x);
  }
  pr(mini);

  return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'G') a[i] = 1;
    if (s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j) {
    int k = j + (j-i);
    if (k < n) {
      if (a[i] == a[j]) continue;
      if (a[i] == a[k]) continue;
      if (a[k] == a[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
int map[10][10];
void las(int y,int x){
    map[y][x]=0;
    int i,o,mv[5]={0,1,0,-1,0};
    for(i=0;i<3;i++,mv[1]++,mv[3]--){
        for(o=0;o<4;o++){
            if(y+mv[o]>0 && y+mv[o]<9 && x+mv[o+1]>0 && x+mv[o+1]<9 && map[y+mv[o]][x+mv[o+1]])
                las(y+mv[o],x+mv[o+1]);
        }
    }
}

int main(void){
    int num,i,o,x,y,data=1;
    scanf("%d",&num);
    for(;num;num--){
        for(i=1;i<=8;i++)
            for(o=1;o<=8;o++)
                scanf("%1d",&map[i][o]);
        scanf("%d\n%d",&x,&y);
        las(y,x);
        printf("Data %d:\n",data++);
        for(i=1;i<=8;i++)
            for(o=1;o<=8;o++)
                printf("%d%s",map[i][o],o==8?"\n":"");
    }
    return 0;
}

Measured memory_bytes: 596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, k; cin >> n >> k;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		int v = 2*min(x, abs(k - x));
		ans += v;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n , m;
    cin >> n >> m;
    if (n == 1){
        if(m == 2)cout << 3 << endl;
        else cout << 2 << endl;
    }else if(n == 2){
        if(m == 1) cout << 3 << endl;
        else cout << 1 << endl;
    }else{
        if(m == 1) cout << 2 << endl;
        else cout << 1 << endl;
    }
}

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


int main() {
  int n;
  cin >> n;
  int ans = 0;
  int max_p=0;
  for(int i=0;i<n;i++){
    int p;
    cin >> p;
    ans += p;
    if(p>max_p) max_p = p; 
  }
  cout << ans - max_p/2 << endl;
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  (s == u) ? cout << a-1 << " " << b << "\n" : cout << a << " " << b-1 << "\n";
return 0;
}


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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    const long long mod=1e9+7;
    long long dp[100005];
    long long  power(long long a, long long b){
        if(b==0)
            return 1LL;
        if(b==1)
            return 1LL * a%mod;
        if(b%2==0){
            long long x=power(a,b/2);
            x=(x*x)%mod;
            return x;
        }
        else{
            long long x=power(a,(b-1)/2);
            x=(x*x)%mod;
            return (x*a)%mod;
        }

    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        long long n,k;
        cin>>n>>k;
        for(int i=k;i>=1;i--){
            dp[i]=power(k/i,n);
            for(int j=2*i ; j<=k ; j+=i)
                dp[i]-=dp[j];
        }
        long long ans=0;
        for(int i=1;i<=k;i++){
            ans=(ans+(dp[i]*i)%mod)%mod;
        }
        cout<<ans%mod;
        return 0;
    }


Measured memory_bytes: 4440
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

const int MAX_s = 1005;
int n, m, M, S, s;

int main() {
    while(true) {
        cin >> n;
        if(n == 0) {
            break;
        }

        S = 0;
        m = MAX_s;
        M = 0;
        for(int i = 0; i < n; i++) {
            cin >> s;
            S += s;
            m = min(m, s);
            M = max(M, s);
        }

        cout << (int)((S - m - M) / (n - 2)) << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
class Main{
    public static void main(String[] a){
                int x = 0;
		int y = 0;
		int z = 0;
		
		for (x = 1; x <= 9; x++){
			for (y = 1; y <= 9; y++){
				z= x*y;
				System.out.println(x + "x" + y + "=" + z);
			}
		}

    }
}

Measured memory_bytes: 23948
#include <stdio.h>
 
int main(){
   int x, y, tmp;

   while(1){
      scanf("%d %d", &x, &y);

      if(x==0 && y==0) break;

      if(x>y){
         tmp = x;
         x = y;
         y = tmp;
      }

      printf("%d %d\n", x, y);
   }

   return 0;
}

Measured memory_bytes: 600
import scala.io.StdIn.readLine

object Main extends App {

  val lines = Iterator.continually(readLine())
  val scores = {
    val xs = for {
      line          <- lines
      Array(m, f, r) = line.split(" ").map { _.toInt }
    } yield (m, f, r)

    xs.takeWhile { _ != (-1, -1, -1) }
  }

  val results = scores.map(solve)

  results.foreach(println)

  def solve(score: (Int, Int, Int)): String = score match {
    case (-1, _, _) | (_, -1, _) => "F"
    case (m, f, r)               =>
      val s = m + f
      if (s >= 80) "A"
      else if (s >= 65) "B"
      else if (s >= 50) "C"
      else if (s >= 30) if (r >= 50) "C" else "D"
      else "F"
  }
}



Measured memory_bytes: 44100
#include <iostream>

#define INF 100000001
#define MAX_H 20001

using namespace std;

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

    int dp[MAX_H];
    fill(dp, dp + MAX_H, INF);
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        for (int j = 0; j < H; j++) {
            if (dp[j] != INF) {
                dp[j + A] = min(dp[j + A], dp[j] + B);
            }
        }
    }

    int ans = INF;

    for (int i = H; i < MAX_H; i++) {
        ans = min(ans, dp[i]);
    }

    cout << ans << endl;
}

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

int main() {
  int N,K;
  int num = 1;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    if(num*2<num+K){
      num*=2;
    }else{
      num+=K;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// AC
public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		int n=sc.nextInt();
		for(int j=1;j<=n;j++){
			int k=sc.nextInt();
			println("Case "+j+":");
			for(int i=0; i<10; i++){
				k=(k*k/100)%10000;
				println(""+k);
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;

void solve() {
	int n, l; cin >> n >> l;
	int r = l + n - 1;

	int eat;
	if (l > 0) eat = l;
	else if (r < 0) eat = r;
	else eat = 0;

	int res = (r + l)*(r - l + 1) / 2 - eat;
	cout << res << endl;
}

int main(void) {
	solve();
	SEKAI_NO_OWARI
}

Measured memory_bytes: 256
//String Palindrome 

#include<iostream>

using namespace std;

bool Palindrome(string s,int start, int end)
{
    int flag = 1;
    for(int i = start;i<=end;i++)
    {
        if(s[i]!= s[end])
        {
            flag = 0;
            break;
        }
        
        end--;
    }
    
    if(flag == 0)
        return false;
    else
        return true;
}


int main()
{
    string s; cin>>s;
    
    int len = s.length();
    
    if( Palindrome(s,0,len-1) && Palindrome(s,0,(len-1)/2 - 1) && Palindrome(s,(len+3)/2 - 1,len-1) )
        cout<<"Yes"<<endl;
    
    else
        cout<<"No"<<endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#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)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	vector<int> h(n);
	rep(i, n)cin>>h[i];
	//sort(h.rbegin(),h.rend());

	ll fire = a - b;
	ll ng = 0, ok = 1e9+5;
	while(ok - ng > 1){
		ll mid = ok + ng; mid /= 2;
		ll tmp = 0;
		rep(i,n){
			ll hp = h[i];
			hp -= mid * b;
			if(hp <= 0) continue;
			tmp += (hp + fire - 1) / fire;
		}
		if(tmp <= mid){
			ok = mid;
		} else {
			ng = mid;
		}
	}
	cout << ok << endl;
}


Measured memory_bytes: 3776
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,fma")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 1<<20;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int sz = 0;
array<int, 4> b[maxn];
int type[maxn], rem[maxn];
set<array<int, 2>> L, T;
void fuck(int i) {
	rem[i] = 1;
	//cout << b[i][2] << " " << i << endl;
	if(T.count({b[i][2], i})) T.erase({b[i][2], i});
	if(L.count({b[i][0], i})) L.erase({b[i][0], i});
}
void new_block(array<int, 4> f, int m) {
	if(f[0]>f[1]||f[2]>f[3]) return;
	//cout << f[0] << " " << f[1] << " " << f[2] << " " << f[3] << " " << m << endl;
	if(m&1) T.insert({f[2], sz});
	if(m&2) L.insert({f[0], sz});
	type[sz] = m;
	b[sz++] = f;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	new_block({2, n-1, 2, n-1}, 3);
	for(int t, x; q--;) {
		cin >> t >> x;
		if(t == 1) {
			auto it = T.lower_bound({x, 1<<30});
			if(it == T.begin()) continue;
			it--;
			int p = it->at(1);
			//cout << b[p][0] << " " << b[p][1] << " " << b[p][2] << " " << b[p][3] << endl;
			fuck(p);
			new_block({b[p][0], b[p][1], b[p][2], x-1}, type[p]);
			new_block({b[p][0], b[p][1], x+1, b[p][3]}, min(type[p], type[p]^2));
		} else {
			auto it = L.lower_bound({x, 1<<30});
			if(it == L.begin()) continue;
			it--;
			int p = it->at(1);
			fuck(p);
			new_block({b[p][0], x-1, b[p][2], b[p][3]}, type[p]);
			new_block({x+1, b[p][1], b[p][2], b[p][3]}, min(type[p], type[p]^1));
		}
		/*
		for(int i = 0; i < sz; i++) if(!rem[i]) cout << b[i][0] << " " << b[i][1] << " "<< b[i][2] << " " << b[i][3] << '\n';
		for(auto i : T) cout << i[0] << " " << i[1] << ", "; cout << '\n';
		for(auto i : L) cout << i[0] << " " << i[1] << ", "; cout << '\n';
		cout << "===\n";
		*/
	}
	ll ans = 0;
	for(int i = 0; i < sz; i++) if(!rem[i]) {
		int X = b[i][1]-b[i][0]+1, y = b[i][3]-b[i][2]+1;
		ans += X*1ll*y;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 15340
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int E = 0, W = 0;
    vint sumE(n), sumW(n);
    rep(i, n) {
        sumE[i] = E;
        sumW[i] = W;
        if (s[i] == 'E') E++;
        else W++;
    }
    int ans = INF;
    rep(i, n) {
        int tmp = sumW[i] + (E - sumE[i]);
        if (s[i] == 'E') tmp--;
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

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

    vector<vector<ll>> sushi;
    sushi.push_back({0, 0});
    for (int i = 0; i < n; i++) {
        ll x, v;
        cin >> x >> v;
        sushi.push_back({x, v});
    }
    sushi.push_back({c, 0});

    vector<ll> c_sumLeft(n + 1);
    for (int i = 1; i <= n; i++) {
        c_sumLeft[i] = c_sumLeft[i - 1] + sushi[i][1] - (sushi[i][0] - sushi[i - 1][0]);
    }
    vector<ll> c_sumRight(n + 1);
    for (int i = 1; i <= n; i++) {
        c_sumRight[i] = c_sumRight[i - 1] + sushi[n - i + 1][1] - (sushi[n - i + 2][0] - sushi[n - i + 1][0]);
    }

    vector<ll> maxc_sumLeft = c_sumLeft;
    for (int i = 1; i <= n; i++) maxc_sumLeft[i] = max(maxc_sumLeft[i], maxc_sumLeft[i - 1]);
    vector<ll> maxc_sumRight = c_sumRight;
    for (int i = 1; i <= n; i++) maxc_sumRight[i] = max(maxc_sumRight[i], maxc_sumRight[i - 1]);

    ll ret = 0;
    for (int left = 0; left <= n; left++) {
        ret = max(ret, (c_sumLeft[left] - sushi[left][0]) + maxc_sumRight[n - left]);
    }
    for (int right = 0; right <= n; right++) {
        ret = max(ret, (c_sumRight[right] + sushi[n - right + 1][0]) + maxc_sumLeft[n - right] - c);
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 9520
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXRR 1000 //√MAXR以上の数を設定する
#define MAXR 200000

ll fac[MAXR], finv[MAXR], inv[MAXR];

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

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


void Prime_factorize(vector<ll>& v,ll n){
    if(n<=1) return;
    ll l=ll(sqrt(n));
    for(ll i=2;i<l+1;i++){
        if(n%i==0){
            Prime_factorize(v,i);Prime_factorize(v,ll(n/i));return;
        }
    }
    v.push_back(n);return;
}

signed main(){
    COMinit();
    map<ll,ll> ma;
    ll n,m;cin >> n >> m;
    vector<ll> vp;
    Prime_factorize(vp,m);
    REP(i,SIZE(vp)){
        ma[vp[i]]++;
    }
    ll ans=1;
    for(auto i=ma.begin();i!=ma.end();i++){
        //cout << ans << endl;
        //cout << i->S+(n-1) << " " << n-1 << endl;
        //cout << COM(i->S+(n-1),n-1) << endl;
        ans*=COM(i->S+(n-1),n-1);
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;
                         
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
    ll n, k;
    cin >> n >> k;
    vector <ll> a;
    ll sum = 0, xx = 0;
    for (int i = 0; i < n; i++) {
     	ll x;
     	cin >> x;
     	sum += x;
     	a.pb(x);
    }
    sort(all(a));
    reverse(all(a));
    for (int i = 0; i < min(k, (ll) sz(a)); i++) {
     	xx += a[i];
    }
    cout << sum - xx;
    re 0;
}

Measured memory_bytes: 2420
import heapq

n, m = map(int, input().split())
baitos = [list(map(int, input().split())) for _ in range(n)]

baitos = sorted(baitos)
# print(sorted(baitos))
# print(baitos)

money = 0
avail = []
# heapq.heapify(avail)
index = 0
for day in range(m):
    while index < n and baitos[index][0] <= day + 1:
        heapq.heappush(avail, -baitos[index][1])
        index += 1
        # baitos.remove(baitos[0])
    # for baito in baitos:
    #     print(baito)
    #     if baito[0] > day + 1:
    #         print("break")
    #         break
    #     else:
    #         heapq.heappush(avail, -baito[1])
    #         baitos.remove(baito)
    # print("baitos", baitos)
    # print("avail", avail)
    if avail:

        money += -heapq.heappop(avail)
        # print(day, money)
    # money += max[1]
    # baitos.remove(max)

print(money)


Measured memory_bytes: 31964
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c = getchar();
    int p = 1;
    x = 0;
    while(!isdigit(c)){
        if(c == '-')p = -1;
        c = getchar();
    }
    while(isdigit(c)){
        x = (x << 1) + (x << 3) + (c ^ '0');
        c = getchar();
    }
    x *= p;
}
const int maxn = 100050;
int a[maxn], n, b[maxn], ta[maxn], tb[maxn], ans, tn, tot, head[maxn];
bool flag, vis[maxn], s[maxn];
struct edge{
    int to, next;
}e[maxn << 1];
inline void add(int u, int v){
    e[++tot].to = v;
    e[tot].next = head[u];
    head[u] = tot;
}
inline void dfs(int u){
    vis[u] = 1;
    for(register int i = head[u]; i; i = e[i].next){
        int v = e[i].to;
        if(!vis[v])dfs(v);
    }
}
int main(){
    //freopen(".out", "w", stdout);
    read(n);
    for(register int i = 1; i <= n; ++i){
        read(a[i]);
        a[n + 1] ^= a[i];
    }
    for(register int i = 1; i <= n; ++i){
        read(b[i]);
        b[n + 1] ^= b[i];
    }
    memset(ta, -1, sizeof(ta)), memset(tb, -1, sizeof(tb));
    for(register int i = 1; i <= n + 1; ++i){
        ta[i] = a[i];
    }
    for(register int j = 1; j <= n + 1; ++j){
        tb[j] = b[j];
    }
    sort(ta + 1, ta + 1 + n + 1), sort(tb + 1, tb + 1 + n + 1);
    for(register int i = 1; i <= n + 1; ++i){
        if(ta[i] != tb[i]){
            puts("-1");
            return 0;
        }
    }
    ++n;
    tn = unique(ta + 1, ta + 1 + n) - (ta + 1);
    tn = unique(tb + 1, tb + 1 + n) - (tb + 1);
    for(register int i = 1; i <= n; ++i){
        a[i] = lower_bound(ta + 1, ta + 1 + tn, a[i]) - (ta + 1);
        b[i] = lower_bound(tb + 1, tb + 1 + tn, b[i]) - (tb + 1);
    }
    for(register int i = 1; i <= n; ++i){
        if(a[i] != b[i] || i == n){
            if(i != n)++ans;
            add(a[i], b[i]), add(b[i], a[i]);
            s[a[i]] = s[b[i]] = 1;
        }
    }
    if(ans == 0){
        puts("0");
        return 0;
    }
    for(register int i = 1; i <= tn; ++i){
        if(!vis[i] && s[i]){
            dfs(i);
            ++ans;
        }
    }
    printf("%d\n", ans - 1);
    return 0;
}

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

unordered_map<int, bool> is;

int main() {

    int n,m,k;
    cin>>n>>m>>k;
    
    for(int i=0; i<=n; i++) {
        for(int j=0; j<=m; j++) {
            is[i*j + (n-i)*(m-j)] = 1;
        }
    }
    
    if(is[k]) {
        cout<<"Yes\n";
    }
    else {
        cout<<"No\n";
    }

    
    return 0;
}

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

void Counting(vector<int>& Count, int i, string Letter, char alphabet, char Alphabet)
{
	for(unsigned int j = 0; j < Letter.size(); j++){
		if(Letter[j] == alphabet || Letter[j] == Alphabet) Count[i]++;
	}
}

int main()
{
	vector<int> Count(26, 0);
	string Letter;
	while(getline(cin, Letter)){
		for(unsigned int i = 0; i < 26; i++){
			char alphabet = 'a';
			char Alphabet = 'A';
			alphabet += i;
			Alphabet += i;
			Counting(Count, i, Letter, alphabet, Alphabet);
		}
	}

	for(unsigned int i = 0; i < 26; i++){
		char alphabet = 'a' + i;
		cout << alphabet << " : " << Count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1184
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	
	int a,b;
	cin>>a>>b;
	cout<<(a+b-1)/b<<endl;
}









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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> child(n);
    vector<ll> dp(k + 1);
    dp[0] = 1;
    for (int i = 0; i < n; i++){
        cin >> child[i];
    }
    for (int i = 0; i < n; i++){
        vector<ll> pre(k + 1);
        for (int candies = k; candies >= 0; candies--){
            int L = 1;
            int R = min(child[i], k - candies);
            if (L <= R){
                pre[candies + L] += dp[candies];
                pre[candies + L] %= mod;
                if (candies + R + 1 <= k){
                    pre[candies + R + 1] = (pre[candies + R + 1] - dp[candies] + mod) % mod;
                }
            }
        }
        for (int j = 0; j < k; j++){
            pre[j + 1] = (pre[j + 1] + pre[j] + mod) % mod;
        }
        for (int candies = 0; candies <= k; candies++){
            dp[candies] = (dp[candies] + pre[candies] + mod) % mod;
        }
    }
    cout << dp[k];
    return 0;
}


Measured memory_bytes: 1792
import sys

for i in sys.stdin.readlines()[:-1]:
    h,w = map(int,i.strip().split())
    for i in range(h):
        for j in range(w):
            if (i+j) % 2 == 0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()

Measured memory_bytes: 9024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var number = ReadLine();
        for (var i = 0; i < Pow(2, 3); i++)
        {
            var sum = ToInt32(number.Substring(0, 1));
            var resu = number.Substring(0, 1);
            for (var j = 0; j < 3; j++)
            {
                var n = ToInt32(number.Substring(j + 1, 1));
                if (((i >> j) & 1) == 1) { sum += n; resu += "+" + n; }
                else { sum -= n; resu += "-" + n; }
            }
            if (sum == 7) { WriteLine(resu+"=7"); return; }
        }
    }
}


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

int main()
{
    string a,b,u;
    cin>>a>>b;
    int c,d;
    cin>>c>>d;
    cin>>u;

    if(u==a)
        cout<<c-1<<" "<<d<<endl;
    else
        cout<<c<<" "<<d-1<<endl;

    return 0;

}


Measured memory_bytes: 256