akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int candidate[50];
int n,p;

int isEnd(int i){
    int j;
    for(j=0;j<n;j++){
        if(candidate[j]&&j!=i) return 0;
    }
    printf("%d\n",i);
    return 1;
}

int main(void){
    int cup,i;
    while(scanf("%d %d",&n,&p),n||p){
        cup=p;
        for(i=0;i<n;i++){
            candidate[i]=0;
        }
        i=0;
        while(1){
            if(cup==0){
                cup=candidate[i];
                candidate[i]=0;
            }else{
                candidate[i]++;
                cup--;
                if(cup==0){
                    if(isEnd(i)) break;
                }
            }
            i=(i+1)%n;
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int m,n,k;
    cin >> m >> n >> k;
    vector<string> vs(m);
    fori(i,0,m) 
        cin >> vs[i];
    //cout << vs.size() << endl;
    //fori(i,0,m) cout << vs[i] << endl;
    int mx = (1 << m), mc = (1 << n);
    int res = 0;
    fori(i,0,mx) {
        fori(j,0,mc) {
            int cnt = 0;
            fori(r,0,m) {
                fori(c,0,n) {
                    if(vs[r][c] == '#' && ( i & (1 << r)) == 0 && ( j & (1 << c)) == 0) {
                        cnt++;
                    }
                }
            }
            if(cnt == k) res++;
        }
    }
    cout << res << endl;
}

int main() {
   // ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3592
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    int a,b;
    cin >> a>> b;
    cout<<a*b<<endl;
    return 0;
}

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

int main(){
    int N, M;
    string A;
    scanf("%d %d", &N, &M);
    vector<string> a;

    while (N--){
        cin >> A;
        a.push_back(A);
    }

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

    for (auto i : a)
        cout << i;
    cout << "\n";
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        for (int i = 0; i < 10; i++) {
            if (s.contains(stringTimes(String.valueOf(i), 2))) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
    public static String stringTimes(String s, int t) {
        String res = "";
        for (int i = 0; i < t; i++) res += s;
        return res;
    }
}


Measured memory_bytes: 23764
import itertools

N, K = map(int,input().split())
A = list(map(int,input().split()))
B = [0] * (N+1)
chk = [N] *N
for k in range(K):
    if A == chk:
        break
    for i in range(N):
        if A[i] == 0:
            B[i] += 1
            B[i+1] -= 1
            continue
        l = i - A[i]
        r = i + A[i]
        if l <= 0:
            B[0] += 1
        else:
            B[l] += 1
        if r >= N-1:
            B[N] -= 1
        else:
            B[r+1] -= 1        
    A = list(itertools.accumulate(B))[:-1]
    B = [0] * (N+1)
print(*A)
#print("B = " ,B)

Measured memory_bytes: 178616
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
#include <memory>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

int g_pCount = 0;

struct Node {
  Node(int key) :
    key_(key),
    left_(nullptr),
    right_(nullptr) {
      g_pCount++;
      DPRINTF("Allocated. (addr %p  key %d  pCount %d)\n", this, this->key_, g_pCount);
    }
  Node() :
    key_(-1),
    left_(nullptr),
    right_(nullptr) {
      Node(-1);
    }

  ~Node() {
    g_pCount--;
    DPRINTF("Deallocated. (addr %p  key %d  pCount %d)\n", this, this->key_, g_pCount);
  }

  int key_;
  Node *left_;
  Node *right_;
};

void insert(Node **root, Node *n)
{
  if (root == nullptr || n == nullptr)
  {
    assert(false && "nullptr catched\n");
    return;
  }

  if (*root == nullptr)
  {
    *root = n;
    return;
  }

  Node *parent = nullptr;
  Node *child = *root;

  while (child != nullptr)
  {
    parent = child;

    if (n->key_ < child->key_)
      child = child->left_;
    else
      child = child->right_;
  }

  if (n->key_ < parent->key_)
  {
    parent->left_ = n;

    DPRINTF("left - parent->key_ %d  n->key_ %d\n",
        parent->key_, n->key_);
  }
  else
  {
    parent->right_ = n;

    DPRINTF("right - parent->key_ %d  n->key_ %d\n",
        parent->key_, n->key_);
  }

}

void printPreorder(Node *node, bool isRoot = true)
{
  if (node == nullptr)
    return;

  printf(" %d", node->key_);

  printPreorder(node->left_, false);
  printPreorder(node->right_, false);

  if (isRoot)
    cout << endl;
}

void printInorder(Node *node, bool isRoot = true)
{
  if (node == nullptr)
    return;

  printInorder(node->left_, false);
  printf(" %d", node->key_);
  printInorder(node->right_, false);

  if (isRoot)
    cout << endl;
}


bool freeNodePointer(Node *root)
{
  if (root == nullptr)
    return false;

  if (freeNodePointer(root->left_))
    delete(root->left_);

  if (freeNodePointer(root->right_))
    delete(root->right_);

  return true;
}

int main()
{
  int numOfOrder;
  cin >> numOfOrder; cin.ignore();

  Node **root = new (Node*);
  *root = nullptr;

  for (int i = 0; i < numOfOrder; i++)
  {
    string order; cin >> order;

    if (order == "insert")
    {
      int key; cin >> key;
      DPRINTF("%s %d\n", order.c_str(), key);

      Node *n = new Node(key);
      insert(root, n);

    }
    else if (order == "print")
    {
      DPRINTF("%s\n", order.c_str());

      printInorder(*root);
      printPreorder(*root);
    }
    else
    {
      // must not be here
      assert(false && "Unknown order");
    }

    cin.ignore();
  }

  freeNodePointer(*root);
  delete(*root);
  delete(root);

  return 0;
}



Measured memory_bytes: 18908
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 58;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,w;
    cin >> n >> w;

    vector<vector<ll>> in(n,vector<ll>(2));

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

    vector<vector<ll>> dp(n+1,vector<ll>(n*(1000) + 1,INF));
    dp[0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= n*1000; j++){
            dp[i+1][j] = dp[i][j];
        }
        for(int j = 0; j <= n*1000; j++){
            if(j + in[i][1] <= n*1000){
                dp[i+1][j + in[i][1]] = min(dp[i+1][j + in[i][1]],dp[i][j] + in[i][0]);
            }
        }
    }

    ll ans = 0;

    for(int i = 0; i < n*1000 + 1; i++){
        if(dp[n][i] <= w){
            ans = i;
        }
    }

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

Measured memory_bytes: 80256
import Control.Monad
import Debug.Trace

data Travel = Travel {
    time  :: Int,
    x :: Int,
    y :: Int
    } deriving (Show, Eq)

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    travel <- forM [1..n] ( \_ -> do
            [t, x, y] <- map read . words <$> getLine :: IO [Int]
            return $ Travel t x y
        )
    putStrLn $ if move travel $ Travel 0 0 0 then "Yes" else "No"

move :: [Travel]
     -> Travel -- current status
     -> Bool
move [] _ = True
move ((Travel time x y):xs) (Travel ctime cx cy) = let
    canMove = let a = (time - ctime) - (abs (x - cx) + abs (y - cy)) :: Int
        in a >= 0 && even a  :: Bool
    nextStates = Travel time x y :: Travel
    in canMove && move xs nextStates

Measured memory_bytes: 74876
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }
inline lint invm(lint a, lint p = mod) { a %= p; return a == 1 ? 1 : -p / a * invm(p % a) % p; }
inline lint powm(lint a, lint n, lint p = mod) { return !n ? 1 : powm(a * a % p, n >> 1, p) * (n & 1 ? a : 1) % p; }

V<lint> fact, ifact;
void init_table(int n) {
  fact.assign(n + 1, 1), ifact.assign(n + 1, 1);
  for (int i = 2; i < n + 1; ++i) fact[i] = i * fact[i - 1] % mod;
  ifact[n] = invm(fact[n]);
  for (int i = n; i > 2; --i) ifact[i - 1] = i * ifact[i] % mod;
}

lint comb(lint n, lint r) {
  if (r < 0 or r > n) return 0;
  return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

lint mulcomb(lint n, lint r) {
  if (n < 1 or r < 0) return 0;
  return fact[r + n - 1] * ifact[r] % mod * ifact[n - 1] % mod;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n, k; cin >> n >> k;
  init_table(n + k);
  lint res = 0;
  for (lint j = 1; j < k + 1; ++j) {
    lint cur = 0;
    for (lint i = 0; i < j + 1; ++i) (cur += (j - i & 1 ? -1 : 1) * comb(j, i) * powm(i, n) % mod) %= mod;
    (res += cur * ifact[j]) %= mod;
  }
  cout << emod(res) << '\n';
}


Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main()
{
	int ans = 0, now = 0, n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'I')now++;
		else now--;
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		Set<String> set = new HashSet<>();

		for(int i=0;i<N;i++) {
			set.add(sc.next());
		}
		System.out.println(set.size()==N?"YES":"NO");
	}
}

Measured memory_bytes: 76552
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 1; i <= (n); i ++)
#define travel(i, u) for (int i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long LL;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 5e5 + 233;

int n, K;
int a[N], b[N], du[N];
vector <int> G[N];
namespace bit {
  const int xb = N << 2;
  int tr[N << 4], tp;
  inline void init(int f) {
    tp = f;
    if (tp == 0) memset(tr, 38, sizeof tr);
    else memset(tr, 168, sizeof tr);
  }
  inline void U(int &x, int v) {
    if (tp == 0) x = min(x, v);
    if (tp == 1) x = max(x, v);
  }
  inline void add(int x, int v) {
    for (x += xb; x; x >>= 1) U(tr[x], v);
  }
  inline int query(int s, int t) {
    s = max(s, 1LL); t = min(t, n);
    int ans = tp == 0 ? 1e18 : -1e18;
    for (s += xb - 1, t += xb + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
      if (~s & 1) U(ans, tr[s ^ 1]);
      if ( t & 1) U(ans, tr[t ^ 1]);
    }
    return ans;
  }
}

inline void link(int x, int y) {
  if (!(1 <= x && x <= n && 1 <= y && y <= n))
    return ;
  x = b[x]; y = b[y];
  // cout << x << " " << y << "\n";
  ++ du[y]; G[x].push_back(y);
}

main(void) {
  read(n); read(K);
  rep (i, n) read(a[i]), b[a[i]] = i;
  // rep (i, n) cout << b[i] << " "; cout << "\n";
  bit::init(1);
  for (int i = 1; i <= n; i ++) {
    link(bit::query(b[i] - K + 1, b[i] - 1), i);
    link(bit::query(b[i] + 1, b[i] + K - 1), i);
    bit::add(b[i], i);
  }
  priority_queue < int, vector <int>, greater <int> > pq;
  rep (i, n) if (!du[i]) pq.push(i);
  vector <int> ans;
  while (!pq.empty()) {
    int u = pq.top(); pq.pop();
    ans.push_back(u);
    for (auto v : G[u]) if (!-- du[v]) pq.push(v);
  }
  static int res[N];
  rep (i, n) res[ans[i - 1]] = i;
  rep (i, n) cout << res[i] << "\n";
}


Measured memory_bytes: 116204
#include <iostream>
#include <stdio.h>
using namespace std;

typedef long long LL;
const int MAX_N = 1e5 + 6;

struct Node {
    Node *lc,*rc;
    LL sum,tag;
    Node():lc(NULL),rc(NULL),sum(0),tag(0){};
    void pull() {
        sum = lc->sum + rc->sum;
    }
};

void push(Node* node,int L,int R) {
    if (L==R) node->tag =0 ;
    if (node->tag ==0) return;
    int mid=(L+R)>>1;
    node->lc->tag += node->tag;
    node->rc->tag += node->tag;
    node->lc->sum += node->tag * (mid-L+1);
    node->rc->sum += node->tag * (R-mid);
    node->tag = 0;
    return;
}

Node* Build(int L,int R) {
    Node* node = new Node();
    if (L==R) return node;
    int mid=(L+R)>>1;
    node->lc=Build(L,mid);
    node->rc=Build(mid+1,R);
    return node;
}

void modify(Node* node,int L,int R,int l,int r,LL val) {
    if (l>R || L>r) return;
    else if (l<=L && R<=r) {
        node->tag += val;
        node->sum += (R-L+1)*val;
        return;
    }
    push(node,L,R);
    int mid=(L+R)>>1;
    modify(node->lc,L,mid,l,r,val);
    modify(node->rc,mid+1,R,l,r,val);
    node->pull();
    return;
}

LL cha[MAX_N];
LL val[MAX_N];

void visit(Node* node,int L,int R) {
    if (L==R) {
        cha[L] = node->sum;
        return;
    }
    push(node,L,R);
    int mid=(L+R)>>1;
    visit(node->lc,L,mid);
    visit(node->rc,mid+1,R);
    return;
}

int a[MAX_N];

int main () {
    int n,m;
    scanf("%d %d",&n,&m);
    Node* root=Build(1,m);
    LL sum=0;
    for (int i=1;n>=i;i++) {
        scanf("%d",&a[i]);
        if (i==1) continue;
        if (a[i] > a[i-1]) {
            sum += (a[i] - a[i-1]);
            if (a[i] - a[i-1] == 1) continue;
            modify(root,1,m,a[i-1] + 2,a[i],1);
            if (a[i] != m) modify(root,1,m,a[i]+1,a[i]+1,-(a[i] - (a[i-1] + 2) + 1) );
        }
        else {
            sum += (a[i] + m - a[i-1]);
            if (a[i] + m-a[i-1] == 1) continue;
            if (a[i-1] + 2 <= m)modify(root,1,m,a[i-1] + 2,m,1);
            if (a[i-1] != m) {
                modify(root,1,m,2,a[i],1);
                modify(root,1,m,1,1,m-a[i-1]);
            }
            else modify(root,1,m,2,a[i],1);
            if (a[i] != m) modify(root,1,m,a[i]+1,a[i]+1,-(a[i] + m - a[i-1] - 1));
        }
        //visit(root,1,m);
        /*for (int i=1;m>=i;i++) {
            cout<<"cha["<<i<<"] = "<<cha[i]<<endl;
        }*/
    }
    visit(root,1,m);
    LL pre=0;
    LL ans=sum;
    for (int i=1;m>=i;i++) {
        pre += cha[i];
        val[i] = pre;
        ans = min(ans,sum-val[i]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 11648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,ans=inf,res,l,r;
  cin>>N;
  vec v(N),sum(N);
  rep(i,N){
    cin>>v[i];
    if(i)sum[i]=sum[i-1]+v[i];
    else sum[i]=v[i];
  }
  rep1(i,N-2){
    l=lower_bound(all(sum),sum[i]/2)-sum.begin();
    l-=l&&labs(sum[i]-sum[l]*2)>labs(sum[i]-sum[l-1]*2);
    r=lower_bound(all(sum),sum[i]+(sum[N-1]-sum[i])/2)-sum.begin();
    r-=labs(sum[N-1]+sum[i]-sum[r]*2)>labs(sum[N-1]+sum[i]-sum[r-1]*2);
    res=max({sum[l],sum[i]-sum[l],sum[r]-sum[i],sum[N-1]-sum[r]})-min({sum[l],sum[i]-sum[l],sum[r]-sum[i],sum[N-1]-sum[r]});
    chmin(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
def f():
    return int(raw_input())
def f2():
    return map(int, raw_input().split())

def merge(left, mid, right):
    L = S[left:mid]
    R = S[mid:right]
    lp, rp, xp = 0, 0, 0
    a, b = L[0], R[0]
    c = right - left
    x = [0] * c
    flg = True
    while flg:
        while xp < c and a <= b:
            x[xp] = a
            lp += 1
            xp += 1
            try:
                a = L[lp]
            except:
                for e in R[rp:]:
                    x[xp] = e
                    xp += 1
                flg = False
                break
        while xp < c and a >= b:
            x[xp] = b
            rp += 1
            xp += 1
            try:
                b = R[rp]
            except:
                for e in L[lp:]:
                    x[xp] = e
                    xp += 1
                flg = False
                break
    S[left:right] = x
    return c

def mergesort(left, right):
    c = 0
    if left + 1 < right:
        mid = (left + right)/2
        c += mergesort(left, mid)
        c += mergesort(mid, right)
        c += merge(left, mid, right)
    return c

global S
n = f()
S = f2()

c = mergesort(0, n)
print " ".join(map(str,S))
print c

Measured memory_bytes: 52884
#include <stdio.h>
#include <math.h>
int main(void){
	int spot_vol,spot_pos[100000],sum,sumnor;
	scanf("%d",&spot_vol);
	scanf("%d",&spot_pos[0]);
	for (int i = 1; i < spot_vol; ++i){
		scanf("%d",&spot_pos[i]);
		sum=sum+abs(spot_pos[i]-spot_pos[i-1]);
	}

	sum=sum+abs(spot_pos[spot_vol-1])+abs(spot_pos[0]);
	sumnor=sum;

	for (int i = 0; i < spot_vol; ++i)
	{
		sum=sumnor;
		if(i==0){
			sum=sum-abs(spot_pos[0])-abs(spot_pos[1]-spot_pos[0])+abs(spot_pos[1]);
			printf("%d\n",sum);
		}else if(i==(spot_vol-1)){
			sum=sum-abs(spot_pos[spot_vol-1]-spot_pos[spot_vol-2])-abs(spot_pos[spot_vol-1])+abs(spot_pos[spot_vol-2]);
			printf("%d\n",sum);
		}else{
			sum=sum-abs(spot_pos[i]-spot_pos[i-1])-abs(spot_pos[i+1]-spot_pos[i])+abs(spot_pos[i+1]-spot_pos[i-1]);
			printf("%d\n",sum);
		}
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double m,v=0;
    ll n;
    cin>>n>>m;
    double*a=new double[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        v+=a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    double q=v/(4*m);
    bool y=1;
    for(ll i=0;i<m;i++){
        if(a[i]<q){
            y=0;
            break;
        }
    }
    if(y)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var X = inputLongArray[0];
            var N = inputLongArray[1];

            var tmp = Console.ReadLine();
            if(tmp=="") Console.WriteLine(X);
            else
            {
                var pi = tmp.Split(' ').Select(i => int.Parse(i)).ToArray();

                if (N == 0)
                {
                    Console.WriteLine(X);
                }
                else if (!pi.Contains(X))
                {
                    Console.WriteLine(X);
                }
                else
                {
                    var back = X - 1;
                    var forward = X + 1;
                    while (true)
                    {
                        if (!pi.Contains(back))
                        {
                            Console.WriteLine(back);
                            break;
                        }
                        else if (!pi.Contains(forward))
                        {
                            Console.WriteLine(forward);
                            break;
                        }
                        back = back - 1;
                        forward = forward + 1;
                    }
                }
            }

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

std::vector<int> z_algorithm(const std::string &s)
{
    int sz = s.length();
    std::vector<int> z(sz, 0);
    int i = 1, j = 0;
    while (i < sz)
    {
        while (i + j < sz && s[j] == s[i + j])
            j++;
        z[i] = j;
        if (j == 0)
        {
            i++;
            continue;
        }
        int k = 1;
        while (i + k < sz && k + z[k] < j)
        {
            z[i + k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return z;
}

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

    string s, t;
    cin >> s >> t;
    string rs = s, rt = t;
    reverse(rs.begin(), rs.end());
    reverse(rt.begin(), rt.end());
    int n = s.size(), m = t.size();
    string str = t + "$" + s;
    string rstr = rt + "$" + rs;
    auto z = z_algorithm(str);
    auto rz = z_algorithm(rstr);
    int ret = 0;
    for (int i = 0; i <= n - m; i++)
    {
        int st = m + 1 + i;
        int a = z[st];
        st = n + 1 - i;
        int b = rz[st];
        if (a + b + 1 == m)
            ret++;
    }
    cout << ret << endl;
}



Measured memory_bytes: 8384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;
map<int,int>mp;
int main() {
    int n,m,x;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d",&x);
        mp[x]++;
    }
    bool f=true;
    scanf("%d",&m);
    for(int i=0;i<m;i++) {
        scanf("%d",&x);
        if(mp[x]>0) mp[x]--;
        else f=false;
    }
    puts(f?"YES":"NO");
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> H(n);
    rep(i, n) cin >> H[i];
    sort(rall(H));
    ll ans = 0;
    rep(i, n){
        if(k) {
            k--;
        } else {
            ans += H[i];
        }
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct imos2d{
    vector<vector<T>> board;
    imos2d(int w,int h):
        board(w+2,vector<int>(h+2,0))
    {}
    // 矩形加算
    void add(pair<int,int> xy1,pair<int,int> xy2,T z){
        int x1=xy1.first,y1=xy1.second;
        int x2=xy2.first,y2=xy2.second;
        board[x1][y1]+=z;
        board[x1][y2+1]-=z;
        board[x2+1][y1]-=z;
        board[x2+1][y2+1]+=z;
    }
    // 累積和
    void build(){
        for(int x=1;x<(int)board.size();x++){
            for(int y=1;y<(int)board[0].size();y++){
                board[x][y]+=board[x][y-1];
            }
        }
        for(int x=1;x<(int)board.size();x++){
            for(int y=1;y<(int)board[0].size();y++){
                board[x][y]+=board[x-1][y];
            }
        }
    }
    // 値取得
    T get(int x,int y){
        return board[x][y];
    }
    // debug
    void debug(){
        for(int x=1;x<(int)board.size()-1;x++){
            for(int y=1;y<(int)board[0].size()-1;y++){
                cout<<board[x][y]<<" ";
            }
            cout<<endl;
        }
    }
};
int main(){
    int n,m,q; cin>>n>>m>>q;
    imos2d<int> imos(n,n);
    while(m--){
        int l,r; cin>>l>>r;
        imos.add({1,r},{l,n},1);
    }
    imos.build();
    while(q--){
        int l,r; cin>>l>>r;
        cout<<imos.get(l,r)<<endl;
    }
    return 0;
}


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

/*
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
*/

using namespace std;

typedef long long LL;
typedef double DB;
typedef unsigned int UI;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;

#define rdi() read<int>()
#define rdl() read<LL>()
#define rds(a) scanf("%s", a)
#define mk(i, j) make_pair(i, j)
#define pb push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = j; i <= k; i ++)
#define Rep(i, j, k) for (int i = j; i >= k; i --)
#define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt)

template<typename t> t read() {
	t x = 0;
	int f = 1;
	char c = getchar();
	while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar();
	return x * f;
}

template<typename t> void write(t x) {
	if (x < 0) {
		putchar('-'), write(-x);
		return;
	}
	if (x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

#define N 200010
struct aa {
	int l, r;
} a[N];
int n, m, i, ans, now;

bool cmp(aa a, aa b) {
	if (a.l == b.l) return a.r > b.r;
	return a.l < b.l;
}

struct bb {
	int val;
	bool operator < (const bb &t) const{
		return val > t.val;
	}
};

priority_queue < bb > Heap;

int main() {
	n = rdi(), m = rdi();
	for (i = 1; i <= n; i++) a[i].l = rdi(), a[i].r = rdi();
	sort(a + 1, a + n + 1, cmp);
	for (now = 1; now <= n; now++) if (a[now].l) break;
	now--;
	for (i = 1; i <= now; i++) Heap.push((bb){a[1].r});
	for (i = 1; i <= m; i++) {
		while (now < n && a[now + 1].l < i) now++, Heap.push((bb){a[now].r});
		if (now < n) {
			now++;
			if (++ans == n) break;
			continue;
		}
		if (!Heap.empty() && Heap.top().val <= i) {
			Heap.pop();
			if (++ans == n) break;
			continue;
		}
	}
	printf("%d\n", n - ans);
	return 0;
}

Measured memory_bytes: 2936
#! usr/bin/perl

use strict;
use warnings;

sub max {
    my ($a,$b)=@_;
    $a>$b ? $a : $b;    
}

chomp(my $line = <STDIN>);
my ($K,$S) = split ' ',$line;

my $count=0;
foreach my$x(0..$S/3) {
    foreach my$y(max($x,$S-$x-$K)..($S-$x)/2) {
        my $z = $S-$x-$y;
        if (($x==$y)&&($y==$z)) {$count += 1;next};
        if (($x==$y)||($y==$z)) {$count += 3;next};
        $count += 6;
    }
}

print "$count\n"

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

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

ll mod = 1e9 + 7;
int inf = 1e9 + 7;
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 (b<a) { a=b; return 1; } return 0; }

int main() {
    int n, w;
    scanf("%d%d", &n, &w);
    vector<ll> value(n);
    vector<int> weight(n);
    rp(i, 0, n) scanf("%d%lld", &weight.at(i), &value.at(i));
    vector<vector<ll>> dp(n, vector<ll>(w+1, -1ll));
    rp(i, 0, n) dp.at(i).at(0) = 0ll;
    dp.at(0).at(weight.at(0)) = value.at(0);
    rp(i, 1, n) {
        int now_w = weight.at(i);
        rp(j, 0, w) {
            chmax(dp.at(i).at(j), dp.at(i-1).at(j));
        }
        rp(k, 0, w-now_w+1){
            if(dp.at(i-1).at(k) >= 0) chmax(dp.at(i).at(k+now_w), dp.at(i-1).at(k) + value.at(i));
        }
    }
    ll res = -1;
    rp(i, 0, w+1) chmax(res, dp.at(n-1).at(i));
    printf("%lld", res);
    return 0;
} 

Measured memory_bytes: 79360
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string a,b;cin>>a>>b;
  string buf=a+b;
  int c=stoi(buf);
  // P(c);
  for(int i=2;i<c;i++){
    if(c==(i*i)){
      P("Yes");
      return 0;
    }
  }
  P("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;

int main() {
	ios_base::sync_with_stdio(0);
	int a,b,n,x,T,cas=0;
	cin>>n;
	int mn=1e6, cnt=0;
	for(int i=0;i<n;++i) {
		cin>>x;
		if(x<=mn) {
			cnt++;
			mn=x;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  bool ok = false;
  for (int i = 0; i <= n/4; i++) {
    if ( (n-(4*i))%7==0 ) ok = true;
  }
  COUT(ok?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n;
char s[300010];

signed main() {
	cin >> n;
	int ta = 0, mu = 0;
	cin >> s[0];
	for (int i = 1; i < n; i++) {
		cin >> s[i];
		if (s[i] == 'E')ta++;
	}
	mu = ta;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E')ta--;
		if (s[i - 1] == 'W')ta++;
		if (ta < mu)mu = ta;
	}
	cout << mu << endl;
	ggr
}

Measured memory_bytes: 512
N = int(input())
H = list(map(int,input().split()))

min = H[0] - 1
flg = 1
for i in range(1,N):
    if min < H[i]:
        min = H[i] - 1
    elif min > H[i]:
        flg = 0
        break

if flg == 1:print("Yes")
else:print("No")


Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
int ap=0;
int atbp=0;
int bp=0;
int main()
{
	int n;
	int a,b;
	scanf("%d %d %d",&n,&a,&b);
	for(int i=0;i<n;i++)
	{
		int t;
		scanf("%d",&t);
		if(t<=a)
			ap++;
		else if(t<=b)
			atbp++;
		else 
			bp++;
	}
	printf("%d",min(ap,min(atbp,bp)));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[410];
long long dp[410][410];
long long s[410];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		s[i]=a[i]+s[i-1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp[i][j]=4e18;
	for(int i=1;i<=n;i++)
		dp[i][i]=0;
	for(int i=1;i<n;i++)
		for(int j=1;j+i<=n;j++){
			for(int k=j;k<j+i;k++)
				dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][i+j]);
			dp[j][j+i]+=s[j+i]-s[j-1];
		}
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 1536
#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;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int q;
  cin >> q;
  int b, e, t;
  rep(i,q) {
    cin >> b >> e >> t;
    rep(i,e-b) swap(*(a.begin()+b+i), *(a.begin()+t+i));
  }
  rep(i,n) {
    cout << a[i];
    if (i==n-1) cout << endl;
    else cout << " ";
  }

  return 0;
}



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

#define int long long int 
#define endl "\n"
typedef long double ld ;


int32_t main() 
{
   
 /*  #ifndef ONLINE_JUDGE 
   freopen("input.txt","r",stdin) ;
   freopen("output.txt","w",stdout);
   #endif */

   int A , B , K ; 
   cin >> A >> B >> K ;
   int num = 0 ;
   vector<int>factor ;
   for(int i = 1 ; i <= min(A,B) ; i++ )
   {
     if( A %i == 0 && B % i == 0 )
     {
       factor.push_back(i) ;
     }
   }
   sort(factor.rbegin(),factor.rend());
   cout<<factor[K-1]<<endl;
   return 0 ;
  
}


Measured memory_bytes: 256
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    a, b = map(int, input().split())
    if a <= 5:
        print(0)
    elif a <= 12:
        print(b // 2)
    else:
        print(b)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29420
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

//#define MOD (int)(1e5 + 7)
#define MOD (100007)

void invalid(void)
{
	printf("-1\n");
	exit(0);
}

struct Magic {
	int A, B;
};

int main(int argc, char **argv)
{
	int H, N;
	scanf("%d%d", &H, &N);
	struct Magic *M = calloc(sizeof(struct Magic), N);
	for (int i = 0; i < N; i++)
		scanf("%d%d", &M[i].A, &M[i].B);
	uint64_t MPforDamage[20000]; // H <= 10000
	for (int i = 0; i < 20000; i++)
		MPforDamage[i] = 99999999999999;
	MPforDamage[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int h = 0; h <= H; h++) {
			int idx = h + M[i].A;
			if (idx >= H)
				idx = H;
			if (MPforDamage[idx] > MPforDamage[h] + M[i].B)
				MPforDamage[idx] = MPforDamage[h] + M[i].B;
		}
	}
	printf("%ld\n", MPforDamage[H]);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
char str[1100000];
int used[1100000];
int main(){
	int a;scanf("%d%s",&a,str);
	int left=0;
	int right=a+1;
	while(left+1<right){
		int M=(left+right)/2;
		for(int i=0;i<a;i++)used[i]=0;
		queue<int>Q;
		vector<int>sec;
		for(int i=a-1;i>=0;i--){
			if(sec.size()==M)break;
			if(str[i]=='I')Q.push(i);
			if(str[i]=='O'){
				if(Q.size()==0)continue;
				used[Q.front()]=1;
				used[i]=1;
				Q.pop();
				sec.push_back(i);
			}
		}
		if(sec.size()<M){
			right=M;continue;
		}
		reverse(sec.begin(),sec.end());
		bool ok=true;
		int at=0;
		for(int i=0;i<a;i++){
			if(str[i]!='O'&&!used[i]){
				if(sec[at]<=i){
					ok=false;break;
				}
				at++;
			}
			if(at==M)break;
		}
		if(at<M)ok=false;
		if(ok)left=M;
		else right=M;
	}
	printf("%d\n",left);
}

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

using namespace std;

int main()
{
    long long int a,res;
    double b;
    scanf("%lld%lf",&a,&b);

    res = (long long int)((b*100)+0.5);
    res *= a;
    res /= 100;


    printf("%lld",res);


    return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;


int main(){
    long long int n; cin >> n;
    if(n % 2 != 0){string s; cin >> s; cout << "No" << endl; }
    else{
        string s; cin >> s;
        int uvijet = true;
        for(int i = 0;i < n/2;i++){
            if(s[i] != s[(n/2)+i]) uvijet = false;
        }
        if(uvijet) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    int ok = n;
    int ng = -1;

    while(ok - ng > 1){
        int mid = (ok + ng) >> 1;
        if((int)((double)mid * 1.08) >= n){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    if((int)((double)ok * 1.08) == n){
        cout << ok << endl;
    }else{
        cout << ":(\n";
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
A,B,C,D = gets.chomp.split(" ").map(&:to_i)
#p [A,B,C,D]
not_div_C = B/C-(A-1)/C
not_div_D = B/D-(A-1)/D
lcm_CD = C.lcm(D)
not_div_C_D = B/lcm_CD-(A-1)/lcm_CD

puts (B-A+1) - (not_div_C + not_div_D - not_div_C_D)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
string s; cin>>s;
int S[s.size()+1],L[s.size()+1];
ll cntS=0,cntL=0;
S[0] = 0;
for(int i = 1; i < s.size()+1; i++){
    if(s[i-1] == '<') {
        cntS++;
        S[i] = cntS;
    }else
    {
        cntS = 0;
        S[i] = 0;
    }//左側にある＜の数を数える
}
L[s.size()] = 0;
for(int i = s.size()-1; i >= 0; i--){
    if(s[i] == '>'){
        cntL++;
        L[i] = cntL;
    }else
    {
        cntL = 0;
        L[i] = 0;
    }    
}//右側にある＞の数を数える
ll ans = 0;
rep(i,s.size()+1){
  //  cout<<"S[i] =="<<S[i]<<" L[i]=="<<L[i]<<endl;
ans += max(S[i],L[i]);
//cout<<ans<<endl;
}//＜と＞の数が大きい方を数える

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


Measured memory_bytes: 7708
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	string s;
  	cin >> s;
  	s[3] = '8';
  	cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
 
roads = []
for i in range(n): roads.append([])
 
is_good_peak_arr = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if h[a] >= h[b]: is_good_peak_arr[b] = False
    if h[b] >= h[a]: is_good_peak_arr[a] = False
 
print(is_good_peak_arr.count(True))

Measured memory_bytes: 20948
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// get a integer
		String s = sc.nextLine();
		int times = 0;
		int len = s.length();
		
		char c = s.charAt(0);
		for (int i = 1; i < len; i++) {
			char ch = s.charAt(i);
			if (ch != c) {
				times++;
				c = ch;
			}
		}
		System.out.println(times);
		sc.close();
	}
}

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

L, R = map(int, input().split())

for i in range(1, M):
    hoge, fuga = map(int, input().split())
    L = max(L, hoge)
    R = min(R, fuga)


if L > R:
    print(0)
else:
    print(R-L+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[500005];
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a[x]++;//核心部分，把上下能修改到的地方都数量加1
        a[x-1]++;
        a[x+1]++;
    }
    int maxv=0;
    for(int i=0;i<=500000;i++)//比大小
        if(a[i]>maxv)
            maxv=a[i];
    cout<<maxv;
    return 0;
 } 

Measured memory_bytes: 640
#B
N = int(input())
A = list(map(int, input().split()))
ans = "APPROVED"

for item in A:
    if item % 2 == 0:
        if item % 3 == 0 or item % 5 == 0:
            ans = "APPROVED"
        else:
            ans = "DENIED"
            break

print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  long int n,k;
  long int ans;
  scanf("%ld%ld",&n,&k);
  long int mod=n%k;
  if(k<=n){
    ans=mod;
    if(k/2<mod){
      ans=k-mod;
    }
  }else{
    ans=mod;
    if(k/2<mod){
      ans=k-mod;
    }
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
const int nax = 10000001;
bool all[nax];
vector<int> primes;
void seive(){
 for(int i=2; i*i<=nax; i++){
  if(!all[i]){
    primes.pb(i);
    for(int j=i*i; j<=nax; j+=i)
       all[j] = 1;
  }
 }
}
int f(int n){
  int pro = 1;
 for(int i : primes){
    if(n==1)
       break;
    int cnt = 1;
    while(n%i==0){
      n/=i;
      cnt++;
    }
   pro*=cnt;
  }
 return pro;
}
/*const int mf = 670000;
int v[nax][mf]*/
void solve()
  {
   //seive();
   int n;
   cin>>n;
   int ans = 0;
   loop(i,1,n+1){
    int times = n/i;
    int curr = times*(2*i + (times-1)*i)/2;
    ans += curr;
   }
   cout<<ans;
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3632