akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;
typedef queue<ll> ql;

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

    int k;
    cin >> k;

    ql q;
    for (int i = 1; i <= 9; i++) {
        q.push(i);
    }

    for (int i = 0; i < k - 1; i++) {
        ll x = q.front();
        q.pop();

        if (x % 10 > 0) {
            q.push(x * 10 + x % 10 - 1);
        }
        q.push(x * 10 + x % 10);
        if (x % 10 < 9) {
            q.push(x * 10 + x % 10 + 1);
        }
    }

    cout << q.front() << endl;

    return 0;
}


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

int main()
{
  string n;
  cin >> n;
  int len = n.length();
  int r = 0;
  for (int i = 0; i < len; i++) {
    r += int(n[i] - '0');
  }
  cout << (r % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3700
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;


int main(){
    ll n,w;
    cin >> n >> w;
    vector<ll> ws(n);
    vector<ll> vs(n);
    rep(i,n) cin >> ws[i] >> vs[i];
    ll dp[w+1][n+1];
    memset(dp,0LL,sizeof dp);
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= w; j++){
            // not chosen
            dp[j][i] = max(dp[j][i-1],dp[j][i]);
            // chosen
            ll newj = j + ws[i-1];
            if (newj <= w) dp[newj][i] = max(dp[newj][i],dp[j][i-1] + vs[i-1]);
        }
    }
    ll ans = 0;
    for(int j = 0; j <= w; j++){
        ans = max(ans,dp[j][n]);
    }

    cout << ans;
    
}









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

typedef long long ll;
const int maxn=100005;
int num[maxn];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n,k;
	while(cin>>n>>k){
		for(int i=0;i<n;i++){
			cin>>num[i];
		}
		int ans=(n-1)/(k-1);
		if((n-1)%(k-1)!=0) ans++;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [0] * N
B = [0] * N

for _ in range(N):
    A[_], B[_] = map(int, input().split())

cnt = 0
for i in reversed(range(N)):
    m = (A[i] + cnt)%B[i]
    if m == 0:
        pass
    else:
        cnt += B[i] - m

print(cnt)


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

const int M=1000005,mod=998244353;
ll F[M];

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}
ll Div(ll n,ll m){return n*Pow(m,mod-2)%mod;}
ll nCk(ll n,ll k){
	if(n<0) return 1;
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n,m;
string A,B,C,D;

bool Check(string s){
	int N=s.size();
	return s==string(N,'0');
}

vl ff(){
	vl a(m+1);
	a[0]++;
	if(Check(A)){
		for(int i=0;i<m&&C[i]=='0'&&D[i]=='0';i++) a[i+1]++;
	}
	else{
		int S=0,t=0;
		for(int i=0;i<n;i++) S+=A[i]-'0';
		for(int i=0;i<m;i++){
			t+=C[i]-'0'+D[i]-'0';
			a[i+1]=nCk(S+t-1,t);
		}
	}
	swap(A,B);reverse(C.begin(),C.end());reverse(D.begin(),D.end());
	return a;
}

ll f(){
	ll res=0,t=0;
	vl a=ff(),b=ff();
	for(int i=0;i<m;i++) if(C[i]=='1'||D[i]=='1'){
		t=(C[i]-'0'+D[i]-'0')*(a[i]+t)%mod;
		(res+=t*b[m-1-i])%=mod;
	}
	swap(A,C);swap(B,D);swap(n,m);
	return res;
}

int main(){
	cin>>n>>m>>A>>B>>C>>D;
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
	if(Check(A)&&Check(B)&&Check(C)&&Check(D)) cout<<1<<endl;
	else cout<<(f()+f())%mod<<endl;
}

Measured memory_bytes: 10208
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	bool check=false;
	rep(i,30){
		rep(j,30){
			if(4*i+7*j==n){
				check=true;
				break;
			}
		}
	}
	cout<<((check)?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll nature(ll a){
  return max(a,-1*a);
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll sumprice;
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    if(i==0){sumprice=max(A.at(0),-1*A.at(0));}
    if(i>0){sumprice+=max(A.at(i)-A.at(i-1),A.at(i-1)-A.at(i));}
    if(i==N-1){sumprice+=max(A.at(N-1),-1*A.at(N-1));}
  }
  ll memo=sumprice;
  for(ll i=0;i<N;i++){
    if(i==0){
      sumprice+=nature(A.at(1))-nature(A.at(0))-nature(A.at(1)-A.at(0));
    }
    else if(i==N-1){
      sumprice+=nature(A.at(N-2))-nature(A.at(N-1))-nature(A.at(N-2)-A.at(N-1));
    }
    else{
      sumprice+=nature(A.at(i+1)-A.at(i-1))-nature(A.at(i)-A.at(i-1))-nature(A.at(i)-A.at(i+1));
    }
    cout<<sumprice<<endl;
    sumprice=memo;
  }
}

Measured memory_bytes: 2048
n,k = map(int,input().split())
s = [1 if ele=="L" else 0 for ele in input()]

before = s[0]
cnt=0

for si in s:
    if si != before:
        cnt += 1
    before = si

score_max = len(s)-1
print(min(score_max, score_max-cnt+k*2))

Measured memory_bytes: 3956
import heapq

N, M= map(int, input().split())
A = list(map(int, input().split()))
a=[-1*i for i in A]
heapq.heapify(a)
for i in range(M):
    m=int(heapq.heappop(a)/2)
    heapq.heappush(a, m)

print(-1*sum(a))

Measured memory_bytes: 14180
#include<stdio.h>
#define N 100

int main(){

  int G[N][N],i,j,n,a,b,c;

  scanf("%d",&n);
  
  for( i= 0 ; i < n ; i++ ){
    for( j =0 ; j < n ; j++ ){
      G[i][j] = 0;
    }
  }
  
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&a,&b);
    for( j = 0 ; j < b ; j++ ){
      scanf("%d",&c);
      G[a-1][c-1] = 1;
    }
  }
  
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      printf("%d", G[i][j]);
      if( j < n-1 ){
	printf(" ");
      }
    }
    
    printf("\n");
    
  }
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define int ll
#define all(in) in.begin(), in.end()
using pii = pair<int,int>;
/*Happy New Year :)*/
signed main(){
    int n,m; cin >> n >> m;
    vector<int>a(n);
    vector<pii>b(m);
    for(auto& e : a ) cin >> e;
    for(auto& p : b) cin >> p.second >> p.first;
    sort(all(b),greater<pii>());
    priority_queue<int,vector<int>,greater<>>pq;
    for(auto e : a) pq.emplace(e);
    for(auto p : b){
        rep(_,p.second){
            if(pq.top() < p.first){
                pq.pop();
                pq.push(p.first);
            } else {
                break;
            }
            if(pq.top() >= p.first) break;
        }
    }
    int sum = 0;
    while(not pq.empty()) {
        sum += pq.top(); pq.pop();
    }
    cout << sum << endl;
}



Measured memory_bytes: 3704
K = int(input())
A, B = map(int, input().split())
A1 = int(A / K)
A2 = int(A % K)
B1 = int(B / K)
# B2 = B % K
if (B1 - A1) >= 1 or A2 == 0:
  print('OK')
else:
  print('NG')


Measured memory_bytes: 9172
sum[3<<17],cnt[3<<17];
N,i,acc,t,k,x;
char f[10];
char buf[2200000];
sz;
main()
{
	read(0,buf,2200000);
	for(;;)
	{
		k=buf[sz++];
		if(k<'0'||k>'9')break;
		N=N*10+k-'0';
	}
	for(i=0;i<N;i++)
	{
		x=0;
		for(;;)
		{
			k=buf[sz++];
			if(k<'0'||k>'9')break;
			x=x*10+k-'0';
		}
		++sum[cnt[x]++];
	}
	i=sz=0;
	for(t=N;t;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		cnt[t]=i-1;
	}
	for(i=1;i<=N;i++)
	{
		if(!cnt[i])
		{
			buf[sz++]='0';
		}
		else
		{
			if(cnt[i-1]!=cnt[i])
			{
				k=0;
				t=cnt[i];
				while(t)
				{
					f[k++]=t%10;
					t/=10;
				}
				acc=k;
			}
			else k=acc;
			while(k--)buf[sz++]=f[k]+'0';
		}
		buf[sz++]='\n';
	}
	write(1,buf,sz);
}

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

typedef long long ll;
string s, t;

int main() {
    ios::sync_with_stdio(0);
    cin >> s >> t;
    int lt = t.length();
    int ans = 1e8;
    for (int i = 0; i < s.length(); i++) {
        if (i + lt > s.length()) break;
        int cnt = 0;
        int z = 0;
        for (int j = i; j < i + lt; j++) {
            if (s[j] == t[z]) {

            } else {
                cnt++;
            }
            z++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
N,D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        ans = 0
        for x in range(D):
            ans += abs(X[i][x] - X[j][x])**2
        for k in range(ans+1):
            if k ** 2 == ans:
                cnt += 1
print(cnt)


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

int main() {
  int N, H, W;
  cin >> N >> H >> W;

  vector<int> A(N);
  vector<int> B(N);
  rep(i, N) cin >> A[i] >> B[i];

  int ans = 0;
  rep(i, N) {
    if (A[i] >= H && B[i] >= W) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll d[5005];

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
ll k,q;
cin>>k>>q;
rep(i,0,k-1)cin>>d[i];

while(q--)
{
	ll n,x,m;
	cin>>n>>x>>m;
	x%=m;
	ll s1=0;
	rep(i,0,k-1)s1+=(d[i]%m!=0)?d[i]%m:m;
	ll cnt=(n-1)/k;
	ll s=x+cnt*s1;
	rep(i,0,(n-1)%k-1)s+=(d[i]%m!=0)?d[i]%m:m;
	ll ans=n-1-s/m;
	//ol(s);on;
	ol(ans);on;
}
return 0;
}



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

typedef struct unionfind{
  vector<int> par;
  unionfind(int N) :par(N){
    for(int i=0;i<N;i++)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int px=root(x);
    int py=root(y);
    if(px!=py){
      par[px]=py;
    }
  }
  bool parcheck(int x,int y){
    int px=root(x);
    int py=root(y);
    return px==py;
  }
};

int main(){
  int i,N,M,a,b,c,ans=1;
  cin>>N>>M;
  unionfind t(N);
  rep(i,M){
    cin>>a>>b>>c;
    t.unite(a-1,b-1);
  }
  set<int> se;
  auto p=se.insert(t.root(0));
  rep(i,N){
    p=se.insert(t.root(i));
    if(p.second)ans++;
  }
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)

int main(void){
    double M,N,MVote=0,tmpm=0;
    cin >> N >> M;
    tmpm = M;
    vector<int> A(1010,0);
    REP(i,N){
        cin >> A[i];
        MVote += A[i];
    }

    FOR(i,0,N){
        if(A[i] >= MVote/(4*tmpm)) M--;
        if(M <= 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define foo(i,n) for(int i=0;i<n;i++)
string a,b;
int main(){
    cin>>a>>b;
    if(a.length() < b.length()) cout<<"LESS"<<endl;
    else if(a.length() > b.length()) cout<<"GREATER"<<endl;
    else if(a<b) cout<<"LESS";
    else if(a>b) cout<<"GREATER";
    else if(a==b) cout<<"EQUAL";
}


Measured memory_bytes: 256
#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 n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
unittest
{
	assert( [ "6 4 3" ].parse.expand.solve == 1 );
	assert( [ "8 3 9" ].parse.expand.solve == 4 );
	assert( [ "12 3 7" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc[ 0 ], abc[ 1 ], abc[ 2 ] );
}

auto solve( long a, long b, long c )
{
	auto r = a - b;
	return ( r < c ) ? c - r : 0L;
}


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

using namespace std;

#define ll long long


int main(){

int n;
string s;
cin >> s;
cin >> n;
map<string,int>mp;
int ln = s.size();vector<string>v;
for(int i=0; i<s.size(); i++)
{
    string blnk = "" ;
    for(int j=i; j<min(i+5,ln); j++)
    {
        blnk += s[j];
        if(!mp[blnk])
        {v.push_back(blnk);
        mp[blnk]++;
        }
    }
}
sort(v.begin(),v.end());

cout << v[n-1] << endl;

}


Measured memory_bytes: 4848
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda demand: demand[1], reverse=True)

x = -1
cnt = 0
while demands:
    ai, bi = demands.pop()

    if ai > x:
        x = bi - 1
        cnt += 1

else:
    print(cnt)


Measured memory_bytes: 23732
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << " ";

int main()
{
    int n;
    cin >> n;
    bool ok = true;
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        if (c % 2 == 0) {
            if (c % 3 == 0) continue;
            if (c % 5 == 0) continue;
            ok = false;
        }
    }
    if (ok) cout << "APPROVED\n";
    else cout << "DENIED\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	long x,sum,fh=0,f=0,a=0;

	scanf("%ld",&x);

	fh=x/500; a=x%500; f=a/5;

	sum=(fh*1000)+(f*5);

	printf("%ld\n",sum);

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#pragma warning(disable : 4996)
int N, M, A, B, C, T, a[55], b[55], d[55][55], d2[55][55];
int main() {
	while (scanf("%d%d%d%d%d%d", &N, &M, &A, &B, &C, &T), N) {
		for (int i = 0; i < N; i++) scanf("%d", &a[i]);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = 0;
				if (j - i == -1) d[i][j] = A;
				if (j - i == 0) d[i][j] = B;
				if (j - i == 1) d[i][j] = C;
			}
		}
		while(T >= 1) {
			if (T & 1) {
				for (int j = 0; j < N; j++) {
					for (int k = 0; k < N; k++) {
						b[j] += a[k] * d[j][k];
					}
				}
				for (int j = 0; j < N; j++) {
					a[j] = b[j] % M;
					b[j] = 0;
				}
			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					for (int l = 0; l < N; l++) {
						d2[j][k] += d[j][l] * d[l][k];
					}
				}
			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					d[j][k] = d2[j][k] % M;
					d2[j][k] = 0;
				}
			}
			T >>= 1;
		}
		for (int i = 0; i < N; i++) {
			if (i) printf(" ");
			printf("%d", a[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2660
#include<bits/stdc++.h>
using namespace std;
int b[105],a[105];
int main(){
    int n,sum=0;
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        scanf("%d",&b[i]);
    }
    a[1]=a[2]=b[1];
    for(int i=2;i<n;i++){
        if(b[i]<a[i]) a[i]=b[i];
        a[i+1]=b[i];
    }
    for(int i=1;i<=n;i++){
        sum+=a[i];
    }
    printf("%d\n",sum);
}

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

int main() {
	string S;
	cin >> S;
	vector<char>A = { 'h', 'i' };
	if (S.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			if (S.at(i) != A.at(0)) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (S.at(i) != A.at(1)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

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

using namespace std;

int main()
{
    long long int n,i,a,b,m,c,sum=0,x,d;
    scanf("%lld%lld%lld",&n,&a,&b);
    c=ceil(b*1.0/a);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&m);
        if(i==0) x=0;
        else x=m-d;
        if(x>=c) sum+=b;
        else sum+=x*a;
        d=m;
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Integer> a = new HashMap<>();
        int[] b = new int[n];
        for (int i = 0; i < b.length; i++) {
            a.put(i, sc.nextInt());
            b[i] = sc.nextInt();
        }
        List<Entry<Integer, Integer>> list_entries = new ArrayList<>(a.entrySet());
        Collections.sort(list_entries, new Comparator<Entry<Integer, Integer>>() {
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
                return obj1.getValue().compareTo(obj2.getValue());
            }
        });
        long money = 0;
        int counter = 0;
        for (Entry<Integer,Integer> entry : list_entries) {
            for (int i = 0; i < b[entry.getKey()] && counter < m; i++) {
                money += entry.getValue();
                counter++;
            }
            if (counter == m) {
                break;
            }
        }
        System.out.println(money);
        sc.close();
    }
}

Measured memory_bytes: 97496
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

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

int main(void) {
    string S;
    ll K;
    cin >> S >> K;
    string T = S;
    int N = S.size();
    multimap<int,int> len;
    bool flag = false, loop = false;
    int x = 0, s = 0;
    ll cnt = 0;
    if (N == 1) {
        cout << K/2 << endl;
        return 0;
    }
    for (int i=0;i<N-1;i++) {
        if (S[i] == S[i+1]) {
            if (flag) x++;
            else { x = 2; s = i; }
            flag = true;
        } else if (flag) {
            flag = false;
            len.emplace(s,x);
        }
    }
#ifdef DEBUG
    for (auto itr: len) cout << itr.first << ": " << itr.second << endl;
#endif
    if (flag) {
        len.emplace(s,x);
        if (S[N-1] == S[0]) {
            x++;
            if (x == N+1) {
                cout << K*N/2 << endl;
                return 0;
            }
            else {
                for (int i=0;i<N-1;i++) {
                    if (S[i] == S[i+1]) {
                        flag = true;
                        x++;
                    } else if (flag) {
                        flag = false;
                        break;
                    }
                }
                len.emplace(s,x);
            }
            loop = true;
        }
    } else if (S[N-1] == S[0]) {
        x = 2; s = N-1;
        flag = true;
        for (int i=0;i<N;i++) {
            if (S[i] == S[i+1]) {
                flag = true;
                x++;
            } else if (flag) {
                flag = false;
                break;
            }
        }
        len.emplace(s,x);
        loop = true;
    }
#ifdef DEBUG
    for (auto itr: len) cout << itr.first << ": " << itr.second << endl;
#endif
    for (auto itr: len) {
        int pos = itr.first, length = itr.second;
        if (pos+length > N) cnt += (K-1)*(length/2);
        else if ((loop && pos+length == N) || (loop && pos == 0)) cnt += length/2;
        else cnt += K*(length/2);
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    l, r = map(int, input().split())
    L[i] = l
    R[i] = r

left = max(L)
right = min(R)

if left <= right:
    print(right-left+1)
else:
    print(0)



Measured memory_bytes: 10868
#include <stdio.h>

int m,f,r;

main(){
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m == -1 && f == -1 && r == -1){
			break;
		}else{
			if(m == -1 || f == -1 || m+f <30){
				printf("F\n");
			}else if(m+f >=80){
				printf("A\n");
			}else if(m+f >=65){
				printf("B\n");
			}else if(m+f >=50 || r >=50){
				printf("C\n");
			}else if(m+f >=30){
				printf("D\n");
			}
		}
	}
	return 0;
}
		
	

Measured memory_bytes: 584
// 最大長の区間を省く
package main

import "fmt"

func main() {
	var k, n int
	var a []int
	fmt.Scan(&k, &n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		var j int
		fmt.Scan(&j)
		a[i] = j
	}
	base := k - a[n-1] + a[0]
	for i := 0; i < n-1; i++ {
		base = max(base, a[i+1]-a[i])
	}
	fmt.Println(k - base)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 6400
#include "bits/stdc++.h"
using namespace std;
#define ll long long

const int INF = 1e9+6;

int main(){
	int n,w;
	cin>>n>>w;
	vector<ll> weight(n),value(n);
	ll sum_values=0;
	for(int i=0;i<n;i++){
		cin>>weight[i]>>value[i];
		sum_values+=value[i];
	}
	vector<ll> dp(sum_values+1,INF);
	dp[0]=0;
	cerr<<dp[0];
	//dp[i] =  minimum total weight for value exactly equal to i
	for(int item=0;item<n;item++){
		for(int value_already=sum_values-value[item];value_already>=0;value_already--){
			dp[value_already+value[item]]=min(dp[value_already+value[item]],dp[value_already]+weight[item]);
		}
	}
	ll ans=0;
	cerr<<ans<<endl;
	for(int i=0;i<=sum_values;i++){
		cerr<<dp[i]<<" ";
		if(dp[i]<=w){
			ans=max(ans,(ll)i);
		}
	}
	cout<<ans<<endl;
	

}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef     long long               ll;
typedef     vector<ll>              vll;
#define     meme(s)                 memset(s,0,sizeof(s))
#define     rall(s)                 s.rbegin(),s.rend()
#define     i(x)                    scanf("%lld",&(x))
typedef     unordered_map<ll,ll>    mll;
#define     pb                      push_back
#define     in2(x,y)                i(x),i(y)
#define     EL                      cout<<'\n'
#define     fio                     ios_base::sync_with_stdio(false),cin.tie(NULL)
#define     all(s)                  s.begin(),s.end()
typedef     unordered_map<ll,vll>   circuit;
typedef     unordered_map<ll,bool>  is;
const ll    MOD=                    1e9+7;
#define     no                      cout<<"NO\n"
#define     yes                     cout<<"YES\n"
#define     fr(n,x)                 for(int n=0;n<x;n++)
#define     pf(x)                   printf("%lld\n",(x))
const ll    mx=                     2e7;
#define     segtree                 ll L=2*node,R=L+1,mid=(l+r)/2
#define     cs(n)                   printf("Case %lld: ",(n))
typedef     pair<ll,ll>             pll;
typedef     set<ll>                 sll;
#define     X                       first
#define     Y                       second
vector<bool>                        pr(mx,1);
void sv()                           {pr[1]=0;for(ll n=2;n*n<=mx;n++){if(pr[n]){for(ll k=2*n;k<mx;k+=n)pr[k]=0;}}}
ll bit[mx];
#define     NT                      cout<<-1;return
void up( ll ind,ll vl)              {while (ind<mx){bit[ind]+=vl;ind+=ind&(-ind);}} //BIT update
ll qr( ll ind)                      {ll res=0;while(ind){res+=bit[ind];ind-=ind&(-ind);}return res;} //BIT query
#define T(j) ll t;cin>>(t);for(ll j=1;j<=t;j++)
#pragma GCC optimize("O3")

void solve() {
    ll x;
    i(x);
   vll siv(x+1,0);
   ll res=0;
    for(ll n=1;n<=x;n++)
    {

        for(ll k=n;k<=x;k+=n)siv[k]++;
        res+=n*siv[n];
    }
    pf(res);
}
int main() {
    //T(n)
    //cs(n),
    solve();
}

Measured memory_bytes: 83784
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 累積和と連想配列
    vector<long long> s(N+1, 0);
    map<long long, long long> nums;
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
    for (int i = 0; i < N+1; ++i) nums[s[i]]++;

    // 集計処理
    long long res = 0;
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}   


Measured memory_bytes: 15872
#include<iostream>
using namespace std;
int main(){
    int S, h, m, s;
    cin >> S;
    
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3084
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder0725
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            if(X >=400 && X <= 599) { Console.WriteLine("8"); }
            if (X >= 600 && X <= 799) { Console.WriteLine("7"); }
            if (X >= 800 && X <= 999) { Console.WriteLine("6"); }
            if (X >= 1000 && X <= 1199) { Console.WriteLine("5"); }
            if (X >= 1200 && X <= 1399) { Console.WriteLine("4"); }
            if (X >= 1400 && X <= 1599) { Console.WriteLine("3"); }
            if (X >= 1600 && X <= 1799) { Console.WriteLine("2"); }
            if (X >= 1800 && X <= 1999) { Console.WriteLine("1"); }
      }

    }
}


Measured memory_bytes: 27516
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int a;
    cin>>a;
    int ans;
    ans = a + a*a + a*a*a;
    cout<<ans<<endl;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c;
string s;
signed main()
{
	cin>>a>>b>>c;
	if((a<c&&c<b)||(a>c&&c>b)){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 764
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
  	
  ll a,b;
  cin>>a>>b;
  if(a>b)
  {
    cout<<-1<<endl;
    return 0;
  }
  ll val1,val2;
  val1=ceil(a/0.08);
  val2=ceil(b/0.1);
  if(val1>val2)
  {
    if(floor(val1*0.1)>b)
    {
      cout<<-1<<endl;
    }
    else
      cout<<val1<<endl;
  }
  else  
  {
  
    if(floor(val2*0.08)>a)
    {
      cout<<-1<<endl;
    }
    else
      cout<<val2<<endl;
  }
	return 0;
}

Measured memory_bytes: 256
Scanf.sscanf (read_line ()) "%d %d" (fun n k ->
    let s = read_line () in
    let rec collect i count cur acc =
        if i < 0 then (
            let acc = count :: acc in
            if s.[0] = '0' then 0 :: acc else acc
        ) else (
            if s.[i] = cur then collect (i - 1) (count + 1) cur acc
                           else collect (i - 1) 1 s.[i] (count :: acc)
        )
    in
    let a = Array.of_list @@ collect (n - 1) 0 '1' [] in
    let al = Array.length a in
    (if Array.length a <= k * 2 + 1 then n else (
        let sum =
            let rec loop i acc =
                if i = k * 2 + 1 then acc else loop (i + 1) (acc + a.(i))
            in
            loop 0 0
        in
        let rec loop s b sum mx =
            if b = al - 1 then mx else
                let sum = sum + a.(b + 1) + a.(b + 2) - a.(s) - a.(s + 1) in
                loop (s + 2) (b + 2) sum (max mx sum)
        in
        loop 0 (k * 2) sum sum
    )) |> Printf.printf "%d\n"
)

Measured memory_bytes: 6016
//みんな大好きWF法!!!!!!!!!!
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define LL_MAX 100000000009
typedef long long ll;

using namespace std;

int main(void){
    ll wf[305][305], wf2[305][305];
    ll N, M, L;
    cin >>N>>M>>L;

    //cout<<LL_MAX<<endl;
    rep(i, N) rep(j, N){
        if(i==j) wf[i][j]=0, wf2[i][j]=0;
        else wf[i][j]=LL_MAX, wf2[i][j]=LL_MAX;
    }
    ll A, B, C;
    rep(i, M){
        cin>>A>>B>>C;
        if(C>L) continue;
        wf[A-1][B-1]=C; wf[B-1][A-1]=C;
    }
    
    rep(k, N) rep(i, N) rep(j, N){
        if(wf[i][k]+wf[k][j] > L) continue;
        wf[i][j] = min(wf[i][k]+wf[k][j], wf[i][j]);
    }
    
    rep(i, N) rep(j, N){
        if(wf[i][j]>L || i==j) continue;
        wf2[i][j]=1;
    }
    
    rep(k, N) rep(i, N) rep(j, N){
        wf2[i][j] = min(wf2[i][k]+wf2[k][j], wf2[i][j]);
    }
    
    ll Q, s, t;
    cin>>Q;
    rep(i, Q){
        cin>>s>>t;
        if(wf2[s-1][t-1]>=LL_MAX) cout<<-1<<endl;
        else cout<<wf2[s-1][t-1]-1<<endl;
    }
    
    /*rep(i, N){
        rep(j, N){
            cout<<wf[i][j]<<" ";
        }
        cout<<endl;
    }*/
    
    return 0;
}


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

int main(){
  long long int n,x=0,k;
  cin >> n;
  k=n;
  while(k/10!=0){
    x+=k%10;
    k/=10;
  }
  x+=k;
  if(n%x==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
int n,l[100],i;
scanf("%d",&n);
int sum,max;
sum=0;
max=0;

for(i=0; i<n; i++){
scanf("%d",&l[i]);
sum+=l[i];
if(l[i]>max) max=l[i];

}

if(max>=sum-max) puts("No");
else if(max<sum-max) puts("Yes"); 

return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, W = MAP()
vw = [LIST() for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
	for j in range(W+1):
		if j < vw[i][1]:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = max(dp[i][j], dp[i+1][j-vw[i][1]]+vw[i][0])

print(dp[N][W])



Measured memory_bytes: 16748
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a, b;
  cin>>a>>b;
  long long int large = max(a, b); 
  long long int small=min(a,b);
    for (long long int lcm = large; ; lcm += large) {
        if (lcm % small == 0) 
        {	cout<<lcm;
         	break;
        }
    }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

template<class T, class S>
inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






int main(){
    int N; std::cin >> N;
    std::set<std::string> sst;
    {
        std::string S;
        for(int i(0); i < N; ++i){
            std::cin >> S;
            sst.insert(S);
        }
    }
    std::cout << sst.size() << std::endl;
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

	int ans = 0;

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			for (int k = 1; k <= n; ++k)
			{
				int cur = __gcd(i, j);
				cur = __gcd(cur, k);
				ans += cur;
			}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
// ⣿⣿⣿⣿⣿⣿⣿⡿⡛⠟⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⠿⠨⡀⠄⠄⡘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⠿⠨⡀⠄⠄⡘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⡿⠛⡧⠁⡴⣦⣔⣶⣄⢠⠄⠄⠹⣿⣿⣿⣿⣿⣿⣿⣤⠭⠏⠙⢿⣿⣿⣿⣿⣿
// ⣿⡧⠠⠠⢠⣾⣾⣟⠝⠉⠉⠻⡒⡂⠄⠙⠻⣿⣿⣿⣿⣿⡪⠘⠄⠉⡄⢹⣿⣿⣿⣿
// ⣿⠃⠁⢐⣷⠉⠿⠐⠑⠠⠠⠄⣈⣿⣄⣱⣠⢻⣿⣿⣿⣿⣯⠷⠈⠉⢀⣾⣿⣿⣿⣿
// ⣿⣴⠤⣬⣭⣴⠂⠇⡔⠚⠍⠄⠄⠁⠘⢿⣷⢈⣿⣿⣿⣿⡧⠂⣠⠄⠸⡜⡿⣿⣿⣿
// ⣿⣇⠄⡙⣿⣷⣭⣷⠃⣠⠄⠄⡄⠄⠄⠄⢻⣿⣿⣿⣿⣿⣧⣁⣿⡄⠼⡿⣦⣬⣰⣿
// ⣿⣷⣥⣴⣿⣿⣿⣿⠷⠲⠄⢠⠄⡆⠄⠄⠄⡨⢿⣿⣿⣿⣿⣿⣎⠐⠄⠈⣙⣩⣿⣿
// ⣿⣿⣿⣿⣿⣿⢟⠕⠁⠈⢠⢃⢸⣿⣿⣶⡘⠑⠄⠸⣿⣿⣿⣿⣿⣦⡀⡉⢿⣧⣿⣿
// ⣿⣿⣿⣿⡿⠋⠄⠄⢀⠄⠐⢩⣿⣿⣿⣿⣦⡀⠄⠄⠉⠿⣿⣿⣿⣿⣿⣷⣨⣿⣿⣿
// ⣿⣿⣿⡟⠄⠄⠄⠄⠄⠋⢀⣼⣿⣿⣿⣿⣿⣿⣿⣶⣦⣀⢟⣻⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⡆⠆⠄⠠⡀⡀⠄⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⡿⡅⠄⠄⢀⡰⠂⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
//        ああ、あなたは私に近づいています
// You thought you would find code here? But it was me DIO
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
typedef long long ll;
#define endl '\n'

const ll mod = 1e9 + 7;

bool ok(ll a, ll b, ll c) {
    return a + b > c && b + c > a && c + a > b;
}

int main () {
    cin.tie(0)->sync_with_stdio(0), cin.exceptions(cin.failbit);
#ifdef BOI
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n; cin >> n;
    vector<ll> l(n);
    for(ll& i : l) cin >> i;
    sort(all(l));
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            for(int k = j + 1; k < n; ++k) {
                if(ok(l[i], l[j], l[k]) && l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) ++cnt;
            }
        }
    }
    cout << cnt;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N, K = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    for i in range(N, 10 * N):
        i_set = set([int(c) for c in str(i)])
        is_broken = False
        for d in h_list:
            if d in i_set:
                is_broken = True
                break
        if not is_broken:
            print(i)
            return


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1000 8
1 3 4 5 6 7 8 9"""
        output = """2000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """9999 1
0"""
        output = """9999"""
        self.assertIO(input, output)


Measured memory_bytes: 59096
#include<stdio.h>


struct Node
{
  int key;
  int left;
  int right;
  int parent;
};

struct Node a[251];

int main()
{
  int n,i;
  
  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++)
    {
      scanf("%d",&a[i].key);
    }
  for(i = 1 ; i <= n ; i++)
    {
      
      if(i * 2 <= n)
	{
         a[i].left = a[i*2].key;
	 if(i*2 + 1 <= n)
	   {
            a[i].right = a[(i*2) + 1].key;
	   }
	}
      if(i >= 2)a[i].parent = a[i/2].key;
    }

  for(i = 1 ; i <= n ; i++)
    {
      printf("node %d: key = %d, ",i,a[i].key);
      if(i >= 2)printf("parent key = %d, ",a[i].parent);
      if(i * 2 <= n)
	{
         printf("left key = %d, ",a[i].left);
	 if(i*2 +1 <= n)
	   {
            printf("right key = %d, ",a[i].right);
	   }
	}
      printf("\n");
    }

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
 
int main()
{
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  int temp = 0;
  rep(i, n-1) {
    if (h[i+1]<=h[i]) temp++;
    else {
      ans = max(temp, ans);
      temp = 0;
    }
  }
  ans = max(temp, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(accumulate([0]+A, lambda acc, a: (acc+a)%M))
ans = 0
S = defaultdict(int)
for b in B:
    ans += S[b]
    S[b] += 1
print(ans)

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

///nの約数を追加する(nを含む)
vl divisor_pick(ll n){
    vl a;
    for(ll i=1LL;i*i<=n;i++){
        if(n%i == 0){
            a.push_back(i);
            if(n/i != i)a.push_back(n/i);
        }
    }
    sort(all(a));
    return a;
}

signed main()
{   
    gearup;
    int n;cin>>n;
    ll res = 0;
    for(int i=1;i<=n;i+=2){
        auto a = divisor_pick(i);
        if(a.size() == 8)res++;
    }
    out(res);
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))

height = [int(i) for i in input().split()]

tele = {}
for num, h in enumerate(height, 1):
    tele[num] = [h, "G"]

for roads in range(m):
    a, b = list(map(int, input().split()))
    if (tele[a][0] > tele[b][0]):
        tele[b][1] = "N"
    elif (tele[a][0] < tele[b][0]):
        tele[a][1] = "N"
    elif (tele[a][0] == tele[b][0]):
        tele[a][1] = "N"
        tele[b][1] = "N"

ans_list = tele.values()
ans = 0
for a in ans_list:
    if (a[1] == "G"):
        ans += 1

print(ans)



Measured memory_bytes: 31216
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
signed main(){
    ll n; cin >> n;
    ll a[100001];
    ll sum = 0;
    string ans = "YES";
    vector<ll> b(n), c(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum%2 != 0) ans = "NO";
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,x,mi=1001,mx=-1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		mi = min(mi,x);
		mx = max(mx,x);
	}
	printf("%d",mx-mi);
}

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

using namespace std;

const int N = 1e7;

int n, divisors[N + 1];
long long ans;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= n; j += i)
			++divisors[j];

	for (int i = 1; i <= n; ++i)
		ans += (long long) i * divisors[i];

	cout << ans << endl;
}


Measured memory_bytes: 42628
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define printa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define printv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define all(v) v.begin(),v.end()
#define debnl(x) cout<<#x<<"="<<x<<nl;
#define deb(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    ll n;
    cin>>n;
    if(n >=30) cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

Measured memory_bytes: 3648