akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, int>PP;
int a[3005];
int fac[3005];
int dp[3005][3005];
int ans[3005];
int cpy[3005], cpy2[3005];
int modpow(int a, int x, int mod) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x /= 2;
	}
	return res;
}

signed main() {
	int p; cin >> p;
	rep(i, p)cin >> a[i];
	fac[0] = 1;
	rep(i, p)fac[i + 1] = fac[i] * (i + 1) % p;

	dp[0][1] = 1;
	for (int i = 1; i < p; i++) {
		rep(j, p + 1)dp[i][j + 1] += dp[i - 1][j];
		rep(j, p + 1) {
			dp[i][j] -= i*dp[i - 1][j]%p;
			dp[i][j] = (dp[i][j] + p) % p;
		}
	}

//	rep(i, p+1)cout << dp[p - 1][i] << ' '; cout << endl;

	for(int i=0;i<p;i++) {
		if (a[i]) {
			rep(j, p+1)cpy[j] = dp[p - 1][j];
			fill(cpy2, cpy2 + p + 1, 0);
			for (int j = p - 1; j >= 0; j--) {
				cpy2[j] += cpy[j + 1];
				cpy[j] += cpy[j + 1] * i;
				cpy[j + 1] = 0;
				cpy[j] %= p;
			}
			fill(cpy, cpy + p + 1, 0);
			int np = fac[i] * fac[p - i - 1] % mod;
			if ((p - i - 1) & 1)np = (p - np) % p;
			int npi = modpow(np, p - 2, p);
			npi = (i - npi + p) % p;
			rep(j, p+1) {
				cpy[j + 1] += cpy2[j];
				cpy[j] -= cpy2[j] * npi%p;
				cpy[j] = (cpy[j] + p) % p;
			}
/*
			cout << i << ": "  ;
			rep(j, p)cout << cpy[j] << ' ';
			cout << endl;
*/
			rep(j, p+1) {
				ans[j] += cpy[j];
				ans[j] %= p;
			}
		}
	}
	ans[1] += ans[p];
	rep(i, p) {
		if (i)cout << ' '; cout << ans[i]%p;
	}
	cout << endl;
}

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


int main(){
	int n;
	cin>>n;
	long long ans1=0,ans2=0;
	while(n--){
		long long a,b;
		cin>>a>>b;
		if(ans1==0&&ans2==0) {
			ans1=a;
			ans2=b;
		}
		
		else{
			if(a>=ans1&&b>=ans2){
				ans1=a;
				ans2=b;
			}
			else{
				long long p,q;
				p=ans1/a;
				q=ans2/b;
				if(ans1%a!=0) p++; 
				if(ans2%b!=0) q++; 
				p=max(p,q);
				
				ans1=p*a;
				ans2=p*b;
			}
		}
		
	}
	cout<<ans1+ans2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N, Q;
    int mark[100001];
    int tree[100001];
    while (1) {
        cin >> N >> Q;
        if (N == 0 && Q == 0) {
            break;
        }

        fill_n(mark, 100001, 0);
        mark[1] = 1; 
        tree[1] = 0;
        for (int i=2; i<=N; ++i) {
            cin >> tree[i];
        } 

        long long sum = 0;
        for (int i=0; i<Q; ++i) {
            char ope;
            int v;
            cin >> ope >> v;
            if (ope == 'Q') {
                for (int j=v; j>=1; j=tree[j]) {
                    if (mark[j] == 1) {
                        sum += j;
                        break;
                    }
                }
            } else if (ope == 'M') {
                mark[v] = 1;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1936
#include <iostream>
#include <unordered_set>

using namespace std;

int main()
{
    unordered_set<long> USet;

    long N;
    long input;
    long A = 0;
    long B = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> input;
        if (USet.find(input) == USet.end())
        {
            USet.emplace(input);
        }
        else
        {
            if (input > A || input > B)
            {
                USet.erase(input);
                if (A > B)
                {
                    B = input;
                }
                else
                {
                    A = input;
                }
            }
        }
    }

    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 4388
import math
from functools import reduce
import itertools
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd,numbers)
ans=0
for i,j,m in itertools.product(range(1,k+1),range(1,k+1),range(1,k+1)):
    ans+=gcd(i,j,m)
print(ans)

Measured memory_bytes: 69272
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string st;
    cin>>st;
    int x=stoi(st);
    int y=0;
    REP(i,st.length()){
        y+=stoi(st.substr(i,1));
    }
    if(!(x%y)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    COUT("Cloudy");
  }
  else if (s == "Cloudy") {
    COUT("Rainy");
  }
  else if (s == "Rainy") {
    COUT("Sunny");
  }
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k, a[100010], ans = 1e9;
int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i <= n - k; i++)
    {
        int l = min(a[i], 0), r = max(a[i + k - 1], 0);
        ans = min(ans, r - l * 2);
        ans = min(ans, r * 2 - l);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<int> ans(N);
    int length = 0;
    rep(i,N) {
        if (i == 0) ans[i] = A[0];
        else {
            if (A[i] > ans[length]) {
                ans[length+1] = A[i];
                length++;
            } else {
                int k = lower_bound(ans.begin(),ans.begin()+length,A[i]) - ans.begin();
                ans[k] = A[i];
            }
        }
    }

    cout << length + 1 << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N;
	cin >> N;

	vector<double> x(N);
	vector<bool> u(N);

	for (ll i = 0; i < N; ++i)
	{
		cin >> x[i];
		string s;
		cin >> s;
		if (s == "JPY")
		{
			u[i] = true;
		}
		else
		{
			u[i] = false;
		}
	}

	double ans = 0;

	for (ll i = 0; i < N; ++i)
	{
		ans += u[i] ? x[i] : x[i] * 380000.0;
	}

	printf("%10.10lf\n", ans);

	//system("pause");
}

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

int main()
{
    ll n;
    vector<ll> tran(5);
    vector<pair<ll, int>> index(5);
    cin >> n;
    for (int i = 0; i < 5; i++)
    {
        cin >> tran[i];
        index[i] = make_pair(tran[i], i);
    }

    //ボトルネックから先は全員最短時間で移動できる
    //ボトルネックまでは先頭が到達してから最後が到達するまでに空で輸送されることはない
    sort(index.begin(), index.end());
    int bn = index[0].second;

    ll ans = 0;
    for (int i = 0; i < 5; i++)
    {
        if (i != bn)
        {
            ans += 1;
        }
        else
        {
            ans += (n + tran[i] - 1) / tran[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	cout << b + max((int)0, 10 - a) * 100 << endl;
}


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

int main () {
  string s;
  cin >> s;
  if (s.at(0) == 'S') cout << "Cloudy" << endl;
  if (s.at(0) == 'C') cout << "Rainy" << endl;
  if (s.at(0) == 'R') cout << "Sunny" << endl;
}

Measured memory_bytes: 256
import collections

def fact(N):
    arr = []
    i=2
    while i*i<=N:
        if N%i==0:
            while N%i==0:
                arr.append(i)
                N//=i
        i+=1
    if N>1:
        arr.append(N)
    return arr

N=int(input())
arr = []
for i in range(1,N+1):
    arr += fact(i)
#print(arr)
arc=collections.Counter(arr)
num74cnt=0
num24cnt=0
num14cnt=0
num4cnt=0
num2cnt=0
for val in arc.values():
    if val >=74:
        num74cnt+=1
    if val >=24:
        num24cnt+=1
    if val >=14:
        num14cnt+=1
    if val >= 4:
        num4cnt+=1
    if val >= 2:
        num2cnt +=1
ans = num74cnt
ans += num24cnt*(num2cnt-1)
ans += num14cnt*(num4cnt-1)
ans += num4cnt*(num4cnt-1)//2*(num2cnt-2)

print(ans)


Measured memory_bytes: 9508
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define LL long long
#define MOD 1000000007

LL mod_pow(LL x,LL n,LL mod){
    if (n == 0) {
        return 1;
    }
    LL res = mod_pow(x * x % mod, n / 2, mod);
    if (n & 1) {
        res = res*x %mod;
    }
    return res;
}

LL mul(LL l, LL r){
    LL ret = 1;
    for (int i = 0; i < l - r + 1; i++) {
        ret *=i + r;
        ret %= MOD;
    }
    return ret;
}

LL comb(LL n,LL x){
    LL ret1 = mul(n,n-x+1);
    LL ret2 = mul(x,1);
    LL ret3 = mod_pow(ret2,MOD-2,MOD);
    return ret1 * ret3  % MOD;
}


int main(void){
    int n,a,b;
    scanf("%d %d %d", &n,&a,&b);
    LL ans =  mod_pow(2,n,MOD) - 1 - comb(n,a) - comb(n,b);   
    for(;;){
        if (ans >= 0) {
            break;
        }
        ans += MOD;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
   int n;
   cin >> n;
   vector <int> h(n);
   for (int i = 0; i < n; i++)
   {
       cin >> h[i];
   }
   vector <int> dp(n, 1000000000);
   dp[0] = 0;
   for (int i = 0; i < n; i++)
   {
       for (int j = i + 1; j < i + 3; j++)
       {
           if (j < n)
           {
               dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
           }
       }
   }
   cout << dp[n - 1];
    return 0;
}

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

int main(){
    size_t H, W, d;
    cin >> H >> W >> d;
    for(size_t i = 0; i < H; ++i, fputc('\n', stdout))for(size_t j = 0; j < W; ++j)fputc("RGBY"[((i + i + j + j) / d & 2) + ((i + W - j) / d & 1)], stdout);
    return 0;
}

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

char conv[128];

void make() {
  for(int i = 0; i < 128; ++i) conv[i] = i;
}

main() {
  int n, m;
  while((cin >> n) && n) {
    make();
    for(int i = 0; i < n; ++i) {
      char a, b;
      cin >> a >> b;
      conv[a] = b;
    }
    cin >> m;
    for(int i = 0; i < m; ++i) {
      char c;
      cin >> c;
      cout << conv[c];
    }
    cout << endl;
  }
}

Measured memory_bytes: 852
using System;
using System.Text;

public class Test
{
	static public void Main( )
	{	
		int n = int.Parse( Console.ReadLine() );
		int[,,] oh = new int[ 4, 3, 10 ];
		for( int i=0; i<n; i++ ) {
			string[] strs = Console.ReadLine().Split( ' ' );
			int b = int.Parse( strs[0] )-1;
			int f = int.Parse( strs[1] )-1;
			int r = int.Parse( strs[2] )-1;
			
			oh[ b, f, r ] += int.Parse( strs[3] );
		}
		StringBuilder output = new StringBuilder();
		for( int i=0; i<4; i++ ) {
			for( int j=0; j<3; j++ ) {
				for( int k=0; k<10; k++ ) {
					output.Append( string.Format( " {0}", oh[ i, j, k ] ) );
				}
				output.Append( "\n" );
			}
			if( 3 != i ) { output.AppendLine( "####################" ); }
		}
		Console.Write( output );
	}
}

Measured memory_bytes: 5688
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll n; cin >> n;
        if(!n) break;
        vl a(n); rep(i,n) cin >> a[i];
        sort(all(a));
        ll ans = linf;
        rep(i,n-1){
            chmin(ans,a[i+1]-a[i]);
        }
        cout << ans << endl;
    }
}


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

using namespace std;

using int64 = long long;

int dp[201][101];

int rec(int w, int b) {
  if(~dp[w][b]) return dp[w][b];
  set< int > grundy;
  if(w > 0) grundy.emplace(rec(w - 1, b));
  for(int i = 1; i <= w; i++) {
    if(b - i >= 0) grundy.emplace(rec(w, b - i));
  }
  if(b > 0) grundy.emplace(rec(w + 1, b - 1));
  int beet = 0;
  while(grundy.count(beet)) ++beet;
  return dp[w][b] = beet;
}

int main() {
  int N;
  memset(dp, -1, sizeof(dp));
  cin >> N;
  int uku = 0;
  while(N--) {
    int w, b;
    cin >> w >> b;
    uku ^= rec(w, b);
  }
  cout << (uku == 0) << endl;
}




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

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


Measured memory_bytes: 3028
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define MAX 305
using namespace std;

int C[MAX],V[MAX],D[MAX],L[MAX];
int n,cost;
int dp[MAX][MAX];


int recv(int i,int j){
  if(dp[i][j] != -1) return dp[i][j]; 
  if(i == n )return 0;
  int res =0;
  //if(j < C[i])return recv(i+1,j);
  //else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*V[i]+recv(i+1,j-k*C[i]));
    }
    //}
  
  return dp[i][j]=res;
}
int recd(int i,int j){
  if(dp[i][j] != -1) return dp[i][j]; 
  if(i == n )return 0;
  int res =0;
  //if(j < C[i])return recd(i+1,j);
  //else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*D[i]+recd(i+1,j-k*C[i]));
    }
    //}
  
  return dp[i][j]=res;
}
int recl(int i,int j){
  if(dp[i][j] != -1) return dp[i][j]; 
  if(i == n )return 0;
  int res =0;
  //if(j < C[i])return recl(i+1,j);
  //else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*L[i]+recl(i+1,j-k*C[i]));
    }
    //}
  
  return dp[i][j]=res;
}



int main(){

  int iori,chihaya=0,makoto=0,miki=0;


  while( cin >> n >> cost ){

    for(int i=0;i<n;i++){
      char ch = getchar();
      while((ch=getchar())!='\n');
      cin >> C[i] >> V[i] >> D[i] >> L[i];
    }

    memset(dp,-1,sizeof(dp));
    chihaya = (chihaya,recv(0,cost));
    //cout << "DEBUG V = " << chihaya << endl;
    /*
    for(int i=0;i < 10;i++){
      for(int j=0;j<10;j++)cout << dp[i][j] << " " ;
      cout << endl; 
    }
    */
    memset(dp,-1,sizeof(dp));
    makoto = recd(0,cost);
    //cout << "DEBUG D = " << makoto << endl;
    memset(dp,-1,sizeof(dp));
    miki = recl(0,cost);
    //  cout << "DEBUG L = " << miki << endl;

    iori=max(chihaya,max(makoto,miki));

    cout << iori << endl;

  }
  return 0;
}

Measured memory_bytes: 1240
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {

  static int n;
  static int[] a;

  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    in = br.readLine().split(" ");
    a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    Heap h = new Heap(a);
    
    br.close();

    h.buildMaxHeap();

    for(int i = 0; i < h.length; i++){
      System.out.print(" " + h.ar[i]);
    }
    System.out.println();
  }
}


class Node {
  int v;
  Node p, l, r;

  Node(int v){
    this.v = v;
  }
}

class Heap {

  static final int INITIAL_VAL = Integer.MIN_VALUE;
  int length;
  int[] ar;

  Heap(int n){
    this.length = n;
    this.ar = new int[n];
    Arrays.fill(ar, INITIAL_VAL);
  }

  Heap(int[] ori){
    this.length = ori.length;
    this.ar = ori.clone();
  }

  // MUST be tested
  // data in "ar" may be LOST
  //   when newSize < length
  public void resize(int newSize){
    int[] newAr = new int[newSize];
    for(int i = 0; i < Math.min(length, newSize); i++){
      newAr[i] = ar[i];
    }
    ar = newAr;
  }

  public void buildMaxHeap(){
    for(int i = length / 2; i >= 0; i--){
      maxHeapify(i);
    }
    return;
  }

  public void maxHeapify(int idx){
    int lIdx = 2 * idx + 1, rIdx = 2 * idx + 2;
    int largest = idx;

    if(lIdx < length && ar[lIdx] > ar[idx]){
      largest = lIdx;
    }
    if(rIdx < length && ar[rIdx] > ar[largest]){
      largest = rIdx;
    }

    if(largest != idx){
      int tmp = ar[idx];
      ar[idx] = ar[largest];
      ar[largest] = tmp;
      maxHeapify(largest);
    }
    return;
  }

  @Override
  public String toString() {
    StringBuilder ret = new StringBuilder("length = " + length + ",\n{ ");
    for(int i = 0; i < length; i++){
      if(i > 0) ret.append(", ");
      ret.append(ar[i]);
    }
    ret.append(" }");
    return ret.toString();
  }

}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<int, int> P;

void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int rec(int l, int r, int pos, vector<int> &preorders, vector<int> &inorders, vector<int> &postorders) {
    if (l >= r) return pos;
    int root = preorders[pos];
    pos++;
    int m = distance(inorders.begin(), find(inorders.begin(), inorders.end(), root));
    pos = rec(l, m, pos, preorders, inorders, postorders);
    pos = rec(m + 1, r, pos, preorders, inorders, postorders);

    postorders.push_back(root);
    return pos;
}

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

    vector<int> preorders(n);
    vector<int> inorders(n);
    vector<int> postorders;
    rep(i, n) cin >> preorders[i];
    rep(i, n) cin >> inorders[i];

    rec(0, n, 0, preorders, inorders, postorders);

    print_line(postorders);
}




Measured memory_bytes: 3160
#include <cstdio>
int main(){
	int s,l[31]={0},n=28;
	while(n--){
		scanf("%d",&s);
		l[s] = 1;
	}
	for(int i=1;i<31;i++){
		l[i]?:printf("%d\n",i);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int x, y, z, d;
  scanf("%d", &x);
  scanf("%d", &y);
  if(x < y){
    z = x;
    x = y;
    y = z;
  }
  while((d = x%y) != 0){
    x = y;
    y = d;
  }
  printf("%d\n", y);
  return 0;
}

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define MAX 500005

template<typename T>
struct SegTree {
  const T INF = numeric_limits<T>::max();
  int n;
  vector<T> dat, lazy;
  SegTree(int _n) : n(), dat(_n*4,INF), lazy(_n*4,0) {
    int x = 1;
    while (x < _n) x <<= 1;
    n = x;
  }
  void set(int i, int x) { dat[i+n-1] = x; }
  void build() { for (int k = n-2; k >= 0; k--) dat[k] = min(dat[k*2+1],dat[k*2+2]); }

  void eval(int k, int p) {
    if (lazy[k] == 0) return;
    if (k < n-1) {
      lazy[k*2+1] += lazy[k];
      lazy[k*2+2] += lazy[k];
    }
    dat[k] = (dat[k] == INF) ? lazy[k] : dat[k] + lazy[k];
    lazy[k] = 0;
  }
  void update(int a, int b, int x, int k, int l, int r) {
    eval(k, r-l);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy[k] += x;
      eval(k, r-l);
    } else {
      int mid = (l+r)>>1;
      update(a,b,x,k*2+1,l,mid);
      update(a,b,x,k*2+2,mid,r);
      dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
  }
  void update(int a, int b, int x) { update(a,b,x,0,0,n); }

  T query(int a, int b, int k, int l, int r) {
    eval(k, r-l);
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return dat[k];
    int mid = (l+r)>>1;
    T vl = query(a,b,k*2+1,l,mid);
    T vr = query(a,b,k*2+2,mid,r);
    return min(vl,vr);
  }
  T query(int a, int b) { return query(a,b,0,0,n); }
  inline T operator[](int a) { return query(a,a+1); }
};

int main(int, char**)
{
  int n, q;
  cin >> n >> q;

  SegTree<int> seg(n);
  rep(i,n) seg.set(i,0);
  seg.build();

  vector<int> ans;
  rep(i,q) {
    int command; cin >> command;
    if (command == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s,t+1,x);
    } else if (command == 1) {
      int s, t; cin >> s >> t;
      ans.push_back(seg.query(s,t+1));
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 6640
n = int(input())
ls = list(map(int,input().split()))
import collections
co = collections.Counter(ls)
ans = 0
for idx,num in co.items():
    ans +=num*(num-1)//2
for i in range(n):
    idx = ls[i]
    num = co[idx]
    if num == 1:
        print(ans)
    else:
        print(ans - num*(num-1)//2 + (num-1)*(num-2)//2)


Measured memory_bytes: 89804
#include "bits/stdc++.h"
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P =pair<int,int>;

int main(){
    int l;
    cin >> l;
    double ans;
    ans=pow(l/3.0,3);
    cout << fixed << setprecision(6) << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    long long int a;
    int two = 0, four = 0, other = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a%4 == 0) {
            four++;
        }
        else if (a%2 == 0) {
            two++;
        }
        else {
            other++;
        }
    }

    if (two == 0) {
        if (four+1 >= other) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        if (four >= other) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  for(int i = 0; i < N; ++i){
    int x;
    cin >> x;
    X = max(X,x);
  }
  for(int i = 0; i < M; ++i){
    int y;
    cin >> y;
    Y = min(Y,y);
  }
  if(X < Y) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
sysread = sys.stdin.readline
sys.setrecursionlimit(10**7)
def run():
    pri = []
    N, A, B, C = map(int, sysread().split())
    vals = {'A':A, 'B':B, 'C':C}
    S = [sysread() for _ in range(N)]

    pri = []
    for idx, s in enumerate(S):
        if vals[s[0]] == vals[s[1]] and vals[s[0]] == 1 and idx !=len(S)-1:
            if s[0] in S[idx+1]:
                vals[s[0]] += 1
                vals[s[1]] -= 1
                pri.append(s[0])
            else:
                vals[s[0]] -= 1
                vals[s[1]] += 1
                pri.append(s[1])
        else:
            if vals[s[0]] <= vals[s[1]]:
                vals[s[0]] += 1
                vals[s[1]] -= 1
                pri.append(s[0])
            else:
                vals[s[0]] -= 1
                vals[s[1]] += 1
                pri.append(s[1])

        if not check_vals(vals):
            print('No')
            return None
    print('Yes')
    for st in pri:
        print(st)

def check_vals(vals):
    for v in vals.values():
        if v < 0:
            return False
    return True

if __name__ == "__main__":
    run()

Measured memory_bytes: 16744
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


n, k = map(int, input().split(), )
a = [ int(x) for x in input().split() ]

g = 0
for aa in a:
    g = gcd(g, aa)

print("POSSIBLE" if k <= max(a) and k%g == 0 else "IMPOSSIBLE")


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

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

    int ans = 0;
    int d1, d10;
    for (int tsumugi = 2; tsumugi <= m; tsumugi++){
        for (int matsuri = 22; matsuri <= d; matsuri++){
            int d1 = matsuri % 10;
            int d10 = matsuri / 10;
            if (d1 == 1){
                continue;
            }
            if (tsumugi == d1 * d10){
                // cout << "Done" << endl;
                // cout << d1 << endl;
                // cout << d10 << endl;
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int len[3],p[3],x,i,j,a;
	char s[3][101];
	for(i=0;i<3;i++)	{
		scanf("%s",s[i]);
		len[i]=strlen(s[i]);
		p[i]=0;
	}
	a=0;
	while(1)	{
		x=s[a][p[a]]-'a';
		p[a]++;
		a=x;
		if(p[a]==len[a])	break;
	}
	printf("%c\n",a+'A');
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
char tolowr(char c) {
  return (c + 0x20);
}

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  S[K-1]=tolowr(S[K-1]);
  cout<<S<<endl;
  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


vector<PI> edges[100100];
li k;

li cost[100100];

inline li dijkstra(li from, li to) {
    rep(i, k)cost[i] = INF;
    priority_queue<PI> pq;
    pq.push({ -1, from});
    while (!pq.empty()) {
        li now_cost = -pq.top().F;
        li now_v = pq.top().S;
        pq.pop();
        if (cost[now_v] <= now_cost) {
            continue;
        }
        cost[now_v] = now_cost;
        //p2(now_v, now_cost);
        if (now_v == to) {
            return now_cost;
        }
        for (auto && edge : edges[now_v]) {
            pq.push({ -now_cost - edge.F, edge.S});
        }
    }
    return INF;
}

int main() {
    cin >> k;
    repp(i, 1, k) {
        edges[i].pb({0, (i * 10) % k});
        edges[i].pb({1, (i + 1) % k});
    }
    cout << dijkstra(1, 0) << endl;
    return 0;
}

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int x;
        cin>>x;
        if(x>=30){
            cout<<"Yes\n";
        }
        else
            cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){
	int n,m,res,min=10000;
	pair<int,int> a[1001];
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	for(int i=0;i<n;i++){
		if(a[i].second<=m&&a[i].first<min){
			min=a[i].first;
		}
	}
	if(min==10000){
		cout<<"TLE";
	}else{
		cout<<min;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<28)
int N;
int t[20][20];
int u[20];
int dp[(1<<16)];
int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    for(int i=0;i<N;i++){
      cin>>u[i];
      for(int j=0;j<N;j++)cin>>t[i][j];
    }
    for(int i=0;i<(1<<N);i++)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<(1<<N);i++){
      for(int j=0;j<N;j++){
	dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+u[j]);
	for(int k=0;k<N;k++)
	  if(i>>k&1)
	    dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+t[j][k]);
      }
    }
    cout<<dp[(1<<N)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
using namespace std;
long long ans=1;
long long n;
int main()
{
    cin>>n;
    long long s=1;
    while(1)
    {
        if(n>=s&&n<s*2)break;
        else
        {s*=2;ans=2*ans+1;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        List<Integer> holeList  = new ArrayList<>();

        for (int i = 0; i < m; i++){
            holeList.add(sc.nextInt());
        }

        long count = 0;
        long countOneBefore = 1;
        long countTwoBefore = 0;

        int holeIndex = 0;
        int holeStair = 0;
        if (holeList.size() != 0){
            holeStair = holeList.get(holeIndex);
        }

        for (int i = 0 ; i < n; i++){

            if (holeStair == (i + 1)){
                // 穴が開いている場合
                count = 0;
                countTwoBefore = countOneBefore;
                countOneBefore = count;

                holeIndex += 1;
                holeStair = holeList.get(Math.min(holeIndex, m - 1));
            }else {
                count = countOneBefore + countTwoBefore;
                if (count >= 1000000007L){
                    count = count % 1000000007L;
                }
                countTwoBefore = countOneBefore;
                countOneBefore = count;
            }
        }

        System.out.println(count);
    }

}

Measured memory_bytes: 59400
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())

ans = 0

if N == 1:
    print(0)
else:
    t = factorization(N)
    for i in t:
        t_ = i[1]
        now = 1
        while True:
            if now > t_:
                break
            ans += 1
            t_ -= now
            now += 1
    print(ans)

Measured memory_bytes: 9496
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        long x = Long.parseLong(lines[0]);
        long sum = 100;
        int year = 0;
            while(sum < x){
                sum = sum + (sum*1/100);
                year++;
            }
        System.out.println(year);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}

Measured memory_bytes: 26944
import copy

N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

MaxIndex = A.index(max(A))

for i in range(N):
    if i != MaxIndex:
        print(A[MaxIndex])
    else:
        B = copy.copy(A)
        del B[MaxIndex]
        print(max(B))


Measured memory_bytes: 14524
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        String[] s = S.split("");
        String[] t = T.split("");
        int count = 0;

        for (int i = 0; i < S.length(); i++) {
            if (!s[i].equals(t[i])) {
                count++;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(count);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 67776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  map<int,int> a;
  for(int i=0;i<n;i++){
    int val;cin>>val;
    a[val]++;
  }
  int ans=0;
  for(auto it:a){
    if(it.first==it.second){
      continue;
    }else if(it.first>it.second){
      ans+=it.second;
    }else{
      ans+=it.second-it.first;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7984
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():
    
    A,B,C =map(int,input().split())
    
    if (A-C)*(B-C)>0:
        print("No")
    else:
        print("Yes")
    



if __name__ == "__main__":
    main()


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

const int N = 3e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e12;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    cout << x / 500 * 1000 + (x - x / 500 * 500) / 5 * 5;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,l=INTM()
    ls=[]
    ct=9999999
    for i in range(n):
        ls.append(l+i)
    ls=sorted(ls,key=lambda x:abs(x))
    print(sum(ls)-ls[0])
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long H,W,h,w;cin>>H>>W>>h>>w;
  vector<vector<long long>>V(H,vector<long long>(W,1000));
  if(H%h==0&&W%w==0)cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    for(int X=h-1;X<H;X+=h){
      for(int Y=w-1;Y<W;Y+=w){
        V[X][Y]=(h*w-h*w*2+1)*1000-1;
      }
    }
    for(int X=0;X<H;X++){
      for(int Y=0;Y<W;Y++){
        if(Y==W-1)cout<<V[X][Y]<<endl;
        else cout<<V[X][Y]<<" ";
      }
    }
  }
}


Measured memory_bytes: 5572
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int main(){
   int n; cin>>n;
   vector<int>a(n);
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   int q;
   cin>>q;
   for(int i=0;i<q;i++){
     int b,m,e;
     cin>>b>>m>>e;
     rotate(a.begin()+b,a.begin()+m,a.begin()+e);
   }
   for(int i=0;i<n-1;i++){
     cout<<a[i]<<" ";
   }
   cout<<a[n-1]<<endl;
   return 0;
}




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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

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

template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}

template <typename T> void print(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void print(const T &value, const Args&... args){std::cout << value << " ";print(args...);}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int H1, M1, H2, M2, K;

  while(cin >> H1 >> M1 >> H2 >> M2 >> K){
    int a = H1 * 60 + M1;
    int b = H2 * 60 + M2;

    int ans = b - K - a;
    print(ans);
  }

  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include <iomanip>

using namespace std;
int main(void){
	int N;
  	cin >>N;
    int a,num=0;
  	for(int i=0;i<N;i++){	
      	cin >>a;
        while(a%2==0){
           a=a/2;
           num++;
        }
      	//cout <<a<<' '<<endl;
    }
  	
  	cout << num<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) loop(i, 0, n)
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << endl
int INF = numeric_limits<int>::max();

typedef long long LL;
typedef pair<int, int> P;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string S;
  string P;
  cin >> S >> P;
  vector<string> r;
  for (int i = 0; i < S.length(); i++) {
    if (i + P.length() > S.length()) continue;
    bool ok = true;
    for (int j = 0; j < P.length(); j++) {
      if (S.substr(i + j, 1) == P.substr(j, 1) || S.substr(i + j, 1) == "?") {
      } else {
        ok = false;
      }
    }
    if (ok) {
      string s = S.substr(0, i) + P +
                 S.substr(i + P.length(), S.length() - (i + P.length()));
      replace(s.begin(), s.end(), '?', 'a');
      r.push_back(s);
    }
  }
  sort(r.begin(), r.end());
  if (r.size() == 0) {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << r[0] << endl;
  }
  // for (string a : r) {
  //   cout << a << endl;
  // }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

typedef struct{
  int u, v, c;
} edge;

int main(){
  int V, M;
  scanf("%d %d\n", &V, &M);

  vector<VI> g(V, VI(V, INF));
  vector<edge> es;
  REP(i, 0, M){
    int a, b, cost;
    scanf("%d %d %d\n", &a, &b, &cost);
    g[a-1][b-1] = cost;
    g[b-1][a-1] = cost;
    edge e;
    e.u = a-1; e.v = b-1; e.c = cost;
    es.push_back(e);
  }

  REP(i, 0, V){
    g[i][i] = 0;
  }

  REP(k, 0, V){
    REP(i, 0, V){
      REP(j, 0, V){
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  int ans = 0;
  for(auto i = es.begin(); i != es.end(); i++){
    if(g[i->u][i->v] < i->c){
      ans++;
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if a == b:
        return a
    else:
        if a < b:
            a, b = b, a #so, a > b
        if b == 0:
            return a
        return gcd(b, a % b)

a, b = map(int, input().split())
print(gcd(a, b))



Measured memory_bytes: 5600