akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg = str(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) if (flg[i] ^ '0')
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] ^ '0') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

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

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    auto legendre = [&](ll n, ll p) -> ll {
        ll res = 0;
        for (ll i = p; i <= n; i *= p)
            res += n / i;

        return res;
    };

    ll ans = 1;
    for (ll p : sieve(n))
        (ans *= legendre(n, p) + 1) %= MOD;

    std::cout << ans << '\n';
}


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

#define int long long

signed main() {
    int n;
    while(cin>>n, n!=0) {
        int memo[4000] = {0};
        bool F[4000] = {false};
        bool f = true;
        for(int i=0; i<n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            memo[a] += (b*c);
            if(memo[a]>=1000000 && !F[a]) {
                f = false;
                F[a] = true;
                cout << a << endl;
            }
        }
        if(f) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1000010
int  arr[1000];
int brr[101][101]={0};
int main()
{
	int n ;
	cin >>n;
	int sum=0;int pp = 0;
	if(n%2){
        pp = n-1;
	}
	else pp = n;

    for(int i=1;i<=n;i++){
        for(int j =1;j<=n;j++){
                if(j!=pp&&(brr[i][j]==0&&brr[j][i]==0)&&i!=j)
                    brr[i][j]=1,sum++;
        }
        pp--;
    }
    cout<<sum<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(brr[i][j])
                cout<<i<<" "<<j<<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>
using namespace std;
#define MOD (long long int)(1e9+7)
#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 INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#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()

const int N = (int)3e5;

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;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


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

  ll ans = LINF;
  reps(p, sqrt(n + 0.01)){
    if(n%p == 0){
      chmin(ans, p-1 + n/p-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    int N=in();
    vector<ll> A;
    ll count_odd;count_odd=0;
    ll temp;
    string ans;
    REP(i,N){
        cin>>temp;
        if(temp%2>0)count_odd++;
    }
    if(count_odd%2>0){
        if(N>1){
            ans="NO";
        }else{
            ans="YES";
        }
    }else{
        ans="YES";
    }
    print(ans);
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

#define N 200010
#define MOD 1000000007


int f[1000010];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n, x, y;
    cin >> n >> x >> y;

    x -= 1, y -= 1;
    int f[n] = {};

    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            int dis = min(j - i, abs(i - x) + 1 + abs(y - j));
            // cout << i << " " << j << " " << dis << "\n";
            f[dis]++;
        }
    }

    for (int i = 0; i < n - 1; ++i)
    {
        cout << f[i + 1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long K = scanner.nextInt();
    long A = scanner.nextInt();
    long B = scanner.nextInt();

    if (A >= B - 1 || K < A) {
      System.out.println(K + 1);
      return;
    }
    K -= A - 1;
    System.out.println(A + K / 2 * (B - A) + (K % 2));
  }
}


Measured memory_bytes: 23252
N = int(input())
A = [int(i) for i in input().split()]

dic = {}
for a in A:
    dic[a] = dic.get(a,0)+1
    
ans = 0
for k in dic:
    if dic[k]>k:
        ans += dic[k]-k
    elif dic[k]<k:
        ans += dic[k]
print(ans)


Measured memory_bytes: 17780
#include<stdio.h>
int main()
{
    double a,b,k;
    scanf("%lf %lf %lf",&a,&b,&k);
    if(a>k){
        a=a-k;
        k=0;
    }else{
        k=k-a;
        a=0;
    }
    if(b>k){
        b=b-k;
        k=0;
    }else{
        k=k-b;
        b=0;
    }
    printf("%.0f %.0f\n",a,b);
}

Measured memory_bytes: 128
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
if c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]:
    if c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
        if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]:
            if c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]:
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 3064
def main():
    n = int(input())
    H = list(map(int,input().split()))

    count = 0
    maximum = 0
    for i in range(n):
        if H[i] >= maximum:
            maximum = max(maximum,H[i])
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*

fun <T> calcPermutationList(sortedList: Array<T>): List<List<T>> {
    val permutationList = mutableListOf<List<T>>()
    val queue = ArrayDeque<List<T>>().apply { addFirst(listOf()) }
    while (queue.isNotEmpty()) {
        val p = queue.removeFirst()

        if (p.size == sortedList.size) {
            permutationList += p
        } else {
            queue += sortedList.filterNot { p.contains(it) }.map { p + it }
        }
    }

    return permutationList
}


fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    calcPermutationList((1..n).toList().toTypedArray())
        .let { it.indexOf(p) - it.indexOf(q) }
        .let(Math::abs)
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 56312
#include <bits/stdc++.h>
using namespace std;
    
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
#define endl '\n'
#define N 10000002
#define MOD 1000000007

signed main() {
    char c;
    cin >> c;
    if(c >= 'A' && c <= 'Z')    cout << "A";
    else    cout << "a";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

map <ll, ll> yakus(ll num){
    map<ll, ll> ret;
    for (ll i=2; i<1e6+1; i++){
        while (true) {
            if (num % i == 0) {
                num /= i;
                ret[i]++;
            } else {
                break;
            }
        }
    }
    if (num != 1){
        ret[num]++;
    }
    return ret;
}

ll saidaik (ll n1, ll n2){
    if (n2 == 0){
        return n1;
    } else {
        return saidaik(n2, n1%n2);
    }
}

int main(void){
    ll a; cin >> a;
    ll b; cin >> b;
    ll c;
    if (a > b){
        c = saidaik(a, b);
    } else {
        c = saidaik(b, a);
    }
    map <ll, ll> ys = yakus(c);
    ll ret = 1;
    for(auto _: ys){
        ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll a = n / 100, b = n % 100;

    bool r1 = a > 0 && a <= 12;
    bool r2 = b > 0 && b <= 12;

    if(r1&&r2){
        cout << "AMBIGUOUS" << endl;
    }
    else if(r1){
        cout << "MMYY" << endl;
    }
    else if(r2){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, s.size()){
    if (s[i] + n > 'Z'){
      s[i] -= 26;  
    }
    s[i] += n;
  }
  cout << s << endl;
  return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(long long N, std::string S){

    string s = S.substr(0,N);
    string t = S.substr(N,N);
    reverse(t.begin(),t.end());

    map<pair<string,string>,lli> cnt;

    for(lli i=0;i<(1LL<<N);i++){
        string sr,sb;
        REP(j,0,N){
            if((i&(1LL<<j)))sr.push_back(s[j]);
            else sb.push_back(s[j]);
        }
        LOG2(sr,sb);
        cnt[{sr,sb}]++;
    }

    lli ans = 0;
    for(lli i=0;i<(1LL<<N);i++){
        string sr,sb;
        REP(j,0,N){
            if((i&(1LL<<j)))sr.push_back(t[j]);
            else sb.push_back(t[j]);
        }
        lli tmp = cnt[{sb,sr}];
        LOG4(ans,sr,sb, tmp );
        ans += tmp;
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    func(N, S);
    return 0;
}


Measured memory_bytes: 60824
#include<stdio.h>

int main(){

int N,M,P;
while(1){

scanf("%d %d %d",&N,&M,&P);
if(N==0&&M==0&&P==0)break;

int x,s=0,y=0;
for(int i=0;i<N;i++){
scanf("%d",&x);s+=x;
if(M==i+1)y=x;

}
if(y!=0){
double t=100*s;
t=t/y*(100-P)/100;
printf("%d\n",(int)t);
}
else printf("0\n");
}
return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int H,h,m,s;
void judge();
void output(int n,int d);
int main() {
  while(true){
    cin >> H >> h >> m >> s;
    if(H==0&&h==0&&m==0&&s==0) return 0;
    judge();
  }
  return 0;
}

void judge(){
  int dn,dd;
  double ds,nh,nm,ns;
  while(true){
    dn = s*(119*H-1)-60*m*(H+1)-3600*h+3600*H;
    dd = 1-119*H;
    rep(i,3){
      ds = (double)dn/(double)dd;
      nh = (double)h/(double)H+(double)m/(60*(double)H)+((double)s+ds)/(3600*(double)H);
      nm = (double)m/60+((double)s+ds)/3600;
      ns = ((double)s+ds)/60;
      if(ns>=1) break;
      if(ds>=0&&ns<1&&nh!=nm&&nh!=ns&&nm!=ns){
        output(dn+dd*s,dd);
        return;
      }
      dn -= 3600*H;
    }
    s=0;
    m++;
    if(m==60){
      m=0;
      h++;
      if(h==H) h=0;
    }
  }
}

void output(int n,int d){
  if(n==0){
    cout << h << " " << m << " " << 0 << " " << 1 << endl;
    return;
  }
  int a,b;
  a=n;
  b=d;
  while(true){
    a = a%b;
    if(a==0){
      n = n/b;
      d = d/b;
      break;
    }
    b = b%a;
    if(b==0){
      n = n/a;
      d = d/a;
      break;
    }
  }
  cout << h << " " << m << " " << n << " " << d << endl;
  return;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;


#define F first
#define S second

#define ERR 1e-9

#if !ONLINE_JUDGE && !EVAL
    #define dbg_var(x) cerr << #x << ": " << x << "\n";
    #define dbg_iter(x, y) cerr  << #x << ": " << print_iterable(x, y) << "\n";
#else
    #define dbg_var(x)
    #define dbg_iter(x, y)
#endif // ONLINE_JUDGE

template <typename T1, typename T2>
string print_iterable( T1 begin_iter, T2 end_iter){
    bool first = true;
    stringstream res;
    res << "[ ";
    for(; begin_iter != end_iter; ++begin_iter){
        if(!first) res << ", ";
        first = false;
        res << *begin_iter;
    }
    res << " ]";
    return res.str();
}

void aggMax(int & res, int x){ if(x > res)res = x; }
void aggMin(int & res, int x){ if(x < res)res = x; }

int II(){ int i; cin >> i; return i; }
void OI(int i){ cout << i; }

// constraints
#define MAXN 1000000

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

    int N = II(), K = II();
    string s; cin >> s;

    vi num; int cons = 1;
    bool ones = (s[0] == '1');

    for(int i=1; i<N; i++){
        if(s[i] == '1') ones = true;
        if(s[i] == s[i-1]) cons++;
        else{
            if(num.size() == 0 && s[0] == '0') num.push_back(0);
            num.push_back(cons);
            cons = 1;
        }
    }
    num.push_back(cons);
    if(ones && s[N-1] == '0') num.push_back(0);

    /*for(int & x : num) cout << x << " ";
    cout << "\n";*/

    K = (K*2)+1;
    //cout << "K: " << K << "\n";

    int act = 0, res = 0;

    if(num.size() == 1){
        cout << num[0] << "\n";
        return 0;
    }
    if(num.size() < K){
        for(int & x : num) res += x;
        cout << res << "\n";
        return 0;
    }
    for(int i=0; i<num.size(); i++){
        act += num[i];
        if(i-K+1 >= 0){
            if( (i-K+1)%2 == 0 ) res = max(res, act);
            act -= num[i-K+1];
        }
    }

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


Measured memory_bytes: 1020
import java.lang.Math.*


fun main(args:Array<String>):Unit {
    val (n, q) = readLine()!!.split(' ').map(String::toInt)
    val maxSegmentTree = MaxSegmentTree(n)
    repeat(q){
        val (a, v) = readLine()!!.split(' ')//.map(String::toInt)
        maxSegmentTree.addAt(a.toInt() - 1, v.toInt())
        val (id, fish) = maxSegmentTree.max()
        println("$id $fish")
    }
}
data class Player(val id:Int, val fish:Int)
class MaxSegmentTree constructor (val mArray:Array<Array<Player>>){
    companion object {
        operator fun invoke(size:Int):MaxSegmentTree{
            val default = Player(0, 0)
            var s = size shl 1
            val a = Array(ceil(log(size.toDouble()) / log(2e0) + 1).toInt()){
                s = (s + 1) shr 1
                Array(s){default}
            }
            a[0] = a[0].mapIndexed{index, player -> player.copy(id = index + 1)}.toTypedArray()
            return MaxSegmentTree(a)
        }
    }
    fun addAt(playerId:Int, value:Int):Unit{
        mArray[0][playerId] = mArray[0][playerId].copy(fish = mArray[0][playerId].fish + value)
        var pos = playerId shr 1
        for (i in 1 until mArray.size){
            mArray[i][pos] = mArray[i - 1][pos * 2]
            if (mArray[i - 1].indices.contains(pos * 2 + 1) && mArray[i][pos].fish < mArray[i - 1][pos * 2 + 1].fish) mArray[i][pos] = mArray[i - 1][pos * 2 + 1]
            pos = pos shr 1
        }
    }
    fun max():Player = mArray.last().first()
}


Measured memory_bytes: 135664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int N, M;
    cin >> N;
    std::vector<int> h(N);
    rep(i,N) cin >> h[i];

    vector<int> cost(N);
    for(int i = 1; i < N; i++){
        int cost1 = INF32;
        int cost2 = INF32;
        if(i-1>=0) cost1 = cost[i-1]+abs(h[i]-h[i-1]);
        if(i-2>=0) cost2 = cost[i-2]+abs(h[i]-h[i-2]);
        cost[i] = min(cost1, cost2);
    }
    cout << cost[N-1] << endl;
}

Measured memory_bytes: 3960
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    int now_x = 0;
    int now_y = 0;
    int now_t = 0;
    bool ok = true;
    rep(i, n) {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = ( abs(x - now_x) + abs(y - now_y) );
        int time_intrvl = t- now_t;
        if ( time_intrvl < dist ) {
            ok = false;
        }
        else if ( ( time_intrvl - dist ) % 2 == 0 ) {
            continue;
        }
        else {
            ok = false;
        }
    }

    if ( ok ) { 
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;

void solve(){
	int r,g;
	cin>>r>>g;
	cout<<g*2-r;
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
S = input()
alphabets = [chr(x + ord('a')) for x in range(26)]
if len(S) < 26:
  n = min(set(alphabets) - set(s for s in S))
  print(S+n)
else:
  current = 'a'
  done = False
  for i in range(26):
    if S[25-i] < current:
      n = min(s for s in S[25-i+1:] if s > S[25-i])
      #sub = [s for s in S[25-i:]]
      #sub.remove(n)
      print(S[:25-i] + n )#+ ''.join(sorted(s for s in sub)))
      done = True
      break
    else:
      current=S[25-i]
  if not done:
    print(-1)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define el cout << endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, a, b; cin >> n >> a >> b;
    vector<lint> h(n); repeat(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    
    auto isok = [&a, &b](vector<lint> h, lint r) {
        bool ret;
        lint s = 0;
        lint n = h.size();
        repeat(i, n) h[i] -= b*r;
        repeat(i, n) {
            if (h[i] <= 0) continue;
            s += (h[i] + (a-b-1)) / (a-b);
        }
        if (r >= s) ret = true;
        else ret = false;
        return ret;
    };
    
    lint ub = 1e9;
    lint lb = 0;
    rep(200) {
        lint mid = (ub + lb) / 2;
        if (isok(h, mid)) {
            ub = mid;
        }
        else {
            lb = mid;
        }
    }
    cout << ub << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define RepG0(i, x) for (int i = head0[x]; i; i = edge0[i].next)
#define v0 edge0[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200010;
struct Edge{ int to, next;} edge[N * 2], edge0[N * 2];

int head[N], num, head0[N], num0;

void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}
void add_edge0(int a, int b) { edge0[++ num0] = (Edge){b, head0[a]}, head0[a] = num0;}

int f[N], dep[N];

void dfs(int x)
{
	//printf("_%d %d\n", x, f[x]);
	RepG0(i, x) if (v0 != f[x]) {
		dep[v0] = dep[x] + 1, f[v0] = x;
		dfs(v0);
	}
}

bool jud(int x, int y) { return (f[x] == y || f[f[x]] == y || f[y] == x || f[f[y]] == x || f[x] == f[y]); }

bool flag;
int ans;

void dfs(int x, int fa, int dis)
{
	if (dis >= dep[x]) return;
	else ans = max(ans, dep[x]);
	RepG(i, x) if (v != fa) {
		if (jud(x, v)) dfs(v, x, dis + 1); 
		else{
			flag = true;
		//	printf("%d %d ???\n", x, v);
		}
	}
}

int main()
{
	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);
	Rep(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge(a, b); add_edge(b, a);
	}
	Rep(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge0(a, b); add_edge0(b, a);
	}
	dfs(y); dfs(x, 0, 0);
	
	if (flag) printf("-1\n");
	else printf("%d\n", ans * 2);
	
	return 0;
}

Measured memory_bytes: 15488
# 番号Nを26進数で表現すればいいはず？

def convert_base_number(new_base, target) :
    result = []

    while True :
        dig = target % new_base
        target = target // new_base
        result.append(dig)

        if (target == 0) :
            break

        # if (target < new_base) :
        #     if (target != 0) :
        #         result.append(target)
        #     break

    return result

# def convert_base_number(new_base, target, result) :
#     X_dumy = target
#     out = ''
#     while X_dumy>0:
#         out = str(X_dumy%new_base)+out
#         result.append(str(X_dumy%new_base))
#         X_dumy = int(X_dumy/new_base)
#     return out

# アルファベットの何番目の数字を返す
def get_alpha(number) :
    base = ord('a')
    return chr(base + number)

# https://tanuhack.com/num2alpha-alpha2num/#i-3
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)


def main() :
    N = int(input())
    print(num2alpha(N).lower())
    # converted = []
    # # convert_base_number(26, N, converted)
    # converted = convert_base_number(26, N-1)
    # # converted = convert_base_number(26, N)
    # print(converted)

    # # out_str = get_alpha(converted[0]-1)
    # out_str =''
    # # for conv in converted[1:] :
    # for conv in converted :
    #     out_str += get_alpha(conv)
    
    # print(out_str)


main()

Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 1e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

vector<vector<int>> to,from;
vector<bool> to_used,from_used;

void dfs(int u){
    if(to_used[u] == true) return;
    to_used[u] = true;

    for(int v : to[u]){
        dfs(v);
    }
}

void rdfs(int u){
    if(from_used[u] == true) return;
    from_used[u] = true;

    for(int v : from[u]){
        rdfs(v);
    }
}

int main(){
    int N,M,P; cin >> N >> M >> P;
    vector<tuple<int,int,int>> edges;
    to.resize(N);
    from.resize(N);
    to_used.resize(N,false);
    from_used.resize(N,false);
    rep(i,M){
        int A,B,C; cin >> A >> B >> C;
        A--; B--;
        C -= P;
        C = -C;
        edges.emplace_back(A,B,C);
        to[A].push_back(B);
        from[B].push_back(A);
    }
    dfs(0);
    rdfs(N-1);

    //bellmanford
    vector<int> dist(N,INF);
    dist[0] = 0;
    int cnt = 0;
    bool upd = true;
    vector<bool> ok(N);
    rep(i,N){
        ok[i] = to_used[i]&from_used[i];
    }
    while(upd){
        upd = false;
        rep(i,M){
            int A,B,C;
            tie(A,B,C) = edges[i];
            if(!ok[A]) continue;
            if(!ok[B]) continue;
            if(dist[B] > dist[A] + C){
                dist[B] = dist[A] + C;
                upd = true;
            }
        }
        cnt++;
        if(cnt > N){
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = max(-dist[N-1],0);
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <stdio.h>
 
#define Max 1000000
 
int cnt=0, count = 0, n;
int A[Max], G[Max];
 
void shellSort(int*,int);
void insertionSort(int*,int,int);
 
int main()
{
  int i,len;
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  shellSort(A,n);
 
  printf("%d\n",count);
  for(i=count-1;i>-1;i-- ){
    printf("%d",G[i]);
    if(i!=0) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n", A[i]);
  }
  return 0;
}
 
void shellSort(int A[], int n)
{
  int i, k;
   
  for( k = 1 ; ; ){
    if( k > n ) break;
    G[count] = k;
    k = 3 * k + 1;
    count++;
  }
   
  for( i = count ; i >= 0 ; i-- ) insertionSort(A, n, G[i]);
}
 
void insertionSort(int A[], int n, int g)
{
  int i, j, v;
 
  for( i = g ; i < n ; i++ ){
    v = A[i];
    j = i - g;
    while( j >= 0 && A[j] > v ){
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

Measured memory_bytes: 6372
n, k = map(int, input().split())
s = input()
lis = [0]
j = 0
if s[0] == '0':
    lis.append(0)
    j = 1
#print(len(lis))
lis[j] += 1
for i in range(1,n):
    #print(len(lis))
    if s[i] != s[i-1]:
        j += 1
        lis.append(0)
    lis[j] += 1
if s[n-1] == '0':
    lis.append(0)
#print(lis)
com = [0] * (len(lis) + 1)
for i in range(len(lis)):
    com[i+1] = com[i] + lis[i]
#print(com)
ans = 0
for i in range(len(lis)):
    if i % 2 == 0:
        ans = max(ans,lis[i])
l = 0
while l < len(com):
    r = l + (2 * k + 1)
    if r >= len(com):
        r = len(com) - 1
    ans = max(ans,com[r] - com[l])
    l += 2
print(ans)


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

using namespace std;

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

    int r;

    cin >> r;

    cout << fixed << setprecision(3) << 2 * r * acosl(-1.0) << "\n";
    
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  vector<int> data(N);
  for (int i = 0; i < N; i++)
  {
    cin>>data[i];
  }

  sort(data.begin(),data.end());
  cout<<data[N-1] - data[0]<<endl;
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,n,i,k;
    cin>>a>>b>>n;
    //k=((a*n)/b)-a*(n/b);
    //cout<<k<<endl;
    if(n>=b)
        k=((a*(b-1))/b);
    else
        {
            k=(a*(n)/b);
        }

    cout<<k<<endl;
}


Measured memory_bytes: 3604
import sys
from fractions import gcd
import bisect
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]



n, a, b = na()

train = a * n
taxi = b


print(min([train, taxi]))
    

Measured memory_bytes: 64620
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nl = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			int n = (int)nl[0];
			long l = nl[1];
			var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			int index = -1;
			for (int i = 0; i < n - 1; i++) {
				if (a[i] + a[i + 1] >= l) {
					index = i;
					break;
				}
			}

			if (index < 0) {
				Console.WriteLine("Impossible");
				return;
			}

			var sb = new StringBuilder();
			for (int i = 0; i < index; i++) {
				sb.AppendLine((i + 1).ToString());
			}

			for (int i = n - 1; i >= index + 1; i--) {
				sb.AppendLine(i.ToString());
			}

			Console.WriteLine("Possible");
			Console.Write(sb.ToString());
		}
	}
}

Measured memory_bytes: 32348
N = int(input())
arr =  [int(i) for i in input().split()] 

count = 0
while(True):
    exits_odd = False
    for i in range(N):
        if arr[i] % 2 != 0:
            exits_odd = True
        else:
            continue
    if exits_odd:
        break
    else:
        count += 1
        for i in range(N):
            arr[i] = arr[i] / 2


print(count)



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

int		main(void)
{
	string s;

	cin >> s;
	for (int tmp = 0; tmp < (1 << 3); tmp++)
	{
		bitset<3> plus(tmp);
		string result;
		int sum = s[0] - '0';
		result += s[0];

		for (int i = 1; s[i]; i++)
		{
			if (plus[i - 1])
			{
				sum += s[i] - '0';
				result += '+';
			}
			else
			{
				sum -= s[i] - '0';
				result += '-';
			}
			result += s[i];
		}
		if (sum == 7)
		{
			cout << result + "=7" << endl;
			return (0);
		}
	}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e18;

lint H, W, N, sx, sy;
string s1, s2;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> H >> W >> N;
	cin >> sy >> sx;
	cin >> s1 >> s2;
	map<char, lint> outline;
	outline['U'] = 0;
	outline['D'] = 0;
	outline['L'] = 0;
	outline['R'] = 0;
	REP(i, N) {
		if (s2[i] == 'R') s2[i] = 'L';
		else if (s2[i] == 'L') s2[i] = 'R';
		else if (s2[i] == 'D') s2[i] = 'U';
		else if (s2[i] == 'U') s2[i] = 'D';
	}
	IREP(i, N) {
		outline[s2[i]] = max(outline[s2[i]] - 1, 0ll);
		outline[s1[i]]++;
		
		if (outline['U'] + outline['D'] >= H || outline['R'] + outline['L'] >= W) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (sx <= outline['L'] || sy <= outline['U'] || sx > W -  outline['R'] || sy > H - outline['D']) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 4020
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){
  int d1,d2,d3;
  int count1=0,count2=0;

  while(scanf("%d,%d,%d",&d1,&d2,&d3)!=EOF){
    if(d1*d1+d2*d2==d3*d3&&d1!=d2)count1++;
    if(d1*d1+d2*d2!=d3*d3&&d1==d2)count2++;
  }

  cout<<count1<<endl;
  cout<<count2<<endl;

  return(0);
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <string.h>
int main()
{
	char a[201];
	gets(a);
	int i;
	printf("%c",a[0]);
	for(i=0;i<strlen(a);i++)
		if(a[i-1]==' '&&a[i]!=' ')
			printf("%c",a[i]);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

void printCurrent(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i != 0) {
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
}

int bubbleSort(int a[], int n) {
    int c = 0;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 1; j <= i; j++) {
            if (a[j] < a[j - 1]) {
                int tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                c++;
            }
        }
    }
    printCurrent(a, n);
    return c;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int c = bubbleSort(a, n);
    cout << c << endl;

    return 0;
}


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

int main() {


int n;
//int *num=new int[4];
//char *s=new char[4];
cin >> n;
double *num=new double[n];
double sum=0;
for(int i=0;i<n;i++){
cin >> num[i];
sum+=num[i];
}
sum/=n;
//sort(num,num+n);

double mi=101;
for(int i=0;i<n;i++){
mi=min(abs(num[i]-sum),mi);
}

for(int i=0;i<n;i++){
if(abs(num[i]-sum)==mi){
cout << i << endl;
break;
}

}


//cout << mi << endl;



}


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

int main()
{
	ll N,M;
    cin >> N;
	cin >> M;
	ll A[M];
	for (int i(0);i<M;++i){
		A[i] = 0;
	}
	ll k,tmp;
	for (int i(0);i<N;++i){
		cin >> k;
		for (int j(0);j<k;++j){
			cin >> tmp;
			A[tmp-1]++;
		}
	}
	ll ans = 0;
	for (int i(0);i<M;++i){
		if (A[i] == N){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    long long h;
    cin >> h;
    long long c = 1;
    long long d = 1;
    while(h / 2)
    {
        h /= 2;
        d *= 2;
        c += d;
    }
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int minx=753;
    for(int i=0;i<s.size()-2;i++)
    {
        char c;
        int m1=0,m=100,a;
        for(int j=i;j<=i+2;j++)
        {
            c=s[j];
            a=c;
            a-=48;
            a*=m;
            m1+=a;
            m/=10;
        }
        m1-=753;
        m1=fabs(m1);
        if(minx>m1)
            minx=m1;
    }
    cout<<minx;
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : Allocation.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

//bool checkAllocated(const vector<int>&, const int, const int);

bool checkAllocated(const vector<int>& v, const int P, const int k){
	int num_truck = 1;
	int load_current_truck = 0;

	for(int i=0; i<v.size(); i++){
		if(v.at(i)>P){
			return false;
		}

		load_current_truck += v.at(i);
		if(load_current_truck > P){
			num_truck += 1;
			load_current_truck = v.at(i);
		}else{
			continue;
		}
	}

	if(num_truck>k){
		return false;
	}else{
		return true;
	}
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v;
	int sum = 0, max = 0;

	int input;
	for(int i=0; i<n; i++){
		cin >> input;
		v.push_back(input);
		sum += input;
		if(max < input){
			max = input;
		}
	}

	int begin = sum / k;
	int end = max * (n / k + 1);

	int largest_no = begin-1;
	int smallest_yes = end;
	bool isAllocated = false;
	//cout << begin << "\n";
	//cout << end << "\n";

	while(abs(smallest_yes - largest_no)>1){
		int current_pos = (smallest_yes + largest_no) / 2;
		isAllocated = checkAllocated(v, current_pos, k);
		if(isAllocated){
			//cout << current_pos << " is allocated\n";
			smallest_yes = current_pos;
		}else{
			//cout << current_pos << " is not allocated\n";
			largest_no = current_pos;
		}
	}

	cout << smallest_yes << "\n";

	return 0;
}



Measured memory_bytes: 3524
N,K=map(int,input().split())
A=[int(i)-1 for i in input().split()]

if K<=N:
    p=0
    for i in range (K):
        p=A[p]
    print(p+1)
else:
    p=0
    t=[-1]*N #言ってない場所は-1、行った場所は-1で示す
    t[0]=0
    for i in range(1,N):
        p=A[p] #今いる場所の番号が次のテレポート先
        if t[p]!=-1: #もし次のテレポート先が行ったことある場所ならループの始まりの証拠
            break
        t[p]=i
    d=i-t[p] #今の番号（i）がループまでの数で、t[p]は１回目に来たときの回数を表すからその差分がループに必要な回数
    K-=i #ループの前までの部分は省く
    K%=d #ループを繰り返した後の余りだけ考える
    
    for i in range(K):
        p=A[p]
    print(p+1)
        
    

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

typedef pair<int,int> pii;
typedef vector<int> vec;
typedef unordered_map<int,int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007
class Graph{
	public:
		int v;
		list<int>*l;

		Graph(int V){
			v=V;
			// map<int,list<int>>l[v];
			l = new list<int>[v+1];

			
		}
	
	void addEdge(int x, int y){
	l[x].push_back(y);
	l[y].push_back(x);
	}
	void bfs(int src){
		queue<int>q;
		bool *visited=new bool[v+1];
		vector<int>path(v+1);
		FOR(i,0,v+1)
		visited[i]=false;
		q.push(src);
		visited[src]=true;
		while(!q.empty()){
			int f=q.front();
			// cout<<" q front "<<f<<endl;
			q.pop();
			// list<int>::iterator i;
			for(auto i=l[f].begin();i!=l[f].end();i++){
				if(!visited[*i])
				{
					q.push(*i);
					// cout<<"pushed "<<*i<<endl;
					visited[*i]=true;
					path[*i]=f;
					// cout<<"path of "<<*i<<"is "<<f<<endl;
				}
			}
		}
		// cout<<"map printing"<<endl;
      if(l[1].begin()==l[1].end())
        cout<<"No"<<endl;
      else{
        cout<<"Yes"<<endl;
		for(int i=2;i<path.size();i++){
			cout<<path[i]<<endl;
		}
      }


	}
};

int main()
{
	JJ;
	int v,m; cin>>v>>m;
	Graph g(v);
	int x,y;

	FOR(i,0,m){
		cin>>x>>y;
		g.addEdge(x,y);
		// cout<<x<<" and "<<y<<endl;
	}
	g.bfs(1);

	


	return 0;
}


Measured memory_bytes: 19036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef struct{ int y; int x; int count; }QUEUE;

int H, W, N, black = 0;
vector<string> S;

int main(void){
    
	cin >> H >> W;
	for(int i = 0; i < H; ++i){
	    string temp;
	    cin >> temp;
	    S.push_back(temp);
	    for(int j = 0; j < temp.size(); ++j) if(temp[j] == '#') ++black;
	}
	
	vector<bitset<1001>> dp(1001);
    queue<QUEUE> que;
    QUEUE q = {0, 0, 0};
    que.push(q);
    while(!que.empty()){
        q = que.front(), que.pop();
        if(q.y == H - 1 && q.x == W - 1){
            cout << H * W - q.count - black - 1 << endl;
            return 0;
        }
        else if(!dp[q.y][q.x]){
            dp[q.y].set(q.x);
            QUEUE temp;
            if(q.y - 1 >= 0 && S[q.y - 1][q.x] != '#'){
                temp.y = q.y - 1, temp.x = q.x, temp.count = q.count + 1;
                que.push(temp);
            }
            if(q.y + 1 < H && S[q.y + 1][q.x] != '#'){
                temp.y = q.y + 1, temp.x = q.x, temp.count = q.count + 1;
                que.push(temp);
            }
            if(q.x - 1 >= 0 && S[q.y][q.x - 1] != '#'){
                temp.y = q.y, temp.x = q.x - 1, temp.count = q.count + 1;
                que.push(temp);
            }
            if(q.x + 1 < W && S[q.y][q.x + 1] != '#'){
                temp.y = q.y, temp.x = q.x + 1, temp.count = q.count + 1;
                que.push(temp);
            }
        }
    }
    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1000000001
#define MAX 200000
using namespace std;
int N, S[MAX];
long long res;

void Merge(int left, int mid, int right) {
	int n1 = mid - left, n2 = right - mid;
	vector<int> L(n1 + 1, INF), R(n2 + 1, INF);
	for (int i = 0; i < n1; i++)
		L[i] = S[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = S[mid + i];
	for (int i = 0, j = 0, k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i++;
		}
		else {
			S[k] = R[j];
			j++;
			res += n1 - i;
		}
	}
}

void MergeSort(int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		MergeSort(left, mid);
		MergeSort(mid, right);
		Merge(left, mid, right);
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> S[i];
	MergeSort(0, N);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4360