akhauriyash/Code-Regression huggingface dataset:
//Problem C
#include<bits/stdc++.h>
using namespace std;

int n,m,x[100005],y[100005],a[100005],ppp[6];
struct city{int year,per,num;}p[100005];
bool operator<(city a,city b){return a.year<b.year;}
void op(int a){
    for(int i=0;i<6;i++)ppp[i]=a%10,a/=10;
    for(int i=5;~i;i--)putchar(ppp[i]+48);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        p[i]=(city){b,a,i};
    }
    sort(p+1,p+m+1);
    for(int i=1;i<=m;i++){
        int per=p[i].per,num=p[i].num;
        x[num]=per,y[num]=++a[per];
    }
    for(int i=1;i<=m;i++)op(x[i]),op(y[i]),putchar('\n');
    return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int step,a[200],n,i,j;

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

int main(){
	while(scanf("%d",&n)*n){
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		step=0;

		for(i=0;i<n-1;i++){
			for(j=0;j<n-i-1;j++){
				if(a[j]>a[j+1]){
					swap(&a[j],&a[j+1]);
					step++;
				}
			}
		}
		printf("%d\n",step);
	}
	return 0;
}

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

string solve() {
  int N;
  cin >> N;
  vector<int> S(pow(2,N));
  for(auto& i: S) cin >> i;

  multiset<int> s;
  for(auto i: S) s.emplace(-i);
  vector<int> q;
  q.emplace_back(*begin(s));
  s.erase(begin(s));
  for(auto sec=1; sec<=N; ++sec) {
    auto pre = q;
    for(auto x: pre) {
      auto i = s.upper_bound(x);
      if(i == end(s)) return "No";
      q.emplace_back(*i);
      s.erase(i);
    }
  }
  return "Yes";
}

int main() {
  cout << solve() << endl;
}


Measured memory_bytes: 18676
#include<stdio.h>
#include<stdlib.h>
int sum=0;
void merge(int *,int,int,int);
void sort(int *,int,int);

int main(){
  int n,i,*S;
  scanf("%d",&n);
  S=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  sort(S,0,n);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",S[i]);
    else printf("%d ",S[i]);
  }
  printf("%d\n",sum);
  free(S);
  return 0;
}

void sort(int *a,int L,int R){
  int mid;
  if(L+1<R){
    mid =(L+R)/2;
    sort(a,L,mid);
    sort(a,mid,R);
    merge(a,L,mid,R);
  }
}

void merge(int *a,int L,int mid,int R){
  int n1=mid-L,n2=R-mid,i,j,k;
  int l[n1],r[n2];
  for(i=0;i<n1;i++){
    l[i]=a[L+i];
  }
  for(i=0;i<n2;i++){
    r[i]=a[mid+i];
  }
  l[n1]=1000000001;
  r[n2]=1000000001;
  i=0;
  j=0;
  for(k=L;k<R;k++){
    if(l[i]>r[j]){
      a[k]=r[j];
      j++;
    }else{
      a[k]=l[i];
      i++;
    }
    sum++;
  }
}



Measured memory_bytes: 5416
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
for i in range(n):
    a[i+1] += a[i]

for i in range(n+1):
    a[i] %= m

import collections
a = collections.Counter(a)
a = a.most_common()
ans = 0
for i in range(len(a)):
    ans += a[i][1] * (a[i][1] - 1) // 2

print(ans)


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

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

    vector<ll> A,B;
    ll asum,bsum;
    asum = bsum = 0;
    ll ans = 0;
    vector<ll> suf;
    ll res = 0;

    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
        asum+=a;
    }
    rep(i,N) {
        int b;
        cin >> b;
        B.push_back(b);
        bsum+=b;
    }

    rep(i,N) {
        ll a = A[i];
        ll b = B[i];

        if (a>b) suf.push_back(a-b);
        else if (a<b) {
            res += b-a;
            ans++;
        }
    }
    sort(suf.begin(),suf.end());
    reverse(suf.begin(),suf.end());

    for (int i=1; i<suf.size(); i++) {
        suf[i] = suf[i-1]+suf[i];
    }


    if (asum<bsum) cout << -1 << endl;
    else if (res==0) cout << 0 << endl;
    else {
        int idx = 0;

        rep(i,suf.size()) {
            if (suf[i]>=res) {
                idx = i;
                break;
            }
        }
        ans += idx + 1;
        cout << ans << endl;
    }
}

Measured memory_bytes: 5796
import itertools
N = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

arr = []
for i in range(1,N+1,1):
    arr.append(i)

dict = (list(itertools.permutations(arr)))
print(abs(dict.index(a)-dict.index(b)))

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

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    int n, k;

    cin >> n >> k;

    int h[n];

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

    int dp[n + 1];
    dp[0] = 0;
    dp[1] = 0;

    dp[2] = abs(h[1] - h[0]);

    for(int i = 3; i <= n; i++) {
        int mn = INT_MAX;
        for(int j = max(1, i - k); j < i; j++) {
            mn = min(mn, dp[j] + abs(h[i - 1] - h[j - 1]));
        }
        dp[i] = mn;
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
double r;
int main()
{
    cin >> r;
    cout << double(r*2*pi);
    return 0;
}


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


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

    ll ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i + 1; j < n-1; j++) {
            for (int k = j + 1; k < n; k++) {
                if ((l.at(i) != l.at(j)) && (l.at(i) != l.at(k)) && (l.at(j) != l.at(k))) {
                    vector<ll> a(3);
                    a.at(0) = l.at(i);
                    a.at(1) = l.at(j);
                    a.at(2) = l.at(k);
                    sort(a.begin(), a.end());
                    if (a.at(2) < a.at(0) + a.at(1)) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
public class Main {

  private static void solve() {
    int n = ni();
    System.out.println(n / 3);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int N, S, A[1 << 18], B[1 << 18], C[1 << 18];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) cin >> B[i];
	for (int i = 1; i <= N - 1; i++) cin >> C[i];

	for (int i = 1; i <= N; i++) {
		S += B[A[i]];
		if (i >= 2 && A[i] - A[i - 1] == 1) S += C[A[i - 1]];
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x,int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x,int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int main() {
  int deg[100005];
  vector<int> to[100005];
  
  int n,m,k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    int ans = uf.size(i)-1-deg[i];
    for (int u : to[i]) {
      if (uf.same(i,u)) ans--;
    }
    if (i == n-1) {
      cout << ans << endl;
    }else{
      cout << ans << ' ';
    }
  }
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(all(p));
    reverse(all(p));
    int ans=0;
    rep(i,n) ans+=p[i];
    cout << ans-p[0]/2 << endl;
return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

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

    string res = "NO";
    rep(i,B+1){
        if (A*i % B == C) res = "YES";
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
// finish date: 2018/07/18
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int H, W;
    cin >> H >> W;
    vs A(H);
    rep(i, H) {
        cin >> A[i];
    }
    map<char, int> mp;
    rep(i, H) {
        rep(j, W) {
            mp[A[i][j]]++;
        }
    }

    int need4 = (H / 2) * (W / 2);
    int need2 = (H % 2) * (W / 2) + (H / 2) * (W % 2);
    int need1 = (H % 2) * (W % 2);

    for (auto element:mp) {
        char c;
        int e;
        tie(c, e) = element;
        need4 -= e / 4;
        e = e % 4;
        if (need4 < 0) {
            e += 4 * (-need4);
            need4 = 0;
        }
        need2 -= e / 2;
        e = e % 2;
        if (need2 < 0) {
            e += 2 * (-need2);
            need2 = 0;
        }
        need1 -= e;
        if (need1 < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [None]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
    

Measured memory_bytes: 13980
using System;
using System.Linq;

namespace B___Algae
{
    class Program
    {
        static void Main(string[] args)
        {
            var rDx2000 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int r = rDx2000[0], D = rDx2000[1], x2000 = rDx2000[2];
            var res = x2000;

            for (int i = 0; i < 10; i++)
            {
                res = r * res - D;
                Console.WriteLine(res);
            }

        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int read();
int M(int x) { return x >= mod ? x - mod : x; }
int fsp(int bs, int p) {
  int rt = 1;
  while (p) {
    if (p & 1) rt = 1ll * rt * bs % mod;
    bs = 1ll * bs * bs % mod, p >>= 1;
  }
  return rt;
}

int n, k;
int fac[4000006], caf[4000006];
void init() {
  int lim = 4000000;
  fac[0] = 1;
  for (int i = 1; i <= lim; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
  caf[lim] = fsp(fac[lim], mod - 2);
  for (int i = lim; i >= 1; --i) caf[i - 1] = 1ll * caf[i] * i % mod;
}
int C(int x, int y) { return 1ll * fac[x] * caf[y] % mod * caf[x - y] % mod; }
int f[2003][2003];

int main() {
  n = read(), k = read(), init();
  if (k == 1) return puts("1"), 0;
  for (int i = 1; i <= n; ++i) f[i][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= i; ++j)
      f[i][j] = M(f[i - 1][j] +
                  1ll * f[i][j - 1] * (n - j + 1) % mod *
                      C(n - i + (n - j + 1) * (k - 1) - 1, k - 2) % mod);
  printf("%d\n", f[n][n]);
  return 0;
}

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


Measured memory_bytes: 46336
N = int(raw_input())
A = map(int, raw_input().split())
d = []
for i in range(N):
  d.append(A[i]-(i+1))
if N%2==0:
  B = sorted(d)[N//2-1:N//2+1]
else:
  B = [sorted(d)[N//2]]
r = []
for b in B:
  s = 0
  for i in range(N):
    s += abs(A[i]-(b+i+1))
  r.append(s)
print min(r)

Measured memory_bytes: 23792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
    
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(b-a>=2*k){
        rep(i,k) cout<<a+i<<endl;
        rep(i,k) cout<<b-k+1+i<<endl;
    }
    else{
        rep(i,b-a+1) cout<<a+i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int N, M, K;
    cin >> N >> M >> K;
    REP(a, 0, N + 1) {
        REP(b, 0, M + 1) {
            if (M * a + N * b - 2 * a * b == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))
def fde(): print("-flag-")

def main():
    N=ii()
    A=list(mi())
    
    dp = [[0]*2 for _ in range(10**5+10)]
    dp[0][0] = A[0]+A[1]
    dp[0][1] = -dp[0][0]

    for i in range(1,N-1):
        dp[i][0]=max(dp[i-1][0]+A[i+1],dp[i-1][1]+A[i+1])
        dp[i][1]=max(dp[i-1][0]-2*A[i]-A[i+1],dp[i-1][1]+2*A[i]-A[i+1])
    
    print(max(dp[N-2]))



if __name__ == "__main__":
    main()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    string res = "";
    while(N>0){
        N--;
        res += char('a'+N%26);
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int ans = 0;
    while(true){
        if (*max_element(h.begin(), h.end()) == 0) break;

        int i = 0;
        while(i < n){
            if (h[i] == 0) ++i;
            else{
                ++ans;
                while(i < n && h[i] > 0){
                    --h[i];
                    ++i;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K in A:
    print('POSSIBLE')
    exit()
if max(A) < K:
    print('IMPOSSIBLE')
    exit()

from fractions import gcd
g = A[0]
for a in A[1:]:
    g = gcd(g,a)
print('POSSIBLE' if K%g==0 else 'IMPOSSIBLE')

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

int main(){
 long long N;
  cin >> N;
  
 
  long long sum=0;
  
  for(int i=1;i<=N;i++){
 
    if(i%3==0 || i%5==0){
     continue;
      
    }
    else{
     sum+=i; 
    }
    
  }
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll solve_ps(ll l, ll r, int bit)
{
	if(l>=r) return (1LL<<(bit+1));
	ll L = 1;
	if(l==0) L=0;
	else
	{
		while(l>L) L=2*L+1;
	}
	ll R = r;
	if(L>=R) return (1LL<<(bit+1));
	else return (1LL<<(bit+1))-(R-L-1);
}

ll solve(ll l, ll r, int bit)
{
	if(bit<0) return 1;
	if((l&(1LL<<bit))==(r&(1LL<<bit))) return solve(l,r,bit-1);
	l&=(1LL<<(bit+1))-1;
	r&=(1LL<<(bit+1))-1;
	return solve_ps(r^(1LL<<bit),l,bit-1)+(1LL<<bit)-l;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll l,r; cin>>l>>r;
	cout<<solve(l,r,61)<<'\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N=sc.nextInt();
      if(N%2==0){
         System.out.print(N/2);
      }else{
         System.out.print(N/2+1);
      }
   }
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

/////////////////////////////////////////////////////////

void Main() {
  int N; cin >> N;
  if(N % 2 == 0){
    cout << N * (N - 2) / 2 << endl;
    rep(i, 1, N + 1){
      rep(j, i + 1, N + 1){
        if(i + j == N + 1) continue;
        cout << i << " " << j << endl;
      }
    }
  }else{
    cout << (N - 1) * (N - 1) / 2 << endl;
    rep(i, 1, N + 1){
      rep(j, i + 1, N + 1){
        if(i + j == N) continue;
        cout << i << " " << j << endl;
      }
    }
  }

}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

int main()
{
	int i = 0, y = 0;
	cin >> i >> y;
	while (i != 0 || y != 0)
	{
		if (i > y)
			cout << y<<" "<< i << endl;
		else
			cout << i<<" "<< y << endl;
		cin >> i >> y;
	
	}
	
	return 0;
}



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

using namespace std;

int main(){
    long long int N,A=0,B=0,asum=0,bsum=0;
    cin >> N;
    vector<long long int> a(N),b(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        asum += a[i];
    }

    for(int i=0;i<N;i++){
        cin >> b[i];
        bsum += b[i];
    }

    for(int i=0;i<N;i++){
        if(a[i]<b[i]){
            if((b[i]-a[i])%2==1){
                A += (b[i]-a[i]+1)/2;
            }else{
                A += (b[i]-a[i])/2;
            }
        }else if(b[i]<a[i]){
            B += a[i]-b[i];
        }
    }

    if(A<=(bsum-asum) && B<=(bsum-asum)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N, K;
	cin >> N >> K;

	double ans = 0.0;

	int l = 0;
	for (int i = 1; i <= N; i++) {
		if (i < K) {
			l = 0;
			while (i * pow(2, l) < K) {
				l += 1;
			}
			ans += pow(0.50, (double)l);
		}
		else {
			ans += 1.0;
		}
	}

	ans = ans / (double)N;

	cout << fixed;
	cout << setprecision(12) << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n;cin>>n;
  vector<ll> A(n);
  rep(i,n){
    cin>>A[i];
  }

  sort(all(A));

  vector<bool> ex(1e6+1, false);

  rep(i,n){
    if(i > 0 && A[i-1] == A[i]) continue;
    ll num = A[i] * 2;
    while(num <= 1e6){
      ex[num] = true;
      num += A[i];
    }
  }

  ll count = 0;
  rep(i,n){
    if(ex[A[i]]){
      count++;
      continue;
    }

    if(i > 0 && A[i-1] == A[i]){
      count++;
      continue;
    }

    if(i + 1 < n && A[i] == A[i+1]){
      count++;
      continue;
    }
  }
  cout<<n-count<<endl;
  return 0;
}

Measured memory_bytes: 5116
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	int n;
	string s="";
	cin>>n;
	while(n!=0){
		if(n%2==0){
			s = "0" + s;
			n =  n / (-2);
		//	printf("0");
		}
		else{
		//	printf("1");
			s = "1" + s;
			n = (n - 1)/(-2);
		}
	}
	if(s=="")printf("0\n");
	else cout<<s<<endl;
}


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

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2019
#endif

template <typename T=int>
struct Fenwick {
    int n;
    vector<T> v;
    
    Fenwick(int size = 100005) : n(size), v(n+1, 0) {}
    inline void add(int p, T val) {
        for (; p <= n; p += (p&-p)) { v[p] += val; }
    }
    inline T query(int p) {
        T tmp = 0;
        for (; p > 0; p -= (p&-p)) { tmp += v[p]; }
        return tmp;
    }
    inline T query(int l, int r) {
        return query(r) - query(l-1);
    }
};

void solve() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    const int N = (n)*(n-1)/2;

    double res[2];
    Fenwick<int> st(n);
    for (int _ = 0; _ < 2; _++) {
        //a.emplace_back(0);
        //b.emplace_back(1);
        //c.emplace_back(0);
        vector<int> id(n);
        iota(id.begin(), id.end(), 0);
        sort(id.begin(), id.end(), [&](auto& u, auto& v){
            return (double)a[u]/b[u] > (double)a[v]/b[v];
        });
        dbg(id);
        vector<pair<int, double>> Ys(n);
        auto f = [&](double x){
            int cnt = 0;
            fill(st.v.begin(), st.v.end(), 0);
            for (int i = 0; i < n; i++) {
                int k = id[i];
                double y = (c[k] - a[k]*x)/b[k];
                Ys[i] = {i, y};
            }
            sort(Ys.begin(), Ys.end(), [&](auto& u, auto& v){
                return u.second < v.second || (u.second==v.second && u.first < v.first);
            });
            dbg(x,Ys);
            for (auto& p: Ys) {
                int i = p.first + 1;
                cnt += st.query(i);
                st.add(i, 1);
            }
            dbg(cnt);
            return cnt;
        };
        double l = -1e18, r = 1e18;
        for (int _ = 0; _ < 300; _++) {
            double mid = (l+r)/2;
            if (f(mid) < (N+1)/2) l = mid;
            else r = mid;
        }
        res[_] = l;
        //a.pop_back();
        //b.pop_back();
        //c.pop_back();
        swap(a, b);
    }
    cout << fixed << setprecision(10);
    cout << res[0] << ' ' << res[1] << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1772
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int h = 0;
	if (a[0] == b[0]) {
		h++;
	}
	if (a[1] == b[1]) {
		h++;
	}
	if (a[2] == b[2]) {
		h++;
	}
	cout << h;
}

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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    int i,n;
    cin>>n;
    set<int> sheet;
    For(i,0,n){
        int a;
        cin>>a;
        if(sheet.count(a)){
            sheet.erase(a);
        }
        else sheet.insert(a);
    }
    cout<<sheet.size();
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 

template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(){
    ll n,q;cin >> n >>q;
    SegTree<ll> st(n,(1LL<<31)-1,[](ll a,ll b){return min(a,b);},[](ll a,ll b){return b;});
    while(q--){
        ll t;cin >> t;
        if(t){
            ll a,b;cin >> a >> b;b++;
            cout << st.query(a,b) <<endl;
        }
        else{
            ll a,b;cin >> a >> b;
            st.change(a,b);
        }
    }
}


Measured memory_bytes: 4888
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll m=min(a,min(b,min(c,min(d,e))));
    cout<<(n+m-1)/m+4<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: u32 = sc.read();
    let b: u32 = sc.read();
    let c: u32 = sc.read();
    let mut cnt = 0;
    for i in a..b+1 {
        if c % i == 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 5032
#include<stdio.h>
int r[101][101][2],h,w,i,j;
int main()
{
	for(i=0;i<=100;i++)
		for(j=0;j<=100;j++)
		{
			r[i][j][0]=r[i][j][1]=(i==1||j==1?1:0);
			if(i>1&&j>1)
			{
				r[i][j][0]=(r[i-2][j][1]+r[i][j-2][0]+r[i-2][j-1][1])%100000;
				r[i][j][1]=(r[i-2][j][1]+r[i][j-2][0]+r[i-1][j-2][0])%100000;
			}
		}
	for(;scanf("%d%d",&w,&h),w;)
		printf("%d\n",(r[h-1][w][1]+r[h][w-1][0])%100000);
	return 0;
}

Measured memory_bytes: 676
import copy
from itertools import combinations
h, w, k = map(int, input().split())
c =[input() for i in range(h)]
ans = 0
y = []
for i in range(h):
    y.append(i)
x = []
for i in range(w):
    x.append(i)
for i in range(h+1):
    ty = list(combinations(y, i))
    for j in range(w+1):
        tx = list(combinations(x, j))
        for l in ty:
            for m in tx:
                cnt = 0
                for p in l:
                    for q in m:
                        if c[p][q] == '#':
                            cnt += 1
                if cnt == k:
                    ans += 1
print(ans)

Measured memory_bytes: 9152
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

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

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
  	cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 6976
import sys
stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

#水を100ずつ区切って考える
A, B, C, D, E, F = rl()
water = [False for x in range(F//100 + 1)]
answer = (-1, 0, 0)
for i in range(F//(100*B) + 1):
    for j in range(F//(100*A) + 1):
        k = i * B + j * A
        if k > len(water) - 1:
            continue
        water[k] = True
for i in range(len(water)):
    if water[i] == True:
        water[i] = i
for x in water:
    if not x or x == 0:
        continue
    max = x * E
    for i in range(max//D+1):
        for j in range(max//C+1):
            y = D * i + C * j
            solution = x*100 + y
            if solution > F:
                break
            if y > max:
                break
            elif solution > 0:
                result = y / solution
                if result > answer[0]:
                    answer = (result, solution, y)

print(answer[1], answer[2])


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

int main() {
  int N;
  cin >> N;
  vector<int> cards(N);
  for(int i = 0; i < N; i++) {
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  int answer = 0 ;
  for(int i = 0; i < N; i++) {
    if( i % 2 == 0 ){
      answer += cards.at(i);
    }
    else{
      answer -= cards.at(i);
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
function Main(input) {
  const args = input.split(" ").map((x) => parseInt(x));
  let a = args[0];
  let b = args[1];
  let c = args[2];
  console.log(a < b && b < c ? "Yes" : "No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15120
n = int(input())
a = sorted([int(i) for i in input().split()])
mod = 10**9+7
if n%2==0:
    able = []
    for i in range(1,n,2):
        able.append(i)
        able.append(i)
else:
    able = [0]
    for i in range(2,n,2):
        able.append(i)
        able.append(i)

if a == able:
    r = n//2
    ans = 1
    for i in range(0,r):
        ans = ans * 2 % mod
    print(int(ans))
else:
    print(0)


Measured memory_bytes: 13880
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll k, a, b;
  ll ans = 0;

  cin >> k >> a >> b;
  k++;

  if (a+2 < b && a <= k){
    ans += a;
    k -= a;

    ans += (b-a) * (k/2);
    ans += k%2;
  } else {
    ans += k;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				ans+=gcd(i,gcd(j,k));
			}
		}
	}
	cout<<ans<<endl;
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL maxn = 3500;
LL n;
int main() {
	scanf("%lld", &n);
	for(LL i = 1LL; i <= maxn; i++) {
		for(LL j = 1LL; j <= maxn; j++) {
			LL a, b, c;
			a = i, b = j;
			LL tmp = 4LL * a * b - a * n - b * n;
			LL tmp_1 = n * a * b;
			if(tmp && tmp_1 % tmp == 0) {
				c = tmp_1 / tmp;
				if(c <= 0)continue;
				printf("%lld %lld %lld\n", a, b, c);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import bisect

a, b, q = list(map(int, input().split()))

s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

x = [int(input()) for _ in range(q)]

s.sort()
t.sort()

i = 0


for i in range(len(x)):

    r_shrine = bisect.bisect_right(s, x[i])
    r_temple = bisect.bisect_right(t, x[i])

    l_shrine = r_shrine-1
    l_temple = r_temple-1

    # print(l_shrine, r_shrine)
    # print(l_temple, r_temple)

    ans = []
    if l_shrine >= 0 and l_temple >= 0:
        ans.append(max(x[i]-s[l_shrine], x[i]-t[l_temple]))  # <<
    if r_shrine < a and r_temple < b:
        ans.append(max(s[r_shrine]-x[i], t[r_temple]-x[i]))  # >>
    if l_shrine >= 0 and r_temple < b:
        min_ = min(x[i]-s[l_shrine], t[r_temple]-x[i])
        ans.append(min_+(t[r_temple]-s[l_shrine]))  # <>
    if r_shrine < a and l_temple >= 0:
        min_ = min(x[i]-t[l_temple], s[r_shrine]-x[i])
        ans.append(min_+(s[r_shrine]-t[l_temple]))  # <>

    print(min(ans))


Measured memory_bytes: 16168