akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}



signed main(){
    int n;cin>>n;
    int cnt[n+1]={};
    for(int i=1;i*i<=n;i++){
        for(int j=1;i*i+j*j<=n;j++){
            for(int k=1;i*i+j*j+k*k<=n;k++){
                int to=(i+j+k)*(i+j+k)-i*j-i*k-j*k;
                if(to<=n)
                cnt[to]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout<<cnt[i]<<endl;
    return 0;
}


Measured memory_bytes: 3672
N,M=map(int,input().split())
S=[]
for i in range(M):
  S.append(list(map(int,input().split())))
  S[-1]=S[-1][1:]
P=list(map(int,input().split()))

ans=0
for i in range(2**N):
  bit=format(i,'0'+str(N)+'b')
  bit=list(map(int,bit))
  on=0
  for s,p in zip(S,P):
    check=0
    for j in s:
      j-=1
      check+=bit[j]
    if check%2==p:on+=1
  if on==M:ans+=1  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int A[20][20], C[20];
int main() {
  int n,m,x;
  cin >> n >> m >> x;
  rep(i,n){
    cin >> C[i];
    rep(j,m)cin >> A[i][j];
  }
  int ans = 1001001001;
  rep(d,1<<13){
    bitset<12> b(d);
    int cost = 0;
    vi s(12,0);
    rep(i,b.size()){
      if(b[i]){
        cost+=C[i];
        rep(j,m){
          s[j]+=A[i][j];
        }
      }
      bool ok = true;
      rep(i,m){
        if(s[i] < x)ok = false;
      }
      if(ok) mins(ans,cost);
    }
  }
  if(ans == 1001001001)ans=-1;
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    map<string, int> S;
    for (int i = 0; i < N; i++)
    {
        string B;
        cin >> B;
        S[B]++;
    }
    string mxname;
    int mx = 0;
    for (auto p : S)
    {
        auto value = p.second;
        if (mx < value)
        {
            mx = value;
        }
    }
    for (auto p : S)
    {
        auto key = p.first;
        auto value = p.second;
        if (mx == value)
        {
            cout << key << endl;
        }
    }
}

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

int main(){
	long long a,b,n;
	cin >> a >> b;
	n=b;
	b--;
	a--;
	for(int i=0;i<a;i++){
		n*=b;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end
void div2(long long M,int& ans){
    while(!(M%2)){
        M/=2;
        ans++;
    }
}

int mul3(long long M){
    int Max=0;
    while(M*3 < 1000000000){
        M*=3;
        Max++;
    }
    return Max;
}

int main() {
    unsigned int N;
    int answer=0;
    int Max2,Max3;
    cin >> N;
    vector<long long>a(N);

    rep(i,N){
        cin>> a[i];
    }

    rep(i,N){
        div2(a[i],answer);
    }

    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

int n;
int h[100005];
int dp[100005] = {0};

int main(){
	memset(dp,0x3f,sizeof(dp)); dp[1] = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++) scanf("%d",&h[i]);
	for(int i = 2;i <= n;i ++) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),dp[i - 2] + abs(h[i] - h[i - 2]));
	printf("%d\n",dp[n]);
	return 0;
}
//

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

int main() {
	int H,W;
  	cin >> H >> W;
  
  	vector<vector<char>> vec(H,vector<char> (W));
  	for(int i = 0; i < H; i++) {
    	for(int j = 0; j < W; j++) {
        	cin >> vec.at(i).at(j);
        }
    }
  
  	for(int i = 0; i < W + 1; i++) {
    	cout << '#';
    }
  
  	cout << '#' << endl;
  
  	for(int i = 0; i < H; i++) {
      	cout << '#';
    	for(int j = 0; j < W; j++) {
          cout << vec.at(i).at(j);
        }
      	cout << '#' << endl;
    }
  
  	
  	for(int i = 0; i < W + 1; i++) {
    	cout << '#';
    }
  
  	cout << '#' << endl;
}

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

using namespace std;

int n;
int dp[33];

int solve(int now){

    if(dp[now] != -1) return dp[now];

    if(now == n) return 1;
    else if(now > n) return 0;
    else {
        return dp[now] = solve(now + 1) + solve(now + 2) + solve(now + 3);
    }

}

int main(){

    while(cin >> n, n){

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

        int pattern = (solve(0) - 1) / 3650 + 1;

        cout << pattern << endl;

    }

}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int main() {
	long long int a, b, n;
	cin >> a >> b >> n;
	if (n >= b) {
		n = b - 1;
	}
	long long int c = a * n / b - a * (n / b);
	cout << c;
}

Measured memory_bytes: 5460
l = list([int(input()) for _ in range(5)])
 
ans = 0
ml = []
 
for i in range(len(l)):
  ans += l[i]
  if ans % 10 == 0:
    pass
  else:
    ans += 10 - (ans % 10)

for i in range(len(l)):
  ml.append(l[i] % 10)
  if ml[i] == 0:
    ml[i] = 10
  
ans -= 10 - min(ml)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  REP(i,K){
    vector<int> imos(N+1,0);
    REP(j,N){
      imos.at(max(0,j-A[j]))++;
      imos.at(min(N,j+A[j]+1))--;
    }
    int sum = 0;
    REP(j,N){
      sum+=imos.at(j);
      A[j]=sum;
    }
    int flag=0;
    REP(j,N){
      if(A[j]!=N){
        flag=1;
      }
    }
    if(flag==0){
      break;
    }
  }

  REP(i,N){
    if(i!=N-1){
      cout << A[i] << " ";
    }else{
      cout << A[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 4816
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i,cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    A,B=map(int,input().split())
    if A==1 and B==1:
        return 1
    AF=[x[0] for x in factorization(A)]
    BF=[x[0] for x in factorization(B)]
    return len(set(AF)&set(BF))+1
    

print(main())


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    cout<<max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e})+5<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int r = int.Parse(s[0]);
        int d = int.Parse(s[1]);
        long x = long.Parse(s[2]);
        for (int i = 0;i < 10; i++)
        {
            x = r * x - d;
            Console.WriteLine(x);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

vvi mult(vvi A, vvi B, ll mod) {
  ll n = A.size();
  vvi C(n, vi(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        C[i][j] += A[i][k] * B[k][j];
        C[i][j] %= mod;
      }
    }
  }
  return C;
}

vvi pow(vvi A, ll x, ll mod) {
  vvi tmp = A;
  vvi ans = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
  while(x) {
    if (x % 2) {
      ans = mult(ans, tmp, mod);
    }
    tmp = mult(tmp, tmp, mod);
    x /= 2;
  }
  return ans;
}

int main() {
  ll L, A, B, M;
  cin >> L >> A >> B >> M;

  ll X = 0;
  ll s = A;

  for (ll d = 1; d <= 18; d++) {
    ll C = [&](){
      ll p = 0;
      for (ll i = 0; i < d - 1; i++) {
        p = p * 10 + 9;
      }
      ll q = p * 10 + 9;

      // p < A + B * i <= q
      // (p - A) / B < i <= (q - A) / B
      q = q - A < 0 ? -1 : (q - A) / B;
      p = (p - A + B) / B;
      q = min(q, L - 1);
      p = max(p, 0ll);
      ll C = max(0ll, q - p + 1);
      return C;
    }();

    vvi A = {
      {([&](){ ll i = 1; for (ll j = 0; j < d; j++) i = i * 10 % M; return i; })(), 0, 0},
      {1, 1, 0},
      {0, B % M, 1},
    };

    vvi B = pow(A, C, M);

    tie(X, s) = [&](){
      ll X_new = X * B[0][0] + s * B[1][0] + 1 * B[2][0];
      ll s_new = X * B[0][1] + s * B[1][1] + 1 * B[2][1];
      X_new %= M;
      s_new %= M;
      return make_pair(X_new, s_new);
    }();
  }

  cout << X << endl;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = [0] * N
A = [list() for _ in range(N)]
for i in range(N):
    C[i], *A[i] = map(int, input().split()) #*は残りをAにinputの意味

def F(p):
    cost = 0
    rikais = [0] * M
    for i in range(N):
        if (p >> i) & 1:
            cost += C[i]
            for t in range(M):
                rikais[t] += A[i][t]
    return rikais, cost

ans = float("inf")
for p in range(2 ** N):
    rikais, cost = F(p)
    all_clear = True
    for r in rikais:
        if r >= X:
            continue
        if r < X:
            all_clear = False
    if all_clear:
        ans = min(cost, ans)
if ans == float("inf"):
    print(-1)
else:
    print(ans)



Measured memory_bytes: 68744
S = input()
ml = 0
cnt = 0

for i in range (len(S)):
  cnt = 0
  for j in range (i+1, len(S)+1):
    cnt = S[i:j].count("A")+ S[i:j].count("T")+ S[i:j].count("G")+ S[i:j].count("C")
   
    if cnt == len(S[i:j]) and cnt > ml:
      ml = cnt
      
print(ml)

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

void addedge(int u, int v) {
	cout<<u<<' '<<v<<'\n';
}

int main() {
	//35c
	int n;
	cin>>n;
	int k = 0;
	while ((1<<k) < n) k ++;
	if ((1<<k) == n) {
		cout<<"No";
		return 0;
	}
	k --;
	cout<<"Yes"<<'\n';
	addedge(3 + n, 1 + n);
	for (int i = 3; i <= n; i += 2) {
		addedge(1, i);
		addedge(i, i - 1 + n);
		addedge(1, i - 1);
		addedge(i - 1, i + n);
	}
	if (n % 2 == 0) {
		int x = (1<<k);
		int y = n ^ 1 ^ x;
		assert(y < n);
		addedge(n, x);
		addedge(n<<1, y);
	}
}

Measured memory_bytes: 3616
h, w = gets.chomp.split.map(&:to_i)
s = readlines.map{|line| line.chomp.split}

(0...h).each{|i| 
    (0...w).each{|j|
        puts [*"A".."Z"][j] + (i + 1).to_s if s[i][j] == "snuke"
    }
}

Measured memory_bytes: 1788
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
 
int main() {
  vector<char> vec(9);
  for(int i=0;i<9;i++){
    cin >> vec.at(i);
  }
  cout << vec.at(0) << vec.at(4) << vec.at(8) << endl;
}


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

#define ll long long
#define ull unsigned long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}

ll h[100010];
ll dp[100010];

int main ()
{
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, v;

    while(sl(n) != EOF)
    {
        for (i = 1; i <= n; i++)
        {
            sl(h[i]);
        }

        dp[1] = 0;
        for (i = 2; i <= n; i++)
        {
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
            if (i-2 >= 1)
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }

        printf("%lld\n", dp[n]);
    }
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
    #include<cstdio>
    #include<vector>
    #include<cmath>
    #include<cstring>
    #include<fstream>
    #include<algorithm>
    using namespace std;
    typedef long long LL;
    const int INF=0x3f3f3f3f;
    const int MAXN=1e5+5;
    int tot,head[MAXN];
    LL dist[MAXN];
    bool vis[MAXN];

    struct Edge
    {
        int from,to,nxt;
        LL cost;
    }e[MAXN*2];

    void addedge(int u,int v,int w)
    {
        e[tot].from=u;
        e[tot].to=v;
        e[tot].cost=w;
        e[tot].nxt=head[u];
        head[u]=tot++;
    }

    void dfs(int u,int fa)
    {
        for(int i=head[u];i!=-1;i=e[i].nxt)
        {
            int to=e[i].to;
            if(to==fa) continue;
            dist[to]=dist[u]+e[i].cost;
            dfs(to,u);
        }
    }

    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            tot=0;
            memset(head,-1,sizeof(head));
            memset(dist,0,sizeof(dist));
            int u,v;
            LL w;
            for(int i=1;i<=n-1;i++)
            {
                scanf("%d%d%lld",&u,&v,&w);
                addedge(u,v,w);
                addedge(v,u,w);
            }
            int q,k;
            scanf("%d%d",&q,&k);
            dfs(k,-1);
    //        for(int i=1;i<=n;i++)
    //            cout<<dist[i]<<" ";
    //        cout<<endl;
            int x,y;
            for(int i=1;i<=q;i++)
            {
                scanf("%d%d",&x,&y);
                printf("%lld\n",dist[x]+dist[y]);
            }
        }
        return 0;
    }
    

Measured memory_bytes: 12288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);


		String b = scan.nextLine();

		if(b.length()<4) {
			System.out.print("No");
		}else {
			if(b.charAt(0) == 'Y'  && b.charAt(1) == 'A'  && b.charAt(2) == 'K'  && b.charAt(3) == 'I') {System.out.print("Yes");}
			else {
			System.out.print("No");
		}}

	}

}


Measured memory_bytes: 24148
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e5;
const int MAXM = 1e5;
int a[MAXN+100],dp[MAXN+100];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

ll fac[100007];

int main()
{
    fac[0] = 1;
    for (ll i = 1; i <= 1e5; i++) fac[i] = (fac[i-1] * i) % mod;

    ll n, m;
    cin >> n >> m;

    if (abs(n-m) > 1) {cout << 0 << "\n"; return 0;}


    if (abs(n-m) == 1) cout << (fac[n] * fac[m]) % mod << "\n";
    if (n == m)  cout << (fac[n] * 2 * fac[m]) % mod << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<string>
#define ll long long
#define INF 0x3f3f3f3f
#define N 1005
using namespace std;

char s[2][10];

int main()
{
	scanf("%s%s",s[0],s[1]);
	if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0]) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=1e6+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int c[maxn];
int jungle[maxn];

int lowbit(int x)
{
	return x&(-x);
}
void updata(int x,int y,int n)
{
	for(int i=x;i<=n;i+=lowbit(i))
		c[i]+=y;
}
int FIND(int x)
{
	int ans=0;
	for(int i=x;i;i-=lowbit(i))
		ans+=c[i];
	return ans;
}

struct node
{
    int l,r;
    int id;
    friend bool operator<(node a,node b)
    {
        return a.r<b.r;
    }
}ques[maxn];


int a[maxn];
int ans[maxn];

int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);//1 2 3 4 3 5
    }

    for(int i=1;i<=k;i++)
    {
        scanf("%d %d",&ques[i].l,&ques[i].r);
        ques[i].id=i;
    }
    sort(ques+1,ques+1+k);
    int next=1;
    for(int i=1;i<=k;i++)
    {
        for(int j=next;j<=ques[i].r;j++)
        {
            if(jungle[a[j]])
            {
                updata(jungle[a[j]],-1,n);
            }
            updata(j,1,n);
            jungle[a[j]]=j;
        }
        next=ques[i].r+1;
        ans[ques[i].id]=FIND(ques[i].r)-FIND(ques[i].l-1);
    }
    for(int i=1;i<=k;i++)
        printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 17380
n=int(input())
a=sorted([x-i for i,x in enumerate(list(map(int,input().split())))])
if n%2==1:
  print(sum([abs(x-a[n//2]) for x in a]))
else:
  print(min(sum([abs(x-a[n//2]) for x in a]),sum([abs(x-a[n//2+1]) for x in a])))


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll result = ( 1000 - N%1000 ) % 1000;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3644
#pragma warning(disable:4996)
#include <stdio.h>

int main(void) {
	long k, x;
	long i;
	scanf("%ld%ld", &k, &x);
	long j = x - (k - 1);
	long h = x + (k - 1);
	j >= -1000000 ? j = j : j = -1000000;
	h <= 1000000 ? h = h : h = 1000000;
	for (i = j; i <= h; ++i) {
		printf("%ld ", i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
n, k = input(), int(input())

dp0 = [[0] * (k + 2) for _ in range(len(n) + 1)]
dp1 = [[0] * (k + 2) for _ in range(len(n) + 1)]
dp1[0][0] = 1

for i in range(len(n)):
    for j in range(k + 1):
        dp0[i + 1][j] += dp0[i][j]
        dp0[i + 1][j + 1] += dp0[i][j] * 9
        if n[i] != '0':
            dp0[i + 1][j] += dp1[i][j]
            dp0[i + 1][j + 1] += dp1[i][j] * (int(n[i]) - 1)
            dp1[i + 1][j + 1] += dp1[i][j]
        elif n[i] == '0':
            dp1[i + 1][j] += dp1[i][j]

print(dp0[len(n)][k] + dp1[len(n)][k])


Measured memory_bytes: 62488
N,M=map(int, input().split())

lst = [0 for i in range(M+1)]
for i in range(N):
    for j in list(map(int, input().split()))[1:]:
        lst[j] += 1

cnt = 0
for i in range(1, M+1):
    if lst[i] == N:
        cnt += 1

print(cnt)


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  int sum=0;
  for(int i=0;i<N;i++)  sum+=A.at(i);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(A.at(i)*4*M>=sum)  cnt++;
  }
  if(cnt>=M)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter


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

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

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)]

    def members(self, x, is_set=False):
        root = self.find(x)
        res = [i for i in range(self.node) if self.find(i) == root]
        if is_set:
            return set(res)
        return res

    def all_root(self):
        return [idx for idx, val in enumerate(self.parent) if val < 0]


def main():
    cities, roads, railroads = map(int, input().split())
    uf_road = UnionFind(cities)
    uf_train = UnionFind(cities)
    for _ in range(roads):
        p, q = map(lambda x: int(x) - 1, input().split())
        uf_road.union(p, q)
    for _ in range(railroads):
        r, s = map(lambda x: int(x) - 1, input().split())
        uf_train.union(r, s)
    each_pair = []
    for i in range(cities):
        each_pair.append(tuple([uf_road.find(i), uf_train.find(i)]))
    pair_count = dict(Counter(each_pair))
    answer = [pair_count[each_pair[i]] for i in range(cities)]
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 52600
package main

import "fmt"

func main() {
	var a = make([]int, 3)
	var k int
	fmt.Scan(&a[0], &a[1], &a[2], &k)

	if a[0] > k {
		fmt.Println(k)
		return
	}

	if a[0] <= k && k <= a[1] {
		fmt.Println(k)
		return
	}

	fmt.Println(a[0] - (k - a[0] - a[1]))
}


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

int main(void){
	vector<int> ans;

	while (1){
		int a, b;
		string op;

		cin >> a >> op >> b;

		if (op == "+"){
			ans.push_back(a + b);
		}
		else if (op == "-"){
			ans.push_back(a - b);
		}
		else if (op == "*"){
			ans.push_back(a * b);
		}
		else if (op == "/"){
			ans.push_back(a / b);
		}
		else{
			break;
		}
	}
	for (int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
using namespace std;
int main()
{
    int n,k,s,i,j;cin>>n>>k;
    if(k>(n-1)*(n-2)/2)cout<<-1;
    else{
        s=n*(n-1)/2-k;
        cout<<s<<endl;
        for(i=1;i<n&&s;i++)
            for(j=i+1;j<=n&&s;j++,s--)
                cout<<i<<" "<<j<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int firstnumber = sc.nextInt();
		// スペース区切りの整数の入力
    if(firstnumber == 1){
      System.out.println("Hello World");
    }
    else {
      int a = sc.nextInt();
  		int b = sc.nextInt();
      // 出力
  		System.out.println(a+b);
    }
	}
}


Measured memory_bytes: 22868
#include <iostream>
using namespace std;
 
int main() {
  unsigned long long H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  long long row_count_first;
  long long row_count_second;
 
  if (W % 2 == 0) {
    row_count_first = W / 2;
    row_count_second = W / 2;
  } else {
    row_count_first = W / 2 + 1;
    row_count_second = W / 2;
  }
  long long res = 0;
  for (int i = 0; i < H; i++) {
    if (i % 2 == 0) {
      res += row_count_first;
    } else {
      res += row_count_second;
    }
  }
  cout << res << endl;
  return 0;
}

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

public class Main {
	final static int MOD = 1000000007;
	final static int intMax = 1000000000;
	final static int intMin = -1000000000;
	final static int[] dx = { 0, 0, -1, 1 };
	final static int[] dy = { -1, 1, 0, 0 };

	static int T;

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[360]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		Reader in = new Reader();
		int N = in.nextInt();
		int W = in.nextInt();
		int[] w = new int[N];
		int[] v = new int[N];
		for(int i = 0; i < N; ++i) {
			w[i] = in.nextInt();
			v[i] = in.nextInt();
		}
		long[] dp = new long[100001];
		Arrays.fill(dp, Long.MAX_VALUE / 2);
		dp[0] = 0;
		for(int i = 0; i < N; ++i) {
			for(int j = 100000 - v[i]; j >= 0; --j) {
				dp[j + v[i]] = Math.min(dp[j + v[i]], dp[j] + w[i]);
			}
		}
		long mx = 0;
		for(int i = 0; i <= 100000; ++i) {
			if(dp[i] <= W) {
				mx = i;
			}
		}
		System.out.println(mx);
		in.close();
	}
}

Measured memory_bytes: 33792
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
int n,p[N];

void task0()
{
	p[1]=n&(-n),p[2]=n^p[1];
	int tot=2;
	rep(i,1,n-1) if(i!=p[1] && i!=p[2]) p[++tot]=i;
	rep(i,1,tot-1) printf("%d %d\n",p[i],p[i+1]);
	printf("%d %d\n",p[tot],p[1]+n);
	rep(i,1,tot-1) printf("%d %d\n",p[i]+n,p[i+1]+n);
	printf("%d %d\n",p[1],n);
	printf("%d %d\n",p[2],2*n);
}

void task1()
{
	rep(i,1,n-1) p[i]=i+1;
	rep(i,1,n-2) printf("%d %d\n",p[i],p[i+1]);
	printf("%d %d\n",p[n-1],p[1]+n);
	rep(i,1,n-2) printf("%d %d\n",p[i]+n,p[i+1]+n);
	printf("%d %d\n",p[1],1);
	printf("%d %d\n",p[2],n+1);
}

void task2()
{
	p[2]=n&(-n),p[1]=p[2]+1,p[3]=n^p[2];
	int tot=3;
	rep(i,2,n-1) if(i!=p[1] && i!=p[2] && i!=p[3]) p[++tot]=i;
	rep(i,1,tot-1) printf("%d %d\n",p[i],p[i+1]);
	printf("%d %d\n",p[tot],p[1]+n);
	rep(i,1,tot-1) printf("%d %d\n",p[i]+n,p[i+1]+n);
	printf("%d %d\n",p[1],1);
	printf("%d %d\n",p[2],n+1);
	printf("%d %d\n",p[2],n);
	printf("%d %d\n",p[3],2*n);
}

void task3()
{
	rep(i,1,2*n-1) printf("%d %d\n",i,i+1);
}

int main()
{
	scanf("%d",&n);
	if(n==(n&(-n))) return puts("No"),0;
	puts("Yes");
	if(n%4==0) task0();
	if(n%4==1) task1();
	if(n%4==2) task2();
	if(n%4==3) task3();
	return 0;
}

Measured memory_bytes: 3248
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
//void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


signed main()
{
	char x, y;
	cin >> x >> y;
	if(x == y) cout << "=" << endl;
	else cout << ((x < y) ? "<" : ">") << endl;
}




Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

bool kaibun(string str){
	for (int i = 0; i < str.length(); i++){
		if (str[i] != str[str.length()-1-i]) return false;
	}
	return true;
}


int main(){
	string s;
	cin >> s;
	int n = s.length();
	string t = s.substr(0, (n-1)/2);
	string r = s.substr((n+3)/2-1, n-(n+3)/2+1);
	if (kaibun(s) && kaibun(t) && kaibun(r)) cout << "Yes" << endl;
	else cout << "No" << endl;
 	return 0;
 }


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

int main()
{
    string ans = "Yes";
    int N;
    cin >> N;
    vector<int> x(N), y(N), t(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < N; ++i)
    {
        if (i == 0)
        {
            continue;
        }
        else
        {
            x[i] -= x[i - 1];
            y[i] -= y[i - 1];
            t[i] -= t[i - 1];
        }
    }
    for (int i = 0; i < N; ++i)
    {
        if (abs(x[i]) + abs(y[i]) <= t[i] && (abs(x[i]) + abs(y[i])) % 2 == t[i] % 2)
        {
            continue;
        }
        else
        {
            ans = "No";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4560
#include<iostream>
#include<string>
using namespace std;
// A placing marbles

//書かれてる整数が全て偶数である限り
//書かれている整数全てを2で割る

int N,sum,box[210];
//string s;
int main(){
	bool B=true;
	cin>>N;
	while(B==true){
		for(int i=0; i<N; i++){
			cin>>box[i];

			while (box[i]%2!=0){
				B=false;
				break;}
			while (box[i]%2==0){
				box[i] = box[i]/2;
				break;
			}	

		}
		if(B==true)sum++;
	}
	
cout<<sum<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    s64 N, M;
    vector< pair<s64, s64> > vec;
    cin >> N >> M;

    vec.resize(N);
    s64 A, B;
    rep (i, N)
    {
        cin >> A >> B;
        vec[i] = make_pair(A, B);
    }

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

    s64 num = 0;
    s64 ans = 0;
    for (int i = 0; i < N && num < M; ++i)
    {
        if (num + vec[i].second <= M)
        {
            num += vec[i].second;
            ans += vec[i].first * vec[i].second;
        }
        else
        {
            ans += (M - num) * vec[i].first;
            num = M;
        }
    }

    cout << ans << "\n";
    return 0;
}



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

int main(){
  int A, B, X;
  cin >> A >> B >> X;
  int flag = 0;
  for(int i = 0; i <= B; i++){
    if(A + i == X) flag = 1;
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N;
  cin >> N;
  vector<pair<int64_t, int64_t>> table;
  
  int64_t y = 0;
  while (N % 2 == 0) {
    N /= 2;
    y++ ;
    if ( N % 2 != 0 && y != 0 ) {
     table.emplace_back(2,y);
      break;
    }
   }
  //cout << N << endl;
  int64_t i = 3;
  while (i*i <= N ) {
    int64_t x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
      // cout << N << endl;
    }
    if (x != 0) {
    table.emplace_back(i,x);
    }
    i += 2;
  }
  
  if (N != 1) {
    table.emplace_back(N, 1);
  }
  
  // ここで各素因数のチェック
  /*for (int i = 0; i < table.size(); i++) {
   	cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/
  
  int64_t ans = 0;
  
  // 長さチェック
  //cout << table.size() << endl;
  
  
  for (int64_t j = 0; j < table.size(); j++) {
    int64_t y = table.at(j).second;
    int64_t b = 1;
    while (y >= b ) {
      ans++ ;
      y -= b; 
      b++ ;
    }
  }
  
   cout << ans << endl;
  
  return 0;
}

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

int main() {
  int alice = 0;
  int bob = 0;
  int n;
  cin >> n;

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

  for(int turn = 0; turn < n; turn++) {
    int maxVal = 0;
    int maxIndex;

    for(uint i = 0; i < cards.size(); i++) {
      if(cards.at(i) > maxVal) {
	maxVal = cards.at(i);
	maxIndex = i;
      }
    }
    if(turn % 2 == 0) {
      alice += maxVal;
    }
    else {
      bob += maxVal;
    }
    cards.erase(cards.begin() + maxIndex);
  }
  cout << alice - bob << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * B.cpp
 *
 *  Created on: Jul 6, 2020
 *      Author: biswaitjitkumar
 */

#include<bits/stdc++.h>

using namespace std;

int main(){
	int n = 5;
	int Array[n];
	for(int i=0;i<n;i++){
		cin>>Array[i];
		if(Array[i]==0){
			cout<<i+1<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3512
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
                string input = Console.ReadLine();
                char[] change = input.ToCharArray();

                for (int i = 0; i < change.Length; i++)
                {
                    if (char.IsLower(change[i]))
                    {
                        change[i] = char.ToUpper(change[i]);
                    }else if(char.IsUpper(change[i])){
                        change[i] = char.ToLower(change[i]);
                    }
                }

                for (int i = 0; i < change.Length; i++)
                {
                    Console.Write(string.Format("{0}", change[i]));
                }
                Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9288
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

int a,b;
string s;
int main(void){
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='0')a++;
        else b++;
    }
    p(s.size()-abs(a-b));
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,ans;
  ans=0;
  cin>>n>>m;
  for (int i=0;i<m;i++){
    int num;
    cin>>num;
    ans=ans+num;
  }
  ans=n-ans;
  if(ans<0){
    cout<<"-1"<<endl;
  } else {
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,k,r,r1,s;

   cin>>a>>b>>k;

  if(k<=a){
     cout<<a-k<<" "<<b<<endl;
  }
  else if(k<=a+b)
  {
      cout<<"0"<<" "<<b-(k-a)<<endl;
  }
  else{

    cout<<"0"<<" "<<"0"<<endl;
  }

 return 0;
}


Measured memory_bytes: 3556
import java.util.*;
import java.util.Map.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] shopOpenData = new int[n][10];
        int[][] shopProfitData = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                shopOpenData[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                shopProfitData[i][j] = sc.nextInt();
            }
        }
        
        int max = -1000000000;
        for (int i = 1; i < 1024; i++) {
            String binaryNumber = Integer.toBinaryString(i);
            while (binaryNumber.length() < 10) {
                binaryNumber = "0" + binaryNumber;
            }
            
            int[] shopOpenCount = new int[n];
            
            for (int j = 0; j < 10; j++) {
                int k = Integer.parseInt(String.valueOf(binaryNumber.charAt(j)));
                if (k == 1) {
                    for (int h = 0; h < n; h++) {
                        if (shopOpenData[h][j] == 1) shopOpenCount[h]++;
                    }
                }
            }
            
            int profit = 0;
            for (int j = 0; j < n; j++) {
                profit += shopProfitData[j][shopOpenCount[j]];
            }
            
            max = Math.max(max, profit);
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 26440
n, m = map(int, input().split())
L, R = [], []
for _ in range(m):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)


res = min(R) - max(L) + 1
if res < 0:
    print(0)
else:
    print(res)

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

int main(int argc, char const *argv[])
{
    int N, K;

    cin >> N >> K;
    int height, counter = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> height;
        if (height >= K)
            counter++;
    }

    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
S = gets.chomp
acgt = {"A" => true, "T" => true, "C" => true, "G" => true}
ans = 0
tmp = 0
S.chars.each do |s|
  if acgt[s]
    tmp += 1
    ans = [tmp, ans].max
  else
    tmp = 0
  end
end
puts ans

Measured memory_bytes: 14288
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  char a[11], b[11], c[11];
  cin >> a >> b >> c;

  pr((char)(a[0]-'a'+'A') << (char)(b[0]-'a'+'A') << (char)(c[0]-'a'+'A'));


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int A= Input.nextInt();
        int B=Input.nextInt();
        int C= Input.nextInt();

        
        if(B-A==C-B){System.out.println("YES");}else{System.out.println("NO");}
      
    }
}

//Learn Before You Earn


Measured memory_bytes: 21844
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    static class City {
        int index;
        int freq = 0;

        public City(int index) {
            this.index = index;
        }
    }

    public static void main(String[] args) throws Exception {
        MyScanner scan = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int x = scan.nextInt();
        int a = scan.nextInt();

        if (x < a) {
            out.println(0);
        } else {
            out.println(10);
        }

        out.close();
    }


    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------

}

Measured memory_bytes: 20820