akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    map<ll,ll>m;
    for(ll i=0;i<n;i++){
        if(m[a[i]]==0){
            m[a[i]]=1;
            ans++;
        }
        else{
            m[a[i]]=0;
            ans--;
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B;
    cin >>A  >> B;
    cout << A * B << "\n";
    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vvi a(n, vi(m));
  rep(i, 0, n) rep(j, 0, m){
    cin >> a[i][j];
    a[i][j]--;
  }

  set<int> s;
  rep(i, 0, m) s.insert(i);

  vi cur(n);
  int ans = inf;
  rep(i, 0, m){
    vi cnt(m);
    rep(j, 0, n) cnt[a[j][cur[j]]]++; 

    int ma = -1, tmp;
    rep(j, 0, m) if(chmax(ma, cnt[j])) tmp = j;
    chmin(ans, ma);

    s.erase(s.lower_bound(tmp));
    rep(j, 0, n){
      while(*s.lower_bound(a[j][cur[j]]) != a[j][cur[j]]){
        cur[j]++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main()
{
	int n;

	while (scanf("%d", &n), n){
		vector<int> v;

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

			scanf("%d", &s);

			v.push_back(s);
		}

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

		v[0] = v[n - 1] = 0;

		int sum = 0;

		for (int i = 0; i < n; i++){
			sum += v[i];
		}

		printf("%d\n", sum / (n - 2));
	}

	return (0);
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;
    
    for(int i=0;i<n;++i){
        
        bool flg=false;
        int maxB=0,maxC=0;
        
        for(int j=0;j<10;++j){
            int tmp;
            cin >> tmp;
            if(maxB<tmp)
                maxB=tmp;
            else if(maxC<tmp)
                maxC=tmp;
            else{
                flg=true;
            }
        }
        
        if(flg)
            cout << "NO" <<endl;
        else
            cout << "YES" <<endl;
        
    }
    
    
    return 0;
}

Measured memory_bytes: 1152
n = int(input())
h = list(map(int,input().split()))

is_judge = True
for i in reversed(range(n-1)):
	if h[i]>h[i+1]:
		if h[i]-1 > h[i+1]:
			is_judge = False
		else:
			h[i] = h[i]-1



if is_judge:
	print('Yes')
else:
	print('No')


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

int main() {
  int N,x;
  cin >> N >> x;
  int child[N];
  for(int i=0; i<N; i++)cin >> child[i];
  
  sort(child,child+N);
  int count = 0;

  for (int i=0; i<N;i++){
    	if (i == N-1){
           if(child[i] == x){
             count++;
           }
        }else{
  	   		x -= child[i];
 	  		if(x < 0)break;
	 	   count++;
       }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=100005;
using namespace std;
int n;
map<int,int>mp;
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        int el;cin>>el;mp[el]++;
    }
    int sm=0;
    int cnt=mp.size();
    for(auto el:mp)sm+=el.second-1;
    if(sm%2)cnt--;
    cout<<cnt<<'\n';
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

#define vowel(n) cout << ((n) ? "vowel" : "consonant"  ) << endl
bool chk(str s)
{
    if(s=="a"||s=="e"||s=="i"||s=="o"||s=="u"){
        return true;
    }else{
        return false;
    }
}

int main()
{
    sts(s);
    vowel(chk(s));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}

//小さい順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//変換(文字から整数)
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}


int main(void){
    int n,k,q;
    i_cin3(n,k,q);
    int scr[n];
    int crr[q];
    rept(i,0,n)
    scr[i]=k;
    rept(i,0,q)
    i_cin(crr[i]);
    rept(i,0,q){
        scr[crr[i]-1]++;
    }
    rept(i,0,n){
        scr[i]-=q;
    }
    rept(i,0,n){
        if(scr[i]>0){
            printf("\nYes");
        }else{
            printf("\nNo");
        }
    }
    return 0;
}

    




Measured memory_bytes: 1280
#import sys
#input = sys.stdin.readline
def main():
    N, K = map( int, input().split())
    t = (N-2)*(N-1)//2
    if K > t:
        print(-1)
        return
    print(N-1+t-K)
    for i in range(1,N):
        print(i, N)
    s = t - K
    cnt = 0
    for i in range(1,N):
        if cnt == s:
            break
        for j in range(i+1, N):
            if cnt == s:
                break
            print(i,j)
            cnt += 1
    return
if __name__ == '__main__':
    main()


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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

string S;

signed main() {
    cin >> S;
    for (int i = S.length(); i > 0; ) {
        if (S.length() < 5) {
            cout << "NO" << endl;
            return 0;
        }
        if (S.substr(i - 5, 5) == "dream") {
            i -= 5;
        } else if (S.substr(i - 5, 5) == "erase") {
            i -= 5;
        } else if (S.substr(i - 6, 6) == "eraser") {
            i -= 6;
        } else if (S.substr(i - 7, 7) == "dreamer") {
            i -= 7;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
class Main 
{
  public static void main(String[] args) 
  {
    Scanner input=new Scanner(System.in);
    String a=input.next();
    if(a.length()==10)
    {
      if(a.contains("2017/01/"))
      {
        String temp=""+ a.charAt(8)+a.charAt(9);
        int tempa=Integer.parseInt(temp);
        if(tempa>=1 && tempa<=31)
        {
          a=a.replace("2017","2018");
          System.out.println(a);
        }
      }
    }
  }
}

Measured memory_bytes: 21972
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ll  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    ll  n, k ; 
    cin >> n >> k ; 
    vector <ll>  a(n), v ; 
    for (ll &i: a) cin >> i ; 
    for (ll i=0;i<n;i++){
        ll sum = 0LL ; 
        for (ll j=i;j<n;j++){
            sum += a[j] ; 
            v.emplace_back(sum) ; 
        }
    }

    ll ans = 0 ; 
    for (ll i=40;i>=0;i--){ 
        ll c = 0 ; 
        vi cur ; 
        for (auto &it: v){ 
            ll x = it;
            if (x&(1LL<<i)) {
                c++ ; 
                cur.pb(x) ; 
            }
        }
        if (c>=k){ 
            ans += (1LL<<i) ; 
            v = cur ; 
        }
    }
    co(ans) ; 
}

signed main()
{
    ios_base::sync_with_stdio(false) ; 
    cin.tie(0),cout.tie(0) ; 
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 8952
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] c = S.toCharArray();
        Arrays.sort(c);
        if (c[0] == 'a' && c[1] == 'b' && c[2] == 'c') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 21844
def resolve():
    x, y = map(int, input().split())
    list = [1, 3, 5, 7, 8, 10, 12]
    lists = [4, 6, 9, 11]
    print("Yes" if (list.count(x) == 1 and list.count(y)) or (lists.count(x) == 1 and lists.count(y)) else "No")
resolve()

Measured memory_bytes: 3060
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int d[4];
    d[0] = n / 1000;
    d[1] = n % 1000 / 100;
    d[2] = n % 100 / 10;
    d[3] = n % 10;
    if((d[0] == d[1] && d[1] == d[2]) || (d[1] == d[2] && d[2] == d[3])){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')


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

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

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

const ll INF = 1LL << 60;

int main(){
  string ans = "Yes";
  int n; cin >> n;
  vector<string> w(n);
  rep(i, n) cin >> w[i];

  for (int i = 1; i < n; i++) {
    if(w[i].front() != w[i-1].back()) ans = "No";
    for (int j = 0; j < i; j++) {
      if (w[i] == w[j]) ans = "No";
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl N;
static set<sl> Ci;

int main(void) {
  cin >> N;
  sl t;
  FOR0(i, N) {
    cin >> t;
    if (Ci.count(t) == 1) {
      cout << "NO" << endl;
      return 0;
    }
    Ci.insert(t);
  }
  cout << "YES" << endl;
  return 0;
}

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

using namespace std;

const int MOD=1e9+7;
const int N=3e3+10;
int n,m,f[2][N<<1][2];
int main(){
        cin>>n>>m;
        for(int i=0;i<n;i++) f[0][i][(i==0)]=4;
        m--;
        for(int i=0;i<m;i++){
                int cur=i&1;
                memset(f[cur^1],0,sizeof(f[cur^1]));
                for(int alr=0;alr<=1;alr++)
                        for(int use=0;use<n;use++){
                                for(int add=-1;add<=1;add++) if (use+add>=0&&use+add<n){
                                        int pos=use+add;
                                        int talr=(pos==0||alr);
                                        f[cur^1][pos][talr]=(f[cur^1][pos][talr]+1LL*(1+(add==0))*f[cur][use][alr])%MOD;
                                }
                }
         
        }
        int ans=0;
        for(int i=0;i<n;i++) 
                ans=(ans+f[m&1][i][1])%MOD;
        cout<<ans%MOD;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int digit(int n) {
  int res = 0;
  while(n >= 1) {
    res += (n % 10);
    n /= 10;
  }
  return res;
}

int main() {
  int N; cin >> N;
  int ans = pow(10, 9) + 10;
  int a, b;
  for(int i = 1; i < N; ++i) {
    a = i; b = N - i;
    int res = digit(a) + digit(b);
    if(ans > res) ans = res;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;

int main() {
    int n; cin >> n;
    vector<int> ary(n);
    rep(i, 0, n) {
        cin >> ary[i];
    }
    map<int, int> dista, distb;
    for(int i=0; i<n/2; i++) {
        if(dista.find(ary[2*i]) == dista.end() ) {
            dista[ary[2*i]] = 1;
        } else {
            dista[ary[2*i]] = dista[ary[2*i]] + 1;
        }
        if(distb.find(ary[2*i+1]) == distb.end() ) {
            distb[ary[2*i+1]] = 1;
        } else {
            distb[ary[2*i+1]] = distb[ary[2*i+1]] + 1;
        }
    }
    int ma = 0, mb=0, maa = 0, mbb = 0;
    int ia = -1, ib = -1, iaa = -1, ibb = -1;
    for (auto itr = dista.begin(); itr != dista.end(); ++itr) {
        if(itr->second > ma) {
            ma = itr->second;
            ia = itr->first;
        } 
    }
    for (auto itr = dista.begin(); itr != dista.end(); ++itr) {
        if(itr->second > maa && itr->first != ia) {
            maa = itr->second;
            iaa = itr->first;
        } 
    }
    for (auto itr = distb.begin(); itr != distb.end(); ++itr) {
        if(itr->second > mb) {
            mb = itr->second;
            ib = itr->first;
        } 
    }
    for (auto itr = distb.begin(); itr != distb.end(); ++itr) {
        if(itr->second > mbb && itr->first != ib) {
            mbb = itr->second;
            ibb = itr->first;
        } 
    }

    int ans = -1; 
    if (ia == ib) {
        if(ma + mbb > mb + maa) {
            ans = n - (ma + mbb);
        } else {
            ans = n - (mb + maa);
        }
    } else {
        ans = n - (ma + mb);
    }
    printf("%d\n", ans);
    return 0;  
}

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

int main()
{
    char s[101];
    int rez = 0, n;
    cin >> s;
    n = strlen(s);
    for (int i = 0; i < n / 2; ++i)
    {
        if (s[i] != s[n - i - 1]) rez++;
    }
    cout << rez;
    return 0;
}


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

count = {}
for _ in range(m):
    p,s = input().split()
    if p not in count:
        count[p] = [0,0]
    if s == 'AC':
        count[p][0] = 1
    elif s == 'WA' and count[p][0] == 0:
        count[p][1] += 1

ac,pena = 0,0
for a,w in count.values():
    ac += a
    if a:
        pena += w
print(ac, pena)


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

int main(void){
    int n;
    cin >> n;
    if(n<=111) cout << "111";
    else if(n<=222) cout << "222";
    else if(n<=333) cout << "333";
    else if(n<=444) cout << "444";
    else if(n<=555) cout << "555";
    else if(n<=666) cout << "666";
    else if(n<=777) cout << "777";
    else if(n<=888) cout << "888";
    else cout << "999";
    cout << endl;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(s string) int {
        max := func(x, y int) int {
                if x > y {
                        return x
                }
                return y
        }

        isACGT := func(s string) bool {
                for _, r := range s {
                        if r == 'A' || r == 'C' || r == 'G' || r == 'T' {
                                continue
                        } else {
                                return false
                        }
                }
                return true
        }

        l := len(s)
        out := 0
        for i := 0; i <= l; i++ {
                for j := i + 1; j <= l; j++ {
                        t := s[i:j]
                        if isACGT(t) {
                                out = max(out, len(t))
                        }
                }
        }
        return out
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 1768
from collections import Counter

h, w = map(int, input().split())
a = []
for _ in range(h):
    aa = list(input())
    a += aa

c = Counter(a)

hq, hr = divmod(h, 2)
wq, wr = divmod(w, 2)
d = {1: hr * wr,
     2: hq * wr + hr * wq,
     4: hq * wq}

for v in c.values():
    q4, r4 = divmod(v, 4)
    if q4 > d[4]:
        r4 += 4 * (q4 - d[4])
        q4 = d[4]
    d[4] -= q4
    q2, r2 = divmod(r4, 2)
    d[2] -= q2
    d[1] -= r2

if any(d.values()):
    ans = "No"
else:
    ans = "Yes"

print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(ki, k){
        vector<int> b(n+1);
        rep(i, n){
            int l = max(0, i-a[i]);
            int r = min(i+a[i]+1, n);
            b[l]++;
            b[r]--;
        }
        rep(i, n) b[i+1] += b[i];
        b.pop_back();
        if(a == b) break;
        a = b;
    }
    rep(i, n){
        if(i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 4792
use std::io::{self, Read};
use std::str::FromStr;
use std::collections::VecDeque;

pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

// vecに記載された有効グラフの接続から、点0から各張点までの最短距離を計算する関数
fn calc_dist(vec: &Vec<Vec<usize>>) -> Vec<i32> {
    let n = vec.len();
    let mut dist: Vec<i32> = vec![-1; n];

    // BFSで探索
    let mut que = VecDeque::new();
    que.push_back((0,0));   // (idx, dist)。始点の距離を0として追加
    while let Some((idx, d)) = que.pop_front() {
        if dist[idx] == -1 {
            dist[idx] = d;
            for p in vec[idx].iter() {
                if dist[*p] == -1 {
                    que.push_back((*p, d+1));
                }
            }
        }
    }

    dist
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();

    let vec: Vec<Vec<usize>> = (0..n)
        .map(|_| {
            let _u: usize = sc.read();
            let k: usize = sc.read();
            (0..k)
                .map(|_| { sc.read::<usize>() - 1 })    // 配列添え字用に1減少
                .collect::<Vec<usize>>()
        }).collect();

    let dist = calc_dist(&vec);
    for i in 0..n {
        println!("{} {}", i+1, dist[i]);
    }
}



Measured memory_bytes: 5036
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


"""
コストが低い人が食べにくいものを食べる．
コストが低い人を追い抜かすことはない，（追い抜かすなら入れ替えて良いから）


"""
def main():
    mod=10**9+7
    N,K=MI()
    A=LI()
    F=LI()
    F.sort()
    A.sort(reverse=True)
    
    if K>=sum(A):
        print(0)
        exit()
        
    def ch(x):
        # x秒でクリアできるか
        temp=0#　必要修行回数
        for i in range(N):
            af=A[i]*F[i]
            if af>x:
                add=(af-x+F[i]-1)//F[i]
                temp+=(add)
                
        return temp <= K
        
    ok=10**12
    ng=0
    
    while ok-ng>1:
        med=(ok+ng)//2
        if ch(med):
            ok=med
        else:
            ng=med 
            
    print(ok)
    
main()


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

using namespace std;

int main(){
    int n;
    set<int> s;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(s.count(a) != 0){
            cout << "NO" << endl;
            return 0;
        }
        s.insert(a);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
s = input()
i = 0
c = 0
res = 0
while i<len(s):
    j = i
    while j<len(s) and s[i]==s[j]:
        j += 1
    if s[i]=="<":
        res += (j-i)*(j-i+1)//2
        c = j-i
    else:
        res += (j-i)*(j-i+1)//2
        if c>j-i:
            res -= j-i
        else:
            res -= c

    i = j

print(res)

Measured memory_bytes: 4120
se=input()
q=int(input())
h=0
se1=""
se2=""
for i in range(q):
    s=input().split()
    if len(s)==1:
        h+=1
    elif len(s)==3:
        if (h+int(s[1])-1)%2==0:
            se1+=s[2]
        else:
            se2+=s[2]
r=se1[::-1]+se+se2
if h%2==0:
    print(r)
else:
    print(r[::-1])



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

const int N = 405 , M = 5e3+5;

int n , m ;

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

    cout<<n/( 2*m+1 ) +(n%( 2*m+1 )>0);


    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 2147483647
 
using namespace std;

#define MAX_V 101

int G[MAX_V][MAX_V];  // cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int mincost[MAX_V];      // 集合Xからの辺の最小コスト
bool used[MAX_V];        // 頂点iがXに含まれているか
int V;                   // 頂点数

int prim(int n)
{
	
	V = n;

	for (int i = 0; i < V; i++) {
		mincost[i] = INF;
		used[i] = false;
	}

	int res = 0;
	mincost[0] = 0;

	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;     // 頂点vをXに追加
		res += mincost[v];  // 辺のコストを加える
		for (int u = 0; u < V; u++) {
			mincost[u] = min(mincost[u], G[v][u]);
		}
	}

	return (res);
}


int main(void)
{
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> G[i][j];
			if (G[i][j] == -1) G[i][j] = INF; 
		}
	}

	cout << prim(n) << endl;


	return (0);
}

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;
#define int long long
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int A,B;
    cin >> A >> B;
    cout << lcm(A,B) << endl;
}



Measured memory_bytes: 256
n,a,b = [int(i) for i in input().split()]
if (b-a)%2==0:
    print((b-a)//2)
else:
    r = a + (b-a-1)//2
    l = n-b+1 + ( n - (a+n-b+1) )//2 
    print(min(r,l))

Measured memory_bytes: 3060
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,m,i,nn,mm, si,ti
    character(:),allocatable:: s,t

    read*, n,m
    allocate(character(n):: s)
    allocate(character(m):: t)
    read*, s
    read*, t
    nn = lcm(n,m)/n
    mm = lcm(n,m)/m

    do i=1,n/mm
        si = mm*(i-1)+1
        ti = nn*(i-1)+1

        if (s(si:si) /= t(ti:ti)) then
            print'(i0)', -1
            stop
        end if
    end do
    print'(i0)', lcm(n,m)
contains
    function lcm(x,y) result(ret)
        integer(int64):: x,y,ret

        ret=x*y/gcd(x,y)
    end function

    recursive function gcd(x,y) result(ret)
    integer(int64):: x,y,ret

    if (mod(x,y) == 0) then
        ret = y
        return
    end if

    ret = gcd(y,mod(x,y))
end function
end program name

Measured memory_bytes: 768
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vector<pair<int, pair<int, int>>> hxy;

int main() {
    cin >> N;
    rep(i, N) {
        int _x, _y, _h;
        cin >> _x >> _y >> _h;
        hxy.emplace_back(_h, mp(_x, _y));
    }

    sort(all(hxy), greater<pair<int, pair<int, int>>>());

    for (int x = 0; x <= 100; ++x) {
        for (int y = 0; y <= 100; ++y) {
            int h = hxy[0].first + abs(x - hxy[0].second.first) + abs(y - hxy[0].second.second);

            bool correct = true;
            rep(i, N) {
                int d = abs(x - hxy[i].second.first) + abs(y - hxy[i].second.second);
                bool b = (hxy[i].first == 0 && h - hxy[i].first <= d) || h - hxy[i].first == d;
                if (!b) correct = false;
            }

            if (correct) {
                cout << x << " " << y << " " << h << 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;
typedef long long ll;

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

    vector<bool> a(26);

    
    unsigned long n = s.size();
    
    for(int i = 0; i < n; i++){
        a[s[i] - 'a'] = true;
    }
    
    int flag = 0;
    for(int i = 0; i < 26; i++){
        if(a[i] == false){
            flag = 1;
            char c = 'a' + i;
            cout << c;
            break;
        }
    }
    if(flag == false) cout << "None";
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int parent[100010];
vint edge[100010];
bool visited[100010];

int dfs(int cur) {
	if (edge[cur].size() == 1)	return 0;
	if (edge[cur].size() == 2) {
		if (visited[edge[cur][0]]) {
			visited[edge[cur][1]] = true;
			return dfs(edge[cur][1]) + 1;
		}
		else {
			visited[edge[cur][0]] = true;
			return dfs(edge[cur][0]) + 1;
		}
	}
	int ret = 0;
	rep(i, edge[cur].size()) {
		int to = edge[cur][i];
		if (!visited[to]) {
			visited[to] = true;
			ret ^= dfs(to) + 1;
		}
	}
	return ret;
}

int main() {
	int n;	cin >> n;
	srep(i, 1, n) {
		int x, y;	cin >> x >> y;	x--;	y--;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	visited[0] = true;
	int ret = 0;
	rep(i, edge[0].size()) {
		visited[edge[0][i]] = true;
		ret ^= dfs(edge[0][i]) + 1;
	}
	cout << (ret ? "Alice" : "Bob") << endl;
	return 0;
}

Measured memory_bytes: 6272
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
 
 
public class Main {
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
        while(true){
        	final int m = sc.nextInt();
        	
        	if(m == 0){
        		break;
        	}
        	
        	int[] next = new int[m + 1];
        	Arrays.fill(next, -1);
        	boolean[] base = new boolean[m + 1];
        	Arrays.fill(base, true);
        	
        	while(true){
        		final int I = sc.nextInt();
        		final int J = sc.nextInt();
        		
        		//System.out.println(Arrays.toString(next));
        		//System.out.println(Arrays.toString(base));
        		
        		if(I == 0 && J == 0){
        			break;
        		}
        		
        		if(base[I] && J == 0){
        			continue;
        		}else if(I == J){
        			continue;
        		}
        		
        		//check
        		boolean flag = true;
        		if(J != 0){
        			int cur = J;
        			
        			while(cur != -1){
        				cur = next[cur];
        				
        				if(cur == I){
        					flag = false;
        					break;
        				}
        			}
        		}
        		
        		if(!flag){
        			continue;
        		}
        		
        		//broke_up_I
        		{
        			int cur = I;
        			

        			for(int i = 1; i <= m; i++){
        				if(next[i] == cur){
        					next[i] = -1;
        				}
        			}
        			
        			while(cur != -1){
        				base[cur] = true;
        				int old = cur;
        				cur = next[cur];
        				next[old] = -1;
        			}
        		}
        		
        		if(J == 0){
        			continue;
        		}else{
        			int limit = J;
        			
        			while(next[limit] != -1){
        				limit = next[limit];
        			}
        			
        			next[limit] = I;
        			base[I] = false;
        		}
        	}
        	
        	ArrayList<Integer> list = new ArrayList<Integer>();
        	for(int i = 1; i <= m ; i++){
        		if(!base[i]){
        			continue;
        		}
        		
        		int height = 0;
        		int cur = i;
        		while(cur != -1){
        			cur = next[cur];
        			height++;
        		}
        		
        		list.add(height);
        	}
        	
        	Collections.sort(list);
        	for(int number : list){
        		System.out.println(number);
        	}
        	System.out.println("end");
        }
    }
 
}

Measured memory_bytes: 26708
import java.util.*;

public class Main{
    static int gcd(int a,int b){
        if(b == 0) return a;
        return gcd(b,a%b);
    }
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int sum=0;
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                for(int m=1;m<=k;m++){
                    sum+=gcd(gcd(i,j),m);
                }
            }
        }
        System.out.println(sum);
    }
}


       
   

Measured memory_bytes: 35668
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K, N = lr()
A = np.array(lr())
A = np.append(A, A[0] + K)
Adiff = np.diff(A)
answer = K - Adiff.max()
print(answer)


Measured memory_bytes: 34168
#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
// func
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

int w, h;
int c[50][50];

void dfs(int x, int y);

void solve()
{
  while (true)
  {
    cin >> w >> h;

    if (w == 0 && h == 0)
      break;

    rep(j, h) rep(i, w)
    {
      cin >> c[i][j];
    }

    int cnt = 0;
    rep(j, h) rep(i, w) if (c[i][j] == 1)
    {
      dfs(i, j);
      cnt++;
    }

    cout << cnt << endl;
  }
}

void dfs(int x, int y)
{
  c[x][y] = 0;
  rep(dy, -1, 2) rep(dx, -1, 2)
  {
    int nx = x + dx;
    int ny = y + dy;
    if (nx >= 0 && ny >= 0 && nx < w && ny < h && c[nx][ny] == 1)
    {
      dfs(nx, ny);
    }
  }
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}



Measured memory_bytes: 3348
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	ll N,M;
	cin>>N>>M;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];
	sort(A.begin(),A.end());

	ll safe=0, out=1e6;
	while(out-safe>1){
		ll mid=(safe+out)/2;
		ll cnt=0;
		for(const auto& a: A){
			cnt += A.end() - lower_bound(A.begin(), A.end(), mid-a);
		}
		(cnt>=M?safe:out)=mid;
	}
	//cout<<safe<<endl;

	auto acc = A;
	rep(i,N-1)acc[i+1]+=acc[i];

	ll cnt = 0;
	ll res = 0;
	for(const auto& a: A){
		ll idx = upper_bound(A.begin(), A.end(), safe-a)-A.begin();
		cnt+=N-idx;
		res += a * (N-idx);
		res += acc.back() - (idx==0?0:acc[idx-1]);
	}

	res += safe * (M-cnt);
	cout<<res<<endl;
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<vector<int>>a(n,vector<int>(n,0));
  for(int i=0;i<n;i++){
    int num;
    cin>>num;
    num--;
    int m;
    cin>>m;
    for(int j=0;j<m;j++){
      int x;
      cin>>x;
      x--;
      a[num][x]++;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<a[i][j];
      if(j!=n-1)cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3156
// C - Triangular Relationship
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K; cin>>N>>K;
	long long ans = 0;
	int q = N/K, r = N%K;
	for(int a=1; a<=N; ++a){
		int b = K - a%K, c = K - b%K;
		if((c + a)%K == 0){
			long long now = 1;
			now *= (1<=b%K && b%K<=r)? q+1: q;
			now *= (1<=c%K && c%K<=r)? q+1: q;
			ans += now;
		}
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int maxa = 0, mina = 0;
  rep(i, n) {
    if (a[i] >= 0) maxa = max(maxa, a[i]);
    else mina = min(mina, a[i]);
  }

  int res;
  if (maxa >= -mina) res = maxa;
  else res = mina;
  int idx;
  rep(i, n) {
    if (a[i] == res) {
      idx = i;
      break;
    }
  }

  int m = 2 * n - 1;
  cout << m << endl;

  rep(i, n) {
    a[i] += res;
    cout << idx + 1 << " " << i + 1 << endl;
  }
  if (res >= 0) {
    rep(i, n - 1) {
      cout << i + 1 << " " << i + 2 << endl;
    }
  }
  else {
    repr(i, n - 2) {
      cout << i + 2 << " " << i + 1 << endl;
    }
  }






  
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var wrong_answer = new wrong_answer();
        wrong_answer.Solve();
    }
}

public class wrong_answer
{
    const int INF = 1 << 29;
    const long INFL = 1L << 60;
    const int MOD = 1000000007;
    const int MOD2 = 998244353;

    myinout IO = new myinout();



    public void Solve()
    {

        var o = IO.intm;
        var n = o[0];
        var h = o[1];
        var a = IO.intm;
        var x = a.Sum();
        IO.yn(x >= n);



    }
}






public static class Math2
{
    public static long pow(long i, long n, long MOD = 1000000007)
    {
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * i % MOD;
            i = i * i % MOD;
            n >>= 1;
        }
        return res;
    }

    public static long gcd(long i, long y)
    {
        while (y != 0)
        {
            var r = i % y;
            i = y;
            y = r;
        }
        return i;
    }

    public static long lcm(long i, long y)
    {
        return i * y / gcd(i, y);
    }

    public static BigInteger bgcd(BigInteger i, BigInteger y)
    {
        while (y != 0)
        {
            var r = i % y;
            i = y;
            y = r;
        }
        return i;
    }

    public static BigInteger blcm(BigInteger i, BigInteger y)
    {
        return i * y / bgcd(i, y);
    }

    public static Dictionary<long, int> primefactorization(long N)
    {

        var ret = new Dictionary<long, int>();

        for (long i = 2; i * i <= N; ++i)
        {
            int cnt = 0;
            while (N % i == 0)
            {
                cnt++;
                N /= i;
            }
            if (cnt != 0) ret[i] = cnt;

        }
        if (N >= 2) ret[N] = 1;

        return ret;

    }

    public static List<long> divisorenumrate(long N)
    {
        var ret = new List<long>();

        for (long i = 1; i * i <= N; ++i)
        {

            if (N % i == 0)
            {
                ret.Add(i);
                ret.Add(N / i);
            }

        }

        return ret;

    }

    public static void swap<T>(ref T a, ref T b)
    {
        var i = a;
        a = b;
        b = i;
    }

}

class myinout
{
    //in
    public string str => Console.ReadLine();

    public string[] strm => str.Split(' ');

    public long[] longm => strm.Select(long.Parse).ToArray();
    public int[] intm => strm.Select(int.Parse).ToArray();
    public char[] charm => str.ToArray();
    public double[] doublem => strm.Select(double.Parse).ToArray();
    public long long1 => longm[0];
    public int int1 => intm[0];
    public char char1 => charm[0];
    public double double1 => doublem[0];



    //out
    public void wri<T>(T i)
    {
        Console.WriteLine(i);
    }
    public void wri<T>(T[] i)
    {
        Console.WriteLine(string.Join(" ", i));
    }

    public void yn(bool i)
    {
        if (i) wri("Yes");
        else wri("No");
    }

}


Measured memory_bytes: 19808