akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var abc = new int[nm[0]][];
        for (var i = 0; i < nm[0]; i++)
            abc[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var dp = new long[nm[0]+1, 401, 401];
        for(var i = 0; i <= nm[0]; i++)
        {
            for(var j = 0; j < 401; j++)
            {
                for (var h = 0; h < 401; h++)
                    dp[i, j, h] = int.MaxValue;
            }
        }
        dp[0, 0, 0] = 0;
        for(var i = 0; i < nm[0]; i++)
        {
            for(var j = 0; j < 401; j++)
            {
                for(var h = 0; h < 401; h++)
                {
                    dp[i + 1, j, h] = Min(dp[i, j, h], dp[i + 1, j, h]);
                    if(j+abc[i][0]<=400&&h+abc[i][1]<=400)
                    dp[i + 1, j + abc[i][0], h + abc[i][1]] =
                        Min(dp[i, j + abc[i][0], h+abc[i][1]], abc[i][2] + dp[i, j, h]);

                }
            }
        }
        long res = int.MaxValue;
        for(var i = 0; i < 401; i++)
        {
            for (var j = 0; j < 401; j++)
            {
                if (i == 0 && j == 0) continue;
                if(i*nm[2]==j*nm[1])
                res = Min(res, dp[nm[0], i, j]);
            }
        }
        WriteLine(res==int.MaxValue?-1:res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

Measured memory_bytes: 62432
package main

import (
	"fmt"
	"sort"
)

func ssort(s string, rev bool) string {
	var t []string
	for i := 0; i < len(s); i++ {
		t = append(t, string(s[i]))
	}
	if rev {
		sort.Sort(sort.Reverse(sort.StringSlice(t)))
	} else {
		sort.Strings(t)
	}
	var r string
	for i := 0; i < len(t); i++ {
		r += string(t[i])
	}
	return r
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ss := ssort(s, false)
	tt := ssort(t, true)
	if ss < tt {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int i,ans=0;
	char s[100010];
	chin(s);
	rep(i,strlen(s)){
		if(!(i%2)&&s[i]=='p')ans--;
		else if(i%2&&s[i]=='g')ans++;
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
    int N, K;
    int l[60];
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> l[i];

    sort(l, l + N, greater<int>());
    int sum = accumulate(l, l + K, 0);
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int b[10];
  
bool dfs(int i,int j,int k){
  if(k==10)
    return true;
  if(i<b[k]){
    if(dfs(b[k],j,k+1))return true; 
  }
  if(j<b[k]){
    if(dfs(i,b[k],k+1))return true;
  }
  return false;
}
 
int main(){
  int a;
  cin >> a;
  while(a>0){
    for(int i=0;i<10;i++){
      cin >> b[i];
    }
    int p=dfs(0,0,0);
    if(p!=0)
      cout << "YES" << endl;
    else
      cout << "NO" <<endl;
    a--;
  }
  return 0;
}

Measured memory_bytes: 1148
#include<stdio.h>
#define INFTY 2000000000
 
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
  
int S[100000000];
int L[1000000],R[1000000];
int count=0;
 
int main(){
  int i;
  int n;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
 
  mergeSort(S,0,n);
 
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);
return 0;
}
 
void merge(int *A,int left,int mid,int right){
  int i,j,k;
  int n1,n2;
 
  n1=mid-left;
  n2=right-mid;
 
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
 
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
 
  L[n1]=INFTY;
  R[n2]=INFTY;
 
  i=0;
  j=0;
 
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }else{
      A[k]=R[j];
      j=j+1;
    }
  }
}
 
void mergeSort(int *A,int left, int right){
  int mid;
 
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n; cin >> n;
    vector<int> Avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> Avec.at(i);
    map<int, int> mcnt;
    for(int i = 0; i < n; ++i) {
        mcnt[Avec.at(i)]++;
    }

    int k = mcnt.size();
    if(k % 2 == 0) cout << k-1 << endl;
    else cout << k << endl;
}

Measured memory_bytes: 8144
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar[4] = {{0,1},{0,-1},{1,0},{-1,0}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int a,b;cin>>a>>b;
  cout << b+max(0,(10-a)*100) << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

def bfs(s):
    q = deque([s])
    visited[s] = True
    
    while q:
        v = q.popleft()
        
        for nv, d in G[v]:
            if visited[nv]:
                if dist[v]+d!=dist[nv]:
                    print('No')
                    exit()
            else:
                visited[nv] = True
                dist[nv] = dist[v]+d
                q.append(nv)

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append((R-1, D))
    G[R-1].append((L-1, -D))
    
visited = [False]*N
dist = [0]*N

for i in range(N):
    if not visited[i]:
        bfs(i)

print('Yes')

Measured memory_bytes: 74416
#include<stdio.h>
#define N 200000
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

int main(void)
{
  int R[N];
  int n, minv, maxv;

  scanf("%d", &n);

  for(int i = 0; i<n; i++)
    scanf("%d", &R[i]);

  minv = R[0];
  maxv = -1000000000;
  
  for (int j = 1; j<= n-1; j++) {
    maxv = MAX(maxv, R[j]-minv);
    minv = MIN(minv, R[j]);
  }
  printf("%d\n", maxv);
  return 0;
}



Measured memory_bytes: 2532
#include"bits/stdc++.h"
using namespace std;
class katana
{
public:
	int a,b;
	katana()
	{
		a=b=0;
	}
	bool operator < (const katana &kb) const
	{
		return this->b > kb.b;
	}
};

int main()
{
	int n,h;
	cin>>n>>h;
	vector<katana> bag(n);
	int maxWield=n-1;
	for(int i=0;i<n;i++)
	{
		cin>>bag[i].a>>bag[i].b;
	}
	sort(bag.begin(),bag.end());
	for(int i=n-2;i>=0;i--)
	{
		if(bag[maxWield].a<bag[i].a)
			maxWield=i;
	}
	int count=0;
	for(int i=0;i<n&&bag[i].b>bag[maxWield].a;i++)
	{
		if(i==maxWield)
			continue;
		h-=bag[i].b;
		count++;
		//cout<<bag[i].b<<endl;
		if(h<=0)
			break;
	}
	int maxhite=bag[maxWield].a;
	if(h >	0)
	{
		if(maxhite<bag[maxWield].b)
		{
			count++;
			h-=bag[maxWield].b;
		}
		if(h>0)
		{
			count+=h/maxhite;
			if(h%maxhite)
				count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, char const *argv[])
{
	long n, k, k1, a, c, c1=0, c2=0;
	scanf("%ld%ld", &n, &k);
	k1=k/2;
	if ((k+2)%2==0)
	{
		a=n-k1;
		if (a>=0) c1=a/k+1;
	}
	a=n;
	c2=a/k;
	c=c1*c1*c1+c2*c2*c2;
	printf("%ld\n", c);
	return 0;
}

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

int main(){
    int N, ans = 0;
    cin >> N;
    string S;
    cin >> S;
    for (int i=0;i<N-2;i++){
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
    cout << ans << endl;
}

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

int main() {
	ll n,m,x;
	ll nmax,mmax;
	nmax = mmax = 12;
	ll c[nmax];
	ll a[nmax][mmax];
	cin >> n >> m >> x;
	rep(i,n) {
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}
	ll n_loop = (1LL << n);
	ll rikai[mmax];
	ll big_num = 1e9;
	ll ans = big_num;
	rep(i,n_loop) {
		ll tmp = i;
		ll money = 0;
		rep(j,m) rikai[j] = 0;
		rep(j,n) {
			if (tmp%2) {
				money += c[j];
				rep(k,m) rikai[k] += a[j][k];
			}
			tmp /= 2;
		}
		bool all_rikai = true;
		rep(j,m) if (rikai[j]<x) all_rikai = false;
		if (all_rikai) ans = min(ans, money);
	}
	if (ans == big_num) {
		cout << -1 << endl;
	}
	else cout << ans << endl;
	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  cout << n * 800 - n / 15 * 200 << endl;
}


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

using namespace std;

int main() {
	string s;
  	cin >> s;
  	string t = "2019/04/30";
  	string ans;
  	if(s == t) ans = "Heisei";
  	for(int i = 0; i < s.size(); i++){
      	if(t[i] == s[i]) continue;
    	if(t[i] < s[i]){
          ans = "TBD";
          break;
        } else {
          ans = "Heisei";
          break;
        }
    }
  	cout << ans << endl;
}

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

int main() {

  int Y,M,D;
  char S;
  cin >> Y >> S >> M >> S >> D;

  if(M <= 4){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    int cnt[4] = {0};

    rep(i,N){
        string S; cin >> S;
        if(S == "AC") cnt[0]++;
        else if(S == "WA") cnt[1]++;
        else if(S == "TLE") cnt[2]++;
        else cnt[3]++;
    }

    printf("AC x %d\n",cnt[0]);
    printf("WA x %d\n",cnt[1]);
    printf("TLE x %d\n",cnt[2]);
    printf("RE x %d\n",cnt[3]);
    return 0;
}


Measured memory_bytes: 3720
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = panaB

panaB = do
    [h,w] <- getIntList
    print $ solveB h w


readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

solveB :: Integer -> Integer -> Integer
solveB 1 _ = 1
solveB _ 1 = 1
solveB h w
    | odd h && odd w = 1 + fst (divMod s 2)
    | otherwise = fst $ divMod s 2
    where s = h * w

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

int main() {
  ll r, D, x;
  cin >> r >> D >> x;
  vector<ll> X(15);
  X[0] = x;

  for (int i = 1; i <= 10; i++) {
    X[i] = r * X[i - 1] - D;
  }
  for (int i = 1; i <= 10; i++) {
    cout << X[i] << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
    int q,si;
    priority_queue<ll> l;
    priority_queue<ll,vector<ll>,greater<ll> > r;
    ll ans=0,a,b,sum=0;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%lld",&a);
        if(a==1){
            scanf("%lld %lld",&a,&b);
            ans+=b;
            if(!l.empty()){
                ans+=max(l.top(),a)-min(l.top(),a);
            }
            if(l.empty()||l.top()>=a){
                l.push(a);
            }
            else if(r.empty()||r.top()<=a){
                r.push(a);
            }
            else if(l.size()==r.size()){
                ans-=max(l.top(),a)-min(l.top(),a);
                l.push(a);
            }
            else{
                r.push(a);
            }
            si=l.size()-r.size();
            if(si>1){
                a=l.top();
                l.pop();
                ans-=(a-l.top())*l.size();
                ans+=(a-l.top())*r.size();
                ans+=(a-l.top());
                r.push(a);
            }
            else if(si<0){
                a=r.top();
                r.pop();
                ans+=(a-l.top())*l.size();
                ans-=(a-l.top())*r.size();
                ans-=(a-l.top());
                l.push(a);
            }
        }
        else{
            printf("%lld %lld\n",l.top(),sum+ans);
        }
    }
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n;
	cin>>n;
	map<string,ll>s;
	for(ll i=0;i<n;i++){
		string t;
		cin>>t;
		sort(t.begin(),t.end());
		s[t]++;
	}
	ll ans=0;
	for(auto itr=s.begin();itr!=s.end();itr++){
		ll val=itr->second;
		ans+=val*(val-1)/2;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 11448
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXA = 2e5 + 5;
const int mod = 1e9 + 7;

inline ll pw(ll a,int b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

ll fac[MAXA],inv[MAXA];

inline ll c(int n,int m)
{
	if(n<0||m<0||n<m) return 0;
	return fac[n]*inv[m]%mod * inv[n-m] %mod;
}

inline ll cc(int n,int m)
{
	ll res=1;
	for(int i=n; i>n-m; --i) res=res*i%mod;
	return res*inv[m]%mod;
}

int main(void)
{
	fac[0]=1;
	for(int i=1; i<MAXA; ++i) fac[i] = fac[i-1]*i %mod;
	inv[MAXA-1]=pw(fac[MAXA-1],mod-2);
	for(int i=MAXA-2; i>=0; --i) inv[i] = inv[i+1]*(i+1) %mod;
	
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int ans = ((pw(2,n)-1 - cc(n,a) - cc(n,b))%mod+mod)%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class119
    {
        static void Main()
        {
            var NL = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var S = new string[NL[0]];
            for (int i = 0; i < NL[0]; i++)
                S[i] = Console.ReadLine();
            Array.Sort(S);
            Console.WriteLine(string.Join("", S));
        }
    }
}


Measured memory_bytes: 13536
#include<bits/stdc++.h>
using namespace std;
int n,k;
string s[1001];
vector<int> v[1001];
void dfs(int d,int p){
  for(int i=0;i<d;i++)cout<<'.';
  cout<<s[p]<<endl;
  for(int i=0;i<v[p].size();i++)
    dfs(d+1,v[p][i]);
}
int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>k>>s[i];
    v[k].push_back(i);
  }
  dfs(0,1);
  return 0;
}

Measured memory_bytes: 1436
def genSumList(l):
        n = len(l)
        ret = []
        for i in range(1,n+1):
                tmp = 0
                for j in range(i):
                        tmp += l[j]
                ret.append(tmp)
        return ret

n = int(input())
a = []
ans = []

for i in range(2):
        a.append(list(map(int, input().split())))

sum1 = genSumList(a[0])
sum2 = genSumList(a[1][::-1])

for i in range(n):
        ans.append(sum1[i] + sum2[(i+1)*(-1)])
print(max(ans))

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

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

  int ans = 0;
  FOR(i,1,N) {
    string a,b;
    a = S.substr(0,i);
    b = S.substr(i,N);
    int tmp = 0;
    sort(ALL(a));
    a.erase(unique(ALL(a)),a.end());
    for (auto ca:a) {
      if (b.find(ca)!=string::npos) tmp++;
    }
    ans = max(ans,tmp);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 long long i,j,k,a,b,c=0,n,t;
 cin>>n;
 long long A[n];
 for(i=0;i<n;i++)
 cin>>A[i];
 sort(A,A+n);
 for(i=0;i+2<n;i++)
 {
   for(j=i+1;j+1<n;j++)
   {
     for(k=j+1;k<n;k++)
     {
       if(A[i]!=A[j]&&A[j]!=A[k]&&A[k]!=A[i]&&A[i]+A[j]>A[k]) c++;
     }
   }
 }
 cout<<c<<endl;
return 0;
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long K) {
  while (A >= B) {
    B *= 2;
    K--;
  }
  while (B >= C) {
    C *= 2;
    K--;
  }
  if (K >= 0) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long K;
  scanf("%lld", &K);
  solve(A, B, C, K);
  return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(void) {
    int n,k,b,t,m;
    vector<int> a;
    cin >> n >> k;
    REP(i,200000){
        a.push_back(0);
    }
    t = 0;
    REP(i,n){
        cin >> b;
        if (a[b-1]==0) t++;
        a[b-1]++;
    }
    if (t<=k) {
        cout << 0;
    } else {
        m = 0;
        SORT(a);
        int c=0;
        while(a[c]==0){
            c++;
        }
        REP(i,t-k) {
            m+=a[c+i];
        }
        cout << m;
    }
    return 0;
}


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

using namespace std;

int M[200005];
int P[200005];

int main(){
	int N;
	scanf("%d", &N);
	M[0] = 200009;
	for (int i = 1; i <= N; i++) {
		scanf("%d", P + i);
		M[i] = min(P[i], M[i - 1]);
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (P[i] < M[i - 1]) {
			ans++;
		}
	}
	printf("%d\n", ans);
}	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 998244353;
const int N = int(3e5) + 999;
#define int long long int
#define inf 1e18

vector<vector<int>> g;
vector<int> vis;
int ans = 0;

void dfs(int node)
{

    vis[node] = 0;
    for (auto x : g[node])
    {
        if (vis[x] == -1)
        {
            dfs(x);
        }
        vis[node] = max(vis[node], vis[x] + 1);
    }

    ans = max(ans, vis[node]);
}

int32_t main()
{
    IOS;
    int n, m;
    cin >> n >> m;
    vis.resize(n + 1, -1);
    g.resize(n + 1);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
    }

    for (int i = 1; i <= n; i++)
    {
        if (vis[i] == -1)
            dfs(i);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++) cout << 'x';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,a,b,s{};
    bool f{};
    vector<int> d[100001];
    cin>>n>>m;
    fr(i,m){
        cin>>a>>b;
        d[a].push_back(b);
        d[b].push_back(a);
    }
    Fr(i,n){
        if(d[i].size()&1u) return puts("No"),0;
        s+=(d[i].size()-2)/2;
        if(d[i].size()>4) f=true;
    }
    if(f) return puts("Yes"),0;
    if(s==2){
        Fr(i,n) if(d[i].size()==4){
            for(auto j:d[i]){
                int p=i,t=j;
                while(d[t].size()==2){
                    for(auto k:d[t]) if(k!=p){
                        p=t,t=k;
                        break;
                    }
                }
                if(t==i) return puts("Yes"),0;
            }
            return puts("No"),0;
        }
    }
    puts(s<2?"No":"Yes");
}

Measured memory_bytes: 9068
#include<stdio.h>
int main(){
  int n, k;
  scanf("%d%d", &n,&k);
  int a[n+1], i, j, t;
  for(i=1;i<n+1;i++)a[i]=0;
  while(k--){
    scanf("%d",&i);
    for(j=0; j<i; j++){
      scanf("%d", &t);
      a[t]+=1;
    }
  }
  int cnt=0;
  for(i=1;i<n+1;i++){
    if(a[i]==0){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}


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

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

int main(){
  ll a, b;
  cin >> a >> b;
  ll ab = gcd(a, b);
  int ans = 1;
  for(ll i=2; i*i<=ab; ++i){
    if(ab%i == 0){
      ++ans;
      while(ab%i == 0){
        ab /= i;
      }
    }
  }
  if(ab >1) ++ans;
  cout << ans << endl;
}

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

ll n,a,x[55],dp[55][55][2505],ans;

ll rec(int pos, int sisa, int sisatot){
	if (pos>n) return !sisa&&!sisatot;
	ll &ret=dp[pos][sisa][sisatot];
	if (ret!=-1) return ret;
	ret=rec(pos+1,sisa,sisatot);
	if (sisa&&sisatot>=x[pos])
	ret+=rec(pos+1,sisa-1,sisatot-x[pos]);
//	cout << pos << " " << sisa << " "
//	<< sisatot << " " << ret << "\n";
	return ret;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> a;
	for (int i=1;i<=n;i++) cin >> x[i];
	memset(dp,-1,sizeof(dp));
	for (int i=1;i<=n;i++) ans+=rec(1,i,i*a);
	cout << ans << "\n";
}

Measured memory_bytes: 59520
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int n = s.length();
    vector<bool> x(n+1, false);
    x[0] = true;
    forn(i,n){ 
        if(!x[i])   continue;
        if(i+5<=n && s.substr(i,5).compare("dream")==0)      x[i+5] = true;
        if(i+7<=n && s.substr(i,7).compare("dreamer")==0)    x[i+7] = true;
        if(i+5<=n && s.substr(i,5).compare("erase")==0)      x[i+5] = true;
        if(i+6<=n && s.substr(i,6).compare("eraser")==0)     x[i+6] = true;
    }
    if(x[n])    cout<<"YES\n";
    else        cout<<"NO\n";

    return 0;
}



Measured memory_bytes: 3740
from sys import stdin, stdout


a, b, c, x, y = map(int, stdin.readline().split())

ans = 0
if 2 * c <= a + b:
    ans += min(x, y) * 2 * c
    q = min(x, y)
    x -= q
    y -= q
    
    if x and 2 * c <= a:
        ans += 2 * c * x
    elif x:
        ans += a * x
    elif y and 2 * c <= b:
        ans += 2 * c * y
    else:
        ans += b * y
    
else:
    ans = x * a + y * b

stdout.write(str(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
using namespace std;

int N, M;
vector<vector<int>> connect;
vector<bool> visited;

bool DFS(int curr, int num) {
	if (curr == N)
		return true;

	if (num >= 3)
		return false;

	visited[curr] = true;
	
	for (int next : connect[curr]) {
		if (visited[next])
			continue;

		if (DFS(next, num + 1))
			return true;
	}
	return false;
}

int main() {
	cin >> N >> M;
	connect = vector<vector<int>>(N + 1, vector<int>());
	visited = vector<bool>(N + 1, false);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		connect[a].push_back(b);
		connect[b].push_back(a);
	}

	if (DFS(1, 1))
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	cout << *(s.begin()) << s.size()-2 << *(s.end()-1) << endl;
}

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

using namespace std;

int main(){
	int n, k;
  	cin >> n >> k;
  	int g = 0;
  	for(int i = 0; i < n; i++) {
    	int x;
      	cin >> x;
      	g = __gcd(g, abs(x - k));
    }
  	cout << g;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define fi first
//#define endl "\n"
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define initialize(array,size,value) for(ll i=0;i<size;i++) array[i]=value
#define couta(array,size) for(ll i=0;i<size;i++) cout<<array[i]<<" "
#define debug(x) cout<<"x: "<<x<<endl
#define dbug(x,y) cout<<"x: "<<x<<"    "<<"y: "<<y<<endl
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
#define mod 1000000007
#define MAXN 100001
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);
vector<ll> prefix_function(string s);

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
        
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1; i*i<=n ; i++){
        ld x=(((ld)n) / ((ld)(i+1)));
        ld y=(((ld)n) / ((ld)(i)));
        ld div=(ld)(n-i)/(ld)i;
        if(ceil(div)==floor(div) && div>0 && div<n && div>x && div<=y){
            //cout<<div<<endl;
            ans+=div;
        }
    }
    cout<<ans<<endl;
}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head = (head+1)%LEN;
  return x;
}

int min(int a, int b){
  return a<b ? a: b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for(int i=1; i<=n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n+1;

  while(head != tail){
  u=dequeue();
  c=min(q, u.t);
  u.t -= c;
  elaps +=c;
  if(u.t>0) enqueue(u);
  else printf("%s %d\n", u.name, elaps);
  }

  return 0;
}


Measured memory_bytes: 12760
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2>>  M2>> K;

    int c1 = H1 * 60 + M1;
    int c2 = H2 * 60 + M2;

    int t = c2-c1;
    if(t < 0) t += 24 * 60;

    int l = t - K;
    if(l < 0) l = 0;

    cout << l << endl; 
}


Measured memory_bytes: 3652
"use strict";

function Main(input) {
    var line=input.split(" ");
    for(var i=0;i<line.length;i++)
        line[i]=parseInt(line[i],10);
    if(line[0] < line[1])
        console.log("a < b");
    else if(line[0] > line[1])
        console.log("a > b");
    else
        console.log("a == b");
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

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

Measured memory_bytes: 15512
n,m=map(int,input().split())
oy=[set() for i in range(n+1)]
ko=[set() for i in range(n+1)]
ans= [0 for i in range(n+1)]
for i in range(m+n-1):
  a,b=map(int,input().split())
  oy[b]|={a}
  ko[a]|={b}
  
for i in range(1,len(oy)):
  if oy[i]==set():
    break

l=[[i,ko[i]]]
while l:
  o,k=l.pop()
  for i in k:
    oy[i].remove(o)
    if len(oy[i])==0:
      l.append([i,ko[i]])
      ans[i]=o
for i in ans[1:]:
  print(i)


Measured memory_bytes: 71044
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
using namespace std;

int main(){
  int n,t,a;cin >> n >> t >> a;
  vector<int> h(n);
  double mn=INF;
  int ans;
  for(int i=0;i<n;i++){
     cin >> h.at(i);
     double x=abs(a-(t-h.at(i)*0.006));
     if(mn>x){
       ans = i;
       mn = x;
     }
  }

  cout << ans+1 <<endl;

}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string S, T; cin >> S >> T;
	vector<int> start(26, -1);
	vector<int> goal(26, -1);

	REP(i,S.length()){
		int a = S[i] - 'a';
		int b = T[i] - 'a';

		if(start[a] != -1 or goal[b] != -1){
			if(start[a] != b or goal[b] != a){
				cout << "No" << endl;
				return 0;
			}
		}else{
			start[a] = b;
			goal[b] = a;
		}
	}

	cout << "Yes" << endl;


	return 0;

}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,east[400000],west[400000],ans;
str s;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++){
        int idx = i+1;
        east[idx] = east[idx-1];
        west[idx] = west[idx-1];
        if(s[i]=='W'){east[idx]++;}
        else{west[idx]++;}
    }
    ans = INT_MAX;
    for(int i=0;i<s.size();i++){
        int idx = i+1;
        int l,r,change;
        l = east [idx-1];
        r = west [s.size()] - west[idx];
        change = l+r;
        ans = min(ans,change);
    }
    cout<<ans<<newl;
}


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

long dp[100010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i <= n; i++)
		dp[i] = -1;
	dp[0] = 0;
	queue<long> que;
	que.push(0);
	while(!que.empty()) {
		long v = que.front(); que.pop();
		for(int i = 1; v + i <= n; i*=6) {
			if(dp[v+i] == -1) {
				dp[v+i] = dp[v] + 1;
				que.push(v+i);
			}
		}
		for(int i = 1; v + i <= n; i*=9) {
			if(dp[v+i] == -1) {
				dp[v+i] = dp[v] + 1;
				que.push(v+i);
			}
		}
	}
	printf("%ld\n", dp[n]);
}

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

int main() {
    ll N;
    cin >> N;
    
    ll t = 1;
    ll ans = 0;
    while(t*t<N){
       if(N%t==0){
           ll p = (N/t) -1;
           if(N/p == N%p){
               ans += ((N/t)-1);
           }      
        }
        ++t;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int

int main()
{
    ll X,Y,A,B,C,in,sum=0;
    cin>>X>>Y>>A>>B>>C;
    vector<pair<ll,ll> >v;
    while(A--)
    {
        cin>>in;
        v.push_back(make_pair(in,3));
    }
    while(B--)
    {
        cin>>in;
        v.push_back(make_pair(in,2));
    }
    while(C--)
    {
        cin>>in;
        v.push_back(make_pair(in,1));
    }

    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    ll ex=0,x=0,y=0;
    for(ll i=0; i<v.size(); i++)
    {
        //cout<<v[i].first<<" "<<v[i].second<<" ";
        if(v[i].second==3 && x<X)
        {
            //cout<<"if"<<endl;
            sum=sum+v[i].first;
            x=x+1;
        }
        else if(v[i].second==2 && y<Y)
        {
            //cout<<"eif"<<endl;
            sum=sum+v[i].first;
            y=y+1;
        }
        else if(v[i].second==1 && ex+x+y<X+Y)
        {
            //cout<<"e"<<endl;
            sum=sum+v[i].first;
            ex=ex+1;

        }

        if(ex+x+y==X+Y)
            break;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 10604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    string S;
    cin >> S;
    cout << min(character_count(S, '0'), character_count(S, '1')) * 2 << endl;
}


Measured memory_bytes: 512
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

void solve() {

}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}



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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(1, N+1):
    L[i] = gcd(L[i-1], A[i-1])
for i in range(N)[::-1]:
    R[i] = gcd(R[i+1], A[i])

M = [gcd(L[i], R[i+1]) for i in range(N)]

print(max(M))

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

using namespace std;

typedef long long ll;

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

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

	sort(vi.begin(), vi.end());
	ll j = n - 2, ans = vi[n - 1];
	for (ll i = n - 3; i >= 0; i--) {
		ans += vi[j];
		i--;
		if (i >= 0) ans += vi[j];
		j--;
	}
	cout << ans;
}


Measured memory_bytes: 4808
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n;
	cin >> n;
	int sum = 0,nn=n;
	while (nn > 0) {
		sum += nn % 10;
		nn /= 10;
	}
	if (n%sum == 0) {
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}

//Ctrl+Aを使わない

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

string s;
int main() {
    cin >> s;
    int n = s.length();
    if (s[0] == s[n - 1])
        --n;
    if (n & 1)
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 3780