akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 200005
typedef long long ll;
int A[M],B[M];
ll dp[M],tot[M];
const ll P=1e9+7;
int main() {
	int n,m=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",A+i);
	for(int i=1;i<=n;++i)
		if(A[i]!=A[i-1]) B[++m]=A[i];
	dp[0]=1;
	for(int i=1;i<=m;++i) {
		dp[i]=(dp[i-1]+tot[B[i]])%P;
		(tot[B[i]]+=dp[i-1])%=P;
	}
	printf("%lld\n",dp[m]);
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

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

using namespace std;

int main() {
	int x,y,z;
	cin >> x >> y >> z;

	swap( x, y );
	swap( x, z );

	cout << x << " " << y << " " << z;
}


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

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 1;
const long long INF = 1e18;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int a, b;
int main (){
  scanf ("%d %d", &a, &b);
  printf ("%d\n", max(a + b, max(a - b, a * b)));
  return 0;
}


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

int main(){
    int flag=0;
    int n,k;
    int MIN=1e5+1,p=0;
    cin >>n>>k;
    int a[n];
    int ans=0;

    for (int i = 0; i < n; i++){
        cin >>a[i];
        
        if(MIN > a[i]){
            MIN = a[i];
            p=i;
        }
    }
    
    ans = (n+k-3)/(k-1);
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s="1";
int n; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	while(--n)
	{
//		cout<<s<<endl;
		int x=s.size()-1;
		while(x>0&&(s[x]==s[x-1]+1||(s[x-1]=='9'&&s[x]=='9')))x--;
		if(s[x]=='9')
		{
			int y=s.size();
			s="1";
			while(y--)s+='0';
		}
		else
		{
			s[x]++;
			for(int i=x+1;i<s.size();i++)
			{
				s[i]=s[i-1]-1;
				if(s[i]<'0')s[i]='0';
			}
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
al = sorted(list(map(int, input().split())))
c = list(np.cumsum(al))

ans = 1
for i in range(n-1):
    if c[i]*2 >= al[i+1]:
        ans += 1
    else:
        ans = 1

print(ans)


Measured memory_bytes: 38468
N,M = map(int,input().split())
aList = [int(x) for x in input().split()]
aList.sort()
bc = []
for _ in range(M):
    b, c = map(int,input().split())
    bc.append((b,c))

bc = sorted(bc, key=lambda x:x[1], reverse=True)

idx = 0
result = 0
b = 0
c = 0
for a in aList:
    if b == 0:
        if idx < len(bc):
            b, c = bc[idx]
            idx += 1
        else:
            c = 0
    if a < c:
        result += c-a
        b -= 1
print(result+sum(aList))

Measured memory_bytes: 23288
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

vector<ll> func(ll x) {
    vector<ll> ret;
    for (ll i = 1; i*i <= x; i++) {
        if (x%i==0) {
            ret.emplace_back(i);
            if (i*i != x) ret.emplace_back(x/i);
        }
    }
    return ret;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N; cin >> N;
    auto A = func(N-1);
    auto B = func(N);

    ll ans = A.size()-1;
    //cout << ans << ln;
    for (auto i : B) {
        if (i==1) continue;
        ll M = N;
        while (M%i==0) {
            M /= i;
        }
        if (M%i==1) ans++;
    }

    cout << ans << ln;
}




Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;


int n;
map<int ,int> cnt;
int a;
int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a;
        cnt[a]++;
    }
    vector<Int> edge;
    for(auto it = cnt.rbegin();it != cnt.rend();it++){
        if(it->second >= 2){
            edge.push_back(it->first);
            it->second -= 2;
        }
        if(it->second >= 2){
            edge.push_back(it->first);
            it->second -= 2;
        }
    }
    if(edge.size() < 2)cout << 0 << endl;
    else cout << edge[0] * edge[1] << endl;
    return 0;
}

Measured memory_bytes: 8052
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
   int n,ans=0;
   cin>>n;
   ans+=n/500;
   ans*=1000;
   n%=500;
   ans+=5*(n/5);
   cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//This template belongs to Juan Carlo Vieri
#include <bits/stdc++.h>
using namespace std;

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void solve() {
  intt a, b, c, k;
  cin >> a >> b >> c >> k;
  intt ans = 0;
  if(k){
    ans += min(a, k);
    k -= min(a, k);
  }
  if(k){
    k -= min(b, k);
  }
  if(k){
    ans -= min(c, k);
  }
  cout << ans << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

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


Measured memory_bytes: 3640
N, Y = gets.chomp.split(' ').map(&:to_i)

ans = (0...(N+2)).to_a.combination(2).map do |i, j|
  [i, j - i - 1, N - j + 1]
end.find do |x, y, z|
  10_000 * x + 5_000 * y + 1_000 * z == Y
end

if ans
  puts ans.join(' ')
else
  puts '-1 -1 -1'
end


Measured memory_bytes: 129276
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    var(string, s, t);
    print(t + s);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  
  int ans=0;
  
  while(true){
    for(int i=0;i<N;i++){
      if(vec[i]%2!=0){
        cout<<ans<<endl;
        return 0;
      }
      vec[i]=vec[i]/2;
    }
    ans++;
  }
  
  
  cout<<ans<<endl;
}

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

int main(){
	long long n,d;
	cin >> n>> d;
	double x,y;
	long long count = 0;
	while(n--){
	cin >> x >> y;
	if(sqrt(x*x + y*y) <= d)count++;
		
	}
	cout<<count;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
  long long n, m, s, t, ans = 0;
  cin >> n >> m;

  // if(n == 1)
  //   s = 1;
  // else
  //   s = n -2;

  // if(m == 1)
  //   t = 1;
  // else
  //   t = m - 2;

  // cout << ((s )* (t) )<< endl;
  if(n == 1 && m == 1)
    cout << 1 << endl;
  else if(n == 1)
    cout << m -2 << endl;
  else if( m == 1)
    cout << n - 2 << endl;
  else
    cout << (n - 2) * (m-2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>

using namespace std;
int main()
{

	long long i, j, N, A, B, tmp;
	
	cin >> A;


	N = A / 3;
	

	cout << N;

	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll n;
	cin>>n;
	map<string,ll> mp;
	FOR(i,0,n-1){
		string S;
		cin>>S;
		++mp[S];
	}
	for(auto i:{"AC","WA","TLE","RE"}){
		cout<<i<<" x "<<mp[i]<<'\n';
	}
}


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

struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> size;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        size = vector<int>(N, 1);
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        }
        else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
};
int main(){
    int N, K, L;
    cin >> N >> K >> L;
    vector<int> p(K), q(K), r(L), s(L);
    for (int i = 0; i < K; i++) scanf("%d %d", &p[i], &q[i]);
    for (int i = 0; i < L; i++) scanf("%d %d", &r[i], &s[i]);
    unionfind uf1(N+1), uf2(N+1), uf3(N+1);
    
    for (int i = 0; i < K; i++) uf1.unite(p[i], q[i]);
    for (int i = 0; i < L; i++) uf2.unite(r[i], s[i]);
    map<pair<int, int>, int> mp;
    for (int i = 1; i <= N; i++) mp[{uf1.root(i), uf2.root(i)}]++;
    for (int i = 1; i <= N; i++) {
        int size = mp[{uf1.root(i), uf2.root(i)}];
        if (i == 1) printf("%d", size);
        else printf(" %d", size);
    }
    cout << endl;
    return 0;
}

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

int main()
{
    int n,a;
    long long min=1000000,max=-1000000,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<min)min=a;
        if(a>max)max=a;
        sum+=a;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3092
#include <stdio.h>


int i,c;

int area(int d) {
    int sum = 0;
    for(i=d; i<=600-d;i += d){
        c = d * i * i;
        sum = sum + c;
        
    }
    return sum;
}

int main(void){
    int d;
    while(scanf("%d", &d) != EOF) {
       printf("%d\n", area(d));
    }
    return 0;
}


Measured memory_bytes: 1988
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int N, Y;
  cin >> N >> Y;
  int ans = 0;

  for (int x = 0; x <=N ; x++) {
    for (int y = 0; y <= N; y++) {
      int z = N - x - y;
      if( z >= 0 ){
        int sum = 10000*x + 5000*y + 1000*z;
        if(sum == Y){
          cout << x << " " << y << " " << z << endl;
          return 0;
        }
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
s=input()
n=int(input())
a=[input() for _ in range(n)]

front=True
f=""
b=""

for q in a:
    if q=="1":front=not front;continue
    l=q.split()
    if l[1]=="1":
        if front:f=l[2]+f
        else:b=b+l[2]
    if l[1]=="2":
        if front:b=b+l[2]
        else:f=l[2]+f

print(f+s+b if front else (f+s+b)[::-1])

Measured memory_bytes: 24084
N = list(map(int, input()))

# print(N)
ans = 0
DP = [0] *2
DP[0] = 0
DP[1] = 1
for i in N:
    a, b = DP[0] ,DP[1]
    DP[0] = a + i if a+i < b +(10-i) else b +(10-i)
    DP[1] = a + i+1 if a + i+1 < b + (9-i) else b + (9-i)

    # print(DP)

print(DP[0] if DP[0] <= DP[1]+1 else DP[1] +1)

Measured memory_bytes: 13508
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> inline void chmin(T& a, T b) { if (a > b)  a = b; }

signed main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> h(N);
	vector<int> dp(N,INF);
	rep(i, N) cin >> h[i];
	dp[0] = 0;
	FOR(i,1,N){
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 310
ll f[N][N][N];
int main(){
  ll n,m; cin>>n>>m;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)for(int k=0;k<N;k++)f[i][j][k]=0;
  f[0][1][1]=1;
  for(int len=0;len<m;len++){
      for(int a=1;a<=n;a++)for(int b=1;b<=n;b++){
	  ll ff=f[len][a][b];
	  if(a==b){
	      mad(f[len+1][a][a],ff*a);
	      mad(f[len+1][a][a+1],ff);
	  }
	  else{
	      mad(f[len+1][a][b],ff*(b-a));
	      mad(f[len+1][b][b],ff*a);
	      mad(f[len+1][a][b+1],ff);
	  }
      }
  }
  ll ans=1;
  for(ll i=1;i<n;i++)ans=ans*i%mod;
  cout<<ans*f[m][n][n]%mod<<endl;
  return 0;
}


Measured memory_bytes: 232960
#include<stdio.h>

int main()
{
  int N,K,count=1;
  scanf("%d %d",&N,&K);
  
  while(N>=K)
  {
    N=N-N%K;
    N=N/K;
    count++;
  }
    
  
  printf("%d",count);

  return 0; 
}


Measured memory_bytes: 128
using System;

class Program
{
    static void Main()
    {
        string str;
        string left;
        string right;

        int mix = 0;
        int h = 0;

        int i = 0;

        while (true)
        {
            str = Console.ReadLine();
            if (str == "-")
                break;

            mix = int.Parse(Console.ReadLine());
            for(i = 0; i < mix; i++)
            {
                h = int.Parse(Console.ReadLine());
                left = str.Substring(0, h);
                right = str.Substring(h);
                str = right + left;
            }

            Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 8808
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		byte[] cc = sc.next().getBytes();
		println(cc[2] == cc[3] && cc[4] == cc[5] ? "Yes" : "No");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S, T;
    cin >> S >> T;
    rep(i, N) {
        cout << S[i] << T[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
typedef long long ll;
int sgn(double x){
    if(fabs(x)<eps){
        return 0;
    }
    if(x<0){
        return -1;
    }else{
        return 1;
    }
}
struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x = _x;
        y = _y;
    }
    void input(){
        scanf("%lf%lf",&x,&y);
    }
    double distance(Point p){
        return hypot(x-p.x,y-p.y);
    }
}p[100005];
int a[100005];   //暂存点的坐标
bool cmpx(const Point &a,const Point &b){
    return a.x<b.x;
}
bool cmpy(int a,int b){
    return p[a].y<p[b].y;
}
double closest(int low,int high){
    if(low+1 == high){    //只有两个点
        return p[low].distance(p[high]);
    }
    if(low+2 == high){   //三个点也好算
        return min(p[low].distance(p[high]),min(p[low].distance(p[low+1]),p[low+1].distance(p[high])));
    }
    int mid = (low+high)>>1;
    double ans = min(closest(low,mid),closest(mid+1,high));
    int i,j,cnt = 0;
    for(int i = low;i <= high;++i ){
        if(p[i].x>=p[mid].x-ans&&p[i].x<=p[mid].x+ans){
            a[cnt++] = i;
        }
    }
    sort(a,a+cnt,cmpy);
    for(int i = 0;i < cnt;++i ){
        for(int j = i+1;j < cnt;++j ){
            if(p[a[j]].y-p[a[i]].y>=ans){
                break;
            }
            ans = min(ans,p[a[i]].distance(p[a[j]]));
        }
    }
    return ans;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0;i < n;++i ){
        p[i].input();
    }
    sort(p,p+n,cmpx);
    printf("%.8f\n",closest(0,n-1));
    return 0;
}



Measured memory_bytes: 5012
import java.io.*;
import java.util.*;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long l = sc.nextLong();
		long[][] dis = new long[n][n];
		for(int i=0;i<n;++i) {
			for(int j=0;j<n;++j) {
				dis[i][j] = i == j ? 0 : MAX;
			}
		}
		
		for(int i=0;i<m;++i) {
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			int w = sc.nextInt();
			dis[u][v] = dis[v][u] = w;
		}
		
		for(int k = 0;k<n;++k) {
			for(int i=0;i<n;++i) {
				for(int j=0;j<n;++j) 
					dis[i][j] = Math.min(dis[i][j],dis[i][k] + dis[k][j]);
			}
		}
		
		
		for(int i=0;i<n;++i) {
			for(int j=0;j<n;++j) {
				if(dis[i][j] <= l) dis[i][j] = 1;
				else dis[i][j] = MAX;
				if(i == j) dis[i][j] = 0;
			}
		}
		
		for(int k = 0;k<n;++k) {
			for(int i=0;i<n;++i) {
				for(int j=0;j<n;++j) 
					dis[i][j] = Math.min(dis[i][j],dis[i][k] + dis[k][j]);
			}
		}
		int q = sc.nextInt();
		while(q-->0) {
			int s = sc.nextInt()-1;
			int t = sc.nextInt()-1;
			if(dis[s][t] >= MAX) out.println(-1);
			else out.println(dis[s][t]-1);
		}
		out.close();
	}
}

Measured memory_bytes: 46380
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	int a, b;
	char x = ' ';
	while (x != '?'){
		cin >> a >> x >> b;
		if (x == '+')
			cout << a + b << endl;
			else if (x == '-')
				cout << a - b << endl;
				else if (x == '*')
					cout << a * b << endl;
					else if (x == '/')
						cout << a / b << endl;
	}
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    if(N%2){
        cout << N*2;
    }else{
        cout << N;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string w;
    cin >> w;
    char alph[30];
    for(int i = 0; i < 30; i++) alph[i] = 0;
    int len = w.length();
    for(int i = 0; i < len; i++){
        alph[w[i]-'a']++;
    }
    for(int i = 0; i < 30; i++){
        if(alph[i] % 2 != 0) {cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 310;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int r;
    cin >> r;
    cout << 3 * r * r;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
int_s = [0] * N
cum_sum_w = [0] * (N + 1)
cum_sum_e = [0] * (N + 1)
answers = [0] * N
for i in range(N):
    if (S[i] == 'W'):
        int_s[i] = 1
    else:
        int_s[i] = 0
    cum_sum_w[i + 1] = cum_sum_w[i] + int_s[i]
for i in range(N):
    if (S[i] == 'E'):
        int_s[i] = 1
    else:
        int_s[i] = 0
    cum_sum_e[i + 1] = cum_sum_e[i] + int_s[i]
for i in range(N):
    answers[i] = cum_sum_w[i] + (cum_sum_e[N] - cum_sum_e[i + 1])
print(min(answers))

Measured memory_bytes: 41336
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

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

  vector<int> a(n);
  int max1=0,max2=0;
  r(i,n){
    cin>>a.at(i);
    if(a.at(i)>=max1){
      max2=max1;
      max1=a.at(i);
    }else if(a.at(i)>=max2){
      max2=a.at(i);
    }
    
  }

  r(i,n){
    if(a.at(i)==max1)cout<<max2<<endl;
    else cout<<max1<<endl;
  }

  return 0;
}


Measured memory_bytes: 2432
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

const inf = int(1e10)

func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}
func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		h[i] = nextInt(sc)
	}
	dp := make([]int, N+10) // 大きめに準備
	for i := 0; i < len(dp); i++ {
		dp[i] = inf // dpテーブルをinfで初期化
	}
	dp[0] = 0 // 初期条件
	for i := 0; i < N; i++ {
		if i+1 < N {
			chmin(&dp[i+1], dp[i]+abs(h[i+1]-h[i]))
		}
		if i+2 < N {
			chmin(&dp[i+2], dp[i]+abs(h[i+2]-h[i]))
		}
	}
	fmt.Println(dp[N-1])
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int,int> P;
//後ろからgreedy 
int main(){
    int N,M;
    cin >> N >> M;
    vector<P> jobs;
    rep(i,N){
        int a,b;
        cin >> a >> b;
        jobs.push_back({a,b}); 
    }
    sort(jobs.rbegin(),jobs.rend());
    priority_queue<int> que;
    int res = 0;
    for(int i = 1; i <= M; i++){
        P p = jobs.back();
        //できる仕事をキューに詰めて最大値をとる.
        while(i >= p.first && jobs.size() != 0){
            jobs.pop_back();
            que.push(p.second);
            p = jobs.back();
        }
        if(!que.empty()){
            res += que.top();que.pop();
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1908
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

const ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<pll> c;
    ll sum=0;
    rep(i,26){
        ll t;
        cin >> t;
        c.push_back(make_pair(t,i+1));
        if(t>=30) sum++;
    }
    vector<vector<pll>> s(d);
    rep(i,d){
        rep(j,26){
            ll v;
            cin >> v;
            s[i].push_back(make_pair(v,j+1));
        }
        sort(s[i].rbegin(),s[i].rend());
    }
    vector<ll> ans,used(26);
    ll tot=d;
    ll cnt=0;
    sort(c.rbegin(),c.rend());
    rep(i,d){
        //cout << ans[i] << endl;
    }
    vector<ll> per(26);
    rep(i,26){
        per[i]=i+1;
    }
    do{
        rep(i,26){
            ans.push_back(per[i]);
            cnt++;
            if(cnt==d) break;
        }
        if(cnt==d) break;
    }while(next_permutation(per.begin(),per.end()));
    sum=min(sum,20LL);
    vector<ll> num(sum);
    rep(i,sum){
        num[i]=c[i].se;
    }
    
    rep(i,d){
        cout << num[i%sum] << endl;
    }
    return 0;
} 

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,m,c;
  cin>>n>>m>>c;
  int b[m];
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  int count=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      int a;
      cin>>a;
      sum+=a*b[j];
    }
    if(sum+c>0) count++;
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int i,n,x,max,min;
	long long int sum;
	sum = 0;
	min = -1000000;
	max = 1000000;
	scanf("%d", &n);

	for (i = 1; i <= n; i=i+1) {
		scanf("%d", &x);
		if (x <= max)max = x;
		if (x >= min)min = x;
		sum = sum + x;
	}
	printf("%d %d %lld\n", max, min, sum);

	return 0;
}


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

using namespace std;

int main(){
	int N;
	cin >> N;
	int d[N];
	for (int i = 0; i < N; i++){
		cin >> d[i];
	}
	sort(d, d + N);

	cout << d[N / 2] - d[N / 2 - 1] << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pint = pair<int,int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int main() {
    int n;
    cin>>n;
    vector<pint> ba(n);
    rep(i,n){
        int a,b;cin>>a>>b;
        ba[i] = {b,a};
    }

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

    int now = 0;
    rep(i,n){
        now += ba[i].second;
        if (now > ba[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}

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

#define N_MAX 100005
#define NIL -1

long n;
vector<long> G[N_MAX];
long color[N_MAX];

void bfs(long i, long id) {
    queue<long> S;
    S.push(i);
    color[i] = id;
    while (S.empty() == false) {
        long u = S.front();
        S.pop();
        for (long j = 0; j < G[u].size(); j++) {
            long v = G[u][j];
            if (color[v] == NIL) {
                color[v] = id;
                S.push(v);
            }
        }
    }
}

void assign_color(long i, long id) {
    bfs(i, id);
}

int main() {
    long m, q, s, t;
    cin >> n >> m;
    for (long i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    // for (long i = 0; i < n; i++) {
    //     cout << "Node " << i << ": ";
    //     for (long j = 0; j < G[i].size(); j++) {
    //         cout << " " << G[i][j];
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    for (long i = 0; i < n; i++) {
        color[i] = NIL;
    }

    long id = 0;
    for (long i = 0; i < n; i++) {
        if (color[i] == NIL) {
            assign_color(i, id);
            id++;
        }
    }

    // for (long i = 0; i < n; i++) {
    //     cout << " " << color[i];
    // }
    // cout << endl;

    cin >> q;
    for (long i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] != color[t]) {
            cout << "no" << endl;
        }
        else {
            cout << "yes" << endl;
        }
    }
}



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

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

    int n, m;
    cin >> n >> m;

    map<int, int> road;
    rep(i, m){
        int a, b;
        cin >> a >> b;

        ++road[a];
        ++road[b];
    }
    rep1(i, n+1){
        cout << road[i] << endl;
    }

    return 0;
}

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

using namespace std;

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

int k;
vector<P> d;
char table[8][8];
vector<int> row;
vector<int> col;

void show_vec(vector<int>);

void solve(){
    
    sort(col.begin(), col.end());
    do{
       
        vector<P> v;
        for (auto &e: d) v.push_back(e);
        
        for (int i = 0 ; i < (int)row.size(); i++)
        {   
            P p;
            p.first = row[i];
            p.second = col[i];
            v.push_back(p);
        }
        bool ok = true;
        for (int i = 0; i < (int)v.size() && ok; i++)
        {
            for (int j = 0; j < (int)v.size(); j++)
            {
                if(i == j) continue;
                int dx = v[i].first - v[j].first;
                int dy = v[i].second - v[j].second;
                if(abs(dx) == abs(dy)){
                    ok = false;
                    break;
                }
            }
            
        }
        if(ok){
            for(auto &e: v){
                //cout << "(" << e.first << ", " << e.second << ")";
                table[e.first][e.second] = 'Q';
            }
        
            break;
        }
    }while(next_permutation(col.begin(), col.end()));
    
    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            cout << table[i][j];
        }
        cout << endl;
        
    }
    
}


int main(){
    cin >> k;
    for (int i = 0; i < 8; i++)
    {
        row.push_back(i);
        col.push_back(i);
    }

    
    for (int i = 0; i < k; i++)
    {
        P p;
        cin >> p.first >> p.second;
        row.erase(find(row.begin(), row.end(), p.first));
        col.erase(find(col.begin(), col.end(), p.second));
        d.push_back(p);
    }
    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            table[i][j] = '.';
        }
       
        
    }
  
    solve();

    return 0;

}

void show_vec(vector<int> v){
    cout << "[";
    for (int i = 0; i < (int)v.size(); i++)
    {
        cout << v[i] << ", ";
    }
    cout << "\b\b]" << endl;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}



Measured memory_bytes: 256
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {


            string a = Console.ReadLine();
            int n = int.Parse(a);

            for (int i = 3; i <= n; i++)
            {
                if (i % 3 == 0)                               //3??§????????????
                {
                    Console.Write(" " + i);                  //i???3??§???????????°??????
                }
                else if (i < n)
                {
                    string s = i.ToString();                 //i?????°????????????????????????

                    if (s.Contains("3"))                    //??????????????????3?????\??£??????????????????
                    {
                        Console.Write(" " + s);             //i???3???????????????????????°??????
                    }
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9812
#include<iostream>
#include<string>
using namespace std;
int j,y;
void DFS(int jp,int yp,string sp){
  if(j==jp&&y==yp){cout<<sp<<endl;return;}
  if(jp<=3&&yp==5 || jp==5&&yp<=3)return;
  if(jp==6&&yp==4 || jp==4&&yp==6)return;
  if(jp==5&&yp==5)return;
  DFS(jp+1,yp,sp+"A");
  DFS(jp,yp+1,sp+"B");
}
int main(){
  cin>>j>>y;
  DFS(0,0,"");
}



Measured memory_bytes: 3204
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

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

#define rall(x)                         \
(x).rbegin(), (x).rend()

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

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    int n, i; cin >> n >> i;
    cout << n - i + 1 << endl;

return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FOR(i,k,n) for(ll i=(k);i<(ll)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
 
using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long double a,b;
  cin>>a>>b;
  auto x = a*b+3e-3;
  ll ans = floor(x);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    char d;
    int p,n,ps,ns,c;
     
    ps=ns=c=0;
    while(cin >> p >> d >> n)
    {
        ps+=p*n;
        ns+=n;
        c++;
    }
    cout << ps << endl << (int)((double)ns/c+0.5) << endl;
}

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

int main()
{
    char a,b;
    cin >> a >> b;
    if(a == 'H' && b == 'H' || a == 'D' && b == 'D'){
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def ec(s):
    ans = [0]
    cur = 0
    for c in s:
        if c == 'W':
            cur += 1
        ans.append(cur)
    return ans


def main():
    n = int(input())
    s = input().strip()
    fr = ec(s)
    ba = ec(reversed(s))
    ans = n
    for i in range(n):
        ans = min(ans, fr[i] + (n - i - 1) - ba[n - 1 - i])
        # print(i, fr[i] + (n - i - 1) - ba[n - 1 - i])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64744
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInts()
    let N = line[0]
    let Y = line[1]
    
    for i in 0...N {
        for j in 0...(N - i) {
            let k = N - i - j
            if 10000 * i + 5000 * j + 1000 * k == Y {
                print(i, j, k)
                return
            }
        }
    }
    
    print("-1 -1 -1")
}

main()


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    ll x,y;
    cin>>x>>y;
    ll cnt=0;
    for(ll i=x;i<=y;i*=2){
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N, R;
  cin >> N >> R;

  if (10 <= N) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
	n = int(input())
	lst = deque()
	for _ in range(n):
		s = input()
		if s == "deleteFirst":
			lst.popleft()
		elif s == "deleteLast":
			lst.pop()
		else:
			cmd, num = s.split()
			if cmd == "insert":
				lst.appendleft(num)
			else:
				try:
					lst.remove(num)
				except ValueError:
					pass
	print(" ".join(list(lst)))

main()


Measured memory_bytes: 69856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    ll n, m;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll res = 0;
    if(n == m){
        vector<ll> fact(n+1);
        fact[0] = 1;
        for(int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i % mod;
        res = fact[n] * fact[m] % mod * 2 % mod;
    }
    else{
        if(n > m)   swap(n, m);
        vector<ll> fact(m+1);
        fact[0] = 1;
        for(int i = 1; i <= m; ++i) fact[i] = fact[i-1] * i % mod;
        res = fact[n] * fact[m] % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024