akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
template <typename Abelian>
struct BIT {
  BIT(int sz_, const Abelian UNITY_ = 0) : UNITY(UNITY_) {
    sz = sz_ + 1;
    dat.assign(sz, UNITY);
  }

  void add(int idx, Abelian value) {
    while (idx < sz) {
      dat[idx] += value;
      idx += idx & -idx;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    while (idx > 0) {
      res += dat[idx];
      idx -= idx & -idx;
    }
    return res;
  }

  int lower_bound(Abelian value) {
    if (value < UNITY) return 0;
    int res = 0, exponent = 1;
    while (exponent < sz) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask < sz && dat[res + mask] < value) {
        value -= dat[res + mask];
        res += mask;
      }
    }
    return res + 1;
  }

private:
  int sz;
  const Abelian UNITY;
  vector<Abelian> dat;
};

template <typename T>
long long solve(const vector<T> &seq) {
  int sz = seq.size();
  vector<T> cp = seq;
  sort(ALL(cp));
  cp.erase(unique(ALL(cp)), cp.end());
  BIT<int> bit(cp.size());
  long long res = 0;
  REP(i, sz) {
    int idx = lower_bound(ALL(cp), seq[i]) - cp.begin() + 1;
    res += i - bit.sum(idx - 1);
    bit.add(idx, 1);
  }
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<long long> a(n + 1, 0);
  FOR(i, 1, n + 1) {
    cin >> a[i];
    a[i] -= k;
  }
  FOR(i, 1, n + 1) a[i] += a[i - 1];
  reverse(ALL(a));
  cout << solve(a) << '\n';
  return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int i, j, n, maxDiff = -1000000000;
  int r[200000];
  int num, diff, min;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &r[i]);
  }

  min = r[0];
  for(i = 1; i < n; i ++) {
    num = r[i];
    diff = num - min;
    if(diff > maxDiff) maxDiff = diff;
    if(num < min) min = num;
  }

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

  return 0;
}


Measured memory_bytes: 2624
#include <iostream>
#include <cstdio>
#include <algorithm>

#define MAXN 1000
#define rop(i,n) for ( int i = 0; i < n; ++i )

using namespace std;

typedef long long ll;

ll x[MAXN], y[MAXN], z[MAXN];
ll t[MAXN];
int N,M;

ll func ( int fx, int fy, int fz )
{
  ll ans = 0;
  rop(i,N) {
    ll tmp = 0;
    if ( fx == 0 ) tmp += -x[i];
    else tmp += x[i];
    if ( fy == 0 ) tmp += -y[i];
    else tmp += y[i];
    if ( fz == 0 ) tmp += -z[i];
    else tmp += z[i];
    t[i] = tmp;
    //cout << "tmp = " << tmp << endl;
  }

  sort ( t, t+N, greater<ll>());

  rop(i,M) {
    ans += t[i];
  }

  //cout << "ans = " << ans << endl;
  return ans;
}

int main()
{
  ll ans,tmp;
  cin >> N >> M;

  for ( int j = 0; j < N; ++j) {
    //scanf("%ld%ld%ld", &x[j], &y[j], &z[j]);
    cin >> x[j] >> y[j] >> z[j];
  }
  /*
  for ( int i = 0; i < N; ++i ) {
    printf("%ld, %ld, %ld\n", x[i], y[i], z[i]);
  }
  */
  ans = func(1,1,1);
  tmp = func(0,1,1); if ( tmp > ans ) ans = tmp;
  tmp = func(1,0,1); if ( tmp > ans ) ans = tmp;
  tmp = func(1,1,0); if ( tmp > ans ) ans = tmp;
  tmp = func(0,0,1); if ( tmp > ans ) ans = tmp;
  tmp = func(1,0,0); if ( tmp > ans ) ans = tmp;
  tmp = func(0,1,0); if ( tmp > ans ) ans = tmp;
  tmp = func(0,0,0); if ( tmp > ans ) ans = tmp;

  cout << ans << endl;
}


Measured memory_bytes: 1144
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > value;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    value.push_back(make_pair(a, b));
  }
  sort(value.begin(), value.end());
  int num = 0;
  long long ans = 0;
  int nokori = m;
  for (int i = 0; i < n; i++) {
    int buy = min(value[i].second, nokori);
    ans += (long long)value[i].first * buy;
    nokori -= buy;
    if (nokori == 0) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        int l = s.length();
        for (int i = 0; i < l / 2; i++) {
            if (s.charAt(i) != s.charAt(l - 1 - i)) {
//                System.err.println(String.format("i=%d [%s], rev_i=%d [%s]", i, s.charAt(i), l - 1 - i, s.charAt(l - 1 - i)));
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23892
#include<cstdio>
#include<iostream>
#include<algorithm>
#define SIZE 100100

using namespace std;

char s[SIZE];
struct aa
{
    int start,ending;
}rec[SIZE];

int main()
{
    int cnt=1;
    int n,k,i=0;
    int ans=-1,tmp;
    rec[0].start=rec[0].ending=-1;
    rec[1].start=-1;
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    for(i=0;s[i];i++)
    {
        if(s[i]=='1' && s[i+1]!='1')
        {
            rec[cnt].ending=i;
            cnt++;
        }
        else if(s[i]=='0' && s[i+1])
        {
            rec[cnt].start=i;
        }
    }
    rec[cnt].ending=n-1;
    for(i=0;i<=cnt-k;i++)
    {
        tmp=rec[i+k].ending-rec[i].start;
        ans=max(ans,tmp);
    }
    if(ans==-1)
        ans=n;
      //  printf("cnt=%d\n",cnt);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<int> g[200000];
vector<ll> cnt(200000);

void dfs(int v, int p, int add) {
  cnt[v] += add;
  for (auto u : g[v]) {
    if (u == p) continue;
    dfs(u, v, cnt[v]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < q; ++i) {
    int p, x;
    cin >> p >> x;
    p--;
    cnt[p] += x;
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; ++i) {
    cout << cnt[i] << (i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

struct Grid {
    int h, w;
    vector<vector<char>> grid;
    vector<vector<bool>> seen;

    void init(int H, int W) {
        h = H;
        w = W;
        grid.assign(H, vector<char>(W));
        seen.assign(H, vector<bool>(W, false));
    }

    void input(){
        for(int i = 0; i < (int)grid.size(); i++) {
            for(int j = 0; j < (int)grid[i].size(); j++) {
                cin >> grid[i][j];
            }
        }
    }

    bool isin(int i, int j) {
        return i >= 0 && i < h && j >= 0 && j < w;
    }

    bool isseen(int i, int j) {
        return i >= 0 && i < h && j >= 0 && j < w && !seen[i][j];
    }
};

int h, w;
Grid g;
int cnt[2];
ll ans = 0;

void dfs(int i, int j, int dis) {
    g.seen[i][j] = true;
    if(g.grid[i][j] == '#') {
        cnt[0]++;
    }else{
        cnt[1]++;
    }

    for(int k = 0; k < 4; k++) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if(g.isseen(ni, nj)) {
            if(dis&1 && g.grid[ni][nj]=='#') dfs(ni, nj, dis+1);
            if(dis&1^1 && g.grid[ni][nj]=='.') dfs(ni, nj, dis+1);
        }
    }
}
 
int main() {
    cin >> h >> w;
    g.init(h, w);
    g.input();
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
        if(g.grid[i][j] == '.' && !g.seen[i][j]) {
            memset(cnt, 0, sizeof(cnt));
            dfs(i, j, 1);
            ans += 1LL * cnt[0] * cnt[1];
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std ;
bool is_war ( const vector <int >& x , const vector <int >& y ) {
for ( int Z = -100; Z <= 100; ++ Z ) {
bool is_ok = true ;
for ( int i = 0; i < x . size (); ++ i ) {
if ( x [ i ] >= Z ) is_ok = false ;
}
for ( int i = 0; i < y . size (); ++ i ) {
if ( y [ i ] < Z ) is_ok = false ;
}
if ( is_ok ) return false ;
}
return true ;
}
int main () {
int N , M ; cin >> N >> M ;
vector <int > x ( N +1) , y ( M +1);
cin >> x [0] >> y [0];
for ( int i = 0; i < N ; ++ i ) {
cin >> x [ i +1];
}
for ( int i = 0; i < M ; ++ i ) {
cin >> y [ i +1];
}
if ( is_war (x , y )) {
cout << " War " << endl ;
}
else {
cout << "No War " << endl ;
}
}

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

#define BUF_SIZE 2000000

int* fget_array(int *arr, int size, char *line) {
  char *tmpbuf = line;
  int i;
  for(i = 0; i < size; i++) {
    char *tmp = strtok(tmpbuf, " ");
    arr[i] = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
  }
  return arr;
}

int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);
  int *arr = malloc(sizeof(int)*num);

  int i, j;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  fget_array(arr, num, line);

  int start, end;
  start = end = 0;
  int tmp = 0;
  long ans = 0;
  while(start < num) {
    while(end < num && (!(arr[end] & tmp))) {
      tmp ^= arr[end++];
    }
    ans += (long)(end-start);
    tmp ^= arr[start++];
  }

  printf("%ld\n", ans);

}

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

using namespace std;

struct UniTree {
    int *par, *depth;

    UniTree(int n) {
        par = new int[n], depth = new int[n];

        for(int i = 0; i < n; i++) {
            par[i] = i;
            depth[i] = 0;
        }
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void link(int x, int y) {
        x = root(x);
        y = root(y);

        if(par[x] == par[y]) return;
        if(depth[x] < depth[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if(depth[x] == depth[y]) depth[x]++;
        }
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    int p[n];
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    UniTree tree(n);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        tree.link(x - 1, y - 1);
    }

    map<int, set<int> > roots;
    for(int i = 0; i < n; i++) {
        roots[tree.root(i)].insert(i);
    }
    int ans = 0;
    for(pair<int, set<int> > pr : roots) {
        set<int> st = pr.second;
        for(int x : st) {
            if(st.find(p[x] - 1) != st.end()) ans++;
        }
    }

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

Measured memory_bytes: 15488
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))

import numpy as np

n = ii()
w = li()

s1_list = []
s2_list = []
for t in range(n-1):
    s1 = sum(w[0:t+1])
    s2 = sum(w[t+1:])
    s1_list.append(s1)
    s2_list.append(s2)

s = np.array(s1_list) - np.array(s2_list)
s = np.abs(s)
print(np.amin(s))

Measured memory_bytes: 21400
import sys

def change(S, N, K):
    K-=1
    print S[:K] + S[K].lower() + S[K+1:]

if __name__ == '__main__':
    input = sys.stdin.read()
    inlst = input.split("\n")
    N, K =inlst[0].split()
    S = inlst[1]
    change(S, int(N), int(K))

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,d;
	sd(d);
	sd(n);
	d=powmod(100,d,mod);
	if(n==100){
		d*=n+1;
	}
	else{
		d*=n;
	}
	pd(d);
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

map<int, int> prime_factor(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

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

    map <int, int> mp;
    for (int i = 2; i <= n; i++) {
        auto mp2 = prime_factor(i);
        for (auto &itr : mp2) {
            mp[itr.first] += itr.second;
        }
    }

    ll ans = 1;
    for (auto &itr : mp) {
        if (itr.first == 1) continue;
        ans = ans * (itr.second + 1) % MOD;
    }

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

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define MOD 1000000007
double probs[3000];

double recur(int i, int n, int heads, int tails, double sa)
{
	if (i == n)
	{
		if (heads > tails)
			return sa;
		else
			return 0;
	}

	double a = recur(i + 1, n, heads + 1, tails, (double)sa * probs[i]);
	double b = recur(i + 1, n, heads, tails + 1, (double)sa * (1 - probs[i]));
	return a + b;
}



int main()
{


	ll n;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> probs[i];

	double dp[n + 1][n + 1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (i == 0 && j == 0)
				dp[i][j] = 1;

			if (j > i)
				dp[i][j] = 0;
			if (i - 1 >= 0 && j - 1 >= 0)
				dp[i][j] += dp[i - 1][j - 1] * (probs[i - 1]);

			if (i - 1 >= 0)
				dp[i][j] += dp[i - 1][j] * (1 - probs[i - 1]);
		}
	}
	double ans = 0;
	for (int i = 0; i <= n; i++)
	{
		if (i > (n - i))
		{
			ans += dp[n][i];
		}
	}





	cout << setprecision(10) << ans << endl;
}













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

int main() {
  string str;
  int size;
  char f,e;
  cin >> str;
  
  f = str.at(0);
  e = str.at(str.size()-1);
  size = str.size() - 2;
  
  cout << f + to_string(size) + e;  
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
  ans = -1
else:
  minus = 0
  plus = []
  for i in range(N):
    dif = A[i] - B[i]
    if dif < 0:
      minus -= dif
    else:
      plus.append(dif)
   
  plus.sort(reverse=True)
  if minus <= 0:
    ans = 0
  else:
    for i in range(len(plus)):
      minus -= plus[i]
      if minus <= 0:
        break
    ans = N-len(plus)+i+1
print(ans)

Measured memory_bytes: 24216
import heapq

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//2))
print(-sum(q))

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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n, ans=0;
      n=Integer.parseInt(sc.next());
      int[] p = new int[n];
      for(int i=0; i<n; i++){
        p[i]=Integer.parseInt(sc.next());
      }

      
      Arrays.sort(p);
      for(int i=0; i<n-1; i++){
        ans=ans+p[i];
      }
      System.out.println(ans+(p[n-1]/2));
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 21204
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		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 r = solve(n, W, w, v);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n, int W, int[] w, int[] v) {
		long[] state = new long[W + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = W; j >= w[i - 1]; j--) {
				state[j] = Math.max(state[j], state[j - w[i - 1]] + v[i - 1]);
			}
		}
		return state[W];
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  bl b=true;
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a%2==1){
      b=false;
      co("first")
        break;
    }
  }
  if(b){
    co("second")
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;
#define ddarr(arr,n,m)rep(i,n){rep(j,m){cout<<arr[i][j]<<' ';}cout <<endl;};


int main() {
    int A, B, C;
    long long K;
    cin >> A >> B >> C >> K;

    if (K % 2 == 0) {
        cout << A - B << endl;
    }
    else {
        cout << B - A << endl;
    }
}

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

int partition(int[], int, int);
int n;
int a[100001];

int main(){
	int q;
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	
	q = partition(a, 0, n-1);
	for(int i = 0 ; i < n ; i++){
		if(i){
			cout << " ";
		}
		if(i == q){
			cout << "[";
		}
		cout << a[i];
		if(i == q){
			cout << "]";
		}
	}
		
		cout << endl;
		
	return 0;
}

int partition(int a[], int p, int r){
	int x, i, j, t;
	int k;
	x = a[r];
	i = p - 1;
	for(j = p ; j < r ; j++){
		if(a[j] <= x){
			i++;
			k = a[i];
			a[i] = a[j];
			a[j] = k;
		}
	}
	
	k = a[i + 1];
	a[i + 1] = a[r];
	a[r] = k;
	
	return i + 1;
}

Measured memory_bytes: 1548
n = int(input())
if n == 1:
  print(1)
elif n == 2 or n == 3:
  print(2)
elif 3 < n < 8:
  print(4)
elif 7 < n < 16:
  print(8)
elif 15 < n < 32:
  print(16)
elif 31 < n < 64:
  print(32)
else:
  print(64)

Measured memory_bytes: 9116
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

int c[30];
int st[30][100000];
ll dp[52][2510];
ll a[101];
bool d[11];
void Solve() {
	int n, k;
	cin >> n >> k;
	for (size_t i = 0; i < k; i++)
	{
		int v;
		cin >> v;
		d[v] = true;

	}

	for (int i = n; i < 100000; i++)
	{
		int ti = i;
		bool wrong = false;
		while (ti > 0)
		{
			int nm = ti % 10;
			if (d[nm]) {
				wrong = true;
				break;
			}
			ti /= 10;
		}
		if (wrong) continue;
		cout << i << endl;
		return;
	}


}
int main() {
	Solve();
	return 0;
}



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

int main()
{
	size_t N;
	std::cin >> N;

	int64_t R = 1;
	for (size_t n = 0; n < N; ++n)
	{
		int64_t A;
		std::cin >> A;

		if (A == 0) {
			R = 0;
			break;
		}

		if (R != -1)
		{
			if (R >= std::numeric_limits<int64_t>::max() / A) {
				R = -1;
			} else {
				R *= A;
				if (R > 1000000000000000000L) {
					R = -1;
				}
			}
		}

	}
	std::cout << R << std::endl;
	return 0;
}

Measured memory_bytes: 3636
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

f x
  | x `mod` 2 == 1 = 0
  | otherwise = 1 + f (x `div` 2)

main = do
  [n] <- getInts
  xs <- map f <$> getInts
  print $ minimum xs


-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;

    if (a <= 9 && b <= 9)
        cout << a * b << '\n';
    else
        cout << -1 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 998244353;
LL quickpow(LL m, LL p)
{
    LL res = 1;
    while (p) {
        if (p & 1)
            res = res * m % mod;
        m = m * m % mod;
        p >>= 1;
    }
    return res;
}
const int maxn = 1e5 + 5;
int p[maxn], a[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        p[a[i]]++;
    }
    if (p[0] != 1 || a[1] != 0) {
        printf("0\n");
        return 0;
    }
    int x;
    for (int i = maxn - 1; i >= 0; i--)
        if (p[i]) {
            x = i;
            break;
        }
    for (int i = 1; i <= x; i++) {
        if (!p[i]) {
            printf("0\n");
            return 0;
        }
    }
    LL res = 1;
    for (int i = 0; i <= n; i++) {
        if (!p[i])
            break;
        res = res * quickpow(p[i], p[i + 1]) % mod;
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	int n,m;
	cin>>n>>m;
	if(n==1&&m==0)
	{
		cout<<"0\n";
		return 0;
	}int c,d;
	for(int i=1;i<=m;i++)
	{
		
		cin>>c>>d;
		if(a[c]!=0&&a[c]!=d)
		{
			cout<<"-1\n";
			return 0;
			break;
		}
		a[c]=d;
		if(c==1&&d==0&&n!=1)
		{
			cout<<"-1\n";
			return 0;	
			break;
		} 
	}
	if(n==1&&m==1&&c==1&&d==0)
	{
			cout<<"0"<<endl;
			return 0;}
	for(int i=1;i<=n;i++)
	{
		if(a[1]==0)
			a[1]=1;
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  string s; cin >> s;
  if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;
typedef pair<int, int> P;
 
int main(){
    int n,u,v,m,k;
    cin >> n >> u >> v >> m;
    if(n==1){
      int usagi_c=0,neko_c=0;
      int usagi_one,neko_one;
      cin>>usagi_one>>neko_one;
      int tmp;
      REP(i,m){
	cin >> tmp;
	if(tmp==usagi_one)usagi_c++;
	if(tmp==neko_one)neko_c++;
      }
      if(u==usagi_c&&v==neko_c)cout << "DRAW"<<endl;
      else if(u==usagi_c)cout << "USAGI"<<endl;
      else if(v==neko_c)cout << "NEKO" << endl;
      else cout << "DRAW" << endl;
    }else{
      
    int usagi_x[n];
    fill(usagi_x,usagi_x+n,0);
    int usagi_y[n];
    fill(usagi_y,usagi_y+n,0);
    int usagi_xy=0,usagi_yx=0;
    int neko_x[n];
    fill(neko_x,neko_x+n,0);
    int neko_y[n];
    fill(neko_y,neko_y+n,0);
    int neko_xy=0,neko_yx=0;
    int usagi_n=0;
    int neko_n=0;
 
    map<int,P> usagi, neko;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> k;
            usagi[k]=P(i,j);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> k;
            neko[k]=P(i,j);
        }
    }
    for(int i=0;i<m;i++){
      bool neko_b=false,usagi_b=false;
      cin >> k;
        auto it = usagi.find(k);
        if(it!=usagi.end()){
            int x=it->second.first,y=it->second.second;
            usagi.erase(k);
            if(++usagi_x[x]==n) usagi_n++;
            if(++usagi_y[y]==n) usagi_n++;
            if(x==y){
                if(++usagi_xy==n) usagi_n++;
            }
            if(x+y==n-1){
                if(++usagi_yx==n) usagi_n++;
            }
            if(usagi_n>=u) usagi_b=true;
        }
 
        it = neko.find(k);
        if(it!=neko.end()){
            int x=it->second.first,y=it->second.second;
            neko.erase(k);
            if(++neko_x[x]==n) neko_n++;
            if(++neko_y[y]==n) neko_n++;
            if(x==y){
                if(++neko_xy==n) neko_n++;
            }
            if(x+y==n-1){
                if(++neko_yx==n) neko_n++;
            }
            if(neko_n>=v) neko_b=true;
        }
        if(neko_b&&usagi_b){
            cout<<"DRAW"<<endl;
            return 0;
        }else if(neko_b){
            cout<<"NEKO"<<endl;
            return 0;
        }else if(usagi_b){
            cout<<"USAGI"<<endl;
            return 0;
        }
    }
    cout<<"DRAW"<<endl;
    }
    return 0;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

long long x;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>x;
    for(long long a = -1000; a <= 1000; a++) {
    	for(long long b = -1000; b <= 1000; b++) {
    		if(a * a * a * a * a - b * b * b * b * b == x) {
    			cout<<a<<" "<<b<<endl;
    			return 0;
			}
		}
	}
    /* end code */
	return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		string S = GetString();
		switch(S)
		{
			case "Sunny":
				Console.WriteLine("Cloudy");
				break;

			case "Cloudy":
				Console.WriteLine("Rainy");
				break;

			case "Rainy":
				Console.WriteLine("Sunny");
				break;
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <vector>

const int MAX_STACK = 1000;

template <typename T> class Stack {
  T s[MAX_STACK];
  int last = 0;

public:
  T top() { return s[last]; }
  void pop() {
    if (last > 0)
      --last;
  }
  void push(T v) { s[++last] = v; }
};

int main() {
  Stack<int> s;
  std::string c;
  std::string op = "*+-";
  while (std::cin >> c) {
    if (std::isdigit(c[0])) {
      s.push(std::stoi(c));
      continue;
    }

    int a, b;
    a = s.top();
    s.pop();
    b = s.top();
    s.pop();

    if (c == "*")
      s.push(a * b);
    if (c == "-")
      s.push(b - a);
    if (c == "+")
      s.push(a + b);
  }

  std::cout << s.top() << std::endl;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
v64 dp;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll a[n][3];
    forn(i,n) forn(j,3) cin >> a[i][j];
    ll dp[n+1][3];
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    forn(i,n){
    	forn(j,3){
    		dp[i+1][j]=max(dp[i][(j+1)%3]+a[i][(j+1)%3],dp[i][(j+2)%3]+a[i][(j+2)%3]);
    	}
    }
    ll t=0;
    t = max(dp[n][0],dp[n][1]);
    t = max(t,dp[n][2]);
    cout << t << ln;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    string s; cin >> s;
    set<char> sc;
    for(char c : s) {
        sc.insert(c);
    }
    cout << ((sc.size() == 2) ? "Yes" : "No") <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n;
  cin >> n;
  n = n % 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n ==9) {
    cout << "hon" << endl;
    return 0;
  }
  if(n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
    return 0;
  }
  if(n == 3) {
    cout << "bon" << endl;
    return 0;
  }
}
  

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

int main() {
    int N;
    cin >> N;
    map<int, int> P;
    for (int i = 1; i <= N; i++) {
        int p;
        cin >> p;
        P[p] = i;
    }

    ll ans = 0;
    multiset<int> L;
    L.insert(0);
    L.insert(0);
    L.insert(N + 1);
    L.insert(N + 1);
    for (int i = N; i >= 1; i--) {
        L.insert(P[i]);
        auto itr = L.lower_bound(P[i]);
        auto l1 = prev(itr);
        auto l2 = prev(l1);
        auto r1 = next(itr);
        auto r2 = next(r1);
        ll cnt = (*l1 - *l2) * (*r1 - *itr) + (*r2 - *r1) * (*itr - *l1);
        ans += cnt * i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>		
using namespace std;
typedef long long int lli;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


bool isPalindrome(char str[]) 
{ 
    int l = 0; 
    int h = strlen(str) - 1;
    // cout<<"HH "<<h<<'\n';
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        {
            // cout<<l<<"  "<<h<<'\n';
            // cout<<str[--l]<<"   "<<str[++h]<<'\n';
            // cout<<"FF"<<'\n';
           return false;
        }
    }
    // cout<<"TT"<<'\n';
   return true;
} 


int main()
{
   fastio
    string str;
    cin>>str;
    int len = str.length();
  //  cout<<"LEN IS "<<len<<'\n';
    char s1[len+1];
    for(int ii = 0;ii< len;ii++)
    s1[ii] = str[ii];
    
    int len2 = (len-1)/2;
  //  cout<<"LEN2 "<<len2<<'\n';
    char s2[len2+1];
    for(int i = 0;i< len2;i++)
    s2[i] = str[i];
    int len3 = len2;
  //  cout<<"LEN3 "<<len3<<'\n';
    char s3[len3+1];
    int k = 0;
    for(int j = ((len+3)*0.5)-1; j<len;j++)
    {
       s3[k] = str[j];
      // cout<<str[j]<<'\n';
       k++;
    }
    s1[len] = '\0';
    s2[len2] = '\0';
    s3[len3] = '\0';
    if(len == 3)
    {
       if(s1[0] == s1[2])
       {
          cout<<"Yes\n";
          return 0;
       }
       else
       {
          cout<<"No\n";
          return 0;
       }
    }
//   cout<<s1<<"      "<<s2<<"      "<<s3<<'\n';
    if(isPalindrome(s1))
    {
       if(isPalindrome(s2))
       {
          if(isPalindrome(s3))
          {
             cout<<"Yes\n";
             return 0;
          }
       }
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i+1]);
    }
  
  for(i=0;i<VMAX+1;i++)
    {
      C[i+1]=0;
    }

  for(j=0;j<n;j++)
    {
      C[A[j+1]]++;
    }

  for(i=1;i<VMAX+1;i++)
    {
      C[i]=C[i]+C[i-1];
    }

  for(j=1;j<n+1;j++)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }

  for(i=1;i<n+1;i++)
    {
      if(i>1)printf(" ");
      printf("%d",B[i]);
    }
  printf("\n");


  return 0;
}



Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    
    ll n= s.size();
    map<char,bool>mp;
    for(ll i=0; i<26; i++){
        mp[i + 'a'] = false;
    }
    for(ll i=0; i<n; i++){
        mp[s.at(i)] = true;
    }
    for(auto i:mp){
        if(!i.second){
            cout << i.first << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

int main(){
	string S;
	int Q, i;
	cin >> S;
	scanf("%d", &Q);
	deque<char> dq;
	for(i = 0; i < S.size(); i++){
		dq.push_back(S[i]);
	}
	int f = 0;
	for(i = 0; i < Q; i++){
		int T;
		scanf("%d", &T);
		if(T == 1){
			f ^= 1;
		}
		else{
			int F;
			char C;
			scanf("%d %c", &F, &C);
			F--;
			if((F ^ f) == 0){
				dq.push_front(C);
			}
			else{
				dq.push_back(C);
			}
		}
	}
	while(dq.size() > 0){
		if(f == 0){
			printf("%c", dq.front());
			dq.pop_front();
		}
		else{
			printf("%c", dq.back());
			dq.pop_back();
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int n; cin >> n;
  string ans = "No";
  
  for(int i=1; i<10; i++){
    if(n % i == 0){
      if(n / i < 10){
        ans = "Yes";
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,p,q,n,x,taihi;
  int A[100001];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  x = A[n-1];
  p=-1;
  for(i=0;i<n;i++){
    if(A[i]<= x){
      p++;
      taihi=A[p];
      A[p]=A[i];
      A[i]=taihi;
    }
  }

  for(i=0;i<n;i++){
    if(i==p)printf("[");
     printf("%d",A[i]);
    if(i==p)printf("]");
     if(i<n-1)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def calc(A, N):
    s = 0L
    count = 0
    pre_sign = 0
    for i in range(N):
        s += A[i]
        if s == 0:
            if pre_sign == 1:
                s -= 1L
            elif pre_sign == -1:
                s += 1L
            count += 1
        elif pre_sign == s/abs(s):
            if s < 0L:
                ope = 1L - s
            else:
                ope = -1L - s
            s += ope
            count += abs(ope)
        pre_sign = s/abs(s)
    return count


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A_minus = [int(input_raw[i]) for i in range(N)]
    A_plus = [int(input_raw[i]) for i in range(N)]
    firstA = A_minus[0]
    first = 0
    if firstA >= 0:
        first = A_minus[0]  + 1
        A_minus[0] = -1

    count_minus =calc(A_minus, N) + first

    first = 0
    if firstA <= 0:
        first = 1 - A_plus[0]
        A_plus[0] = 1

    count_plus =calc(A_plus, N) + first
    count = min(count_minus, count_plus)


    print count




if __name__ == '__main__':
    main()


Measured memory_bytes: 18488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll GCD(ll x, ll y)
{

    if (x < y)
    {
        const ll a = x;
        x = y;
        y = a;
    }
    ll b = 100000;
    while (b)
    {
        b = x % y;
        x = y;
        y = b;
    }
    return x;
}

ll LCM(ll x, ll y)
{
    ll g = GCD(x, y);
    return x / g * y;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n, 0);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }

    set<ll> v;

    for (ll i = 0; i < n; i++)
    {
        ll cn = 0;
        while (a[i] % 2 == 0)
        {
            a[i] /= 2;
            cn++;
        }
        v.insert(cn);
    }
    bool possible = (v.size() == 1 ? true : false);
    if (!possible)
    {
        cout << 0 << endl;
        return 0;
    }
    ll k = 1;
    for (ll i = 0; i < n; i++)
        k = LCM(k, b[i] / 2);

   

    cout << (m / k + 1) / 2<< endl;
}

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

int md = 1e9 + 7, d[401][401], a[401], b[401], p[401][401];

int main() {
	int n, c;
	scanf("%d%d", &n, &c);
	f(i, 1, n + 1)scanf("%d", a + i);
	f(i, 1, n + 1) {
		scanf("%d", b + i);
		f(j, a[i], b[i] + 1) {
			int t = 1;
			f(k, 0, 401) {
				p[i][k] += t;
				t = (ll)t*j%md;
				if (p[i][k] >= md)p[i][k] -= md;
			}
		}
	}
	d[0][0] = 1;
	f(i, 1, n + 1) {
		d[i][0] = (ll)(b[i] - a[i] + 1)*d[i - 1][0] % md;
		f(j, 1, c + 1)f(k, 0, j + 1) {
			d[i][j] += (ll)d[i - 1][j - k] * p[i][k] % md;
			if (d[i][j] >= md)d[i][j] -= md;
		}
	}
	printf("%d", d[n][c]);
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<math.h>
using namespace std;

int main(){
    
    long X;
    long M=100;
    cin >> X;
    
    for(int year=1; M<=X; year++){
        M*=1.01;
        //cout << year << " " << M << " " << X << endl;
        if(M>=X){
            cout << year << endl;
            break;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 3636
n, a, b =map(int, input().split())
ans=0
if n%(a+b)==0:
    ans=n//(a+b)*a
elif n%(a+b)>0 and n%(a+b)<a:
    ans=n//(a+b)*a + n%(a+b)
else:
    ans=n//(a+b)*a + a
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		int p=n/100;
		n%=100;
		Console.WriteLine("{0}",p*5>=n?1:0);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140