akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[200][8], a[300000], b[300000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<vector<LL>>vec;
vector<Pll>v,v2;
map<LL,Pll>ma;
multiset<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m >> k;
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, m) {

			rep(mask, 1 << (m - 1)) {
				bool ok = 1;
				rep(k, m-2) {
					if (((mask >> k)&1)&((mask >> (k + 1))&1) && (mask >> k) & 1) {
						ok = false;
					}
				}

				if (!ok)continue;
				if (j > 0 && ((mask >> (j-1)) & 1)) {
					dp[i + 1][j - 1] += dp[i][j];
					dp[i + 1][j - 1] %= MOD;
				}
				else if (j < m - 1 && ((mask >> (j)) & 1)) {
					dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j + 1] %= MOD;
				}
				else {
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j] %= MOD;
				}
				

			}

		}
	}
	cout << dp[n][k-1]%MOD << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n;
    std::cin >> n;
    i64 ret = std::numeric_limits<i64>::max();
    for (i64 i = 1; i * i <= n; i++) {
        if (n % i) continue;
        i64 x = i, y = n / i;
        ret = std::min(ret, x + y - 2);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}

int main(){
   int n;
   cin>>n;
   map<string,int> mp;
   vector<string> g;
   rep(i,n){
      string s;
      cin >> s;
      sort(s.begin(),s.end());
      mp[s]++;
      if(mp[s]==1) g.push_back(s);
   }
   ll sum=0;
   rep(i,g.size()){
      ll a = mp[g[i]];
      if(a>=2)sum += a*(a-1)/2;
   }
   cout << sum << endl;
   return 0;
}

Measured memory_bytes: 16628
#include <stdio.h>

#define abs(v) ((v ^ (v >> 31)) - (v >> 31))

int main() {
	int x;
	int y;
	int a = 1;
	int yltx = 1;
	int xlty = 1;
	int zero = 0;

	scanf("%d%d", &x, &y);

	if(x > 0 && y > 0) {
		yltx = 0;
		xlty = 2;
	} else if(x < 0 && y < 0) {
		yltx = 2;
		xlty = 0;
	} else if(x == 0 && y > 0) {
		yltx = 0;
	} else if(y == 0 && x < 0) {
		xlty = 0;
	}

	if(abs(x) < abs(y)) {
		a = abs(y) - abs(x) + yltx;
	} else if(abs(x) > abs(y)) {
		a = abs(x) - abs(y) + xlty;
	} else if(x == y) {
		a = 0;
	}

	printf("%d\n", a);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
	int flag[123456 * 2 + 1], i, j, n, count;
	scanf("%d",&n);
	for(i = 0;i <= 123456 * 2 + 1;i++)
		flag[i] = 1;
	while(n != 0){
		for(i = 2;i <= sqrt((double)2 * n);i++){
			for(j = i * 2;j <= 2 * n;j += i)
				flag[j] = 0;
		}
		count = 0;
		for(i = n + 1;i <= 2 * n;i++){
			if(flag[i] == 1)
				count++;
		}
		printf("%d\n",count);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1992
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
inline int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int n,m,ans,dp[8080][210],jc[8080],jcv[8080],f[16384],g[16384];
int w[14][8192];
void init()
{
	jc[0]=1;
	for(int i=1;i<=n+2;++i)jc[i]=1ll*jc[i-1]*i%mod;
	jcv[n+2]=kpow(jc[n+2],mod-2);
	for(int i=n+2;i;--i)jcv[i-1]=1ll*jcv[i]*i%mod;
	for(int len=1,i=0;len<16384;len<<=1,++i)
	{
		int tmp=kpow(3,(mod-1)/len/2);
		w[i][0]=1;
		for(int j=1;j<len;++j)w[i][j]=1ll*w[i][j-1]*tmp%mod;
	}
}
void ntt(int f[],int opt,int lim)
{
	static int r[16384],now;
	if(now!=lim)
	{
		now=lim;
		for(int i=1;i<lim;++i)r[i]=(r[i>>1]>>1)|(i&1?lim>>1:0);
	}
	for(int i=1;i<lim;++i)if(i<r[i])swap(f[i],f[r[i]]);
	int x,y;
	for(int len=1,i=0;len<lim;len<<=1,++i)
		for(int j=0;j<lim;j+=len<<1)
			for(int k=0;k<len;++k)
			{
				x=f[j+k],y=1ll*f[j+k+len]*w[i][k]%mod;
				f[j+k]=pl(x,y);
				f[j+k+len]=pl(x,mod-y);
			}
	if(opt==-1)
	{
		reverse(f+1,f+lim);
		int inv=kpow(lim,mod-2);
		for(int i=0;i<lim;++i)f[i]=1ll*f[i]*inv%mod;
	}
}
int C(int a,int b)
{
	if(a<b)return 0;
	return 1ll*jc[a]*jcv[b]%mod*jcv[a-b]%mod;
}
int main()
{
	scanf("%d %d",&n,&m);
	init();
	int lim=1;
	while(lim<=2*n)lim<<=1;
	dp[0][0]=1;
	for(int j=1;j<=m;++j)
	{
		for(int i=0;i<=n;++i)dp[i][j]=1ll*dp[i][j-1]*(1+C(i+1,2))%mod;
		memset(f,0,lim<<2),memset(g,0,lim<<2);
		for(int i=0;i<=n;++i)f[i]=1ll*dp[i][j-1]*jcv[i]%mod,g[i]=jcv[i+2];
		g[0]=0;
		ntt(f,1,lim),ntt(g,1,lim);
		for(int i=0;i<lim;++i)f[i]=1ll*f[i]*g[i]%mod;
		ntt(f,-1,lim);
		for(int i=0;i<=n;++i)dp[i][j]=(dp[i][j]+1ll*f[i]*jc[i+2])%mod;
	//	for(int i=0;i<=n;++i)printf("%d ",dp[i][j]);printf("\n");
	}
	for(int i=0;i<=n;++i)ans=(ans+1ll*dp[i][m]*C(n,i))%mod;
	printf("%d",ans);
	return 0;
}


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

using namespace std;

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

typedef complex<double> P;

namespace std {
  bool operator < (P const& a, P const& b) {
    if(real(a) != real(b)) return real(a) < real(b);
    return imag(a) < imag(b);
  }
}

double const EPS = 1e-8;

#define prev(G, i) ( G[((i-1)+G.size())%G.size()] )
#define curr(G, i) ( G[i%G.size()] )
#define next(G, i) ( G[(i+1)%G.size()] )

double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

typedef vector<P> Polygon;

enum { counter_clock_wise=+1, clockwise=-1, cab_online=+2, abc_online=-2, on_segment = 0 };
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return counter_clock_wise;
  if(cross(b, c) < 0) return clockwise;
  if(dot(b, c) < 0) return cab_online;
  if(norm(b) < norm(c)) return abc_online;
  return on_segment;
}

Polygon convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

struct Line : public vector<P>
{
  Line(P const& a, P const& b) {
    push_back(a), push_back(b);
  }
};

typedef Line Segment;

bool is_intersect_ss(Segment const& s, Segment const& t) {
  return ( ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) < EPS )
    && ( ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) < EPS );
}

// contain: 2, on segment: 1, the other case: 0
int contains(Polygon const& G, P const& p) {
  bool x = false;
  for(int i=0; i<(int)G.size(); i++) {
    P v1 = curr(G, i)-p, v2 = next(G, i) - p;
    if( v1.imag() > v2.imag() ) swap(v1, v2);
    if( v1.imag() <= 0 && 0 < v2.imag() && cross(v1, v2) > 0 ) x = !x;
    if( cross(v1, v2) == 0 && dot(v1, v2) <= 0 ) return 1;
  }
  return (x?2:0);
}

int main() {

  int N, M;
  while(cin >> N >> M && (N|M)) {
    Polygon G1(N), G2(M);
    rep(i, N) cin >> G1[i].real() >> G1[i].imag(); 
    rep(i, M) cin >> G2[i].real() >> G2[i].imag(); 
    
    G1 = convex_hull(G1); N = G1.size();
    G2 = convex_hull(G2); M = G2.size();
    //    cout << "convex hull\n";
    bool ok = (!contains(G1, G2[0])) && (!contains(G2, G1[0]));
    rep(i, N) {
      rep(j, M) {
	Segment s1 = Segment(curr(G1, i), next(G1, i));
	Segment s2 = Segment(curr(G2, j), next(G2, j));
	if(is_intersect_ss(s1, s2)) { ok = 0; }
      }
    }
    
    cout << (ok ? "YES\n" : "NO\n");
  }
  
  return 0;
}

Measured memory_bytes: 1224
A,B,C,X,Y=[int(i) for i in input().split()]
C*=2

ans=0
if A+B<C:
    ans=A*X+B*Y
else:
    ans=C*min(X,Y)
    if X>Y:
        X-=Y
        if A>C:
            ans+=C*X
        else:
            ans+=A*X
    else:
        Y-=X
        if B>C:
            ans+=C*Y
        else:
            ans+=B*Y
print(ans)



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[1005][1005];

void Main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];
    dp[0][0] = 1;
    rep(i, H) {
        rep(j, W) {
            if (i + 1 < H && grid[i + 1][j] == '.') {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= MOD;
            }
            if (j + 1 < W && grid[i][j + 1] == '.') {
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= MOD;
            }
        }
    }
    cout << dp[H-1][W-1] % MOD << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 9216
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979

using namespace std;

int main() {
	string s, ss;
	cin >> s >> ss;
	Sort(s);
	sort(ss.begin(), ss.end(), greater<char>());

	if (s < ss)cout << "Yes" << endl;
	else cout << "No" << endl;

	

	return 0;
}



Measured memory_bytes: 256
# coding: utf-8
import math

def hensa(n,*s):
    sum = 0
    for i in range(n):
        sum += s[i]
    avg = sum/n
    sum2 = 0
    for i in range(n):
        sum2 += (s[i]-avg)**2
    return math.sqrt(sum2/n)

while True:
    n = int(input().rstrip())
    if n == 0:
        break;
    s = list(map(float, input().rstrip().split()))
    print("{0:.5f}".format(hensa(n,*s)))


Measured memory_bytes: 5784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
#define mp make_pair
const int maxn=2e5;
int a[maxn+5];
int n;
int main()
{
    //freopen("ce.in","r",stdin);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=2;i<=n;++i)
        if(a[i]==a[i-1])
        {
            puts("NO");
            return 0;
        }
    puts("YES");
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
	int n,m;
    cin>>n>>m;
	int a[n];
	rep(i,0,n)a[i]=-1;
	int b,c;
	rep(i,0,m){
		cin>>b>>c;
		b--;
		if(a[b]!=-1&&c!=a[b])return cout<<"-1"<<endl,0;
		a[b]=c;
	} 
	if(n==1&&a[0]==-1)return cout<<"0"<<endl,0;
	if(a[0]==0&&n!=1)return cout<<"-1"<<endl,0;
	rep(i,0,n){
		if(a[i]==-1&&i==0)cout<<"1";
		else if(a[i]==-1)cout<<"0";
		else cout<<a[i];
	}
	cout<<endl;
	return 0;
}
int main(){
    waste;
    int t;
//    cin>>t;
    t=1;
    while(t--){
		solve();
    }
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

#define MAX 100000

int n, k;
long long T[MAX];

int check(long long p) {
    int  i = 0;
    for(int j = 0; j < k; j++) {
        long long s = 0;
        while(s + T[i] <= p) {
            s = s + T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve()
{
    long long left = 0;
    long long right = 100000 * 10000;
    long long mid;

    while(right - left > 1) {
        mid = (left + right) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main() {
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++) {
        scanf("%lld", &T[i]);
    }
    int res = solve();
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3488
#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 MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


int main(void){
    ll n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    REP(i, n) cin >> a[i+1];
    vector<int> p;
    p.push_back(0);
    p.push_back(1);
    //経路の作成
    //134134
    vector<bool> checked(n+1, false);
    checked[1] = true;
    int x = -1, y = -1;
    FOR(i, 1, k) {
        int next = a[p[i]];
        //cout << i << "," << p[i] << "," << next <<endl;
        //次の場所が訪問済みならパス作成終了
        if(checked[next]) {
            //0を含まない
            x = distance(p.begin(), find(ALL(p), next)) - 1;
            y = i - x;
            break;
        }
        p.push_back(next);
        checked[next] = true;
    }
    //cout << x << "," << y << endl;
    //巡回前に終わった
    if(x == -1 && y==-1) {
        cout << p[k+1] << endl;
        return 0;
    }
    cout << p[x+1 + (k-x)%y] << endl;
    
    return 0;
}

Measured memory_bytes: 5068
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

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 pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50




int main(){
    int N;
    cin>>N;
    map<int,int>mp;
    REP(i,N){
        int A;
        cin>>A;
        mp[A]++;
    }
    int res=0;
    for(auto m:mp){
        //cout<<m.first<<" "<<m.second<<endl;
        if(m.second%2==0)res++;
    }
    cout<<SZ(mp)-res%2<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

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

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  if(n <= k)
  {
    cout << 0 << endl;
    return 0;
  }

  sort(h.begin(), h.end(), greater<ll>());
  ll ans = accumulate(h.begin()+k, h.end(), 0LL);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int a = s[0] - 48, b = s[1] - 48, c = s[2] - 48, d = s[3] - 48;
    if (a + b + c + d == 7)
    {
        cout << a << '+' << b << '+' << c << '+' << d << "=7";
        return 0;
    }
    if (a + b + c - d == 7)
    {
        cout << a << '+' << b << '+' << c << '-' << d << "=7";
        return 0;
    }
    if (a + b - c + d == 7)
    {
        cout << a << '+' << b << '-' << c << '+' << d << "=7";
        return 0;
    }
    if (a + b - c - d == 7)
    {
        cout << a << '+' << b << '-' << c << '-' << d << "=7";
        return 0;
    }
    if (a - b + c + d == 7)
    {
        cout << a << '-' << b << '+' << c << '+' << d << "=7";
        return 0;
    }
    if (a - b + c - d == 7)
    {
        cout << a << '-' << b << '+' << c << '-' << d << "=7";
        return 0;
    }
    if (a - b - c + d == 7)
    {
        cout << a << '-' << b << '-' << c << '+' << d << "=7";
        return 0;
    }
    if (a - b - c - d == 7)
    {
        cout << a << '-' << b << '-' << c << '-' << d << "=7";
        return 0;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

    string S; cin >> S;

    vector<int> nums;
    if (S[0] == '0') nums.push_back(0);
    for (int i = 0; i < N;) 
    {
        int j = i;
        while (j < N && S[j] == S[i]) j++;
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0);

    vector<int> sums (nums.size()+1, 0);
    rep(i, nums.size())
    {
        sums[i+1] = sums[i] + nums[i];
    }

    int ans = 0;
    for (int left = 0; left < (int)sums.size(); left += 2)
    {
        int right = left + 2*K+1 ;
        if (right >= sums.size()) right = sums.size() - 1;
        ans = max(ans, sums[right] - sums[left]);
    }

    cout << ans << endl;
}

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

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

    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (cnt[a]) {
            cout << "NO" << endl;
            return 0;
        }
        cnt[a]++;
    }
    cout << "YES" << endl;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int sum = 0;
  rep(i,3){
    int a;
    cin >> a;
    sum += a;
  }
  if(sum >= 22){
    cout << "bust" << "\n";
  }else{
    cout << "win" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>


int main()
{
    int N;
    int L;

    scanf("%d %d", &N, &L);
    int tmp = ((N + 1) * N / 2) + ((L - 1) * N);
    int ans;
    if (L * (L + N - 1) <= 0) {
        ans = tmp;
    } else if (L > 0) {
        ans = tmp - L;
    } else {
        ans = tmp - (L + N - 1);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<long long> L(N);
    REP(i,N)cin >> L[i];
    sort(L.begin(),L.end());

    ll res = 0;

    REP(i,N){
        for(int j=i+1;j<N;j++){
            int k = lower_bound(L.begin(),L.end(),L[i] + L[j]) -L.begin();
            res += max(k - (j+1),0);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    int n,X; cin >> n >> X;
    vector<int> x(n);
    vector<int> tmp(n);
    int i = 0;
    int min = pow(10,9);
    while (i < n) {
        cin >> tmp[i];
        x[i] = abs(tmp[i] - X);
        if (x[i] < min) min = x[i];
        i++;
    }
    i = min;
    int D = 0;
    while (i > 0) {
        int flag = 1;
        int j = 0;
        while (j < n) {
            if (x[j] % i != 0) {
                flag = 0;
                break;
            } 
            j++;
        }
        if (flag) {
            D = i;
            break;
        } 
        i--;
    }
    cout << D << endl;
}

Measured memory_bytes: 3948
### subroutines

def oprod(x1, y1, x2, y2)
  x1 * y2 - x2 * y1
end

def p_in_tr?(x1, y1, x2, y2, x3, y3, xp, yp)
  op12 = oprod(x2 - x1, y2 - y1, xp - x1, yp - y1)
  op23 = oprod(x3 - x2, y3 - y2, xp - x2, yp - y2)
  op31 = oprod(x1 - x3, y1 - y3, xp - x3, yp - y3)

  (op12 >= 0 && op23 >= 0 && op31 >= 0) ||
    (op12 <= 0 && op23 <= 0 && op31 <= 0)
end

def dd_c_l(x1, y1, x2, y2, xc, yc)
  vx = x2 - x1
  vy = y2 - y1

  # ([t*vx+x1,t*vy+y1]-[xp,yp]) * [vx,vy] = 0
  # [t*vx+x1-xp,t*vy+y1-yp] * [vx,vy] = 0
  # vx*(t*vx+x1-xp)+vy(t*vy+y1-yp) = 0
  # t*vx^2+vx(x1-xp)+t*vy^2+vy(y1-yp) = 0
  # t*(vx^2+vy^2) = vx*(xp-x1)+vy*(yp-y1)
  # t = (vx*(xp-x1)+vy*(yp-y1)) / (vx^2+vy^2)

  t = (vx * (xc - x1) + vy * (yc - y1)).to_f / (vx ** 2 + vy ** 2)
  x = t * vx + x1
  y = t * vy + y1
  dd = (x - xc) ** 2 + (y - yc) ** 2

  return dd if (t > 0 && t < 1)

  dd1c = (x1 - xc) ** 2 + (y1 - yc) ** 2
  dd2c = (x2 - xc) ** 2 + (y2 - yc) ** 2
  [dd1c, dd2c].min
end

### main

while true
  x1, y1 = gets.strip.split(' ').map{|s| s.to_i}
  break if x1 == 0 && y1 == 0

  x2, y2 = gets.strip.split(' ').map{|s| s.to_i}
  x3, y3 = gets.strip.split(' ').map{|s| s.to_i}

  xc, yc = gets.strip.split(' ').map{|s| s.to_i}
  r = gets.strip.to_i
  #p [[x1, y1], [x2, y2], [x3, y3], [xc, yc], r]

  rr = r ** 2
  dd1 = (x1 - xc) ** 2 + (y1 - yc) ** 2
  dd2 = (x2 - xc) ** 2 + (y2 - yc) ** 2
  dd3 = (x3 - xc) ** 2 + (y3 - yc) ** 2
  #p "dd1=#{dd1}, dd2=#{dd2}, dd3=#{dd3}, rr=#{rr}"

  rel = ''

  if dd1 <= rr && dd2 <= rr && dd3 <= rr
    rel = 'b'
  elsif dd1 > rr && dd2 > r && dd3 > rr
    dd12 = dd_c_l(x1, y1, x2, y2, xc, yc)
    dd23 = dd_c_l(x2, y2, x3, y3, xc, yc)
    dd31 = dd_c_l(x3, y3, x1, y1, xc, yc)

    min_dd = [dd12, dd23, dd31].min

    p_in_tr = p_in_tr?(x1, y1, x2, y2, x3, y3, xc, yc)

    if p_in_tr && min_dd >= rr
      rel = 'a'
    elsif ! p_in_tr && min_dd > rr
      rel = 'd'
    else
      rel = 'c'
    end
  else
    rel = 'c'
  end

  puts rel
end

Measured memory_bytes: 6120
#include<stdio.h>

int main(void)
{
	int a;
	int b;
	char op;
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		
		if(op == '+'){
			printf("%d\n",a + b);
		}
		else if(op == '-'){
			printf("%d\n",a - b);
		}
		else if(op == '*'){
			printf("%d\n",a * b);
		}
		else if(op == '/'){
			printf("%d\n",a / b);
		}
		else if(op == '?'){
			break;
		}
	}
	return (0);
}

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

int main()
{
	int n,A,B;
	cin>>n>>A>>B;
	int t1=0,t2=0,t3=0;
	for (int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		if (x<=A) t1++;
		if (x>A && x<=B) t2++;
		if (x>B) t3++;
	}
	cout<<min(t1,min(t2,t3));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  int count = 0;
  cin >> N;
  vector<int> A(N);
  vector<int> E(N);

  for(int i = 0; i < N; i++){
    cin >> A[i];
    if((A[i] % 2) == 0){
      E[count] = A[i];
      count++;
    }
  }
  if(count == 0){
    cout << "APPROVED" << endl;
    return 0;
  }

  for (int i = 0; i < count; i++) {
    if ((E[i] % 3) == 0 || (E[i] % 5) == 0) {
    }else{
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn=100+10;
const int maxw=1e5; 
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
ll n,W;
ll w[maxn],v[maxn];
ll f[maxw];
int main(){
	read(n);read(W);
	for(re int i=1;i<=n;i++){
		read(w[i]);read(v[i]);
	}
	for(re int i=1;i<=n;i++){
		for(re int j=W;j>=w[i];j--){
			f[j]=max(f[j],f[j-w[i]]+v[i]);
		}
	}
	cout<<f[W]<<endl;
	return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
k = []
now = 0
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    k.append([a,b])
k.sort()
for i in range(N):
    if (now+k[i][1])<M:
        ans += k[i][0]*k[i][1]
        now += k[i][1]
    else:
        ans += k[i][0]*(M-now)
        print(ans)
        break

Measured memory_bytes: 20048
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int last = s[0];
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != last) {
            last = s[i];
            ans++;
        } 
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;  // limit for array size
int n,h;
ll dp[2][2 * N] = {},lazy[2][N] = {},u = -1,mod = 1000000007;
void calc(int p, ll k, int x){
	if(lazy[x][p]==u) dp[x][p] = (dp[x][p<<1] + dp[x][p<<1|1])%mod;
	else dp[x][p] = lazy[x][p]*k%mod;
}
void apply(int p, ll value,ll k,int x){
	dp[x][p] = value*k%mod;
	if(p<n) lazy[x][p] = value;
}
void built(int l, int r, int x){
	int k = 2;
	for(l += n, r += n - 1;l>1;k <<= 1){
		l >>= 1, r >>= 1;
		for(int i=r;i>=l;--i) calc(i,k,x);
	}
}

void push(int l,int r,int x){
	int s = h,k = 1<<(h - 1);
	for(l += n,r += n-1;s>0;--s,k>>=1){
		for(int i=l>>s;i<=r>>s;++i){
			if(lazy[x][i]!=u){
				apply(i<<1,lazy[x][i],k,x);
				apply(i<<1|1,lazy[x][i],k,x);
				lazy[x][i] = u;
			}
		}
	}
}
void modify(int l,int r,ll value,int x){
	if(value==u) return;
	push(l,l+1,x); push(r-1,r,x);
	int l0 = l,r0 = r,k = 1;
	for(l += n, r += n;l<r;l >>=1,r >>= 1, k<<=1){
		if(l&1) apply(l++,value,k,x);
		if(r&1) apply(--r,value,k,x);
	}
	built(l0,l0+1,x); built(r0-1,r0,x);
}
ll query(int l, int r,int x){
	push(l,l+1,x); push(r-1,r,x);
	ll res = 0;
	for(l += n,r += n;l<r;l>>=1,r>>=1){
		if(l&1) (res += dp[x][l++]) %= mod;
		if(r&1) (res += dp[x][--r]) %= mod;
	}
	return res;
}

ll s[100010],A[100010],B[100010];
int main() {
	int i;
	ll a,b;
	cin >> n >> a >> b;
	n += 2; h = sizeof(int)*8 - __builtin_clz(n);
	for(i=2;i<n;i++){
		cin >> s[i];
	}
	ll inf = -(max(a,b) + 1LL);
	s[0] = inf; s[1] = inf;
	int j = 0,k = 0;
	for(i=2;i<n;i++){
		while(s[i] - a >= s[j+1] && j<n) j++;
		while(s[i] - b >= s[k+1] && k<n) k++;
		A[i] = j; B[i] = k;
	}
	modify(0,n,0,0); modify(0,n,0,1);
	modify(0,1,1,0); modify(0,1,1,1);
	for(i=2;i<n;i++){
		ll x = query(0,A[i] + 1,1);
		ll y = query(0,B[i] + 1,0);
		modify(i-1,i,x,0); modify(i-1,i,y,1);
		if(s[i] - s[i-1]<a) modify(0,i-1,0,0);
		if(s[i] - s[i-1]<b) modify(0,i-1,0,1);
	}
	cout << (query(0,n,0) + query(0,n,1))%mod*(mod + 1)/2%mod << endl;
}

Measured memory_bytes: 7296
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        n: i32,
        k: i32,
    }
    let mut prob = 0f64;
    for mut i in 1..(n + 1) {
        let mut p = 0;
        while i < k {
            i *= 2;
            p += 1;
        }
        prob += 0.5f64.powi(p);
    }
    println!("{}", prob / (n as f64));
}



Measured memory_bytes: 4352
package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n1 string
	fmt.Scan(&n1)
	n2, _ := strconv.Atoi(n1)

	cnt := 0
	list := make([]int, n2)
	for i :=0; i < n2; i++ {
		var c string
		fmt.Scan(&c)
		list[i], _ = strconv.Atoi(c)
	}

	for {
		for i, v := range list {
			if  v % 2  != 0 {
				fmt.Println(cnt)
				os.Exit(0)
			}
			list[i] = v/2
		}
		cnt++
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    while(n!=0){
        ans++;
        n/=k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, add, sub, mul;

    scanf("%d %d", &a, &b);
    add = a + b;
    sub = a - b;
    mul = a * b;
    if(add>sub){
        if(add>mul){
            printf("%d\n", add);
        }
        else{
            printf("%d\n", mul);
        }
    }
    else{
        if(sub>mul){
            printf("%d\n", sub);
        }
        else{
            printf("%d\n", mul);
        }
    }
    return 0;
}


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

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let mut N: usize = read();
    let mut K: usize = read();
    let mut minuses = vec![];
    let mut pluses = vec![];
    for _ in 0..N {
        let val: i32 = read();
        match val.cmp(&0) {
            std::cmp::Ordering::Equal => {
                N -= 1;
                K -= 1;
            }
            std::cmp::Ordering::Less => {
                minuses.push(-val as u64);
            }
            std::cmp::Ordering::Greater => {
                pluses.push(val as u64);
            }
        }
    }
    if K == 0 {
        println!("0");
        return;
    }
    minuses.reverse();
    let mut ans = std::u64::MAX;
    for (one, another) in &[(&minuses, &pluses), (&pluses, &minuses)] {
        for (i, &v) in one.iter().enumerate() {
            if K == i + 1 {
                ans = std::cmp::min(ans, v);
                break;
            }
            if K - i - 1 > another.len() {
                continue;
            }
            // dbg!(K, i, v, K - i - 2, another[K - i - 2]);
            ans = std::cmp::min(ans, v * 2 + another[K - i - 2]);
        }
    }
    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};

int h, w, n;
int a[101 * 101];
int c[101][101];

int bfs(int x, int y, int col){
  queue < pii > q;
  q.push(make_pair(x, y));
  int cnt = 1;
  c[x][y] = col;
  if(cnt == a[col]){
    return 0;
  }
  while(!q.empty()){
    pii v = q.front();
    q.pop();
    for(int cc = 0; cc < 4; ++cc){
      int cx = v.first + dx[cc];
      int cy = v.second + dy[cc];
      if(cx <= 0 || cx > h || cy <= 0 || cy > w){
        continue;
      }
      if(!c[cx][cy]){
        q.push(make_pair(cx, cy));
        c[cx][cy] = col;
        ++cnt;
        if(cnt == a[col]){
          return 0;
        }
      }
    }
  }
  return 0;
}

int main(){
  scanf("%d %d %d", &h, &w, &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
  }
  int xptr = 1, yptr = 1;
  int dir = 0;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= a[i]; ++j){
      c[xptr][yptr] = i;
      yptr += !dir ? 1 : -1;
      if(!dir && yptr == w + 1){
        ++xptr;
        yptr = w;
        dir = 1;
      }
      if(dir && yptr == 0){
        ++xptr;
        yptr = 1;
        dir = 0;
      }
    }
  }
  for(int i = 1; i <= h; ++i){
    for(int j = 1; j <= w; ++j){
      printf("%d ", c[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*int r;
	scanf("%d", &r);
	printf("%d\n", 3 * r*r);*/

	/*int n, d;
	scanf("%d %d", &n, &d);
	int one = 1 + 2 * d;
	if (n%one) {
		printf("%d\n", n / one + 1);
	}
	else {
		printf("%d\n", n / one);
	}*/

	int n;
	int a[200001];
	int s[200001];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		s[i] = a[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		if (s[n - 1] == a[i])
			printf("%d\n", s[n - 2]);
		else
			printf("%d\n", s[n - 1]);
	}
	return 0;
}

Measured memory_bytes: 3072
strN = input().rstrip()
K = int(input())

maxD = len(strN)

dp = [[[0]*(K+1) for j in range(2)] for i in range(maxD+1)]
dp[0][0][0] = 1
for d, Nd in enumerate(strN):
    Nd = int(Nd)
    for isLtN in range(2):
        for numNot0 in range(K+1):
            for x in range(10):
                if not isLtN and x > Nd: continue
                isLtN2 = isLtN or x < Nd
                numNot02 = numNot0 + (x != 0)
                if numNot02 > K: continue
                dp[d+1][isLtN2][numNot02] += dp[d][isLtN][numNot0]

ans = dp[-1][0][K] + dp[-1][1][K]
print(ans)


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

int main() {
    int N;
    vector<bool> prime(10001, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= 10000/2; i++) {
        if (!prime[i]) continue;
        for (int j = 2; j * i <= 10000; j++) {
            prime[i*j] = false;
        }
    }
    while (cin >> N) {
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (prime[i+1] && prime[N-i]) count++;
        }

        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <set>

using namespace std;
void input(set<int> &);
void output(set<int> &);

int main()
{
    set<int> A, B;
    input(A);
    input(B);

    set<int>::iterator it = B.begin();
    while (it != B.end())
    {
        if (A.find(*it) != A.end())
        {
            A.erase(*it);
        }
        it++;
    }

    output(A);


    // //法2
    // set<int> C;
    // set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(C, C.begin()));
    // output(C);
 
}


void input(set<int> & A)
{
    int n;
    cin >> n;

    int a;
    while (n--)
    {
        cin >> a;
        A.insert(a);
    }
}

void output(set<int> & A)
{
    set<int>::iterator it = A.begin();
    while (it != A.end())
    {
        cout << *it << endl;
        it++;
    }
}


Measured memory_bytes: 21848
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  ll ans=0; int w=0;
  rep(i,n){
    if(s[i]=='W') {ans+=(ll)i-w;w++;}
  }
  cout << ans << endl;
}

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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 1000 * 1000 + 10, mod = 998244353; 

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string s;
	cin>> s;
	int n = s.size(), cnt = 0;
	ll sumx = 0, sumy = 0;
	for(int i = 0; i < n; i++)
	{
		if(s[i]=='B') 
		{
			cnt++;
			sumy += n - cnt;
			sumx += i;
		}
	}
	cout<< sumy - sumx << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	i64 n, k;
	cin >> n >> k;
	i64 ans=0, num=0;
	vector<pair<int, int>> data(n);
	ff(i, 0, n) {
		cin >> data.at(i).first;
		cin >> data.at(i).second;
	}
	sort(data.begin(), data.end());
	ff(i, 0, n) {
		int a,b;
		a = data.at(i).first;
		b = data.at(i).second;
		num += b;
		ans = a;
		if (num >= k) {
			cout << ans << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 200005;
const ll MOD = 1e9 + 7;
ll fac[MAXN], invfac[MAXN];
ll inv[MAXN];
ll binom(ll a, ll b) {
	if (b < 0) return 0;
	if (b > a) return 0;
	return (((fac[a] * invfac[b]) % MOD) * invfac[a - b]) % MOD;
}
ll modex(ll a, ll p, ll m = MOD) {
	if (!p) return 1;
	if (p & 1) return a * modex(a, p - 1, m) % m;
	ll v = modex(a, p >> 1, m);
	return v * v % m;
}
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i % MOD;
	invfac[MAXN - 1] = modex(fac[MAXN - 1], MOD - 2);
	for (int i = MAXN - 2; i >= 0; --i)
		invfac[i] = invfac[i + 1] * (i + 1) % MOD;
	for (int i = 1; i < MAXN; ++i)
		inv[i] = invfac[i] * fac[i - 1] % MOD;
	int n, a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	ll denom = modex(a + b, MOD - 2);
	ll x = a * denom % MOD;
	ll y = b * denom % MOD;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ll z = binom(i + n - 1, n - 1) * (i + n) % MOD * 100 % MOD * denom % MOD;
		ans += modex(x, i) * modex(y, n) % MOD * z;
		ans += modex(y, i) * modex(x, n) % MOD * z;
		ans %= MOD;
	}
	printf("%lld\n", ans);
}


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

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

int main(){
  ll a,b; cin >> a >> b;
  cout << (a*b)/gcd(a,b) << endl;
}

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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c ,n, sum, A[500010], B[500000],rui[500000],  dp[5000];
str S;bool check = true;	vector<ll> v;
ll arr[1000000];ll N = 150000;
void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

}


int main() {
	//Code Line
cin >> n;
 Eratosthenes();

 for(int i = n;i < N;i++){
 if(arr[i]){
	 cout << i << endl;
	 break;
 }
 }


	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
#define a first
#define b second

//vi arr(200010);

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

	int n;
	cin >> n;
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	int arr[12][12];
	memset(arr, 0, sizeof arr);
	ll ans = 0;
	string s;
	rep(i, 1, n + 1){
		s = to_string(i);
		arr[s[0] - '0'][s[s.length() - 1] - '0']++;
	}
	rep(i, 1, n + 1){
		s = to_string(i);
		ans += arr[s[s.length() - 1] - '0'][s[0] - '0'];
	}
	cout << ans << endl;
	return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,ans=0;
	string a;
	cin>>a;
	for (i=0;i<a.size();i++){
		if (a[i]=='-'){
			ans--;
		}
		else {
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

val sc = Scanner(System.`in`)

fun main(args : Array<String>) {
    val n = sc.nextInt()
    val ll = listOfInt(n).sorted().toIntArray()

    var count = 0
    for(i in 0 until ll.size-2) {
        for(j in i+1 until ll.size-1) {
            for(k in j+1 until ll.size) {
                if (ll[i] + ll[j] > ll[k]) {
                    count++
                } else {
                    break
                }
            }
        }
    }

    println(count)
}

fun listOfInt(n: Int) = (1..n).map { sc.nextInt() }

Measured memory_bytes: 48684