akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#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;

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

inline void solve(){
    int h,w;
    cin >> h >> w; 
    string s[h];
    for (int i=0;i<h;i++) cin >> s[i];
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            if (s[i][j]=='.'){
                int cnt=0;
                for (int k=0;k<8;k++){
                    int x=i+dx[k],y=j+dy[k];
                    if (x<0 or x>=h or y<0 or y>=w) continue; 
                    if (s[x][y]=='#') cnt++;
                }
                cout << cnt ; 
            }
            else cout << '#';
        }
        cout << endl ; 
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3628
S = input()
S = list(S)
N = len(S)
change = ['1','0']

icchi0 = 0
count = 0
S0 = ['0'] * N
for i in range(N):
    if i%2 == 1:
        S0[i] = '1'
        
for i in range(N):
    if S[i] == S0[i]:
        icchi0 += 1
        
if icchi0 >= N/2:
    print(N-icchi0)
else:
    print(icchi0)
        
    
    

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

int main()
{
	char a;
	int d=0,x=0;
	cin >> a;
	if (a>='a'&&a<='z')
	{
		x=1;
	}
	else
	{
		d=1;
	}
	
	if (d==1&&x==0)
	{
		cout << "A" << endl;
		return 0;
	}
	else if (d==0&&x==1)
	{
		cout << "a" << endl;
		return 0;
	}
} 

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int lcm(int a,int b){	//a,b < 20だしいいよね
		if (a < b){
			swap(a,b);
		}
		int times = a * b;
		vector<int> num;
		int gcd,lcm;
		while(1){
			int n;
			n = a % b;
			if(n == 0){	break;}
			a = b;
			b = n;
		}
		gcd = b;
		lcm = times / gcd;
	return lcm;
}

int main(){
	int h,w;
	while(1){
		cin >> h >> w ;
		if(h == 0 && w == 0){	break;}
		char donut[10][20];
		for(int i=0;i<10;i++){
			for(int j=0;j<20;j++){
				donut[i][j] = 0;
			}
		}
		string code[1600];
		bool much[1600];
		for(int i = 0; i < 1600; i++){
			code[i] = "";
			much[i] = true;
		}	//初期化…

		int l = lcm(w,h);	//ななめの最大数
		int a = 0;	//strの数を数えます

		for(int i = 0; i < h; i++){
			for(int j =0; j < w; j++){
				cin >> donut[i][j];
			}
		}	//input

		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				for(int i = 0; i < h; i++){	//縦列
					code[a].append(1,donut[(y + i)%h][x]);
					code[a+1].append(1,donut[h-(y + i)%h-1][x]);
				}
				a += 2;
				for(int j = 0; j < w; j++){	//横列
					code[a].append(1,donut[y][(x + j)%w]);
					code[a+1].append(1,donut[y][w-(x+j)%w-1]);//absつけなくても0になりません！
				}
				a += 2;
				for(int k = 0; k < l; k++){	//ななめ
					code[a].append(1,donut[(y + k)%h][(x + k)%w]);
					code[a+1].append(1,donut[(y + k)%h][(l + x - k)%w]);
					code[a+2].append(1,donut[(l + y - k)%h][(x + k)%w]);
					code[a+3].append(1,donut[(l + y - k)%h][(l + x - k)%w]);
				}
				a += 4;
			}
		}
		string mag = "";
		//a:strの数-1

		sort(code,code+a);//nとn+1を比べます

		for(int i = 0; i < a-1; i++){
			if(code[i][0] != code[i+1][0]){
				much[i+1] = false;
			}
		}
		for(int i = 1; i < l; i++){	//2文字目から
			for(int j = a-1; j > 0; j--){	//逆順
				if(much[j] == true && code[j].length() >= i+1 && code[j-1].length() >= i+1){//=を忘れていました
					//jのi+1文字目とj-1のi+1文字目を比べるよ
					if(code[j][i] != code[j-1][i]){
						much[j] = false;
					}else{
						mag = code[j];
						mag.resize(i+1);
					}
				}
			}
		}
		if(mag == ""){
			cout << "0" << endl;
		}else{
			cout << mag << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1532
import math

a,b,x=map(int,input().split())

if x>=(a*a*b)/2:
    y=(2*b-2*x/(a*a))/a
    d=math.degrees(math.atan(y))
else:
    y=(a*b*b)/(2*x)
    d=math.degrees(math.atan(y))
print(d)


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

int main(){
  int n, m;
  cin >> n >> m;
  int ans = 0;

  ans += n*(n - 1)/2 + m*(m - 1)/2;
  cout << ans << endl;
  return 0;
}


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

int main(){
    long long N;
    cin >> N;
    long long A, B;
    long long i;
    vector<long long> avec, bvec;
    for(i=1; i<=N; i++){
        cin >> A >> B;
        avec.push_back(A);
        bvec.push_back(B);
    }
    sort(avec.begin(),avec.end());
    sort(bvec.begin(),bvec.end());
    long long cenminbai, cenmaxbai;
    if(N%2==1){
        cenminbai=avec[(N-1)/2];
        cenmaxbai=bvec[(N-1)/2];
    }else{
        cenminbai=avec[(N-2)/2]+avec[N/2];
        cenmaxbai=bvec[(N-2)/2]+bvec[N/2];
    }
    cout << cenmaxbai-cenminbai+1 << endl;
    system("pause");
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100

map<pair<ll, ll>, ll> dp;

int main()
{
    int n;
    ll w;
    cin >> n >> w;
    vll weight(n+1), value(n+1);
    for(int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
    }

    dp[{0,0}] = 0;

    for(auto x: dp)
    {
        if(x.first.first + 1 <= n)
        {

        if(dp.count({x.first.first+1, x.first.second}))
        {
            dp[{x.first.first+1, x.first.second}] = max(dp[{x.first.first+1, x.first.second}], dp[{x.first.first, x.first.second}]);
        }
        else
        {
            dp[{x.first.first+1, x.first.second}] = dp[{x.first.first, x.first.second}];
        }

        if(dp.count({x.first.first+1, x.first.second + weight[x.first.first + 1]}))
        {
            dp[{x.first.first+1, x.first.second+weight[x.first.first+1]}] = max(dp[{x.first.first+1, x.first.second + weight[x.first.first + 1]}], dp[{x.first.first, x.first.second}] + value[x.first.first]);
        }
        else
        {
            dp[{x.first.first+1, x.first.second+weight[x.first.first+1]}] = dp[{x.first.first, x.first.second}] + value[x.first.first + 1];
        }
        }
    }
    ll ans = 0;
    for(auto x: dp)
    {
        if(x.first.first == n && x.first.second <= w)
        {
            ans = max(ans, x.second);
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 13952
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7);

int main(void) {
	int n, sum1 = 0, sum2 = 0, ave = 0;
	cin >> n;
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave = ave / n;
	for (int i = 0;i < n;i++) {
		sum1 += (a[i] - ave)*(a[i] - ave);
		sum2 += (a[i] - ave - 1)*(a[i] - ave - 1);
	}
	cout << min(sum1, sum2) << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n,a=0,b=0;
    ll dp[100000];
    memset(dp,0,sizeof(dp));
    cin>>n;
    vi v;
    r(i,0,n)
    {
      cin>>k;
      v.pb(k);
    }
    dp[1]=abs(v[0]-v[1]);
    r(i,2,n)
    {
      dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  ll n; cin >> n;
  string s; cin >> s;
  s += '0';
  vl v;
  ll cnt;

  if(s[0] == '.')
    cnt = 1;
  else 
    cnt = -1;

  for(int i = 0; i < n; i++){
    if(s[i] == s[i + 1]){
      if(s[i] == '.')
        cnt++;
      else
        cnt--;
    }
    else{
      v.pb(cnt);
      if(s[i] == '#')
        cnt = 1;
      else
        cnt = -1;
    }
  }

  if(v.size() % 2 == 1 or (v[0] > 0 and v.size() % 2 == 0))
    v.pb(0);

  if(v.size() == 2 and v[0] > 0)
    v.pb(0);

  ll ans = 0;

  rep(i, v.size()) {
    if(v[i] > 0)
      ans += v[i]; 
  }
  // #.#.#.#. -> ########
  // ..###### 
  // ....####

  ll temp = ans;
  for(int i = 0; i < v.size(); i += 2){

    if(i == 0 and v[0] > 0){
        temp -= v[i];
        chmin(ans, temp);
        ++i;
      }

    temp = temp - v[i + 1] - v[i];
    chmin(ans, temp);
  }

  pr(ans);

  return 0;
}


Measured memory_bytes: 2552
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int h, w;
  cin >> h >> w;
  map<char, int> mp;
  REP(i, h) {
    string s;
    cin >> s;
    REPe(e, s) { mp[e]++; }
  }
  vecint num;
  int cnt = 0;
  for (auto e : mp) {
    if (e.second % 2 != 0) {
      cnt++;
    }
    if (e.second % 4 != 0) {
      num.push_back(e.second % 4);
    }
  }
  string ans = "Yes";
  if (h % 2 == 0 && w % 2 == 0) {
    if (num.size() != 0) ans = "No";
  } else if (h * w % 2 == 0) {
    int x = (h % 2 == 0) ? h : w;
    int sum = 0;
    REPe(e, num) { sum += e; }
    if (cnt != 0 || sum > x) ans = "No";
  } else {
    int x = h + w;
    int sum = 0;
    REPe(e, num) { sum += e; }
    if (cnt != 1 || sum > x) ans = "No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int n=0;
  string as;
  string bs;
  int a[100]={};
  int b[100]={};
  int c[100]={};
  int i=0;
  int alen=0;
  int blen=0;
  int clen=0;
  int k=0;
  int j=0;

  cin>>n;

  for(j=0;j<n;j++)
    {
      for(i=0;i<100;i++)
        a[i]=b[i]=c[i]=0;
      alen=0;
      blen=0;
      clen=0;
      k=0;

      cin>>as;
      cin>>bs;

      alen=as.size();
      blen=bs.size();

      for(i=0;i<alen;i++)
        {
          a[i]=as[alen-i-1];
          //printf("a[%d]=%d\n", i, a[i]);                                      
          switch(a[i])
            {
            case '0' : a[i]=0; break;
            case '1' : a[i]=1; break;
            case '2' : a[i]=2; break;
            case '3' : a[i]=3; break;
            case '4' : a[i]=4; break;
            case '5' : a[i]=5; break;
            case '6' : a[i]=6; break;
            case '7' : a[i]=7; break;
            case '8' : a[i]=8; break;
            case '9' : a[i]=9; break;
            }
        }

      for(i=0;i<blen;i++)
        {
          b[i]=bs[blen-i-1];
          //printf("b[%d]=%d\n", i, b[i]);                                      
          switch(b[i])
            {
            case '0' : b[i]=0; break;
            case '1' : b[i]=1; break;
            case '2' : b[i]=2; break;
            case '3' : b[i]=3; break;
            case '4' : b[i]=4; break;
            case '5' : b[i]=5; break;
            case '6' : b[i]=6; break;
            case '7' : b[i]=7; break;
            case '8' : b[i]=8; break;
            case '9' : b[i]=9; break;
            }
        }

      clen=(alen > blen)? alen : blen;

      for(i=0;i<clen;i++)
        {
          c[i]+=a[i]+b[i];
          c[i+1]=c[i]/10;
          if(c[clen]!=0)
            k=1;
          c[i]=c[i]%10;
        }

      if(clen>80 || c[80]!=0)
        cout<<"overflow"<<endl;

      else
        {
          for(i=clen+k-1;i>=0;i--)
            cout<<c[i];
          puts("");
        }
    }

}

Measured memory_bytes: 1212
# -*- coding: utf-8 -*-
h,w = map(int, input().split())

c = []
for _ in range(10):
    line = list(map(int, input().split()))
    c.append(line)

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k]+c[k][j])

res = 0
for _ in range(h):
    for a in map(int, input().split()):
        if a>=0:
            res += c[a][1]
print(res)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define ar array
#define vvll vector<vll>
#define repa(i, b, n) for (int i = b; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1e9
#define MP make_pair
#define ll long long int
#define M 1000000007
#define all(a) a.begin(), a.end()
// debugging
#define db(x) cout << x << "\n";
#define db1(x) cout << #x << "=" << x << "\n"
#define db2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << "\n"
#define db3(x, y, z) cout << #x << "=" << x << ", " << #y << "=" << y << ", " << #z << "=" << z << "\n"
#define dba(x)       \
    for (auto i : x) \
    cout << i << "\t"
#define dbm(x)                \
    for (auto i : x)          \
    {                         \
        for (auto j : i)      \
            cout << j << " "; \
        cout << "\n";         \
    }
#define MOD 1000000007
using namespace std;
const int maxN = 100000;
void solve()
{
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, n;
    cin >> x >> n;
    vi a(n);
    set<int> st;
    rep(i, n) cin >> a[i], st.insert(a[i]);
    int ans = INT_MAX, xx = INT_MAX;
    for (int i = x; i <= 101; i++)
    {
        if (st.find(i) == st.end())
        {
            if (abs(x - i) <= ans)
            {
                ans = abs(x - i);
                xx = min(xx, i);
            }
        }
    }

    for (int i = x; i >= -101; i--)
    {
        if (st.find(i) == st.end())
        {

            if (abs(x - i) <= ans)
            {

                ans = abs(x - i);
                xx = min(xx, i);
            }
        }
    }

    db(xx);
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2




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

	int dg = 1;
	rep(i, 0, d)dg *= 100;
	if (n == 100) {
		puts(101 * dg);
	}
	else {
		puts(n*dg)
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j] <= x ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

int main() {
  int i, q;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  q = partition(0, n - 1);
  
  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == q ) printf("[");
    printf("%d", A[i]);
    if ( i == q ) printf("]");
  }
  printf("\n");
  
  return 0;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e6 + 5;

int F[N], I[N];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}
int C(int n, int k) { return k > n || k < 0 || n < 0 ? 0 : 1LL * I[k] * I[n - k] % MOD * F[n] % MOD; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	F[0] = 1;
	for (int i = 1; i < N; i++) F[i] = 1LL * F[i - 1] * i % MOD;
	I[N - 1] = Power(F[N - 1], MOD - 2);
	for (int i = N - 1; i > 0; i--) I[i - 1] = 1LL * I[i] * i % MOD;
	int n; cin >> n;
	int ans = F[n];
	for (int i = 1; i < n; i++) ans = (ans - 1LL * F[i] * F[n - 1 - i] % MOD * C(i - 1, n - 1 - i) % MOD + MOD) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8064
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  string a, b; cin >> a >> b;
  if(sz(a) > sz(b)) {
    cout << "No\n"; return;
  }
  for(int i = 0; i < sz(a); i++) {
    if(a[i] != b[i]) {
      cout << "No\n"; return;
    }
  }
  cout << "Yes\n";
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


Measured memory_bytes: 3612
n = int(input())
a_list = list(map(int, input().split()))
counter = 0
while True:
    fl = 0
    for i in a_list:
        fl += i%2
    if not fl == 0:
        break
    else:
        counter += 1
        for i in range(n):
            a_list[i] //= 2
print(counter)


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];

    int ctr = 0;
    for(int i = 0; i < n; i += 2){
        if(a[i] % 2 == 1) ctr++;
    }
    
    cout << ctr << endl;
    
    
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    long long x; cin >> x;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (x >= a[i]) ++res, x -= a[i];
        else break;
    }
    if (res == N && x) --res;//--resじゃなくてcout << N << endl;じゃないの？って感じ。答えが N になる場合というのは、x がちょうどぴったりaiの総和になっている場合のみにかぎられることに注意。
    cout << res << endl;
}


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

int main(){
	int N,L;
	cin >> N >> L;
	int R=L+N-1;
	int ans=0;
	if(L*R<=0)for(int i=L;i<=R;i++)ans+=i;
	else if(R<0)for(int i=L;i<=R-1;i++)ans+=i;
	else for(int i=L+1;i<=R;i++)ans+=i;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int,input().split())
N = []
for i in range(A,A+K):
  if i <= B:
    print(i)
    N.append(i)
for j in range(B-K+1,B+1):
  if  j >= A and j not in N:
    print(j)
    N.append(i)

Measured memory_bytes: 9184
import java.util.ArrayList;
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);
         
        final int n = sc.nextInt();
         
        for(int i = 0; i < n; i++){
           int x = 0;
           int y = 0;
           
           int m_dist = 0;
           int m_x=0,m_y=0;
           
           while(true){
        	   final int dx = sc.nextInt();
        	   final int dy = sc.nextInt();
        	   
        	   if(dx == 0 && dy == 0){
        		   break;
        	   }
        	   
        	   x += dx;
        	   y += dy;
        	   
        	   if(m_dist < x*x + y*y){
        		   m_dist = x*x + y*y;
        		   m_x = x;
        		   m_y = y;
        	   }else if(m_dist == x*x + y*y && m_x < x){
        		   m_x = x;
        		   m_y = y;
        	   }
           }
           
           System.out.println(m_x + " " + m_y);
        }
         
         
    }
 
}

Measured memory_bytes: 12000
n=int(input())
X=[]
for i in range(2):
    X.append(list(map(int,input().split())))
    
res=0
for i in range(n):
    x=X[0][:i+1]
    y=X[1][i:]
    cnt=sum(x)+sum(y)
    if cnt>res:
        res=cnt

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef std::numeric_limits< double > dbl;
struct Dice
{
	int d[6];
	void roll(char c){
		if(c == 'S'){
			int b = d[0];
			d[0] = d[4];
			d[4] = d[5];
			d[5] = d[1];
			d[1] = b;

		}else if(c == 'N'){
			int b = d[0];
			d[0] = d[1];
			d[1] = d[5];
			d[5] = d[4];
			d[4] = b;
		}else if(c == 'W'){
			int b = d[0];
			d[0] = d[2];
			d[2] = d[5];
			d[5] = d[3];
			d[3] = b;
		}else{
			int b = d[0];
			d[0] = d[3];
			d[3] = d[5];
			d[5] = d[2];
			d[2] = b;
		}
	}

	int top(){
		return d[0];
	}
};

int main()
{	
	Dice dd;
	int b;
	for(int i=0; i<6 ;i++){
		cin >> b;
		dd.d[i] =b; 
	}
	string str;
	cin >> str;
	for(int i=0; i<str.size() ;i++) dd.roll(str[i]);

	cout << dd.top() << endl;
	return 0;
}





Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<tuple<string,int,int>> a;
  for(int i=1;i<=N;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
  cout<<get<2>(a.at(i))<<endl;
  }
  return 0;
}  

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	H := readint()
	var ac, mc int
	for mc = 1; 1 < H; mc *= 2 {
		ac += mc
		H /= 2
	}
	ac += mc

	fmt.Println(ac)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 640
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, raw_input().split())
if K == 1:
	print 0
else:
	print N - K

Measured memory_bytes: 2812
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int a = s[0] - '0';
	if (s.size() > 1 && s[s.size() - 1] != '9') {
		cout << (s.size() - 1) * 9 + a - 1 << endl;
	}
	else if (s.size() > 1) {
		cout << (s.size() - 1) * 9 + a << endl;
	}
	else {
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;

struct node
{
    ll taste, col, idx;
    node(){}
    node(ll t, ll c, ll i)
    {
        taste = t, col = c, idx = i;
    }
    bool operator<(const node&nd)const
    {
        return taste<nd.taste;
    }
};

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    ll a, b, c;
    cin>>x>>y>>a>>b>>c;

    vector<ll>va(a),vb(b),vc(c),tmp;

    for(i=0; i<a; i++)
    {
        cin>>va[i];
    }
    for(i=0; i<b; i++){
        cin>>vb[i];
    }
    for(i=0; i<c; i++){
        cin>>vc[i];
    }

    sort(va.rbegin(), va.rend());
    sort(vb.rbegin(), vb.rend());
    for(i=0; i<x; i++)
    {
        tmp.push_back(va[i]);
    }
    for(i=0; i<y; i++){
        tmp.push_back(vb[i]);
    }
    for(i=0; i<c; i++)
    {
        tmp.push_back(vc[i]);
    }

    sort(tmp.rbegin(), tmp.rend());
    ll ans = 0;

    for(i=0; i<x+y; i++)
        ans+=tmp[i];

    cout<<ans<<endl;

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i%3 != 0 && i%5 != 0)
        {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)

int main() {
    // your code goes here
    ll a,b,m,s[100005],t[100005],ans;
    ll e=10000000000,f=10000000000;
    cin >> a >> b >> m;
    rep(i,1,a){
        cin >> s[i];
        e=min(e,s[i]);
    }
    rep(i,1,b){
        cin >> t[i];
        f=min(f,t[i]);
    }
    ans=e+f;
    rep(i,1,m){
        ll x,y,c;
        cin >> x >> y >> c;
        ans=min(ans,s[x]+t[y]-c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, v, ans = 0;
	vector<int> num(3);

	cin >> num[0] >> num[1] >> num[2];

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

	if (num[0] == 5 && num[1] == 5 && num[2] == 7) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}


	return 0;
}

Measured memory_bytes: 256
INF=float('inf')
cost=[-1,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=list(map(int,input().split()))

dp=[-INF]*(N+1)
dp[0]=0

for i in range(1,N+1):
    for a in A:
        if i-cost[a]>=0:
            dp[i]=max(dp[i],dp[i-cost[a]]*10+a)
print(dp[N])

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

int main()
{
    vector<int> X(5);
    for (int i = 0; i < 5;i++)
    {
        cin >> X.at(i);
        if (X.at(i) == 0)
        {
            cout << i+1 << endl;
            break;
        }
    }

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n,m,ans;
int dp[100100];
vector <int> adj[100100];
int solve(int i)
{
    if(!adj[i].size())
        return 0;
    int &ret=dp[i];
    if(ret+1)
        return ret;
    ret=0;
    for(int j=0;j<adj[i].size();j++)
        ret=max(ret,solve(adj[i][j])+1);
    return ret;
}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0,x,y;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
    }
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)
        ans=max(ans,solve(i));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    n: usize
  };

  let res = match n % 10 {
    0 => "pon",
    1 => "pon",
    2 => "hon",
    3 => "bon",
    4 => "hon",
    5 => "hon",
    6 => "pon",
    7 => "hon",
    8 => "pon",
    9 => "hon",
    _ => unreachable!(),
  };
  println!("{}", res);
}


Measured memory_bytes: 2136
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int l[10];
	int v1, v2;
	char c;
	int d;

	while(cin >> l[0]){
		d=l[0];
		for(int i=1;i<10;i++){
			cin >> c >> l[i];
			d+=l[i];
		}
		cin >> c >> v1 >> c >> v2;

		double t = (double)d/(v1+v2);
		d=0;
		//cout << t<<endl;
		for(int i=0;i<10;i++){
			d+=l[i];
			//cout << v1*t <<" "<<d<<endl;
			if(v1*t <= d){
				cout << i+1 <<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

for k in range(N):
    B = int(input())
    for l in range(3):
        for m in range(3):
            if A[l][m] == B:
                A[l][m] = 0

if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 0):
    print ("Yes")
elif (A[0][0] == A[1][0] == A[2][0] == 0) or (A[0][1] == A[1][1] == A[2][1] == 0) or (A[0][2] == A[1][2] == A[2][2] == 0):
    print ("Yes")
elif (A[0][0] == A[1][1] == A[2][2] == 0) or (A[0][2] == A[1][1] == A[2][0] == 0):
    print ("Yes")
else:
    print ("No")

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int nc2(int n) { return n * (n - 1) / 2; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N, K;
    cin >> N >> K;

    if (K > nc2(N - 1)) {
        cout << "-1\n";
        return 0;
    }

    vector<pair<int, int>> res;
    for (int v = 2; v <= N; v++)
        res.emplace_back(1, v);

    int paired = nc2(N - 1);
    for (int v = 2; v <= N; v++) {
        for (int u = v + 1; u <= N; u++) {
            if (paired > K) {
                res.emplace_back(u, v);
                paired--;
            } else break;
        }
    }

    cout << sz(res) << endl;
    for (auto p : res) {
        cout << p.first << " " << p.second << "\n";
    }

    return 0;
}




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

namespace ABC
{
    class ProgramE
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var w = long.Parse(inputs[1]);

            var maxV = 0L;
            var list = new long[n, 2];
            for (var i = 0; i < n; i++)
            {
                var inputs1 = Console.ReadLine().Split(" ");
                list[i, 0] = long.Parse(inputs1[0]);
                list[i, 1] = long.Parse(inputs1[1]);
                maxV += list[i, 1];
            }

            var dp = new long[n + 1, maxV + 1];
            for (var i = 0; i < n + 1; i++)
            {
                for (var j = 0; j < maxV + 1; j++)
                {
                    dp[i, j] = (int)1e9 + 7;
                }
            }
            dp[0, 0] = 0;

            for (var i = 0; i < n; i++)
            {
                for (var sumV = 0; sumV < maxV + 1; sumV++)
                {
                    if (sumV >= list[i, 1])
                    {
                        dp[i + 1, sumV] = Math.Min(dp[i, sumV - list[i, 1]] + list[i, 0], dp[i, sumV]);
                    }
                    else
                    {
                        dp[i + 1, sumV] = dp[i, sumV];
                    }
                }
            }

            var result = 0L;
            for (var i = 0; i < maxV + 1; i++)
            {
                if (dp[n, i] <= w)
                {
                    result = i;
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

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

    sort(a, a+n);
    int ans = 1;
    for(int i=1;i<n;i++){
        if(a[i] != a[i-1])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
(defun get-input-array (n)
  (let ((rst (make-array n)))
    (dotimes (i n)
      (setf (aref rst i) (read)))
    rst))

(defun main (n k)
  (let* ((input (get-input-array n))
        (hi 0))
    (if (=  k 0)
        (setf hi 0)
      (setf hi k))
    (setf input (sort input #'>))
    (loop for i from hi to (- n 1)
          sum (aref input i))))

(format t "~A~%" (main (read) (read)))


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

int main(void) {
  int n;
  cin >> n;
  bool four = false;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'Y') four = true;
  }
  cout << (four ? "Four" : "Three") << endl;
  return 0;
}

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


int main(){
   int x,y,z; cin>>x>>y>>z;
   int t;
   t=x; x=y; y=t;
   int u;
   u=x; x=z; z=u;
   cout<<x<<" "<<y<<" "<<z<<endl;
   return 0;
}

   


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 1E9 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll dp[105][100005], arrW[105], arrC[105] ;

int main()
{
    ll n, w, ans = 0, limit, maxVal = 0 ;
    cin >> n >> w ;
    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &arrW[i], &arrC[i]) ;
        maxVal = max(maxVal, arrC[i]) ;
    }
    limit = n * maxVal ;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= limit; j++) {
            dp[i][j] = INF ;
        }
    }
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 0 ;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= limit; j++) {
            if (j < arrC[i]) {
                dp[i][j] = min(dp[i - 1][j], dp[i][j]) ;
            }
            else {
                dp[i][j] = min(dp[i - 1][j], arrW[i] + dp[i - 1][j - arrC[i]]) ;
            }
            if (dp[i][j] <= w) {
                ans = max(ans, (ll)j) ;
            }
        }
    }
    cout << ans ;

    return 0 ;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int x, i = 1, s;

int main() {
	cin >> x;
	while (true) {
		s += i;
		if (s>=x) break;
		i++;
	}
	cout << i << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    vector<int> pnum(p.size(),0);
    for(int i = 0;i < p.size();i++){
        int P = p[i];
        int N = n;
        while(N != 0){
            pnum[i] += N/P;
            N /= P;
        }
    }
    // 3.25 3.5.5 5.15
    int a,b,c,d,e;
    a = b = c = d = e = 0;
    for(int i = 0;i < p.size();i++){
        if(pnum[i] >= 2)a++;
        if(pnum[i] >= 4)b++;
        if(pnum[i] >= 14)c++;
        if(pnum[i] >= 24)d++;
        if(pnum[i] >= 74)e++;
    }
    int ans = e;
    ans += d*(a-1);
    ans += c*(b-1);
    ans += b*(b-1)/2*(a-2);
    cout << ans << endl;
    //cin >> n;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int A;
	cin >> A;
	for (int i = 1; i <= 9; i++) {
		if (A%i==0 && A/i<=9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No"<< endl;
	return 0;
}

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

int main() {
  int n;
  int step[31] = {1,1,2};
  for(int i=3;i<31;i++) {
    step[i] = step[i-1]+step[i-2]+step[i-3];
  }
  while(cin >> n) {
    if(n==0) break;
    cout << (step[n]+3650)/3650 << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  int s, t, i, max = 0, c;
  while(scanf("%d%d", &s, &t) && s && t){
    max = s + t; c = 0;
    for(i = 1; i < 5; ++i){
      scanf("%d%d", &s, &t);
      if(max < s + t){
        max = s + t;
        c = i;
      }
    }

    switch(c){
    case 0: putchar('A'); break;
    case 1: putchar('B'); break;
    case 2: putchar('C'); break;
    case 3: putchar('D'); break;
    case 4: putchar('E'); break;
    }

    printf(" %d\n", max);
  }
return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(long long i = a; i < b; i++)
#define ll long long
using namespace std;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

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

int main(){
  int n, a,b,c,d;
  cin >> n;
  a = n/1000;
  b = (n%1000)/100;
  c = (n%100)/10;
  d = n%10;
  if( a==b && b==c || b==c && c==d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  ll n;
  cin >> n;
  vector<ll>a(3*n);
  rep(i,3*n) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll count =0;
  for(ll i = 0; i<n;i++){
    count += a.at(2*i+1);
  }
  cout << count << endl;
}

Measured memory_bytes: 2560