akhauriyash/Code-Regression huggingface dataset:
<?php

fscanf(STDIN, '%d', $n);
for ($count = 0; $count < $n; $count++) {
    $a = explode(' ', rtrim(fgets(STDIN)));
    $b = 0;
    $c = 0;
    for ($i = 0; $i < 10; $i++) {
        if ($a[$i] > $b) {
            $b = $a[$i];
        } elseif ($a[$i] > $c) {
            $c = $a[$i];
            if ($c > $b) {
                $tmp = $b;
                $b = $c;
                $c - $tmp;
            }
        } else {
            break;
        }
    }

    echo $i === 10 ? 'YES' : 'NO';
    echo PHP_EOL;
}

Measured memory_bytes: 6588
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n + 2, 0);
    int score = k - q;
    while(q--){
        int pos;
        cin >> pos;
        a[pos]++;
    }
    for(int i = 1; i <= n; i++){
        if(score + a[i] <= 0){
            cout << "No" << nl;
        }else{
            cout << "Yes" << nl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {

	int n, x;
	int hantei = 0;

	scanf("%d", &n);

	while (n--) {
		scanf("%d", &x);

		hantei += isprime(x);

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

int isprime(int x) {
	int p, i;

	if (x % 2 == 0 && x != 2) {
		return 0;
	}
	else if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else {
		p = pow(x, 0.5);

		for (i = 2; i <= p; i++) {
			if (x%i == 0) {
				return 0;
			}
		}
	}

	return 1;
}




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

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

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

  if ((int)s.size() != a + b + 1) {
    cout << "No" << endl;
    return;
  }

  if (s[a] != '-') {
    cout << "No" << endl;
    return;
  }

  rep((int)s.size(), i ){
    int t = s[i] - '0';
    if (i != a && (t < 0 || 9 < t)) {
      cout << "No" << endl;
      return ;
    }
  }

  cout << "Yes" << endl;
  return;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(input())
    
print('AC x %s'%(S.count('AC')))
print('WA x %s'%(S.count('WA')))
print('TLE x %s'%(S.count('TLE')))
print('RE x %s'%(S.count('RE')))

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
typedef pair<long double, long long> P;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<long double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    vector<vector<P>> dp(N + 1, vector<P>(N + 1, P(0, 0)));
    dp[0][0] = P(0, 1LL);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (dp[i][j].second == 0) continue;
            if (dp[i + 1][j + 1].first < dp[i][j].first + v[i]) {
                dp[i + 1][j + 1] = P(dp[i][j].first + v[i], dp[i][j].second);
            } else if (dp[i + 1][j + 1].first == dp[i][j].first + v[i]) {
                dp[i + 1][j + 1].second += dp[i][j].second;
            }
            if (dp[i + 1][j].first < dp[i][j].first) {
                dp[i + 1][j] = dp[i][j];
            } else if (dp[i + 1][j].first == dp[i][j].first) {
                dp[i + 1][j].second += dp[i][j].second;
            }
        }
    }

    long double ans_value = 0;
    long long ans_num = 0;
    for (int i = A; i <= B; i++) {
        long double ave = dp[N][i].first / (i);
        if (ave > ans_value) {
            ans_value = ave;
            ans_num = dp[N][i].second;
        } else if (ave == ans_value) {
            ans_num += dp[N][i].second;
        }
    }

    cout << setprecision(20) << ans_value << endl;
    cout << ans_num << endl;
}

Measured memory_bytes: 384
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,a[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>n;
	for(i=2;i*i<n;i++)
	{
		if(n%i<1)
		{
			for(k=0;n%i<1;n/=i)
			{
				k++;
			}
			for(m=0;(m+1)*(m+2)/2<=k;)m++;
			s+=m;
		}
	}
	if(n>1)s++;
	cout<<s;
}

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

using namespace std;

typedef long long ll;

ll n, m, Q;
ll a[2005][2005];
ll b[2005][2005];
ll c[2005][2005];
ll d[2005][2005];
ll e[2005][2005];
ll f[2005][2005];

int main()
{
    scanf("%lld%lld%lld", &n, &m, &Q);
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= m; j++)
        {
            scanf("%1lld", &a[i][j]);
            d[i][j] = d[i][j - 1] + a[i][j];
        }
    }
    for(ll j = 1; j <= m; j++)
    {
        for(ll i = 1; i <= n; i++)
        {
            d[i][j] += d[i - 1][j];
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= m; j++)
        {
            if(a[i][j] && a[i][j - 1]) b[i][j] = 1;
            e[i][j] = e[i][j - 1] + b[i][j];
        }
    }
    for(ll j = 1; j <= m; j++)
    {
        for(ll i = 1; i <= n; i++)
        {
            e[i][j] += e[i - 1][j];
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= m; j++)
        {
            if(a[i][j] && a[i - 1][j]) c[i][j] = 1;
            f[i][j] = f[i][j - 1] + c[i][j];
        }
    }
    for(ll j = 1; j <= m; j++)
    {
        for(ll i = 1; i <= n; i++)
        {
            f[i][j] += f[i - 1][j];
        }
    }
    while(Q--)
    {
        ll x1, x2, y1, y2;
        scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
        ll ans = 0;
        x1--, y1--;
        ans += d[x2][y2] - d[x1][y2] - d[x2][y1] + d[x1][y1];
        y1++;
        ans -= e[x2][y2] - e[x1][y2] - e[x2][y1] + e[x1][y1];
        y1--;
        x1++;
        ans -= f[x2][y2] - f[x1][y2] - f[x2][y1] + f[x1][y1];
        x1--;
        printf("%lld\n", ans);
    }
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  bool app[26];
  for(int i=0;i<26;i++){
    app[i]=false;
  }
  for(int i=0;s[i]!='\0';i++){
    app[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!app[i]){
      char c=i+'a';
      cout<<c<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
    
  return 0;
}

Measured memory_bytes: 3740
s = input()
a = 0
t = 0
for i in s:
    if i == 'A' or i == 'T' or i == 'G' or i == 'C':
        t += 1
    else:
        if t > a:
            a = t
            t = 0
if t > a:
	a = t
print(a)


Measured memory_bytes: 3060
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
/*namespace*/
using namespace std;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(x) (x).begin(),(x).end()

int main(){
    string S;
    int A=0;
    getline(cin,S);
    if(S[0]==S[1]){
        if(S[2]==S[3]&&S[0]!=S[2]){
           A=1; 
        }
    }else if(S[0]==S[2]){
        if(S[1]==S[3]&&S[0]!=S[1]){
            A=1;
        }
    }else if(S[0]==S[3]){
        if(S[1]==S[2]&&S[0]!=S[1]){
            A=1;
        }
    }
    if(A==1){
        cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#ifdef int
#define INF (LLONG_MAX / 2)
#else
#define INF (INT_MAX / 2)
#endif
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-9)
#define mkpr make_pair
#define mktp make_tuple
#define var auto
#define self (*this)
#define in :
#define True true
#define False false
#define None nullptr
#define is ==
#define is_not !=
#define AST(exp, msg) if(!(exp)){EPR((msg))} assert((exp));
#define TAST(exp, msg) if(!(exp)){EPR((msg))} while(!(exp)){}
#define EPR(msg) cerr << (msg) << endl;
#define DBLEQ(a, b) (abs((a) - (b)) < EPS)
#define fst first
#define scd second
#define out &
#define tv(tp, i) get<i>(tp)
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
const int MGN = 10; const int ARYSZ_MAX = (int)1e7;



int32_t main(int32_t argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef _DEBUG
    vs args(argv, argv+argc);
    string sample = make_sample(args, 3);
    ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#endif


    int X,Y, A,B,C; cin>>X>>Y>>A>>B>>C;
    vl P(A); REP(i,A) cin>>P[i];
    vl Q(B); REP(i,B) cin>>Q[i];
    vl R(C); REP(i,C) cin>>R[i];

    sort(P.rbegin(), P.rend());
    sort(Q.rbegin(), Q.rend());

    priority_queue<ll> pq_r, pq_g, pq_t;
    REP(i,X) pq_r.push(P[i]);
    REP(i,Y) pq_g.push(Q[i]);
    REP(i,C) pq_t.push(R[i]);
    pq_r.push(-1);
    pq_g.push(-1);
    pq_t.push(-1);

    ll ans = 0;
    //int x=0, y=0;
    REP(i, X+Y) {
        ll rd = pq_r.top();
        ll gr = pq_g.top();
        ll tr = pq_t.top();

        if (tr >= max(rd, gr)) {
            ans += tr;
            pq_t.pop();
            continue;
        }

        if (rd >= max(gr, tr)) {
            ans += rd;
            pq_r.pop();
            continue;
        }

        if (gr >= max(rd, tr)) {
            ans += gr;
            pq_g.pop();
            continue;
        }
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

int n,m;
vector <int> adj[101];
bitset <101> mark;
bool Cyc;

void dfs(int x)
{
    if(mark[x])
        Cyc=1;
    if(Cyc)
        return ;
    mark[x]=1;
    for(int i=0;i<adj[x].size();i++)
        dfs(adj[x][i]);
    mark[x]=0;
}


int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(int i=0;i<n;i+=5)
        dfs(i);
    if(Cyc)
        cout<<1<<endl;
    else
        cout<<0<<endl;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
s+wが小さい順に載せるのが最適
*/

struct D{
	ll w,s,v,id;
};
bool operator<(const D &lhs, const D &rhs){
	if(lhs.w+lhs.s<rhs.w+rhs.s){
		return true;
	}else if(lhs.w+lhs.s==rhs.w+rhs.s){
		return lhs.id<rhs.id;
	}
	return false;
}

ll n,dp[20010]={},ans=0;
D block[1010];

int main(void){
	cin>>n;
	rep(i,n){
		ll w,s,v;
		cin>>w>>s>>v;
		block[i]={w,s,v,i};
	}
	//
	sort(block,block+n);
	//
	rep(i,n){
		ireg(j,0,block[i].s){
			if(j+block[i].w>20000)break;
			dp[j+block[i].w]=max(dp[j+block[i].w],dp[j]+block[i].v);
		}
	}
	rep(i,20010)ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
	string s;
	cin >> s;
	string ans;
	for (char c : s) {
		if (c == '0') {
			ans += '0';
		}
		else if (c == '1'){
			ans += '1';
		}
		else {
			if (ans.end() == ans.begin()) {
				continue;
			}
			ans.erase(ans.end() - 1);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
N,T = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(N)]
C = sorted(C, key = lambda x : x[1],reverse =False)
#print(C)

A =[1001]
for i in C:
    if i[1] <= T:
        A.append(i[0])

print(min(A) if min(A) != 1001 else "TLE")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    long  money;
    long  happy1000;
    long  happy5;
    long  happyall;

    cin >> money;

    happy1000 = (money / 500) * 1000;
    happy5 = ((money % 500) / 5) * 5;

    happyall = happy1000 + happy5;

    cout << happyall << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  ll a,b,ans=1;
  cin>>a>>b;
  for(ll i=2;i*i<=min(a,b);i++){
    if(a%i==0 && b%i==0) ans++;
    if(a%i==0){
      for(;a%i==0;) a/=i;
    }
    if(b%i==0){
      for(;b%i==0;) b/=i;
    }
    if(a*b==1){
      cout<<ans;
      return 0;
    }
  }
  if(max(a,b)%min(a,b)==0 && min(a,b)!=1) ans++;
  cout<<ans;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    string S;
    cin >> S;
    int K;
    cin >> K;

    int N = S.size();

    long long ans = 0;
    int left = 0, right = 0;
    while(right < N){
        if(left == right) ++right;
        while(right < N and S[right-1] == S[right]) ++right;
        ans += (right-left)/2;
        //cout << left << " " << right << endl;
        left = right;
    }
    ans *= K;
    if(S[0] == S[N-1]){
        int num_head = 1, num_tail = 1;
        REP(i, N-1){
            if(S[i] == S[i+1]) ++num_head;
            else break;
        }
        for(int i = N-1; i > 0; --i){
            if(S[i-1] == S[i]) ++num_tail;
            else break;
        }
        if(num_head == N){
            cout << (long long)N*K/2 << endl;
            return 0;
        }
        if(num_head%2 == 1 and num_tail%2 == 1) ans += K-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
static const int MAX = 100;

int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;

    for(int i = 0; flag; i++){
        flag = 0;
        
        for(int j = N-1; j >= i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

void trace(int A[], int N){
    int i;
    rep(i, N){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main(){
    int A[MAX], N;

    cin >> N;
    rep(i, N) cin >> A[i];

    int sw = bubbleSort(A, N);
    trace(A, N);

    cout << sw << endl;
}


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

int main(){
    while(1){
        int m, f, r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1){
            cout << 'F' << endl;
        }else if((m + f) < 30){
            cout << 'F' << endl;
        }else if((m + f) >= 80){
            cout << 'A' << endl;
        }else if((m + f) >= 65){
            cout << 'B' << endl;
        }else if((m + f) >= 50){
            cout << 'C' << endl;
        }else if((m + f) >= 30){
            if(r >= 50){
                cout << 'C' << endl;
            }else{
                cout << 'D' << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include <vector>

using namespace std;

int main()
{
	int Num;
	cin >> Num;
	
	int intCount = 0;



	for (int n = 1;n <= Num;n++)
	{
		int ans = 1;
		
		vector<int> x(n + 1);
		int num = n; // 素因数分解する変数num 

		for (int i = 2; i <= n; i++) {
			while (num % i == 0) { // 素数で割り切れなくなるまで割っていく
				x.at(i)++;
				num /= i;
			}
		}

		for (int i = 2; i <= n; i++)
		{
			ans *= x.at(i) + 1;
		}


		if (ans == 8&&n%2==1)
		{
			intCount++;
		}
		

	}

	cout << intCount << endl;
	
}

Measured memory_bytes: 3564
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let l: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut s1: i32 = 0;
    let mut s2: i32 = 0;
    for i in &l {
        s2 += *i;
    }
    let mut ans: i32 = 1000000;
    for i in l {
        s1 += i;
        s2 -= i;
        ans = min(ans, (s1 - s2).abs());
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
const int MOD = 1000000007;
using namespace std;

void solve(void)
{
    ll n;
    cin >> n;
    n *= 2;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < n; i += 2)
    {
        ans += min(v[i], v[i + 1]);
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3580
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			long[]A = new long[N];
			Map<Long,Long>map = new TreeMap<Long,Long>();
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextInt();
				if(map.containsKey(A[i])) {
					map.put(A[i], map.get(A[i])+1);
				}else {
					map.put(A[i], (long)1);
				}
			
			}
			int Q = scan.nextInt();
			long []B = new long[Q];
			long []C = new long[Q];
			
			for(int i = 0;i<Q;i++) {
				B[i] = scan.nextLong();
				C[i] = scan.nextLong();	
			}
			
			long goukei = 0;
			for(int i = 0;i<N;i++)goukei+=A[i];
			
			
			for(int i = 0;i<Q;i++) {
				
				if(!map.containsKey(B[i])) {
					System.out.println(goukei);
					continue;
				}
				
				long kosuu = map.get(B[i]);
				
				long sa = C[i]*kosuu-B[i]*kosuu;
				
				goukei+=sa;
				System.out.println(goukei);
				
				map.put(B[i], (long)0);
				
				if(map.containsKey(C[i])) {
					map.put(C[i], map.get(C[i])+kosuu);
				}else {
					map.put(C[i], kosuu);
				}
				
				
				
				
			}
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 71240
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 3005;
const ll MOD = 1000000007;

int n,q;
int a[MAXN];

ll ans;
ll f[MAXN][MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> q;
	for (int i = 1;i <= n;i++)
		cin >> a[i];
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= n;j++)
			if (a[i] > a[j])
				f[i][j] = 1;
	for (int x,y,i = 1;i <= q;i++)
	{
		cin >> x >> y;
		for (int j = 1;j <= n;j++)
		{
			if (j == x || j == y)
				continue;
			f[j][x] = f[j][y] = (f[j][x] + f[j][y]) * ((MOD + 1) / 2) % MOD;
		}
		for (int j = 1;j <= n;j++)
		{
			if (j == x || j == y)
				continue;
			f[x][j] = f[y][j] = (f[x][j] + f[y][j]) * ((MOD + 1) / 2) % MOD;
		}
		f[x][y] = f[y][x] = (f[x][y] + f[y][x]) * ((MOD + 1) / 2) % MOD;
	}
	for (int i = 1;i <= n;i++)
		for (int j = i + 1;j <= n;j++)
			(ans += f[i][j]) %= MOD;
	for (int i = 1;i <= q;i++)
		(ans *= 2) %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70656
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int INF=1e9;

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

    int n,k;
    cin >> n >> k;
    vector<int> arr(n);
    vector<int> dp(n,INF);
    F0R(i,n) cin >> arr[i];
    dp[0]=0;
    FOR(i,1,n)
    {
        FOR(j,1,k+1)
        {
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i-j]-arr[i]));
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}


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

char c[21][21];
int w, h;
int sy, sx;
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
bool f[21][21];
int ans = 0;

void dfs(int y, int x){
    f[y][x] = true;
    ans++;
    for(int i = 0; i < 4; i++){
        int newy = y + dy[i];
        int newx = x + dx[i];
        if(0 <= newy && newy < h && 0 <= newx && newx < w && f[newy][newx] == false && c[newy][newx] != '#'){
            dfs(newy, newx);
        }
    }
    return;
}

int main(){
    while(cin >> w >> h, w, h){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> c[i][j];
                if(c[i][j] == '@'){
                    sy = i;
                    sx = j;
                }
                f[i][j] = false;
            }
        }
        ans = 0;
        dfs(sy, sx);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3024
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
#define ll long long
using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    priority_queue<ll> que;
    for (ll i=0; i<n; i++){
        ll p;
        cin>>p;
        que.push(p);
    }
    
    for (ll i=0; i<m; i++){
        ll p=que.top();
        que.pop();
        p/=2;
        que.push(p);
    }
    
    ll sum=0;
    for (ll i=0; i<n; i++){
        sum+=que.top();
        que.pop();
    }
    
    cout<<sum<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=(1<<19);
int n;
int A[20],B[20];
int cbit[maxn];
int dp[maxn][19];
void update(int &a,int b)
{
	if(a==-1||a>b)a=b;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&B[i]);
	}
	for(int msk=0;msk<(1<<n);msk++)
	{
		cbit[msk]=0;
		for(int i=0;i<n;i++)
		{
			if(msk>>i&1)cbit[msk]++;
		}
	}
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
		dp[1<<i][i]=i;
	for(int msk=1;msk<(1<<n);msk++)
	{
		for(int i=0;i<n;i++)if(msk>>i&1)
		{
			if(dp[msk][i]==-1)continue;
			int val=(((cbit[msk]-1)&1)==(i&1))?A[i]:B[i];
			int sta=(cbit[msk]-1)&1;
			int meet=0;
		//	cout<<msk<<" "<<i<<" "<<val<<" "<<sta<<" "<<dp[msk][i]<<endl;
			for(int j=0;j<n;j++)if(!(msk>>j&1))
			{
				if((j&1)==sta)//B
				{
				//	cout<<j<<" "<<B[j]<<endl;
					if(B[j]>=val)
					{
						update(dp[msk|(1<<j)][j],dp[msk][i]+meet);
					}
				}
				else
				{
				//	cout<<j<<" "<<A[j]<<endl;
					if(A[j]>=val)
					{
						update(dp[msk|(1<<j)][j],dp[msk][i]+meet);
					}
				}
				meet++;
			}
		}
	//	system("pause");
	}
	int ans=-1;
//	cout<<(1<<n)-1<<endl;
	for(int i=0;i<n;i++)
	{
		if(dp[(1<<n)-1][i]==-1)continue;
		update(ans,dp[(1<<n)-1][i]);
//		cout<<dp[(1<<n)-1][i]<<endl;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  map<char, int> w;
  for (int i = 0; i < n; ++i) {
    w[s[i]]++;
  }
  if (w['R'] > w['B']) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<char> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  if(data.at(K-1) == 'A'){
    data.at(K-1) = 'a';
  }else if(data.at(K-1) == 'B'){
    data.at(K-1) = 'b';
  }else if(data.at(K-1) == 'C'){
    data.at(K-1) = 'c';
  }
  for(int i = 0; i < N; i++){
    cout << data.at(i);
  }

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	char c;

	scanf("%c", &c);

	printf("%s\n", c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant");

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a > 0) cout << "Positive" << endl;
    else if(b >= 0) cout << "Zero" << endl;
    else if((b-a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
}


Measured memory_bytes: 3620
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

x,y = inm()
if abs(x-y)<=1:
  print('Brown')
else:
  print('Alice')



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

using namespace std;

struct UnionFind
{
    vector<int> par;

    UnionFind(int N)
    {
        par = vector<int>(N,-1);
    }

    int root(int A)
    {
        if(par[A]<0) return A;
        return par[A]=root(par[A]);
    }

    int size(int A)
    {
        return -par[root(A)];
    }

    bool connect(int A,int B)
    {
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B))
        {
            swap(A,B);
        }
        par[A]=par[A]+par[B];
        par[B]=A;
        return true;
    }

    bool same(int x,int y){return root(x)==root(y);}
};

vector<int> to[100005];
int deg[100005]={0};

int main()
{
    int N,M,K;cin >> N >> M >> K;
    UnionFind uf(N);
    for(int i=0;i<M;++i)
    {
        int a,b;
        cin >> a >> b;
        --a;--b;
        deg[a]++;
        deg[b]++;
        uf.connect(a,b);
    }
    for(int j=0;j<K;++j)
    {
        int a,b;cin >> a >> b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    for(int i=0;i<N;++i)
    {
        int res = uf.size(i)-1-deg[i];
        for(int u=0;u<to[i].size();++u)
        {
            if(uf.same(i,to[i][u])) --res;
        }
        if(i!=N-1) cout<<res<<" ";
         else cout << res << endl;
    }
}

Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
int main()
{
    int n,i,a;
    int a_max=0,arr_max=0;
   
    cin >> n;                       //scanf("%d",&n);
    vector<int> arr(100001,0);      //int b[100001]={0};
    
    for(i=0;i<n;i++)
    {
        cin >> a;                   //scanf("%d",&a);
        if(a_max<a)
        {
            a_max=a;
        }
        arr[a]++;
        
        if(a!=0)
        {
            arr[a-1]++;
        }
        if(a<100000)
        {
            arr[a+1]++;
        }
    }
    
    for(i=0; i < a_max+1; i++)
    {
        if(arr_max<arr[i])
        {
            arr_max=arr[i];
        }
    }
    
    cout << arr_max << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
ll a[1 << 17];
ll ra[2][1 << 17];
ll s[1 << 17];
int n, q;
bool can(ll x, int id) {
	ll dif = a[id] - x;
	int le = lower_bound(a, a + n, x - dif) - a;
	bool res = false;
	return id - le + 1 <= n - id - 1;
}
int main() {
	cin >> n >> q;
	rep(i, n)cin >> a[i];
	rep(i, n)s[i + 1] = s[i] + a[i];
	rep(i, n) {
		if (i % 2==0) {
			ra[0][i + 1] = ra[0][i] + a[i];
			ra[1][i + 1] = ra[1][i];
		}
		else {
			ra[1][i + 1] = ra[1][i] + a[i];
			ra[0][i + 1] = ra[0][i];
		}
	}
	rep(i, q) {
		ll x; cin >> x;
		int le = lower_bound(a, a + n, x) - a; int ri = n;
		if (le == n)le--;
		while (ri - le > 1) {
			int mid = (ri + le) / 2;
			if (can(x, mid))le = mid;
			else ri = mid;
		}
		if (!can(x, le))le--;
		int num = n - le - 1;
		int id = lower_bound(a, a + n, x - (a[le] - x)) - a;
		if (x > a[le])id = le;
		int num2 = le - id + 1;
		int lle = max(id - (num - num2),0);
		cout << s[n] - s[le + 1] + ra[(lle % 2) ^ 1][lle] << endl;
	}
	//stop
		return 0;
}


Measured memory_bytes: 5376
A, B, C, X, Y = map(int, input().split())

# Aピザ, Bピザのみ
ans1 = A * X + B * Y

# ABピザのみ
ans2 = C * max(X, Y) * 2

# ABピザとAピザ, Bピザ
if X > Y:
    ans3 = C * Y * 2 + A * (X - Y)
else:
    ans3 = C * X * 2 + B * (Y - X)

print(min(ans1, ans2, ans3))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#if 1
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

long func(long a, long b){
	long long q =  ((long long)a*a - (long long)b*b); 
	long long p =  ((long long)2*((long long)a-b));

	if( q % p != 0 ){
		return -1;
	}
	else{
		return q / p;
	}

}

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

	int x,y,z;
	x = a+b;
	y = a-b;
	z = a*b;

	int maxval = x;
	if(maxval < y) maxval = y;
	if(maxval < z) maxval = z;

	cout << maxval << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int T,n,t[210000];
    scanf("%d %d",&n,&T);
    for(int i=0;i<n;i++){
        scanf("%d",&t[i]);
    }
    int dt,ans=0;
    for(int i=0;i<n-1;i++){
        dt=t[i+1]-t[i];
        if(dt>T)ans+=T;
        else ans+=dt;
    }
    printf("%d\n",ans+T);
    return 0;
}


Measured memory_bytes: 896
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n - 1]);
    let mut a_v = vec![0usize; n];
    for v in a {
        a_v[v - 1] += 1;
    }

    let ans = a_v.iter().take(n).join("\n");
    println!("{}", ans);
}


Measured memory_bytes: 6288
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

    ll ans = a[0] / 2;
    a[0] %= 2;
    for (int i = 1; i < n; ++i) {
        if (a[i - 1] == 1 && a[i] > 0) {
            ++ans;
            --a[i];
        }
        ans += a[i] / 2;
        a[i] %= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import math

A, B, H, M = map(int, input().split())

theta_m = (math.pi * 2 * (M/60)) 
theta_h = (math.pi * 2 * (H/12)) + (math.pi/6 * (M/60))

theta = abs(theta_h - theta_m)

Ax, Ay = A *  math.cos(theta), A * math.sin(theta)
Bx, By = B, 0.0

print(math.sqrt(((Ax - Bx) ** 2) + ((Ay - By) ** 2)))


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

struct edge { int from, to, cost; };

bool comp(const edge &e1, const edge &e2) {
  return e1.cost < e2.cost;
}

typedef pair<long long, int> plli;

int parent[10000];
int rnk[10000];
void init(int n) {
  for (int i=0; i<n; i++) {
    parent[i] = i;
    rnk[i] = 0;
  }
}

int find(int i) {
  if (parent[i] == i) {
    return i;
  }
  return parent[i] = find(parent[i]);
}
void unite(int i, int j) {
  i = find(i);
  j = find(j);
  if (rnk[i] < rnk[j]) {
    parent[i] = j;
  } else {
    parent[j] = i;
    if (rnk[i] == rnk[j]) {
      ++rnk[i];
    }
  }
}
int main() {
  int n, m;
  cin>>n>>m;
  vector<edge> edges;
  for (int i=0; i<m; i++) {
    int s, t, d;
    cin>>s>>t>>d;
    edges.push_back({s, t, d});
  }
  init(n);
  sort(edges.begin(), edges.end(), comp);

  long long sum= 0;
  for (auto e: edges) {
    if (find(e.from) == find(e.to)) {
      continue;
    }
    sum += e.cost;
    unite(e.from, e.to);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 4600
from collections import Counter

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

S = sum(A)
cntA = Counter(A)

for _ in range(Q):
    B, C = map(int, input().split())
    D = C - B
    S += D * cntA[B]
    cntA[C] += cntA[B]
    cntA[B] = 0

    print(S)

Measured memory_bytes: 24108
#include <iostream>
#include <map>
using namespace std;
const int MAXN = 1010;
int w[MAXN];
bool done[MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, mini = 100000;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        mp[w[i]] = 0;
        mini = min(mini, w[i]);
    }
    {
        int k = 0;
        for (auto& p : mp) p.second = k++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (done[i]) continue;
        int cnt = 0, now = i, mi = 100000, sum = 0;
        while (1) {
            if (done[now]) break;
            cnt++;
            done[now] = true;
            mi = min(mi, w[now]);
            sum += w[now];
            now = mp[w[now]];
        }
        int tmp = sum+(cnt-2)*mi;
        tmp = min(tmp, sum+mi+mini*(cnt+1));
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3240
use proconio::*;
fn main() {
    input! {
        n :usize,
        ar : [i64; n],
    }

    let mut forward = 0i64;
    let mut res = 0;
    for person in ar {
        if person > forward {
            forward = person;
        } else {
            res += forward - person;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 5488
n=int(input())
if n==0:
  print(0)
  exit()
ans=[]
for i in range(10**5):
  if n==0:
    break
  k=n%(pow(2,i+1))
  if k==0:
    ans.append(0)
  else:
    ans.append(1)
    n-=pow(-2,i)
ans.reverse()
print("".join(map(str,ans)))

Measured memory_bytes: 3060
n,a,b=(int(x) for x in input().split())
t=0
c=1
while c<=n:
    d=str(c)
    e=list(d)
    f=0
    for x in e:
        f=f+int(x)
    if f>=a:
        if f<=b:
            t=t+c
    c=c+1
print(t)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    static final long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t[] = new int[n];
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Data tdata[] = new Data[n];
        Data adata[] = new Data[n];
        tdata[0] = new Data(t[0], t[0]);
        for (int i = 1; i < n; i++) {
            if (t[i - 1] != t[i]) {
                tdata[i] = new Data(t[i], t[i]);
            } else {
                tdata[i] = new Data(1, t[i]);
            }
        }
        adata[n - 1] = new Data(a[n - 1], a[n - 1]);
        for (int i = n - 2; i >= 0; i--) {
            if (a[i] != a[i + 1]) {
                adata[i] = new Data(a[i], a[i]);
            } else {
                adata[i] = new Data(1, a[i]);
            }
        }
        sc.close();
        long ans = 1;
        for (int i = 0; i < n; i++) {
            int count = commonCount(tdata[i], adata[i]);
            if (count == -1) {
                System.out.println(0);
                return;
            } else {
                ans = (count * ans) % mod;
            }
        }
        System.out.println(ans);

    }

    static int commonCount(Data d1, Data d2) {
        if (d1.min > d2.max || d1.max < d2.min) {
            // 共通範囲が存在しない
            return -1;
        } else {
            int max = Math.min(d1.max, d2.max);
            int min = Math.max(d1.min, d2.min);
            return max - min + 1;
        }
    }
}

class Data {
    int min, max;

    Data(int min, int max) {
        this.min = min;
        this.max = max;
    }

}


Measured memory_bytes: 87392
#include <iostream>
#include <vector>
#include <set>

using namespace std;

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

    vector<set<int>> edges(n);

    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--,  b--;
        edges[a].insert(b);
        edges[b].insert(a);
    }
    bool flag = false;

    for(int i=1;i<n-1;i++){
        if(edges[0].count(i) && edges[i].count(n-1))
            flag = true;
    }
    cout << (flag?"POSSIBLE":"IMPOSSIBLE") << endl;


    return 0;
}


Measured memory_bytes: 28416
import java.util.Scanner;

class Main {

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

		int x = sc.nextInt();
		
		int sum;
		int t = 0;

		for(int i=1; i<=x; i++){
			sum = i * (i+1) / 2; 
			if(x<=sum){
				t = i;
				break;
			}
		}

		System.out.println(t);
		
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
struct dessert{
  ll x, y, z;
  dessert(ll a, ll b, ll c) {
    x = a;
    y = b;
    z = c;
  }
};
vector<dessert> data;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    ll x, y, z;
    cin >> x >> y >> z;
    data.push_back(dessert(x, y, z));
  }
  ll aans = -1e18;
  for (int i = 0; i < 8; i++) {
    int bit = i;
    int a, b, c;
    a = (bit&1 ? 1: -1);
    bit >>= 1;
    b = (bit&1 ? 1: -1);
    bit >>= 1;
    c = (bit&1 ? 1: -1);
    vector<ll> d;
    for (int j = 0; j < n; j++) {
      d.push_back(data[j].x * a + data[j].y * b + data[j].z * c);
    }
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    for (int j = 0; j < m; j++) {
      ans += d[j];
    }
    aans = max(aans, ans);
  }
  cout << aans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

vector<P> getPrimeFactors(ll n) {
  vector<P> p;

  if (n == 0) return p;

  p.push_back(P(1, 1));

  ll num = n;
  for (ll i = 2; i * i <= n; i++) {
    if (num % i != 0) continue;

    ll cnt = 0;

    while (num % i == 0) {
      num /= i;
      cnt++;
    }

    p.push_back(P(i, cnt));

    if (num == 1) break;
  }

  if (num != 1) {
    p.push_back(P(num, 1));
  }

  return p;
}

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

  ll n, p;
  cin >> n >> p;

  auto v = getPrimeFactors(p);

  ll ans = 1;
  for (auto pr : v) {
    ll num = pr.first;
    ll cnt = pr.second;

    for (int j = 0; j < cnt / n; j++) {
      ans *= num;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,z;
  scanf("%d", &x);
  
  y = x % 1000;
  
  if (y == 0)
    z = y;
  else
    z = 1000 - y;
  
  printf("%d", z);
  
  return 0;
  
}



Measured memory_bytes: 1708
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] A = new int[n];

        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }

        int v = 0;
        int k = 0;

        int cnt = 0;
        int m = 1;

        ArrayList<Integer> G = new ArrayList<Integer>();
        while (true) {
            G.add(m);

            m = 2 * (m + 1) - 1;

            if (m > n) {
                break;
            }
        }
        Collections.reverse(G);

        for (int i = 0; i < G.size(); i++) {
            for (int j = G.get(i); j < n; j++) {
                v = A[j];
                k = j - G.get(i);
                while (k >= 0 && A[k] > v) {
                    A[k + G.get(i)] = A[k];
                    k = k - G.get(i);
                    cnt++;
                }
                A[k + G.get(i)] = v;
            }
        }

        System.out.println(G.size());
        for (int l = 0; l < G.size() - 1; l++) {
            System.out.print(G.get(l));
            System.out.print(" ");
        }
        System.out.println(G.get(G.size() - 1));

        System.out.println(cnt);
        for (int l = 0; l < n; l++) {
            System.out.println(A[l]);
        }

    }
}


Measured memory_bytes: 299500
n, k = map(int, input().split())
s = input()
s += "@" # banpei
ans, tmp = 0, 0
r, l = 0, 0
t, j = 0, 0
d = {}
cnt = 0
while True:
    bit = s[r] # current bit
    if bit == "@": # archive last, break
        tmp = r - l
        ans = max(ans, tmp)
        break
    if bit == "1":
        tmp = r - l + 1
        ans = max(ans, tmp)
    else:
        if cnt == k:
            l = d[j]; j += 1
            cnt -= 1

        while s[r+1] == "0":
            r += 1
        d[t] = r+1; t += 1
        cnt += 1

    r += 1 # move right

print(ans)


Measured memory_bytes: 45548
def main():
    n,Q = map(int,input().split())
    s = input()
    q =[]
    for i in range(Q) :
        l,r=map(int,input().split())
        q.append([l-1,r-1])
    sum_ary = [0] * n

    for i in range(1,n):
        sum_ary[i] = sum_ary[i-1]
        if s[i] == 'C' and s[i-1] == 'A':
            sum_ary[i] += 1

    for i,query in enumerate(q):
        print(sum_ary[query[1]] - sum_ary[query[0]])
if __name__ == '__main__':
    main()


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


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

        ll a,b;
        cin>>a>>b;

        ll ans = (a*b)/__gcd(a,b);
        cout<<ans<<endl;
    timer();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n+1);
    vector<ll> b(m+1);
    vector<ll> psa(n+1,0);
    vector<ll> psb(m+1,0);
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        psa[i] = psa[i-1] + a[i];
    }
    for(ll i=1;i<=m;i++){
        cin>>b[i];
        psb[i] = psb[i-1] + b[i];
    }
    ll ans = 0;
    for(ll i = 0;i<=n;i++){
        ll x = k - psa[i];
        if(x < 0){
            break;
        }
        ll low = 1,high = m,y = 0;
        while(low<=high){
            ll mid = (low+high)/2;
            if(psb[mid]<=x){
                y = mid;
                low = mid + 1;
            }else{
                high = mid - 1;
            }
        }
        ans = max(ans,i+y);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9604
#include<stdio.h>
int main(void)
{
    int n,k,h[100000],i,count = 0;
    scanf("%d %d",&n,&k);
    for(i = 0 ; i < n ; i++)
    {
        scanf("%d",&h[i]);
    }
    for(i = 0 ; i < n ; i++)
    {
        if(h[i] >= k)
        {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 2076
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String a = "";
    String b = "";

    for (int i=0;i<m;i++){
      a += n+"";
    }

    for (int j=0;j<n;j++){
      b += m+"";
    }

    if (n>=m){
      System.out.println(b);
    }
    else{
      System.out.println(a);
    }
  }
}


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

int main(){
    
    int a, b; cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; ; i++){
        if( (i-1)*(a-1) + a >= b ){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn christmasEveEveEve() -> String {

    let mut d = String::new();
    io::stdin().read_line(&mut d).unwrap();
    let d = d.trim_right().parse::<i32>().unwrap();

    let mut ans = String::from("Christmas");
    for _ in 0..(25 - d) {
        ans.push_str(" Eve");
    }
    ans
}

fn main() {
    let ans = christmasEveEveEve();
    println!("{}", ans);
}


Measured memory_bytes: 4352