akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

ll H, W;
std::vector<std::vector<long long>> A;

ll cache[80][80][160 * 80];

ll solve(ll y, ll x, ll diff){
    if(cache[y][x][diff] != -1){
        return cache[y][x][diff];
    }
    ll ret = numeric_limits<ll>::max();
    const int d = A[y][x];
    if(y == H - 1 && x == W - 1){
        ret = min(diff + d, abs(diff - d));
    }else{
        if(y + 1 < H){
            ret = min(ret, solve(y + 1, x, diff + d));
            ret = min(ret, solve(y + 1, x, abs(diff - d)));
        }
        if(x + 1 < W){
            ret = min(ret, solve(y, x + 1, diff + d));
            ret = min(ret, solve(y, x + 1, abs(diff - d)));
        }
    }
    cache[y][x][diff] = ret;
    return ret;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    scanf("%lld",&H);
    scanf("%lld",&W);
    // H = 80;
    // W = 80;
    A.resize(H, vector<ll>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&A[i][j]);
            // A[i][j] = i;
        }
    }
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            ll b;
            scanf("%lld",&b);
            A[i][j] = abs(A[i][j] - b);
            // A[i][j] = abs(A[i][j] - j);
        }
    }
    memset(cache, -1, sizeof(cache));
    cout << solve(0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 640256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define int long long
#define mod 1000000007
#define N 200007
using namespace std;
inline int read(){
    int x=0,w=0;char ch=getchar();
    while (!isdigit(ch))w|=ch=='-',ch=getchar();
    while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
    return w?-x:x;
}
int ksm(int x,int k){
    int res=1;
    while(k){
        if(k&1)res=res*x%mod;
        x=x*x%mod;
        k>>=1;
    }
    return res;
}
int mn[N],c[N],w[N],cnt[N],jc[N],inv[N],n,A,B,ans;
signed main(){
//  freopen("keep.in", "r", stdin); freopen("keep.out", "w", stdout); 
    n=read(),A=read(),B=read();
    memset(mn,0x3f,sizeof(mn));
    jc[0]=1;
    for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%mod;
    inv[n]=ksm(jc[n],mod-2);
    for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    for (int i=1;i<=n;++i){
        c[i]=read(),w[i]=read();
        mn[c[i]]=min(mn[c[i]],w[i]);//颜色集合最小值 
        ++cnt[c[i]];//集合元素个数 
    }
    int Mn=1,mnn=inf;
    for (int i=1;i<=n;++i)
        if (mn[i]<mn[Mn])
            Mn=i;//找出全局最小值的颜色 
    for (int i=1;i<=n;++i)
        if (i!=Mn)
            mnn=min(mn[i],mnn);//找出除全局最小值的集合以外的所有数的最小值 
    for (int i=1;i<=n;++i){
        if (w[i]!=mn[c[i]]&&w[i]+mn[c[i]]<=A)continue;//如果这个值不是所在集合的最小值但它与所在集合的最小值的和小于A，那么它是有意义的 
        if (c[i]!=Mn&&w[i]+mn[Mn]<=B)continue;//如果这个值不在全局最小值所在的集合中 ，但它与全局最小值的和小于B，那么它是有意义的
        if (c[i]==Mn&&w[i]+mnn<=B)continue;//如果它在全局最小值所在的集合中，且它与除全局最小值的集合以外的所有数的最小值的和小于B，那么它是有意义的 
        --cnt[c[i]];//如果它不符合以上条件，那么它的存在是没有意义的
    }
    int num=cnt[Mn];
    for (int i=1;i<=n;++i)
        if (i!=Mn&&mn[Mn]+mn[i]<=B)//如果这种颜色存在且它不是全局最小值所在的集合 
            num+=cnt[i];
    ans=1;
    for (int i=1;i<=n;++i)
        if(mn[i]!=inf&&(i==Mn||mn[i]+mn[Mn]<=B))
            ans=ans*inv[cnt[i]]%mod;
    for (int i=1;i<=num;++i)
        ans=ans*i%mod;//这里是求有重复元素的排列种数 
    printf("%lld",ans);
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll parent[200010];

ll root(ll x){
    if(x == parent[x]) return x;
    else return parent[x] = root(parent[x]);
}

void unite(ll a, ll b){
    a = root(a); b = root(b);
    if(a == b) return;
    parent[a] = b;
}

bool same(ll a, ll b){
    return root(a) == root(b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    ll K[100010];
    vector<ll> L[100010];
    cin >> N >> M;
    vector<ll> tree[100010];
    rep(i,0,N){
        cin >> K[i];
        rep(j,0,K[i]){
            ll tmp;
            cin >> tmp;
            tree[tmp].push_back(i);
            L[i].push_back(tmp);
        }
    }
    rep(i,0,N){
        parent[i] = i;
    }
    rep(i,1,M+1){
        ll n = tree[i].size();
        if(n == 1) continue;
        rep(j,0,n-1){
            unite(tree[i][j], tree[i][j+1]);
        }
    }
    bool ans = true;
    ll v = root(0);
    rep(i,1,N){
        if(root(i) != v) ans = false;
    }
    if(ans){
        print("YES");
    }else{
        print("NO");
    }




}


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

int main() {
	int W, N;
	vector<int> V;
	cin >> W >> N;
	for (int i = 1; i <= W; i++) {
		V.push_back(i);
	}
	for (int i = 0; i < N; i++) {
		int A, B;
		char C;
		cin >> A >> C >> B;
		A--, B--;
		swap(V[A], V[B]);
	}
	for (int i = 0; i < W; i++) {
		cout << V[i] << endl;
	}
}


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

int main() {
	int N, Y;
	cin >> N >> Y;
	for (int z = 0; z*1000 <= Y; z++) {
		for (int y = 0; z * 1000 + y * 5000 <= Y; y++) {
			if ((N - y - z) * 10000 + y * 5000 + z * 1000 == Y) {
				printf("%d %d %d\n", N - y - z, y, z);
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  vector<long>A(N+1);
  ins(A);
  vector<long>B(N);
  ins(B);
  long cnt=0,left,right;
  rep(i,N){
    left=min(A[i],B[i]);
    A[i]-=left;
    B[i]-=left;
    right=min(A[i+1],B[i]);
    A[i+1]-=right;
    B[i]-=right;
    cnt+=left;
    cnt+=right;
  }
  out(cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LL long long
#define P pair<int, int>
#define Fengexian cout<<"WZY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl
const LL N = 1e5 + 10;
const LL mod = 998244353;
const LL inf = 0x3f3f3f3f;
const double eps = 1e-9;
using namespace std;
template <typename tp>
inline void read(tp &x)
{
	x = 0; char c = getchar(); bool f = 0;
	for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar()) ;
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()) ;
	if (f) x = -x;
}
int n,a[N],num[N],maxn,flag;
signed main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),num[a[i]]++,maxn=max(maxn,a[i]);
	for(int i=maxn;i>=0;i--)
	{
		int zz=max(maxn-i,i);
		if(!num[zz]) return 0*puts("Impossible");
		num[zz]--;
	}
	for(int i=1;i<=((maxn+1)>>1);i++)
		if(num[i])
			return 0*puts("Impossible");
	return 0*puts("Possible");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int w,h,x,y,c;
  double s;
  scanf("%d%d%d%d", &w, &h, &x, &y);
  if(x*2==w && y*2==h) c=1;
    else c=0;
  printf("%lf %d", (double)w*h/2, c);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{

	int sum, i;
	int value[9];

	while(scanf("%d", &sum), sum != 0) {
		for (i = 0; i < 9; i++) {
			scanf("%d", &value[i]);
			sum -= value[i];
		}
		printf("%d\n", sum);
	}

	return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#include <queue>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf INT_MAX
#define mod 1000000009
using namespace std;

inline int FastI() {
	char c = ' '; int a = 0;
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) {
		a *= 10;
		a += c - '0';
		c = getchar();
	}
	return a;
}

int main() {
	speed;
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>>v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ll take = min(m, v[i].second);
		m -= take;
		ans += take * v[i].first;
	}
	cout << ans;
}

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

int main(){
    int n;
    cin>>n;
    int p=-1, l=0, ans=0;
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        if(a==p) l++;
        else{
            ans+=l/2;
            p=a;
            l=1;
        }
    }
    ans+=l/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = [LF() for _ in range(n)]
        e = []
        for i in range(n):
            for j in range(i+1,n):
                k = sum([(a[i][_]-a[j][_])**2 for _ in range(3)]) ** 0.5
                t = a[i][3] + a[j][3]
                e.append((k-t,i,j))
        e.sort()
        uf = UnionFind(n)
        r = 0
        for k,i,j in e:
            if uf.union(i,j):
                if k > 0:
                    r += k

        rr.append('{:0.3f}'.format(r))

    return '\n'.join(map(str,rr))


print(main())




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

int main(){
    int n;
  	cin >> n;
    int l[n];
  	
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }

    int m = -1;
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += l[i];
        if(l[i] > m){
            m = l[i];
        }
    }

    (sum-m > m?cout<<"Yes"<<endl:cout<<"No"<<endl);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#define INT long long int
 
using namespace std;
string s;
 
INT dp(int x, INT v, INT z)
{
    if( x == s.size() ) return z+v;
    return dp(x+1, v*10+(s[x]-'0'), z) + dp(x+1, (s[x]-'0'), z+v);
}
 
int main()
{
    cin>>s;
    cout<<dp(1, s[0]-'0', 0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
 
#include <limits.h>
 
using namespace std;
 
typedef long long ll;
 
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
int main(void) {
    int N, K;
    cin >> N >> K;
 
    if (K % 2 != 0) {
        ll a = N / K;
        cout << a * a * a << endl;
    } else {
        ll a = N / K;
        ll b = (N - K / 2) / K;
        if (N - K / 2 >= 0) {
            b++;
        }
        cout << a * a * a + b * b * b << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

min_money = float('inf')

for k in range(max(X,Y) + 1):
    i = X - k
    j = Y - k
    sum_momey = 2 * k * C
    if (i > 0):
        sum_momey += i * A
    if (j > 0):
        sum_momey += j * B
    if min_money > sum_momey:
        min_money = sum_momey

print(min_money)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const lint MOD = (lint)1e9 + 7;
lint comb[2005][2005];

lint com(int n, int r){
    if(n<0 or r<0) return 0;
    if(n<r) return 0;
    return comb[n][r];
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, K, L;
    cin>>N>>K;
    L = N - K;
    if(N==K){
        printf("1\n");
        for(int i=2;i<=K;i++) printf("0\n");
        return 0;
    }
    for(int i=0;i<=2000;i++){
        comb[i][0] = 1;
        for(int j=1;j<=i;j++) comb[i][j] = (comb[i-1][j-1]+comb[i-1][j]) % MOD;
    }
    for(int i=1;i<=K;i++){
        lint ans = (com(L-1, i)+2*com(L-1, i-1)+com(L-1, i-2)) % MOD * com(K-1, i-1) % MOD;
        printf("%lld\n", ans);
    }
    //cout<<com(4, 2)<<endl;
    return 0;
}

Measured memory_bytes: 30208
#include<bits/stdc++.h>
#include <cstdint>
using namespace std;
#define int  unsigned long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;
public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
signed main(){
  using mint = modint<1000000007>;
  int N;
  mint K;
  mint x=0,y=0;
  int maxi=0;
  cin >> N >> K.a;
  int A[2000+10];
  rep(i,N){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(A[i] > A[j]) y+=1;
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(A[i] > A[j]){
        /*int number = A[i];
        A[i] = A[j];
        A[j] = number;*/
        x+=1;
      }
    }
  }
  //cout << x << endl;
  //if(h==0) cout << (x*K%1000000007+((K/2)*y)%1000000007*(K-1)%1000000007)%1000000007 << endl;
  //else cout << (x*K%1000000007+(((K-1)/2)*y)%1000000007*K%1000000007)%1000000007 << endl;
  //cout << (((x*((1+K))%1000000007)*K)%1000000007)/2 << endl;
  //cout << x*(1+K)*K/2%1000000007<< endl;
  cout << (x*K+K/2*y*(K-1)).a << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<vector>
#include<iomanip>
using namespace std;
int main(){
    int n; //n面体のサイコロをもつ
    int k; //目標の点数
    int count; // ｋまでにcount連続で1/2をひく
    int now=0; // 現在の点数
    double p =1.0; //表の出る確率
    double pro=0.0; //すぬけ君が勝つ確率
    int deme=1; //出目
    double n_p=0.0; //出目iが出る確率

    cin >> n >> k;
    n_p = 1.0/n;
    
    for(int i=1;i<=n;i++){
        now = deme; //出目の特典をもらう
        while(now < k){ // 得点がｋを超えるまで足し続ける
            now *=2; // 得点を2倍にする
            p *= 0.5;  // 表の出る確率
            
        }
        pro += p*n_p; // 各面の値が出る確率
        
        //初期化
        now =0; 
        p = 1.0;
        deme++; //出目を変更
    }
    
    printf("%.9f\n",pro);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int p[]=new int[m];
		String s[]=new String[m];
		for(int i=0;i<m;i++) {
			p[i]=scan.nextInt();
			s[i]=scan.next();
		}
		scan.close();

		int ans_array[]= new int[n];
		int wrong_array[]= new int[n];
		for(int i=0;i<n;i++) {
			ans_array[i]=0;
			wrong_array[i]=0;
		}
		int wrong=0,ans=0;
		for(int i=0;i<m;i++) {
			if(ans_array[p[i]-1]==0 ) {
				if(s[i].equals("AC")) {
					ans++;
					ans_array[p[i]-1]=1;
					wrong+=wrong_array[p[i]-1];
				} else {
					wrong_array[p[i]-1]++;
				}
			}
		}

		System.out.println(ans+" "+wrong);
	}
}

Measured memory_bytes: 70924
//
// Created by kuribohkute on 29/12/2018.
//

#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef long long cc;

bool was[10];

int main() {

    int n;
    vector<int> a, b;
    cin >> n;
    a.resize(n);
    b.resize(n);
    int res = 0;
    cc sum = 0;
    for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];
    for (int i = 0; i < n; i++) cin >> b[i], sum -= b[i];
    if (sum < 0) {
        cout << "-1";
        return 0;
    }
    vector<int> c;
    cc tmp = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            tmp += b[i] - a[i];
            res++;
        } else
            if (b[i] < a[i]) {
                c.emplace_back(a[i] - b[i]);
            }
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
//    cout << c.size() << "\n";
    for (auto x: c) {
        if (tmp <= 0) {
            break;
        }
        tmp -= x;
        res++;

    }
    cout << res;
    return 0;
}

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

bool CheckPrimeNumber(int n){
    int cnt=0;
    
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)cnt += 1;
    }
    if(cnt==0 || n==2)return true;
    else      return false;
}

int main(){
    int n, count=0; cin >> n;
    int a;
    
    for(int i=0;i<n;i++){
        cin >> a;
        if(CheckPrimeNumber(a))count += 1;
    }

    cout << count << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define endl "\n"
#define int long long
using namespace std;    


int32_t main(){

    fast
    int n,k;
    cin>>n>>k;
    set<int>s;
    int temp;
    for(int i=0;i<k;i++){
        int nos;
        cin>>nos;
        for(int i=0;i<nos;i++){
            cin>>temp;
            s.insert(temp);
        }
    }
    cout<<(n-s.size());



    return 0;
}



Measured memory_bytes: 3644
#include<stdio.h>

typedef struct {char suit, value;}Card;

void bubble(Card A[], int N){
	int i, j;
	Card t;
	for(i = 0; i < N; i++){
		for(j = N - 1; j >= i; j--){
			if(A[j].value < A[j - 1].value){
				t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
}

void selection(Card A[], int N){
	int i, j, minj;
	Card t;
	for(i = 0; i < N; i++){
		minj = i;
		for(j = i; j < N; j++){
			if(A[j].value < A[minj].value)minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(Card A[], int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0)printf(" ");
		printf("%c%d", A[i].suit, A[i].value);
	}
	printf("\n");
}

int isStable(Card C1[], Card C2[], int N){
	int i;
	for(i = 0; i< N; i++){
		if(C1[i].suit != C2[i].suit)return 0;
	}
	return 1;
}

void str2Card(Card *t, char str[]){
	t -> suit = str[0];
	t -> value = str[1] - '0';
}

int main(void){
	Card C1[100],C2[100];
	int N, i;
	char str[3];
	
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%s", str);
		str2Card(&C1[i], str);
	}
	
	for(i = 0; i < N; i++)C2[i]= C1[i];
	
	bubble(C1, N);
	selection(C2,N);
	
	print(C1, N);
	printf("Stable\n");
	print(C2, N);
	if(isStable(C1, C2, N)){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	
	return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>
#include <numeric>

using namespace std;


int main(){
  string s;
  long long n;
  long long result = 0;
  long long lx=0;
  long long rx=0;
  cin >> s;
  n = s.length();
  long long l=0;
  long long r=n-1;
  while (l<=r) {
    while (l<n) {
      if (s[l] != 'x')
	break;
      lx++;
      l++;
    }
    if (l == n) {
      cout << 0 << endl; // s = xxxxx...
      return 0;
    }
    while (0<=r) {
      if (s[r] != 'x')
	break;
      rx++;
      r--;
    }
    if (s[l] != s[r]) {
      cout << -1 << endl;
      return 0;
    } else {
      long long add = lx > rx?lx - rx:rx - lx;
      lx = 0;
      rx = 0;
      result += add;
      if (l==r) {
	cout << result << endl;
	return 0;
      }
      l++;
      r--;
    }
  }
  cout << result << endl;
  return 0;

}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int l[55];
signed main(void)
{
	int n, k;
	cin >> n >> k;
	REP(i, n) cin >> l[i];
	sort(l, l+n);
	reverse(l, l+n);
	int sum = 0;
	REP(i, k) {
		sum += l[i];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

V<V<bool> > flag;
vvll dp;
vll a;

ll f(ll l, ll r) {
    if (flag[l][r]) return dp[l][r];
    flag[l][r] = true;
    if (l==r) return dp[l][r] = a[l];
    else return dp[l][r] = max(a[l]-f(l+1, r), a[r]-f(l, r-1));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    a.resize(n); REP(i, n) cin >> a[i];
    flag.resize(n, V<bool>(n, false));
    dp.resize(n, vll(n, 0));
    ll ans = f(0, n-1);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 72064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

full = (1 << 60) - 1
uninity = [0] * (N+1)
dp = [0] * (N+1)
twice = [0] * (N+1)
for x in order[::-1]:
    p = parent[x]
    n = twice[x].bit_length() - 1
    if n >= 0:
        dp[x] |= (1 << (n+1)) - 1
    can_use = full & (~dp[x])
    lsb = can_use & (-can_use)
    uninity[x] = lsb
    dp[x] |= lsb
    dp[x] &= full & ~(lsb - 1)
    
    twice[p] |= (dp[x] & dp[p])
    dp[p] |= dp[x]

x = max(uninity)
answer = x.bit_length() - 1
print(answer)

Measured memory_bytes: 40864
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int n, k;
vector<int> a;
int main() {
	scanf("%d%d", &k, &n);
	int atmp;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &atmp);
		a.push_back(atmp);
	}
	sort(a.begin(), a.end());
	int ans = k;
	for (int i = 0; i < n - 1; ++i) {
		ans = min(ans, k - (a[i + 1] - a[i]));
	}
	ans = min(ans, k - (a[0] + k - a[n - 1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define MOD 998244353
#define ios ios::sync_with_stdio(0), cin.tie(0)
 
using namespace std;

int main()
{
    ios;
    
    int n, k;
    cin >> n >> k;
    int h[n];
    fop(i,0,n) cin >> h[i];
    
    int dp[n];
    dp[0] = 0;
    fop(i,1,n) dp[i] = pow(10,9);
    
    fop(i,1,n){
        fop(j,1,k+1){
            if(i-j < 0) continue;
            int a = dp[i-j] + abs(h[i-j]-h[i]);
            dp[i] = min(dp[i], a);
        }
    }
    cout << dp[n-1];
    
    
    return 0;
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<998244353>;

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

const int MAXN = 1.01e7;
num fact[MAXN];
num ifact[MAXN];
num p2[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		fact[i] = fact[i-1] * num(i);
	}
	ifact[N] = fact[N].inv();
	for (int i = N; i >= 1; i--) {
		ifact[i-1] = ifact[i] * num(i);
	}
	p2[0] = 1;
	for (int i = 1; i <= N; i++) {
		p2[i] = p2[i-1] + p2[i-1];
	}

	num res = 1;
	for (int i = 1; i <= N; i++) {
		res = res + res + res;
	}

	for (int i = N/2+1; i <= N; i++) {
		res -= 2 * fact[N] * ifact[i] * ifact[N-i] * p2[N-i];
	}
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 118656
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    long long n,d,k,j,su=0,cnt=0;
    scanf("%lld %lld",&n,&d);
    double x;
    while(n--)
    {
        scanf("%lld %lld",&k,&j);
         x=sqrt((k*1.00*k*1.00)+(j*1.00*j*1.00));
         if(x<=d*1.00)
         cnt++;
        
    }
    
    printf("%lld\n",cnt);
    return 0;
}

Measured memory_bytes: 2116
#include <stdio.h>

int main(void) {

  int n,c;
  scanf("%d %d", &n, &c);
  long d[c+1][c+1];
  for (int i = 1; i <= c; i++) {
    for (int j = 1; j <= c; j++) {
      scanf("%ld", &d[i][j]);
    }
  }
  int color[n+1][n+1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &color[i][j]);
    }
  }
  long list[3][c+1];
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j <= c; j++) {
      list[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if ((i+j)%3 == 0) {
        list[0][color[i][j]]++;
      } else if ((i+j)%3 == 1) {
        list[1][color[i][j]]++;
      } else {
        list[2][color[i][j]]++;
      }
    }
  }
  long wrongness;
  long min = -1;
  for (int color_0 = 1; color_0 <= c; color_0++) {
    for (int color_1 = 1; color_1 <= c; color_1++) {
      if (color_1 == color_0) {
        continue;
      }
      for (int color_2 = 1; color_2 <= c; color_2++) {
        if (color_2 == color_0 || color_2 == color_1) {
          continue;
        }
        wrongness = 0;
        for (int i = 1; i <= c; i++) {
          wrongness += d[i][color_0]*list[0][i]+d[i][color_1]*list[1][i]+d[i][color_2]*list[2][i];
        }
        if (min == -1 || wrongness < min) {
          min = wrongness;
        }
      }
    }
  }
  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,count=0;
    cin>>n;
    long long int a[n],b[n]={0};
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        if((i-a[i])>=0)
        {
            b[i-a[i]]++;
        }
    }
    for(long long int i=0;i<n;i++)
    {
        if(((a[i]+i)<n)&&(b[a[i]+i]!=0))
        count=count+b[a[i]+i];
    }
    cout<<count;
    return 0;
}

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

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<int> v1(n);
        vector<int> v2(m);
        for(int i=0; i<n; ++i) {
            cin >> v1[i];
        }
        for(int i=0; i<m; ++i) {
            cin >> v2[i];
        }
        int ret1=1000, ret2=1000;
        int sum1 = accumulate(begin(v1), end(v1), 0);
        int sum2 = accumulate(begin(v2), end(v2), 0);
        for(int i=0; i<n; ++i) {
            for(int j=0; j<m; ++j) {
                if(sum1 - sum2 == (v1[i]-v2[j])*2) {
                    if(ret1 + ret2 > v1[i] + v2[j]) {
                        ret1 = v1[i];
                        ret2 = v2[j];
                    }
                }
            }
        }
        if(ret1 == 1000) cout << -1 << endl;
        else cout << ret1 << " " << ret2 << endl;
    }
}


Measured memory_bytes: 3044
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] C = new int[N];
        int[][] A = new int[N][M];
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        int min = INF;
        for (int bit = 1; bit < 1 << N; bit++) {
            int[] sum = new int[M];
            int val = 0;
            for (int k = 0; k < N; k++) {
                int mask = 1 << k;
                boolean buy = (mask & bit)!=0;
                if(buy) {
                    val += C[k];
                    for (int i = 0; i < M; i++) {
                        sum[i] += A[k][i];
                    }
                }
            }
            boolean ok = true;
            for (int i = 0; i < M; i++) {
                if(sum[i]<X)ok=false;
            }
            if(ok){
                if(min>val){
                    min = val;
                }
            }
        }

        System.out.println(min==INF?-1:min);
    }

    public static void main(String[] args) {
        new Main();
    }
}

Measured memory_bytes: 37416
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll bef=10,cnt=1;
 rep(j,0,4){
 ll t=(n/llpow(10,j))%10;
  if(t==bef)cnt++;
  else cnt=1;
  if(cnt==3){
   py;return 0;
  }
  bef=t;
 }
 pn;
return 0;}




Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var input = make([]string, 2)
	var n, k int
	if scanner.Scan() {
		input = strings.Split(scanner.Text(), " ")
		n, _ = strconv.Atoi(input[0])
		k, _ = strconv.Atoi(input[1])
	}

	//var flag bool
	var count int
	count = 1
	for ;n > k;{
		if n > k {
			n = n / k
			count++
		} else {
		}
	}
	if n/k ==0{
		fmt.Println(count)

	} else {
		fmt.Println(count+1)

	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
long long qmult(long long X, long long Y, long long M) {
    if (Y == 0) return 0; 
    long long half = qmult(X, Y/2, M);
    half += half;
    half %= M;
    if (Y % 2==1) half += X;
    return half%=M;
}
long long qexp(long long A, long long B, long long M) {
    if (B == 0) return 1; 
    long long half = qexp(A, B/2, M); 
    half = qmult(half, half, M); 
    half %= M;
    if (B%2==1) half *= A%M; 
    return half%M;
}

ll C(int n, int k) {
	ll x = 1, y = 1;
	FOR(i,0,k-1) {
		y*=n-i;
		x*=k-i;
		y%=MOD;
		x%=MOD;
	}
	return (y*qexp(x,MOD-2,MOD)) % MOD;
}

int32_t main() {
	IAMSPEED
	ll n,a,b; cin >> n >> a >> b;
	ll ans = (qexp(2,n,MOD)-1+MOD) % MOD;
	ans = (ans - C(n,a) + MOD) % MOD;
	ans = (ans - C(n,b) + MOD) % MOD;
	cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String str = sc.next();
    int min;
    int numE = 0;
    for (int i=0; i<n; i++) {
      if (str.charAt(i) == 'E') {
        numE++;
      }
    }
    min = numE;

    for (int i=0; i<n; i++) {
      if (str.charAt(i) == 'E') {
        numE--;
      }
      if (i>0 && str.charAt(i-1) == 'W') {
        numE++;
      }
      if (numE < min) {
        min = numE;
      }
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 30996
/* ex6_2
   UMAboogie */

#include<stdio.h>
#include<string.h>
#define SIZE 101
//文字列の大きさを定義
int main(void){
  int length;
  char word[SIZE]; //言葉をいれる配列を宣言

  scanf("%s",word); //言葉を入力

  length = strlen(word); //言葉の文字数を計算

  printf("%c%d%c\n",word[0],length-2,word[length-1]); //1文字目と言葉の文字数-2と最後の文字を出力

  return 0;
}


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

void swap(int* x, int* y){
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

int main(){
	int input = 0, a = 0, b = 0, c = 0;
	for(int i = 0; i <= 10; i++){
		cin >> input;
		if(c < input){
			swap(&c, &input);
		}
		if(b < c){
			swap(&b, &c);
		}
		if(a < b){
			swap(&a, &b);
		}
		if(a < c){
			swap(&a, &c);
		}
	}
	cout << a << endl;
	cout << b << endl;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1160
from itertools import groupby,accumulate
import bisect
n,m = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()
le=len(A)
#print(A)
B=list(accumulate([0]+A))
ok=0 #可能
ng=10**10 #不可能
ans=0
while 1<abs(ng-ok):
  mid=(ng+ok)//2
  ans=0
  cnt=0
  for i in range(le):
    x = mid-A[i]
    cnt1=int(bisect.bisect_left(A,x))
    cnt+=(le-cnt1)
    #ans+=A[i]*(le-cnt1)+B[n]-B[cnt1]
  if cnt>=m:
    ok=mid
  else:
    ng=mid
cnt=0
for i in range(le):
  x=ok-A[i]
  cnt1=int(bisect.bisect_left(A,x))
  cnt+=le-cnt1
  ans+=A[i]*(le-cnt1)+B[n]-B[cnt1]
print(ans+(m-cnt)*ok)

Measured memory_bytes: 58936
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, a[114];
vector<int>vec;
int ans[114];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		vec.push_back(a[i]);
	}
	rep(i, n) {
		for (int j = vec.size() - 1; j >= 0; j--) {
			if (vec[j] == j + 1) {
				ans[i] = j + 1;
				vec.erase(vec.begin() + j);
				goto loop;
			}
		}
		cout << -1 << endl; return 0;
	loop:;
	}
	rep(i, n) {
		cout << ans[n - i - 1] << endl;
	}
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x  
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;


int n=55555;
bool  p[55559];

void  seive(){
    p[0]=p[1]=true;
    for (int i=4;i<=n;i+=2) p[i]=true;
    for (int i=3;i*i <= n;i += 2){
        if (p[i] == false)
        for (int j=i*i;j<=n;j+= i*2)
                p[j] = true;
    }
}


inline void solve(){
    seive();
    int n,s=28; cin>>n; 
    for (int i=10;i<=55555 and n>0;i++){
        if (p[i] == false and i%5==1){
            cout << i << " ";
            n--;
        }
    }
    cout << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3540