akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	string s;
	cin >> s;
	SORT(s);
	
	cout << (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No") << nl;
	
	return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

bool graph[50][50]={false};
bool reached[50];
ll n,m,ans=0;

void dfs(ll v){
  reached[v]=true;
  rep(i,n){
    if(!(graph[v][i])) continue;
    if(reached[i]) continue;
    dfs(i);
  }
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  cin>>n>>m;
  vector<ll> a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  rep(i,m){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    rep(j,n) reached[j]=false;
    dfs(0);
    bool flag=false;
    rep(j,n) if(!(reached[j])) flag=true;
    if(flag) ans++;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H, W;

    while(1)
    {
        scanf("%d %d", &H, &W);

        if(H == 0 && W == 0)
        {
            return 0;
        }

        int i, j;
        for(i = 0; i < H; ++i)
        {
            for(j = 0; j < W; ++j)
            {
                printf("%c", '#');
            }

            printf("\n");
        }

        printf("\n");
    }
}

Measured memory_bytes: 572
sl = list(input())
tl = list(input())
n = len(sl)
from collections import defaultdict
dic = defaultdict(list)

for idx, s in enumerate(sl):
    dic[s].append(idx)
    dic[s].append(idx + n)

for s in dic:
    dic[s] = sorted(dic[s])

import bisect
ans = 0
now = -1
for t in tl:
    if dic[t] == []:
        print(-1)
        exit()
    idx = bisect.bisect_right(dic[t], now)
    ans += dic[t][idx] - now
    now = dic[t][idx]
    now %= n

print(ans)




Measured memory_bytes: 63272
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n;
  cin>>n;
  cin.ignore();
  string s;
  getline(cin,s);
  int len = s.size();
  if(len<=n){
    cout<<s<<endl;
    return 0;
}
  else{
    string str = s.substr(0,n);
    cout<<str<<"..."<<endl;
  }
 return 0; 
}


Measured memory_bytes: 3632
from fractions import gcd

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

M = max(A)
G = A[0]
for i in range(1, N):
    G = gcd(G, A[i])

if K <= M and K % G == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 88172
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int[][] a = new int[h][w];
        int[] point = new int[90001];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                a[i][j] = sc.nextInt();
                point[a[i][j]] = i * w + j;
            }
        }
        long[] ds = new long[h * w + 1];
        for (int i = 1; i <= h * w; i++) {
            if (i > d) ds[i] = ds[i - d] + abs(point[i] / w - point[i - d] / w) + abs(point[i] % w - point[i - d] % w);
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            out.println(ds[r] - ds[l]);
        }
    }
    static class sc {
        static Scanner s = new Scanner(in);

        static String next() {
            return s.next();
        }

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

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

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

Measured memory_bytes: 71112
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	string a, b;
	cin >> a >> b;

	if(a.length() > b.length()) puts("GREATER");
	else if(a.length() < b.length()) puts("LESS");
	else{
		rep(i, a.length()){
			if(a[i] > b[i]) puts("GREATER");
			else if(a[i] < b[i]) puts("LESS");
			else continue;
			return 0;
		}
		puts("EQUAL");
	}

	return 0;
}


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

MOD = 10 ** 9 + 7

def fact(N, M):
    a = min(N, M)
    b = max(N, M)

    fa = 1
    for i in range(2, a + 1):
        fa = (fa * i) % MOD

    fb = fa
    for i in range(a + 1, b + 1):
        fb = (fb * i) % MOD

    return (fa * fb) % MOD


diff = abs(N - M)
if diff >= 2:
    ans = 0
elif diff == 1:
    ans = fact(N, M)
else:
    ans = (2 * fact(N, M)) % MOD

print(ans)


Measured memory_bytes: 3064
n = int(input())
S = []
# c1:Bで始まってAで終わるもの
# c2:Bで始まるが、A以外で終わるもの
# c3:Bで始まらないが、Aで終わるもの
# c4:Bでも始まらないし、Aでも終わらないもの

ans = 0
c1 = 0
c2 = 0
c3 = 0
for _ in range(n):
  s = input()
  ans += s.count("AB")
  if s.startswith("B") and s.endswith("A"):
    c1 += 1
  elif s.startswith("B"):
    c2 += 1
  elif s.endswith("A"):
    c3 += 1
if c2 + c3 > 0:
  ans += min(c1+c2, c1+c3)
else:
  if c1 != 0:
    ans += c1 - 1
print(ans)




Measured memory_bytes: 74296
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
# include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
//const long long inf = 63;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli ans[303][303], p[303][303];

void solve()
{
	memset(ans,63,sizeof ans);
	memset(p,63,sizeof p);
	lli inf = ans[0][0];
    lli n, m, l;
    cin>>n>>m>>l;
    for(int i = 1; i <= n; i ++)
        ans[i][i] = 0;
    for(int i = 0; i < m; i ++)
    {
        lli a, b, c;
        cin>>a>>b>>c;
        ans[a][b] = min(ans[a][b], c);
        ans[b][a] = min(ans[b][a], c);
    }
    for(int k = 1; k <= n; k ++)
    {
        for(int i = 1; i <= n; i ++)
        {
            for(int j = 1; j <= n; j ++)
            {
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);
            }
        }
    }
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= n;j ++)
        {
            if(ans[i][j] <= l)
                p[i][j] = 0;
        }
    }
    for(int k = 1; k <= n; k ++)
    {
        for(int i = 1; i <= n; i ++)
        {
            for(int j = 1; j <= n; j ++)
            {
                p[i][j] = min(p[i][j], p[i][k] + 1 + p[k][j]);
            }
        }
    }
    lli q;
    cin>>q;
    while(q --)
    {
        lli u, v;
        cin>>u>>v;
        if(p[u][v] == inf)
        {
            cout<<-1<<'\n';
            continue ;
        }
        cout<<p[u][v]<<'\n';
    }
    return ;
}
/*
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 2048
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  
  $d = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  for ($i=0; $i<$n; $i++) {
    for ($j=$i+1; $j<$n; $j++) {
      $ans += $d[$i]*$d[$j];
    }
  }

 echo $ans;

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

/*
ll bfs(vector<ll>& A, vector<ll>& B, ll A_count, ll B_count, ll time, const ll K)
{
    ll total_count = 0, Abook = 0, Bbook = 0;
    if(A.size() > A_count && K >= time + A[A_count])
    {
        Abook = bfs(A, B, A_count+1, B_count, time+A[A_count], K);
    }
    if(B.size() > B_count && K >= time + B[B_count])
    {
        Bbook = bfs(A, B, A_count, B_count+1, time+B[B_count], K);
    }
    total_count = max(Abook, Bbook);
    return max(A_count + B_count, total_count);
}
*/

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<ll> B(M);
    vector<ll> total_A(N+1), total_B(M+1);
    ll AoverK = 0, BoverK = 0;
    total_A[0] = 0;total_B[0] =0;
    for(size_t i=0;i<N; i++)
    {
        cin >> A[i];
        total_A[i+1] = total_A[i] + A[i];
        if(total_A[i+1] <= K) AoverK = i+1;
        //cerr << total_A[i+1] << endl;
    }
    for(size_t i=0;i<M; i++)
    {
        cin >> B[i];
        total_B[i+1] = total_B[i] + B[i];
        if(total_B[i+1] <= K) BoverK = i+1;
        //cerr << total_B[i+1] << endl;
    }
    ll count = 0;
    //cerr << AoverK << ":" << BoverK << endl;
    for(ll i=0;i<=N; i++)
    {
        for(ll j=BoverK;j>=0; j--)
        {
            if(total_A[i] + total_B[j] <= K)
            {
                count=max(count, i+j);
                BoverK=j;
                break;
            }
        }
    }
    //ll count = bfs(A, B, 0, 0, 0, K);
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 9520
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, std::vector<long long> A){
  ll ans=0,x=0;
  auto sum = [&](ll x){
    ll ret=0;
    for (auto &&i : A)
    {
      ret+=(x^i);
    }
    return ret;
  };
  ll bitcount=0;
  while((1LL<<bitcount)<=K){
    ++bitcount;
  }
  vector<ll> cnt(60);
  REP(N){
    For(j,60){
      if((1LL<<j)&A[i]){
        ++cnt[j];
      }
    }
  }
  dump(cnt);
  dump(bitset<64>(K));
  ans=sum(K);
  Rev(i,bitcount){
    dump(i);
    if(((1LL<<i)&K)==0LL){
      continue;
    }
    ll x=(K&(~((1LL<<i)-1LL)))^(1LL<<i);
    For(j,i){
      if(cnt[j]*2<N){
        x|=(1LL<<j);
      }
    }
    dump(bitset<64>(x));
    ans=max(ans,sum(x));
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM
import Data.List

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

build :: [Int] -> Map -> Map
build [] m = m
build (a:as) m = build as $ countUp a 1 m

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  as <- readIntsLine
  let res = sortOn snd . IM.toList $ build as IM.empty
  print . sum . map snd $ take (length res - k) res

Measured memory_bytes: 47484
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

long long dp[60][3000];

int main(){
  int n, a; cin >> n >> a;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    v.push_back(k);
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 50; j >= 0; j--) {
      for (int k = 3000; k >= 0; k--) {
        if (dp[j][k] > 0) {
          dp[j+1][k+v[i]] += dp[j][k];
        }
      }
    }
  }
  long long count = 0;
  for (int i = 1; i <= n; i++) {
    if (dp[i][i*a] > 0) count += dp[i][i*a];
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    int ans = 0;
    rep(i, 0, n - 1) {
        setmax(ans, a[i + 1] - a[i]);
    }
    setmax(ans, a[0] + (k - a[n - 1]));
    cout << k - ans << "\n";
    return 0;
}



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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int l = s[0] - '0';
  for (int i = 0; i < 8; ++i) {
    bitset<3> b(i);
    int total = l;
    for (int j = 0; j < 3; ++j) {
      if (b.test(j)) total += (s[j+1] - '0');
      else total -= (s[j+1] - '0');
    }
    if (total == 7) {
      cout << s[0] << (b.test(0)?'+':'-') << s[1] << (b.test(1)?'+':'-')
           << s[2] << (b.test(2)?'+':'-') << s[3] << "=7" << endl;
      return 0;
    }
  }
}

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

int cmp(const void *a, const void *b) {
  return *(int*)a > *(int*)b;
}

int main(void) {
  int n;
  int max = -1, maxi = -1, half = -1, halfi = -1;
  int *a;
  scanf("%d", &n);
  a = (int*)calloc(n, sizeof(int));
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < n; i++) {
    if (max < a[i]) {
      maxi = i;
      max = a[i];
    }
  }
  half = max;
  for (int i = 0; i < n; i++) {
    if (abs((double)max/2 - half) >= abs((double)max/2 - a[i]) && maxi != i) {
      halfi = i;
      half = a[i];
    }
  }
  printf("%d %d\n", max, half);

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
/*     -- AUTHOR -- 
  ---- cervotrex ---- 
*/
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
// ordered_set <int> s  ;
// auto x=s.find_by_order(k);
// s.order_of_key(val);

template <typename T1,typename T2>
struct sort_sec{
    typedef pair<T1,T2> type;
    bool operator()(type const& a,type const& b)const{
        return a.second > b.second;
    }
};

struct P{
    int x,y;
    bool operator<(const P &p){
        if(x!=p.x)
            return x<p.x;
        else
            return y<p.y;
    }
};

vector<vector<int> > adj;
vector<bool> vis;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
    int t=1;
    // cin>>t;
    while(t--){
      int s,w; cin>>s>>w;
      if(s>w)
        cout<<"safe\n";
    else
        cout<<"unsafe\n";
    }
    return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        int i=0;
        int[] sum=new int[2];
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] tokens = line.split(" ");
                for(int j=0;j<4;j++){
                	sum[i]+=Integer.parseInt(tokens[j]);
                }
                i++;
                if(i==2){
                	break;
                }
            }
            System.out.println(Integer.max(sum[0],sum[1]));
        }
    }

}

Measured memory_bytes: 24164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)

int N;
long long K;
vector<int> A, B;

vector<int> dp;
vector<int> same[200200];
vector<int> nxtA, nxtB;

void print_result(int piv) {
    if (piv == -1) return;
    while (piv < N) {
        if (nxtA[piv] != -1) {
            piv = nxtA[piv];
            continue;
        } else {
            cout << A[piv++] << endl;
        }
    }
}

int main() {

    cin >> N >> K;

    A.resize(N);
    REP(i, N) cin >> A[i];

    // B : Aを2回繰り返した配列
    REP(i, 2 * N) B.emplace_back(A[i % N]);

    // same[i] : 数iが格納されているindexのvector
    REP(i, 2 * N) same[B[i]].emplace_back(i);

    // nxtA[i] : Aの中で, A[i]と同じ数が次に現れるindexの次のindex (無ければ-1)
    nxtA.resize(N);
    REP(i, N) {
        nxtA[i] = (same[A[i]][(int)(upper_bound(same[A[i]].begin(), same[A[i]].end(), i) - same[A[i]].begin())] + 1);
        if (nxtA[i] > N) nxtA[i] = -1;
    }

    // nxtB[i] : Bの中で, B[i]と同じ数が次に現れるindexの次のindex
    nxtB.resize(N);
    REP(i, N) nxtB[i] = (same[B[i]][(int)(upper_bound(same[B[i]].begin(), same[B[i]].end(), i) - same[B[i]].begin())] + 1) % N;

    int cur = 0;
    while (true) {
        if (nxtB[cur] == 0) {
            if (nxtA[cur] == -1) dp.emplace_back(cur);
            dp.emplace_back(-1);
            break;
        }
        if (nxtA[cur] != -1) {
            cur = nxtA[cur];
            continue;
        }
        dp.emplace_back(cur);
        cur = nxtB[cur];
    }

    print_result(dp[(K - 1) % (int)dp.size()]);

}

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

int main() {
  bool cards[4][13];
  for (int i=0; i<4; i++) {
    for (int j=0; j<13; j++) {
      cards[i][j] = false;
    }
  }
  int n;
  cin >> n;
  char design;
  int rank;
  while (n--) {
    cin >> design >> rank;
    int x = rank-1;
    switch (design) {
    case 'S':
      cards[0][x] = true;
      break;
    case 'H':
      cards[1][x] = true;
      break;
    case 'C':
      cards[2][x] = true;
      break;
    case 'D':
      cards[3][x] = true;
      break;
    default:
      break;
    }
  }
  char ans;
  for (int i=0; i<4; i++) {
    for (int j=0; j<13; j++) {
      if (cards[i][j]==false) {
        switch (i) {
        case 0:
          ans = 'S';
          break;
        case 1:
          ans = 'H';
          break;
        case 2:
          ans = 'C';
          break;
        case 3:
          ans = 'D';
          break;
        default:
          break;
        }
        cout << ans << " " << j+1 << endl;
      }
    }
  }
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        b.at(i)=a.at(i);
    }
    sort(b.begin(),b.end());
    int count=0;
    for(int i=0;i<n;i++){
        if(a.at(i)!=b.at(i)) count+=1;
        else count+=0;
    }
    if(count<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		decimal[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),decimal.Parse);
    decimal[,] dp = new decimal[n+1,n+1];//x個投げた時、表がx個となる確率

    dp[0,0] = 1;
    decimal answer = 0;

    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j <= i; j++)
      {
        dp[i,j] += dp[i-1,j]*(1-nums[i-1]);
        if(j != 0) dp[i,j] += dp[i-1,j-1]*nums[i-1];
      }
    }

    for(int i = n/2+1; i <= n; i++)
    {
      answer += dp[n,i];
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 152544
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut input_string = String::new();
    stdin.read_line(&mut input_string);
    let twoN = 2 * input_string.trim().parse::<u8>().unwrap();
    input_string.clear();
    stdin.read_line(&mut input_string);
    let mut skewers = input_string.as_str()
        .split_whitespace()
        .map(|s| s.parse::<u8>().unwrap())
        .collect::<Vec<u8>>();
    skewers.sort();
    let mut i = 0 as usize;
    let mut sum = 0 as u16;
    while (i as u8) < twoN {
        sum += (skewers[i] as u16);
        i += 2;
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352
def p(st):
    l=len(st)
    tc=1
    ac=0
    p=s[0]
    for i in range(1,l):
        if st[i]==p:
            tc+=1
        else:
            ac+=tc//2
            tc=1
            p=st[i]
    else:
        ac+=tc//2
    return ac

s=input()
k=int(input())
n=len(s)
if n==1:
    print(k//2)
    exit()
if n==2:
    if s[0]==s[1]:
        print(k)
    else:
        print(0)
    exit()
ac=p(s)
if k>1:
    ac4=p(s+s+s+s)
    if ac*4==ac4:
        print(ac*k)
    elif ac4-ac*4==3:
        print(ac*k+(k-1))
    elif ac4-ac*4==2:
        print(ac*k+(k//2))
else:
    print(ac)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <iomanip>

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

using namespace std;

int main() {
  int N;
  int a[100001];
  cin >> N;

  int ans = 0;
	rep(i, N) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
	try:
		path = [0]*100
		while True:
			a,b = map(int, raw_input().split())
			if a == 0: break
			path[a-1] += 1; path[b-1] += 1
		if path[0]%2 == path[1]%2 == 1 and sum(filter(lambda x:x%2==1,path[2:])) == 0:
			print "OK"
		else:
			print "NG"
   	except:
   		break

Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 2e2 + 6;//, mod = 1e9 + 7;
struct Edge {
	int u, v, flow = 0, cap;
	Edge(int u, int v, int cap) : u(u), v(v), cap(cap) {
	}
};
int match[maxn];
struct Dinic {// 0 indexed
	int n, m, s, t;
	vector<Edge> edges;
	vector<vi> g;
	vi lst, lvl;
	Dinic(int n, int s, int t) :n(n), s(s), t(t) {
		m = 0;
		g.resize(n);
		lst.resize(n);
		lvl.resize(n);
	}
	void add_edge(int u, int v, int cap) {
		edges.pb(Edge(u, v, cap));
		edges.pb(Edge(v, u, 0));
		g[u].pb(m++);
		g[v].pb(m++);
	}
	bool bfs() {
		queue<int> q;
		fill(all(lvl), -1);
		lvl[s] = 0;
		q.push(s);
		while(!q.empty()) {
			int u = q.front();
			q.pop(); 
			for(auto i : g[u]) {
				if(lvl[edges[i].v]!=-1) continue;
				if(edges[i].cap-edges[i].flow<1) continue;
				lvl[edges[i].v] = lvl[u]+1;
				q.push(edges[i].v);
			}
		}
		return lvl[t] != -1;
	}
	int dfs(int v, int mn) {
		if(mn==0) return 0;
		if(v==t) return mn;
		for(ll &i = lst[v]; i < g[v].size(); i++) {
			int x = g[v][i];
			int u = edges[x].v;
			if(lvl[u] != lvl[v]+1||edges[x].cap-edges[x].flow<1) continue;
			int t = dfs(u, min(mn, edges[x].cap-edges[x].flow));
			if(!t) continue;
			edges[x].flow += t;
			edges[x^1].flow -= t;
			return t;
		}
		return 0;
	}
	int solve() {
		int flow = 0;
		while(true) {
			if(!bfs()) break;
			fill(all(lst), 0);
			while(int f = dfs(s, 1e9)) {
				flow += f;
				fill(all(lst), 0);
			}
		}
        int N = (n-2)/2;
		for(auto i : edges) {
			if(i.flow==1&&i.u>1&&i.v>1) {
				if(i.u>i.v) swap(i.u, i.v);
				//assert();
				//cout << i.u << " " << i.v << "edge\n";
				match[i.u-2] = i.v-2-N;
			}
		}
		return flow;
	}
};
int n, m;
int mat[maxn][maxn];
map<int, int> cnt[maxn];
set<int> h[maxn];
void gay_sort(int x) {
	for(int _ = 0; _ < n; _++)
		for(int i = 1; i < n; i++)
			if(mat[i][x]<mat[i-1][x]) swap(mat[i][x], mat[i-1][x]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int t, i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			cin >> t, t--;
			cnt[i][t/m]++;
			h[i].insert(t);
		}
	}
	for(int i = 0; i < m; i++) {//super retarded algorithm
		//cout << i << "============\n";
		Dinic d(n + n + 2, 0, 1);// n rows + n colours + s + t
		for(int i = 0; i < n; i++) d.add_edge(0, 2+i, 1);
		for(int i = 0; i < n; i++) d.add_edge(2+n+i, 1, 1);
		for(int j = 0; j < n; j++) {
			for(auto x : h[j]) {
				d.add_edge(2+j, 2+n+x/m, 1);
			}
		}
		d.solve();
		for(int j = 0; j < n; j++) {
			for(auto x : h[j]) {
				if(x/m==match[j]) {mat[j][i] = x;break;}
			}
			h[j].erase(mat[j][i]++);
		}
	}
	for(int i = 0; i < n; i++, cout << "\n")
		for(int j = 0; j < m; j++)
			cout << mat[i][j] << " ";
	for(int i = 0; i < m; i++) gay_sort(i);
	for(int i = 0; i < n; i++, cout << "\n")
		for(int j = 0; j < m; j++)
			cout << mat[i][j] << " ";
	
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll a, b, c;
    cin >> a >> b >> c;
    cout << max(0LL, c - (a-b)) << endl;

    return 0;
}


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

int main(){
  int H,W;cin >> H >> W;
  vector<string> S(H);
  for(int r=0;r<H;r++){
    cin >> S[r];
  }
  vector<vector<int>> M(H,vector<int>(W,0));
  if(S[0][0]=='#'){
    M[0][0]=1;
  }
  for(int j=1;j<W;j++){
    if(S[0][j-1]==S[0][j]){
      M[0][j] = M[0][j-1];
    }else{
      M[0][j] = M[0][j-1]+1;
    }
  }
  for(int i=1;i<H;i++){
    if(S[i][0]==S[i-1][0]){
      M[i][0] = M[i-1][0];
    }else{
      M[i][0] = M[i-1][0] + 1;
    }
    for(int j=1;j<W;j++){
      int DN = M[i-1][j];
      int RT = M[i][j-1];
      if(S[i][j]!=S[i-1][j]){
        DN ++;
      }
      if(S[i][j]!=S[i][j-1]){
        RT ++;
      }
      M[i][j] = min(DN,RT);
    }
  }
  int ans = M[H-1][W-1];
  if(S[H-1][W-1]=='#'){
    ans ++;
  }
  cout << ans/2 << endl;
}

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

int main(){
    int N,K; cin >> N >> K;
    long long a[N+1]={};
    for(int i=1;i<=N;i++) cin >> a[i];
    for(int i=0;i<N;i++){
        a[i+1]+=a[i];
    }
    map<long long,int> ma;
    ma[a[0]%K]++;
    long long ans=0;
    for(int i=1;i<=N;i++){
        if(i>=K){
            ma[((a[i-K]-(i-K))%K+K)%K]--;
        }
        ans+=ma[((a[i]-i)%K+K)%K];
        ma[((a[i]-i)%K+K)%K]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#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;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c; cin >> a >> b >> c;
  cout << min(b / a, c) << '\n';
  return 0;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
arr=[]
arrb=list(map(int,input().split()))

for i in range(n):
	arr1=list(map(int,input().split()))
	arr.append(arr1)
ans=0
for i in range(n):
	count=0
	for j in range(m):
		count+=(arr[i][j]*arrb[j])
	count+=c
	if(count>0):
		ans+=1
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		
		String s=stdIn.next();
		
		if(s.equals("a") || s.equals("e") || s.equals("i") ||s.equals("o") || s.equals("u"))
			System.out.println("vowel");
	else
		System.out.println("consonant");

	}
 
}


Measured memory_bytes: 9556
#include <stdio.h> 
int main(void) 
{
  float a, b; 

  scanf("%f %f\n", &a ,&b); 

  if (a == b){ 

    printf("a == b\n"); 

  } 

  else if (a > b) { 

    printf("a > b\n"); 

  } 

  else { 

    printf("a < b\n"); 

  } 
  return 0; 
} 



Measured memory_bytes: 2048
import java.util.Scanner;


public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		while(sc.hasNext()){
			long a, ta, b, tb, gcd, lcm;
			a = ta = sc.nextLong();
			b = tb = sc.nextLong();
			gcd = lcm = 1;
			
			int d = 2;
			
			
			while(true){
				if(ta / d == 0 || tb / d == 0)
					break;
				
				if(ta % d == 0 && tb % d == 0){
					gcd *= d;
					ta /= d;
					tb /= d;
				}else{
					d++;
				}
			}
			
			lcm = a * b / gcd;
			
			System.out.printf("%d %d\n", gcd, lcm);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  string ans;
  while (n > 0) {
    int m = n % 26;
    if (m == 0) {
      ans.push_back('z');
      n--;
    } else {
      ans.push_back('a' + m - 1);
    }
    n /= 26;
  }
  for (int i = (int)ans.size() - 1; ~i; i--) {
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
vector<ll> L(100001),R(100001),A(200001);
ll ans = 0;

ll bubbleSort(vector<ll> A){
    ll cnt = 0;
    for(int i = 0; i < A.size()-1;i++){
        for(int j = A.size()-1; j > i;j--){
            if(A[j] < A[j-1]){
                swap(A[j],A[j-1]);
                cnt++;
            }
        }
    }
    return cnt;
}

void merge(ll l, ll mid, ll r){
    ll n1 = mid - l;
    ll n2 = r - mid;
    for(int i = 0; i < n1;i++){
        L[i] = A[l+i];
    }
    for(int i = 0; i < n2;i++){
        R[i] = A[mid+i];
    }
    L[n1]=MOD;R[n2]=MOD;
    int cntl=0,cntr=0;
    for(int i = l; i < r;i++){
        if(L[cntl] > R[cntr]){
            A[i] = R[cntr];
            cntr++;
            // cout << L[cntl] << " : r : " << R[cntr-1] << " **  " << n1-cntl << endl;
            // cout << n1 << " : " <<  cntl << " : "<< n1-cntl << endl;
            ans += n1-cntl;
        }else{
            A[i] = L[cntl];
            cntl++;
        }
    }
}

void mergeSort(ll l, ll r){
    if(l+1 <  r){
        ll mid = (l+r)/2;
        mergeSort(l,mid);
        mergeSort(mid,r);
        merge(l,mid,r);
    }
    
}

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

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

    // ll cnt = bubbleSort(a);
    // cout << cnt << endl;
    mergeSort(0,n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5824
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <valarray>
#include <iomanip>
using namespace std;
vector<int> Data;

int Get_Gcd(int a,int b)
{
	if (b>a)
	{
		int tmp = a;
		a = b;
		b = tmp;
	}

	int Result = a % b;

	if (Result==0)
	{
		return b;
	}

	return Get_Gcd(b, Result);
}

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

	long int Sum=0;

	for (int a = 1; a <= Max; a++)
	{
		for (int b = 1; b <= Max; b++)
		{
			for (int c = 1; c <= Max; c++)
			{
				Sum += Get_Gcd(Get_Gcd(a, b),c);
			}
		}
	}

	cout << Sum << endl;

	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;

int main() {

    int N;

    vector<int> n_vec;

    int cnt = 0;

    cin >> N ;

    for (int i = 1; i <= N; i++){

        if(i % 2 == 1){
            n_vec.push_back(i);
        }
    }

    
    for (int i = 0; i < n_vec.size(); i++){
        int t = n_vec.at(i);
        int tmp = 0;
        for (int j = 1; j <= N; j++){
            if (t % j == 0){
                tmp++;
            }
        }
        if (tmp == 8){
            cnt++;
        }

    }

    cout << cnt << endl;




}

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

//{{{
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int N = 5e3 + 10;

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;

int n, k;

LL p[N], c[N];
LL sum[N], cnt[N];
bool vis[N];

LL func(int pos)
{
    LL t = k;
    LL ret = 0;

    if (t > 5 * cnt[pos])
    {
        if (sum[pos] > 0)
        {
            LL d = t / cnt[pos];
            assert(d >= 5);
            d -= 5;
            ret += d * sum[pos];
            t -= cnt[pos] * d;
        }
        else
            t = cnt[pos];
    }

    // if (sum[pos] > 0)
    //{
    // ret += t / cnt[pos] * sum[pos];
    // t = t % cnt[pos];
    //}
    // else
    //{
    // t = t % cnt[pos];
    // if (t == 0) t = cnt[pos];
    //}

    // if (t == 0) return ret;

    int cur = pos;
    LL val = c[p[cur]];
    cur = p[cur];

    LL v = val;
    for (int i = 2; i <= t; i++)
    {
        int nxt = p[cur];
        v += c[nxt];
        val = max(val, v);
        cur = nxt;
    }
    ret += val;

    return ret;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n >> k)
    {
        for (int i = 1; i <= n; ++i) cin >> p[i];
        for (int i = 1; i <= n; ++i) cin >> c[i];

        clr(vis, false);
        for (int i = 1; i <= n; i++)
        {
            if (vis[i] == true) continue;

            set<int> st;
            LL cur = i;
            LL v = c[p[cur]];
            st.insert(p[cur]);

            cur = p[cur];

            for (int a = 2; a <= 2 * n; a++)
            {
                int nxt = p[cur];
                if (st.find(nxt) != st.end())
                {
                    break;
                }
                assert(a < n + 1);
                v += c[nxt];
                st.insert(nxt);
                cur = nxt;
            }

            for (auto idx : st)
            {
                vis[idx] = true;
                cnt[idx] = st.size();
                sum[idx] = v;
            }
        }

        LL ans = func(1);
        for (int i = 2; i <= n; i++)
        {
            LL v = func(i);
            ans = max(ans, v);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int P[8], Q[8];
  for(int i=0;i<N;i++) cin >> P[i];
  for(int i=0;i<N;i++) cin >> Q[i];
  bool aLi[8]{false};
  bool bLi[8]{false};
  int a=1;
  for(int i=0;i<N;i++)
  {
    int c=0;
    for(int j=1;j<P[i];j++)
    {
      if(aLi[j-1]==false) c++;
    }
    //cout << c << endl;
    int Bi=1;
    for(int j=1;j<N-i;j++) Bi=Bi*j;
    a+=c*Bi;
    aLi[P[i]-1]=true;
  }
  
  int b=1;
  for(int i=0;i<N;i++)
  {
    int c=0;
    for(int j=1;j<Q[i];j++)
    {
      if(bLi[j-1]==false) c++;
    }
    int Bi=1;
    for(int j=1;j<N-i;j++) Bi=Bi*j;
    b+=c*Bi;
    bLi[Q[i]-1]=true;
  }
  
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int ans=-50;
	{
		int tmp=5000;
		for(int i=0;i<3;i++){
			int x;
			cin>>x;
			tmp=min(tmp,x);
		}
		ans+=tmp;
	}
	{
		int tmp=5000;
		for(int i=0;i<2;i++){
			int x;
			cin>>x;
			tmp=min(tmp,x);
		}
		ans+=tmp;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void) {
	int a,b,c,d;

	d=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	for(int i=a;i<=b;i++){
		
		if(c%i==0) 
			d++;
		
		

	}
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double 
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
string convertnum(int num){
    string s;
    for (int i = 0; i < 3;i++){
        s[i] = num % 10 + '0';
        num /= 10;
    }
    return s;
}
signed main()
{
    int n,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    for (int p = 0; p < 1000;p++){
        string pin = convertnum(p);
        int pinpointer = 0;
        for (int i = 0; i < n;i++){
            if(s[i]==pin[pinpointer])
                pinpointer++;
        }
        if(pinpointer==3)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			long ans = 0;
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = i + 1;
				if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
					ans += a[i];
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 36696