akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[10];
map<string,int> mp;
string s0="01234567";
int dx[4]={1,-1,4,-4};
queue<string> que;
void bfs()
{
    que.push(s0);
    mp[s0]=1;
    while(!que.empty()) {
        string str=que.front();
        //cout<<str<<endl;
        que.pop();
        int pos;
        for(pos=0;pos<8;pos++) {
            if(str[pos]=='0') break;
        }
        for(int i=0;i<4;i++) {
            if(pos==3&&i==0) continue;
            if(pos==4&&i==1) continue;
            int x=pos+dx[i];
            if(x<0||x>=8) continue;
            string sss=str;
            sss[pos]=str[x];
            sss[x]=str[pos];
            if(!mp[sss]) {
                que.push(sss);
                mp[sss]=mp[str]+1;
                //cout<<sss<<endl;
            }

        }
    }
    return;

}
int main()
{
    bfs();
    while(scanf("%d",&a[0])==1) {
        for(int i=1;i<8;i++) scanf("%d",&a[i]);
        string s;
        for(int i=0;i<8;i++) s+=a[i]+'0';
        //cout<<s<<endl;
        cout<<mp[s]-1<<endl;

    }

    return 0;
}



Measured memory_bytes: 5448
import java.util.Scanner;

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

    String s = sc.nextLine();
    int num = 0;
    for(int i=0;i<s.length();i++){
      if(s.charAt(i) == '+'){
        num++;
      }
      else{
        num--;
      }
    }
    System.out.println(num);
  }
}


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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int cnt[ N ];

void go( int x ) {
        for( int i = 1; i * i <= x; i++ ) {
                if( x%i == 0 ) {
                        cnt[i]++;
                        if( x/i != i ) cnt[x/i]++;
                }
        }
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        int a , b , k;
        cin >> a >> b >> k;
        go( a );
        go( b );
           vector <int> C;
        for( int i = 1; i <= 100; i++ ) {
                if( cnt[i] == 2 ) C.push_back( i );
        }
        for( int i = C.size() - 1 , j = 1; i >= 0; i-- , j++ ) {
                if( j == k ) {
                        return cout << C[i] << endl,0;
                }
        }
        return 0;
}














Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int oo=1e9+7;
int dp[100005];
int n, k, h[100005];
int main()
{
    cin >> n >> k;
    for (int i=1; i<=n; i++) dp[i]=oo;
    for (int i=1; i<=n; i++) cin >> h[i];
    dp[1]=0; dp[2]=abs(h[1]-h[2]);
    for (int i=3; i<=n; i++){
        for (int j=1; j<=k; j++){
            if (i-j>0){
                dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,c,s=0,x,cnt=0;
    vector<ll>b,a;
    cin>>n>>m>>c;
    for(ll i=0;i<m;i++)
    {
         cin>>x;
         b.push_back(x);
    }
    for(ll i=0;i<n;i++)
    {
        for(ll i=0;i<m;i++)
        {
            cin>>x;
            s+=x*b[i];
        }
        if(s+c>0) cnt++;
        s=0;
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = max(max(a+b, a-b), a*b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        if(A==B){
            System.out.println(C);
        }else if(A==C){
            System.out.println(B);
        }else{
            System.out.println(A);
        }
    }
}

Measured memory_bytes: 23124
import math

H,W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
    exit()

odd_c = int(math.ceil(W / 2))
even_c = W // 2

odd_r = int(math.ceil(H / 2))
even_r = H // 2

print(odd_c * odd_r + even_c * even_r)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  string S;
  cin >> K >> S;
  S.size();
  if( S.size() <= K){
    cout << S << endl;
  }
  else if( S.size() > K){
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    stack<char> st;
    char ch;
    while ((ch = getchar()) != '\n') {
        if (st.empty()) {
            st.push(ch);
        }else if (ch == 'T' && st.top() == 'S') {
            st.pop();
        }else{
            st.push(ch);
        }
    }
    
    cout<<st.size()<<endl;
    
    
    return 0;
}


Measured memory_bytes: 512
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

n = int(input())
list_s = list((map(int, input().split())))
q = int(input())
list_t = list((map(int, input().split())))
ans = 0
for numbert in list_t:
    if binarySearch(list_s,numbert) != "NOT_FOUND":
        ans += 1
    
print(ans)



Measured memory_bytes: 16708
#include<iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
	int A, B;
	cin >> A >> B;

	int ans[3];
	ans[0] = A + B;
	ans[1] = A - B;
	ans[2] = A * B;
	int Amax = max(ans[0], ans[1]);
	for (int i = 0; i < 3; i++)
	{
		if (ans[i] > Amax)
		{
			Amax = ans[i];
		}
	}
	cout << Amax;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main(){
	int N, ID;
	cin >> N;
	set<int> grand;
	for(int i = 0; i < N; i++){
		cin >> ID;
		if(grand.count(ID) == 0)
			grand.insert(ID);
		else
			grand.erase(ID);
	}

	cout << grand.size();

	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    string ans = "";
    while (N > 0)
    {
        N--;
        ans += char('a' + N % 26);
        N /= 26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

int main() {
	speed;
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	cout.precision(9);
	cout << fixed << w * h / 2.0 << ' ' << (w - x == x && h - y == y ? 1 : 0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int A[M];
    rep(i, M){
        cin >> A[i];
    }

    int count_head = 0;
    int count_tail = 0;
    rep(i, M){
        if(A[i] < X){
            count_head++;
        }else if(A[i] > X){
            count_tail++;
        }else{
            cout << -1 << endl;
        }
    }

    cout << min(count_head, count_tail) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 
@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //     
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise 
I won't let it go. I'll build myself again like a fighter gets back up after 
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
#define fr(i,start,end, inc) for(ll i=(start); i<(end); i+=inc)
#define rf(i,end,start, inc) for(ll i=(start-1); i>=(end); i-=inc)
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define pl pair<ll, ll>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

bool compare(vector<ll> &a, const vector<ll> &b){
    return a.size()>b.size();
}

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

bool inline isPrime(ll n) { 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}

template<class T>
void printv(T &v, ll n){
    if(n==-1)
        n = v.size();
    rep(i,n)
        cout << v[i] << " ";
    cout << "\n";
}


void solve(){
    ll n,m,sum=0;
    cin>>n>>m;
    vector<ll>v(n);
    rep(i,n){
        cin>>v[i];
        sum+=v[i];
    }
    sort(all(v),greater<ll>());
    if(v[m-1]>=(sum/(4*m))){
        yes;
    }
    else
        no;
}
void solve2(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout <<c<<" "<<a<<" "<<b<<"\n";
}

int main(){
    fsync
    ll test=1;
    // cin >> test;
    while(test--){
        solve2();
    }
}

Measured memory_bytes: 256
N = int(input())

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

#ワーシャルフロイド法で条件を満たすものがあるか確認
for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()

ans = 0
for i in range(N-1):
    for j in range(i,N):
        for k in range(N):
            if i == k or j == k:
                continue
            if A[i][j] == A[i][k] + A[k][j]: # A[i][j]はiとjのノードを直接結ぶものではない
                break
        else:
            ans += A[i][j]

print(ans) 

Measured memory_bytes: 44124
import copy
import time


N = int(input())
As = list(map(int, input().split()))
As = [0] + As + [0]

t0 = time.time()

def dist(a, b):
    return abs(a - b)


dAs = [dist(As[i], As[i+1]) for i in range(N+1)]
sumdAs = sum(dAs)
# print(time.time()-t0, 'a')

def rem(i):
    ret = copy.deepcopy(dAs)
    print('copy', ret)
    ret[i] = dist(As[max(0, i-1)], As[i+1])
    print('rett', ret, i)
    ret = ret[:max(0, i-1)] + ret[i:]
    print('As', As)
    print('ret', ret)
    return ret

def calc(i):
    return sumdAs - dist(As[i], As[i-1]) - dist(As[i+1], As[i]) + dist(As[i+1], As[i-1])


for i in range(1, N+1):
    print(calc(i))


Measured memory_bytes: 14556
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s == u) a--;
  else b--;
  cout << a << ' ' << b << endl;
}


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

int main(){
    string T;
    cin >> T;
    rep(i,T.size()){
        if(T[i]=='?'){
            cout << 'D';
        }else{
            cout << T[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3756
R=range
def F(a,b):A=len(a);r=[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)];return r+[1]
def Z(X):
 i,j,k=X;U,V,W=M[i][j],M[j][k],M[i][k];A,B,C=map(len,[S[i]for i in X]);q=A+B+C
 for l in R(A+1):
  if U[l]!=0:
   for r in R(l,A+B+1):
    if (B<r-l or V[r-l]==1) and W[min(A,r)]==1:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in'abc']
T=R(3)
M=[[F(S[i],S[j])for j in T]for i in T]
from itertools import *;print(min([Z(i)for i in permutations(T)]))

Measured memory_bytes: 56156
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
int w,h,n,a,b,c,x0=0,y0=0,x1,y1;
cin>>w>>h>>n;x1=w,y1=h;

for(int i=1;i<=n;i++)
{
	cin>>a>>b>>c;
	if(c==1)
	{
		x0=max(x0,a);
	}
	else if(c==2)
	{
		x1=min(x1,a);
	}
	else if(c==3)
	{
		y0=max(y0,b);
	}
	else if(c==4)
	{
		y1=min(y1,b);
		
	}
	
}
if((x1-x0)>0 &&(y1-y0)>0)
cout<<(x1-x0)*(y1-y0);
else
cout<<"0";

return 0;
}
//​g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "h" "h.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g (in directory: /home/kamil/youtube/atcoder-dp)


Measured memory_bytes: 256
import java.util.*;
public class Main{
	static String DubDoc(int p, String[] s){
		char[] alph = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
		int[][] count = new int[26][p];
		String t = "";
		for(int i=0; i<26; i++){
			for(int j=0; j<p; j++){
				for(int k=0; k<s[j].length(); k++){
					if(s[j].charAt(k)==alph[i])count[i][j]++;
				}
			}
			Arrays.sort(count[i]);
			for(int l=0; l<count[i][0]; l++){
				t += alph[i];
			}
		}
		return t;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] S = new String[n];
		for(int i=0; i<n; i++){
			S[i] = sc.next();
		}
		System.out.println(DubDoc(n, S));
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static std::string const YES = "Yes";
static std::string const NO = "No";

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string w;
  std::cin >> w;
  std::multiset<char> cs;
  for (auto ch : w) {
    cs.insert(ch);
  }
  bool ret = true;
  for (char ch = 'a'; ch <= 'z'; ch++) {
    if ((cs.count(ch) % 2) != 0u) {
      ret = false;
      break;
    }
  }
  std::cout << (ret ? YES : NO) << std::endl;
  return 0;
}


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

int main(void) {
    int n; cin >> n;
    string s; cin >> s;

    int total = 1;
    for(int i = 1; i < n; i++) {
        if(s[i-1]!=s[i]) {
            total ++;
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <array>
#include <map>
#include <set>

using namespace std;

bool check(const vector<vector<int>> &table)
{
    for (int i = 1; i < table.size(); i++)
    {
        for (int j = 1; j < table[i].size(); j++)
        {
            if (table[i][j] - table[i][0] != table[i - 1][j] - table[i - 1][0])
            {
                return false;
            }
        }
    }

    for (int i = 1; i < table[0].size(); i++)
    {
        for (int j = 1; j < table.size(); j++)
        {
            if (table[j][i] - table[j][0] != table[j - 1][i] - table[j - 1][0])
            {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    vector<vector<int>> vs(3, vector<int>(3));
    for (auto &vv : vs)
    {
        for (auto &v : vv)
        {
            cin >> v;
        }
    }

    cout << (check(vs) ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n + 2];
        a[0] = 0;
        a[n + 1] = 0;
        for (int i = 1; i < n + 1; i++) {
            a[i] = in.nextInt();
        }

        int total = 0;
        for (int i = 0; i < n + 1; i++) {
            total += Math.abs(a[i + 1] - a[i]);
        }

        for (int i = 1; i < n + 1; i++) {
            int ans = 
                total - 
                Math.abs(a[i - 1] - a[i]) - 
                Math.abs(a[i] - a[i + 1]) + 
                Math.abs(a[i - 1] - a[i + 1]);
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 60504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

int main() {
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << (H - h) * (W - w) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
#define P pair<int, int>
#define ll long long
typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h, m;
    if(h1 > h2){
        h = (h2 + 24) - h1;
    }else{
        h = h2 - h1;
    }
    if(m1 > m2){
        h--;
        m2 += 60;
        m = m2 - m1;
    }else{
        m = m2 - m1;
    }
    int ans = h * 60 + m - k;
    cout << ans << endl;
}


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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

int main() {
  int n;
  std::cin >> n;
  std::map<std::string, int> mp;
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto &e: mp) {
    if (e.second > mx) mx = e.second;
  }
  for (auto &e: mp) {
    if (e.second == mx) std::cout << e.first << std::endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, LIM; scanf("%d %d", &N, &LIM);
  vector<int> W(N), V(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &W[i], &V[i]);
  }

  vector<vector<int>> dp(N + 5, vector<int>(305, 0));
  // int sum = 0;
  for (int i = 0; i < N; ++i) {
    int diff = W[i] - W[0];
    // sum += diff;
    for (int p = i + 1; p >= 1; --p) {
      for (int j = 0; j <= 300; ++j) {
        if (j - diff >= 0) {
          dp[p][j] = max(dp[p][j], dp[p - 1][j - diff] + V[i]);
        }
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= 300; ++j) {
      if (1LL* i * W[0] + j <= LIM) {
        ans = max(ans, dp[i][j]);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
import heapq

def func(x):
    return -x

def main():
    N, M = map(int, input().split())
    A = list(map(func,map(int, input().split())))
    heapq.heapify(A)
    cnt = 0
    while cnt < M:
        cnt += 1
        tmp = -heapq.heappop(A)
        heapq.heappush(A,-(tmp//2))
    
    print(-sum(A))

if __name__ == "__main__":
    main()

Measured memory_bytes: 72216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int extend = a - 1;
		int total = 1;
		int res = 0;
		
		while (total < b) {
			total += extend;
			res++;
		}
		System.out.println(res);
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 23252
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

void solve(){
    ll N;
    cin >> N;
    ll A[200010], B[200010];
    rep(i,0,N) cin >> A[i] >> B[i];
    map<lpair,ll> mp;
    vector<lpair> lp;
    ll cnt0 = 0;
    rep(i,0,N){
        if(A[i] == 0 && B[i] == 0){
            cnt0++;
            continue;
        }else if(A[i] == 0){
            mp[{0,1}]++;
            lp.push_back({0,1});
        }else if(B[i] == 0){
            mp[{1,0}]++;
            lp.push_back({1,0});
        }else{
            ll v = gcd(abs(A[i]),abs(B[i]));
            A[i] /= v;
            B[i] /= v;
            if(A[i] < 0 && B[i] < 0){
                A[i] *= -1;
                B[i] *= -1;
            }

            mp[{A[i], B[i]}]++;
            lp.push_back({A[i],B[i]});
        }
    }
    sort(lp.begin(), lp.end(), [](lpair l1, lpair l2){
        return min(l1.first, l1.second) > min(l2.first, l2.second);
    });
    
    ll ans = 1;
    map<lpair, ll> check;
    
    for(auto &e: lp){
        lpair l1 = e;
        if(check[l1]) continue;
        check[l1]++;
        ll n = mp[l1];
        lpair l2;
        // print("===");
        // print(l1.first, l1.second);
        if(l1.first > 0 && l1.second > 0){
            // どっちも正
            l2 = {l1.second, -l1.first};
            // print(l2.first, l2.second);
            check[l2]++;
            ll v1 = mp[l2];
            l2 = {-l1.second, l1.first};
            // print(l2.first, l2.second);
            check[l2]++;
            ll v2 = mp[l2];
            ll v = power(2,n) + power(2,v1+v2) - 1 + MOD;
            v %= MOD;
            ans *= v;
            ans %= MOD;

        }else if(l1.first < 0 || l1.second < 0){
            // どっちか負
            lpair l2 = {l1.second, -l1.first};
            ll v = power(2,n) + power(2,mp[l2]) - 1 + MOD;
            v %= MOD;
            ans *= v;
            ans %= MOD;
            check[l2]++;
        }else{
            // どっちか0
            lpair l2 = {l1.second, l1.first};
            ll v = power(2,n) + power(2,mp[l2]) - 1 + MOD;
            v %= MOD;
            ans *= v;
            ans %= MOD;
            check[l2]++;
        }

    }
    ans = (ans + cnt0 - 1 + MOD) % MOD;
    print(ans);

    

}

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

Measured memory_bytes: 72152
import heapq

n, m = map(int, input().split())

q = []
heapq.heapify(q)

a = list(map(int, input().split()))

for i in range(n):
    heapq.heappush(q, - a[i])

for i in range(m):
    v = - heapq.heappop(q)
    heapq.heappush(q, - (v // 2))

ans = 0
for i in range(n):
    v = - heapq.heappop(q)
    ans += v
print(ans)

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

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  for(ll i=0;i<n;i++) {
    cin >> s[i];
  }
  vector<string> s2(n);
  for(ll i=0;i<n;i++) {
    string temp;
    for(ll j=0;j<n;j++) {
      temp=temp+s[j][i];
    }
    s2[i]=temp;
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    bool flag=true;
    for(ll k=0;k<n;k++) {
      string temp=s[(k+i)%n];
      string temp2=s2[k].substr(i)+s2[k].substr(0,i);
      if(temp!=temp2) {
        flag=false;
        break;
      }
    }
    if(flag) {
      ans+=n;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int sum;

void search(int sum1,int x){
    if(sum1 == x){
        sum++;
        return;
    }
    if(sum1 > x)
        return;
    search(sum1+1,x);
    search(sum1+2,x);
    search(sum1+3,x);
}

int main(void){
    int num,days,years;
    for(;sum=0,days=0,years=0,scanf("%d",&num),num;){
        search(1,num);
        search(2,num);
        search(3,num);
        days=sum/10;
        if(sum%10 != 0)
            days++;
        years=days/365;
        if(days%365 != 0)
            years++;
        printf("%d\n",years);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
using namespace std;
#define rep(a,b) for(int a=0;a<b;a++)
#define repd(a,b,c) for(int a=b;a<c;a++)

int main() {
	int n;
	long long int c[5] = {};
	long long int ans = 0;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'M') c[0]++;
		else if (s[0] == 'A') c[1]++;
		else if (s[0] == 'R') c[2]++;
		else if (s[0] == 'C') c[3]++;
		else if (s[0] == 'H') c[4]++;
	}
	rep(i, 5) {
		repd(j, i + 1, 5) {
			repd(k, j + 1, 5) {
				ans += c[i] * c[j] * c[k];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int h,w;
    int i,j;
    while(1){
        scanf( "%d %d" , &h , &w );
        if( h == 0 && w == 0 ) break;
        for( i = 0; i < h ; i++ ){
            for( j = 0 ; j < w ; j++ ){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


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

int main()
{
	int N,K;
	cin >> N >> K;
	rep(i,N)
	{
		cin >> p[i];
	}
	sort(p,p+N);
	int sum = 0;
	rep(i,K)
	{
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3632
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

int main()
{
    speed();
    ll a;
    cin>>a;
    if(a==0)
        cout<<1<<endl;
    else
        cout<<0<<endl;

return 0;
}

Measured memory_bytes: 3648
#include <cstdio>

int main (int argc, char const* argv[])
{
	int a=2000,b=2000,c,i;
	for(i=0;i<3;i++){
		scanf("%d",&c);
		if(a>c)a=c;
	}
	for(i=0;i<2;i++){
		scanf("%d",&c);
		if(b>c)b=c;
	}
	
	printf("%d\n",a+b-50);
	
	
	return 0;
}

Measured memory_bytes: 1020
import sys
import math

n,m=map(int,input().split())
mod=10**9+7
val1=math.factorial(m)
val2=math.factorial(n)
if abs(n-m)>1:
	print("0")
elif (n==m):
	print((val1*val2*2)%mod)
else:
	print((val1*val2)%mod)

Measured memory_bytes: 5168
#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>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }
bool Q;
struct Line {
    mutable long long k, m, p;
    bool operator<(const Line& o) const {
        return Q ? p < o.p : k < o.k;
    }
};
struct LineContainer : multiset<Line> {
    const long long inf = LLONG_MAX;
    long long div(long long a, long long b) {
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(long long k, long long m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    long long query(long long x) {
        assert(!empty());
        Q = 1; auto l = *lower_bound({0, 0, x}); Q = 0;
        return l.k * x + l.m;
    }
};
int dp[200005];
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int c; cin >> c;
	vector<int> h(n); for (int o = 0; o < n; o++) { cin >> h[o]; }
	LineContainer L;
	L.add(2 * h[0], -h[0] * h[0]);
	for (int i = 1; i < n; ++i) {
		dp[i] = -L.query(h[i]) + c + h[i] * h[i];
		L.add(2 * h[i], -h[i] * h[i] - dp[i]);
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int a[m];
    vector<bool> check(n);
    for (int i=0; i<m; i++) {
        cin >> a[i];
        check[a[i]] = 1;
    }
    int forward = 0;
    for (int i=x; i<n; i++) {
        if (check[i]) forward++;
    }
    int backward = 0;
    for (int i=x; i>0; i--) {
        if (check[i]) backward++;
    }
    int ans = min(forward, backward);
    cout << ans << '\n';
   
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x,n;
	cin>>x>>n;
	bool s[102];
	for(int i=0;i<102;i++) s[i]=true;
	int f;
	for(int i=1;i<=n;i++) {
		cin>>f;
		s[f]=false;
	}
	for(int i=0;;i++) {
		if(s[x-i]) {
			cout<<x-i<<endl;
			return 0;
		}
		if(s[x+i]) {
			cout<<x+i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//W?????????
		int W = sc.nextInt();
		//H?????????
		int H = sc.nextInt();
		//x?????????
		int x = sc.nextInt();
		//y?????????
		int y = sc.nextInt();
		//r?????????
		int r = sc.nextInt();
		//?????¶??? (x+r) <= W (y+r) <= H 0 < (x+r) 0 <(y+r)
		if((x+r) <= W && (y+r) <= H && 0<(x+r) && 0 < (y+r)){
			//Yes?????¨???
			System.out.println("Yes");
		}else{
			//No?????¨???
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26356
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	ll N;
	cin >> N;
	ll now=1;
	ll ans=0;
	for(int i=0;i<N;i++){
		ll A;
		cin >> A;
		if(now==A || i==0)
			now++;
		if(i==0)
			ans+=A-1;
		else
			ans+=(A-1)/now;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

#define endl '\n'
#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define lson (idx<<1)
#define rson ((idx<<1) | 1)

const int mx = 2e5 + 9;

int n, q;

struct node {
    int l, r;
    int val;
    int lazy = mx;
};

struct SegTree {
    node tree[10 * mx];

    void build(int idx, int l, int r) {
        int mid = (l + r) / 2;

        tree[idx].l = l, tree[idx].r = r;
        if (l == r) {
            if (l == n) tree[idx].val = 1;
            else tree[idx].val = n;
            return;
        } 

        build(lson, l, mid);
        build(rson, mid + 1, r);

        tree[idx].val = min(tree[lson].val, tree[rson].val);
    }

    void propagate(int idx) {
        tree[idx].val = min(tree[idx].val, tree[idx].lazy);
        tree[lson].lazy = min(tree[lson].lazy, tree[idx].lazy);
        tree[rson].lazy = min(tree[rson].lazy, tree[idx].lazy);

        tree[idx].lazy = mx;
    }

    void update(int idx, int L, int R, int x) {
        int l = tree[idx].l, r = tree[idx].r;
        propagate(idx);

        if (r < L or R < l) return;
        if (L <= l and r <= R) {
            tree[idx].val = min(tree[idx].val, x);
            tree[idx].lazy = min(tree[idx].lazy, x);
            return;
        }

        update(lson, L, R, x);
        update(rson, L, R, x);

        tree[idx].val = min(tree[lson].val, tree[rson].val);
    }

    int query(int idx, int L, int R) {
        int l = tree[idx].l, r = tree[idx].r;
        propagate(idx);

        if (r < L or R < l) return mx;
        if (L <= l and r <= R) {
            return tree[idx].val;
        }

        int q1 = query(lson, L, R);
        int q2 = query(rson, L, R);

        return min(q1, q2);
    }
};

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

    SegTree R, C;
    R.build(1, 1, n);
    C.build(1, 1, n);

    ll ans = ll(n - 2) * (n - 2);
    while (q--) {
        int t, x; cin >> t >> x;
        if (t == 1) {
            int hi = R.query(1, x, x);
            ll stones = max(0, hi - 2);

            ans -= stones;
            R.update(1, x, x, 1);
            C.update(1, 1, hi, x);

        } else {
            int hi = C.query(1, x, x);
            ll stones = max(0, hi - 2);

            ans -= stones;
            C.update(1, x, x, 1);
            R.update(1, 1, hi, x);
        }
    }

    cout << ans << endl;
}


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

int main()
{
    int n,k,i,sum=0;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<k;i++)
    {
       sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool painted[111][111];

int main(void){
	int w,h,i,j,n,k,x,y,a,ans;
	cin >> w >> h >> n;
	for(k=0; k<n; ++k){
		cin >> x >> y >> a;
		switch(a){
			case 1:
			for(i=0; i<x; ++i){
				for(j=0; j<h; ++j){
					painted[i][j] = true;
				}
			}
			break;
			case 2:
			for(i=x; i<w; ++i){
				for(j=0; j<h; ++j){
					painted[i][j] = true;
				}
			}
			break;
			case 3:
			for(i=0; i<w; ++i){
				for(j=0; j<y; ++j){
					painted[i][j] = true;
				}
			}
			break;
			case 4:
			for(i=0; i<w; ++i){
				for(j=y; j<h; ++j){
					painted[i][j] = true;
				}
			}
			break;
		}
	}
	ans = h*w;
	for(i=0; i<w; ++i){
		for(j=0; j<h; ++j){
			if(painted[i][j]){
				--ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define MX 5050
bool f[MX];
bool L[MX][MX], R[MX][MX];
int a[MX];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++) scanf("%d", a + i);
	f[0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = MX - a[i]; j >= 0; j--)
			if(f[j] && j + a[i] < MX) f[j + a[i]] = 1;
		for(int j = 0; j < MX; j++) L[i][j] = f[j];
	}
	for(int i = 1; i < MX; i++) f[i] = 0;
	for(int i = n - 1; i >= 0; i--) {
		for(int j = MX - a[i]; j >= 0; j--)
			if(f[j] && j + a[i] < MX) f[j + a[i]] = 1;
		for(int j = 0; j < MX; j++) R[i][j] = f[j];
	}
	int res = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] >= k) continue;
		bool flag = true;
		int mx = 0;
		vector<int> vec;
		for(int j = 0; j < k; j++) {
			if(i && L[i - 1][j] && j + a[i] >= k) flag = false;
			if(i < n - 1 && R[i + 1][j] && j + a[i] >= k) flag = false;
			if(i < n - 1 && R[i + 1][j]) vec.push_back(j);
		}
		if(!flag) continue;
		if(i) for(int j = 0; j + a[i] < k; j++) {
			if(L[i - 1][j]) {
				int p = lower_bound(vec.begin(), vec.end(), k - j) - vec.begin(); p--;
				if(p >= 0) {
					if(vec[p] + j + a[i] >= k) {
						flag = false;
						break;
					}
				}
			}
		}
		res += flag;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 49920
import heapq

def Dijk(s): #始点Sのダイクストラ, すべての行先への最短距離のリストを返す
    Cost = [float("inf") for i in range(N)]
    Cost[s] = 0
    Q = [[0, s]]
    V = [False for i in range(N)]
    while Q:
        Next = heapq.heappop(Q)
        V[Next[1]] = True
        for node in Edge[Next[1]]:
            if V[node[1]] == False:
                if Next[0] + node[0] < Cost[node[1]]:
                    Cost[node[1]] = Next[0] +node[0]
                    heapq.heappush(Q, [Cost[node[1]], node[1]])
    return Cost


N, M = map(int, input().split())
Edge = [[] for i in range(N)]
Search = []
for i in range(M):
    a, b, c = map(int,input().split())
    a, b = a-1, b-1
    Edge[a].append([c, b])
    Edge[b].append([c, a])
    Search.append((a, b, c))

Ans = 0
Length = []
for i in range(N):
    Length.append(Dijk(i))

for s in Search:
    for i in range(N):
        if Length[i][s[0]] + s[2] == Length[i][s[1]]:
            break
    else:
        Ans += 1

print(Ans)

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(a >= k)cout << a-k << ' ' << b << endl;
  else if(a + b >= k)cout << 0 << ' ' << a + b - k << endl;
  else cout << 0 << ' ' << 0 << endl;
}

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


int main() {
	int n, A[100], cun=1;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A, A + n);
	for (int i = 0; i < n-1; i++) {
		if (A[i] != A[i + 1])cun++;
	}
	cout << cun << endl;


	return 0;
}





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

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> k(M, 0);
    vector<int> p(M, 0);
    vector<vector<int>> s(M);
    for(int i{0}; i<M; ++i){
        cin >> k.at(i);
        s.at(i) = vector<int>(k.at(i), 0);
        for(int j{0}; j<k.at(i); ++j){
            cin >> s.at(i).at(j);
        }
    }
    for(int i{0}; i<M; ++i){
        cin >> p.at(i);
    }

    int n{0};
    for(int bit{0}; bit<(1<<N); ++bit){
        bool result{true};
        for(int i{0}; i<M; ++i){
            int sum{0};
            for(int j{0}; j<k.at(i); ++j){
                if(bit & (1 << (s.at(i).at(j)-1))){
                    ++sum;
                }
            }
            if(sum%2 != p.at(i)){
                result = false;
                break;
            }
        }
        if(result){
            ++n;
        }

    }

    cout << n << endl;
}


Measured memory_bytes: 3528
#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(){
  string a;
cin >> a;
 
if (a == "AAA" || a == "BBB"){
  cout << "No" << endl;
}
else{
   cout << "Yes" << endl;
}
 
return 0;
  
}

Measured memory_bytes: 3584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < N; i++) {
                set.add(in.nextInt());
            }
            out.println(N == set.size() ? "YES" : "NO");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 53652
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int A;
  int damage = 0;
  vector<int> B(N+1, 0);
  REP(i, N){
    cin >> A >> B[i+1];
    chmax(damage, A);
  }

  sort(B.begin()+1, B.end(), greater<>());

  int ans = INF;
  REP(i, N+1){
    if(i != 0) B[i] += B[i-1];
    if(H-B[i] <= 0) chmin(ans, i);
    else chmin(ans, i+(H-B[i]+damage-1)/damage);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024