akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD2 1000000007
#define MOD 1000000009
#define endl "\n"
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vvi vector <vector<int>>
#define F first
#define S second


ll power(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
         
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;  
        x = (x*x) % p;  
    }  
    return res;  
}

int main()
{   
    IOS;
        #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
        #endif
    
    ll n;
    cin >> n;
    if(n == 1) {
        cout << 0;
        return 0;
    }
    ll a = power(10, n, MOD2);
    a -= ((power(9, n, MOD2) * 2ll) % MOD2);
    a += power(8, n, MOD2)  % MOD2;
    if (a < 0) a += MOD2;

    cout << a;

    
    
    
return 0;
}


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

int main() {
    /*変数定義，入力*/
    ll N;
    int A[3][3];
    bool isA[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
    rep(i, 3){
        rep(j, 3){
            cin >> A[i][j];
        }
    }

    cin >> N;
    
    int b;
    rep(i, N){
        cin >> b;
        rep(row, 3){
            rep(column, 3){
                if(A[row][column] == b){
                    isA[row][column] = true;
                }
            }
        }
    }

    //判定
    rep(i, 3){
        if(isA[i][0] && isA[i][1] && isA[i][2]){
            cout << "Yes";
            return 0;
        }
    }

    rep(i, 3){
        if(isA[0][i] && isA[1][i] && isA[2][i]){
            cout << "Yes";
            return 0;
        }
    }

    if(isA[0][0] && isA[1][1] && isA[2][2]){
        cout << "Yes";
        return 0;
    }
    if(isA[0][2] && isA[1][1] && isA[2][0]){
        cout << "Yes";
        return 0;
    }

    cout << "No";

    //vector<ll> a(N);  rep(i, N) cin >> a[i];

    /*終了*/
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int32_t main()
{
	IOS;
	int n, a, b;
	cin>>n>>a>>b;
	int mx=min(a, b);
	int mn=a+b-n;
	mn=max(0LL, mn);
	cout<<mx<<" "<<mn;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  if(s.at(0)!=s.at(1)&&s.at(1)!=s.at(2)&&s.at(0)!=s.at(2)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
void sellection(int*,int);
int c=0;

int main()
{

  int n,i;
  
  scanf("%d",&n);
  int A[n];

  for(i=0;i<n;i++){
  scanf("%d",&A[i]);
   }

 sellection(A,n);
 
  for(i=0;i<n;i++)
  {
  if(i==0)printf("%d",A[i]);
  else printf(" %d",A[i]);
  }
  printf("\n%d\n",c);

  return 0;
  
}

void sellection(int *A,int N)
{
  int i,minj,j,a;
  for(i=0;i<N;i++)
  {
  minj=i;
      for(j=i;j<N;j++)
      {
      if(A[j]<A[minj])
      {
      minj=j;
      }
      }
      
      if(i!=minj)
      {
      
      a=A[i];
      A[i]=A[minj];
      A[minj]=a;
      
      c++;
      }
    
  
  }
  
}



Measured memory_bytes: 2108
import java.util.*;

public class Main {

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

        String s = sc.next();

        // 回文にできるか判定する
        String[] array = s.split("x+");
        StringBuilder builder = new StringBuilder();
        for (String v: array
             ) {
            builder.append(v);
        }
        String formatted = builder.toString();

        for (int i = 0; i < formatted.length() / 2; i++) {
            if (formatted.charAt(i) != formatted.charAt(formatted.length() - 1 - i)) {
                System.out.println(-1);
                return;
            }
        }

        builder = new StringBuilder(s);

        int index = 0;
        long ans = 0;
        while (index < builder.length() / 2) {
            boolean firstIsX = builder.charAt(index) == 'x';
            boolean endIsX = builder.charAt(builder.length() - 1 - index) == 'x';
            if (firstIsX && !endIsX) {
                builder.insert(builder.length() - index, "x");
                ans++;
            } else if (!firstIsX && endIsX) {
                builder.insert(index, "x");
                ans++;
            } else {
                index++;
            }
        }

        System.out.println(ans);
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b, c, x;
  	cin >> a >> b >> c >> x;
  	ll cnt = 0;
  	x /= 50;
	rep(i,a+1){
    	rep(j,b+1){
        	rep(k,c+1){
            	if(10*i+2*j+k==x) cnt++;
            }
        }
    }
  
 	cout << cnt << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll s=0,t=0;cin>>s>>t;
  ll a=s*t/2;
  if(a*2!=s*t)a++;
  if(s==1||t==1)cout<<1;
  else cout<<a;
  }


Measured memory_bytes: 23680
#include <iostream>
#include <math.h>

using namespace std;

bool primeNumberChecker(unsigned int num){
	if (num==2) {
		return true;
	}
	if (num%2==0) {
		return false;
	}
	for (int j=3; j<=sqrt(num); j+=2) {
		if (num%j==0) {
			return false;
		}
	}
	return true;
}


int main(int argc, char const* argv[])
{
	unsigned int n, number[10000], ans=0;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> number[i];
		if (primeNumberChecker(number[i])){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    int N, nmax, tmp;  cin >> N;
    int f[N][10];
    int p[N][11];
    for(int i=0; i<N; i++){
        for(int j=0; j<10; j++) cin >> f[i][j];
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<11; j++) cin >> p[i][j];
    }
    nmax = pow(2,10);

    ll ans, ans1;
    ans = -200000000000LL;
    for(int i=1; i<nmax; i++){
        tmp = i;
        ans1 = 0;
        int c[N];
        for(int j=0; j<N; j++)  c[j] = 0;
        for(int j=0; j<10; j++){
            if(tmp%2==1){
                for(int k=0; k<N; k++){
                    if(f[k][j] == 1)    c[k]++;
                }
            }
            tmp /= 2;
        }
        for(int j=0; j<N; j++){
            ans1 += p[j][c[j]];
        }
        ans = max(ans,ans1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import copy
n=int(input())
ans=[]
mins=55
a=[list(input()) for _ in range(n)]
for i in a:
  if mins > len(i):
    mins=min(mins,len(i))
    m=copy.copy(i)
for i in m:
  flg=0
  for j in a:
    if i not in j:
      flg=1
  if flg==0:
    ans.append(i)
    for j in a:
      j.remove(i)
ans.sort()
print(*ans,sep='')

Measured memory_bytes: 9384
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
import math

Pj = 0

for i in range(N-1):
  k = i + 1  
  Pj = Pj + sum(1 for x in P[k:] if P[i] > x) * math.factorial(N-1-i)

Pj += 1

Qj = 0

for i in range(N-1):
  k = i + 1  
  Qj = Qj + sum(1 for x in Q[k:] if Q[i] > x) * math.factorial(N-1-i)

Qj += 1

print(abs(Pj - Qj))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n);
	vector<int> c(m), d(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < n; i++) {
		pair<int, int> mn(1e9, 1e9);
		for (int j = 0; j < m; j++) {
			int e = abs(c[j] - a[i]) + abs(d[j] - b[i]);
			mn = min(mn, make_pair(e, j));
		}
		cout << mn.second + 1 << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a=0,b=0,c;
    cin>>c;
    if (c==5)
        a++;
    else if (c==7)
        b++;
    cin>>c;
    if (c==5)
        a++;
    else if (c==7)
        b++;
    cin>>c;
    if (c==5)
        a++;
    else if (c==7)
        b++;
    cout<<(a==2&&b==1?"YES\n":"NO\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  sort(all(s));
  rep(i,n){
    cout << s[i];
  }
  cout << endl;
}

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

using namespace std;

constexpr uint64_t mod_base = 1'000'000'007ULL;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  uint64_t n;
  cin >> n;
  vector<uint64_t> nums(n);
  for (uint64_t i = 0; i < n; ++i) {
    cin >> nums[i];
  }

  constexpr uint64_t num_bits = 61;
  vector<vector<uint64_t>> bits(n, vector<uint64_t>(num_bits));
  for (uint64_t i = 0; i < n; ++i) {
    uint64_t idx = 0;
    for (auto x = nums[i]; x; x >>= 1) {
      bits[i][idx] = x & 1;
      ++idx;
    }
  }


  vector<uint64_t> bit_sum = bits.back();
  vector<uint64_t> xor_sum(vector<uint64_t>(num_bits, 0));

  for (int64_t i = n - 2; i >= 0; --i) {
    auto cnt = n - i - 1;
    for (uint64_t b = 0; b < num_bits; ++b) {
      auto val = bit_sum[b];
      if (bits[i][b]) {
        val = cnt - val;
      }
      xor_sum[b] += val;
    }
    for (uint64_t b = 0; b < num_bits; ++b) {
      bit_sum[b] += bits[i][b];
    }
  }

  uint64_t result = 0;
  uint64_t base = 1;
  for (uint64_t b = 0; b < num_bits; ++b) {
    result += (xor_sum[b] % mod_base) * base;
    // cout << " # " << result << endl;
    result %= mod_base;

    base = (base * 2ULL) % mod_base;
    // base = base * 2ULL;
  }


  cout << result << endl;
}


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

using namespace std;

int main(){
   string X;
   cin >> X;
   long long int S=0;
   long long int ans = X.size();
   for(long long int i=0;i<X.size();i++){
      if(X[i] == 'S') S++;
      if(X[i] == 'T'){
         if(S>0){
            S--;
            ans-=2;
         }
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 640
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>

//型宣言
typedef int INPUT_N;
typedef std::string ANSWER_TYPE;

//関数のプロトタイプ宣言
void printAnswer(ANSWER_TYPE answer);
int main() {
	//入力の取得
	INPUT_N input = 0;
//	std::getline(std::cin, input);
	std::cin >> input;

	//答え
	ANSWER_TYPE answer(input < 1200? "ABC": "ARC");

	printAnswer(answer);
	//正常終了
	return EXIT_SUCCESS;
}
//回答出力
void printAnswer(ANSWER_TYPE answer) {
	//答えの出力
	std::cout << answer << std::endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
bool a[15]; 
int d[15];
string b,c;
int judge=0; 
void dfs(int n){
	if(n==10){
		for(int i=0;i<10;i++){
			if(a[i]==false){//进c 
				c.push_back('0'+d[i]);
			}
			else{
				b.push_back('0'+d[i]);
			}
		}
		int ok=1;
		for(int j=0;j<b.size()-1;j++){
			if(b[j]>b[j+1]){
				ok=0;
				break;
			}
		}
		for(int j=0;j<c.size()-1;j++){
			if(c[j]>c[j+1]){
				ok=0;
				break;
			}
		}
		if(ok)judge=1;
		b.clear();c.clear();
		return;
	}
	else{
		a[n]=true;
		dfs(n+1);
		a[n]=false;
		dfs(n+1);
		return;
	}
}
/*void ddfs(int n){
	cout<<n<<endl;
	if(n==10){
		judge=0;
		dfs(0);
		for(int i=0;i<n;i++){
			cout<<d[i]<<' ';
		}
		cout<<endl;
		if(judge){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
		return;
	}
	for(int i=1;i<=10;i++){
		int ok=1;
		for(int j=0;j<n;j++){
			if(d[j]==i){
				ok=0;break;
			}
		}
		if(ok){
			d[n]=i;
			ddfs(n+1);
		}
	}
}*/
int main(){
	int n;
	cin>>n;
	while(n--){
		b.clear();c.clear(); 
		judge=0;
		for(int i=0;i<10;i++){
			cin>>d[i];
		}
		dfs(0);
		if(judge){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll H, W;
    cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return;
    }
    ll diff = ( (max(H, W) / 3) + ((max(H, W) % 3) > 0)  ) * min(H, W) - ((max(H, W) / 3) * min(H, W));

    ll maxS, minS, a,b,c;
    for (ll i = H/2; i <= H; i++) {
		a = i * (W/2);
		b = i * (W/2 + (W & 1));
		c = (H - i) * W;
        minS = min(a, min(b,c));
        maxS = max(a, max(b,c));
        diff = min(diff, maxS - minS);
    }

    for (ll i = W/2; i <= W; i++) {
		a = (H/2) * i;
		b = (H/2 + (H & 1)) * i;
		c = H * (W - i);
        minS = min(a, min(b, c));
        maxS = max(a, max(b, c));
        diff = min(diff, maxS - minS);
    }

    cout << diff << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long int l,r;
	cin >> l >> r;
	long long int mod=2019;
	if(r-l>=2019){
		for(long long int i=l;i<l+2019;i++){
			for(long long int j=l+1;j<=l+2019;j++){
				if(i!=j && (i*j)%2019<mod){
					mod=(i*j)%2019;
				}
			}
		}
	}else{
		for(long long int i=l;i<r;i++){
			for(long long int j=l+1;j<=r;j++){
				if(i!=j && (i*j)%2019<mod){
					mod=(i*j)%2019;

			//		printf("%d %d\n",i,j);
				}
			}
		}
	}
	cout << mod << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, C;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    if( x > (K - x) ){
      C += K - x;
    }else{
      C += x;
    }
  }
  cout << C * 2 << endl;
  
}

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

int main(){
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  
  if(s<t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

alis = []
for _ in range(n):
    alis.append(list(map(int,input().split())))

total = c
cnt = 0
for i in range(n):
    for j in range(m):
        t = alis[i][j]*blis[j]
        total += t
        
    if total > 0:
        cnt += 1
    
    total = c

print(cnt)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	ll n, t, s = 0;
	cin >> n;
	t = n;
	while (t > 0) {
		s += (t % 10);
		t /= 10;
	}
	if (n%s == 0) wrln("Yes");
	else wrln("No");
	return 0;
}


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

from collections import deque

cnt=1
q=deque([1,2,3,4,5,6,7,8,9])
while cnt<k:
    tmp=q.popleft()
    if tmp%10!=0:
        q.append(tmp*10+tmp%10-1)
    q.append(tmp*10+tmp%10)
    if tmp%10!=9:
        q.append(tmp*10+tmp%10+1)
    cnt+=1

print(q.popleft())

Measured memory_bytes: 18944
#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <climits> // INT_MAX
#include <cmath> // ceil()
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;
const int INF = INT_MAX;
using Graph = vector<vector<int>>;
using Vi = vector<int>;
using Vpii = vector<pair<int, int>>;
using Pii = pair<int, int>;


vector<bool> seen;
int ans = 0;
int land = 0;
bool is_tree = false;
Pii region;


void dfs(Graph &g, int x, int y) {
    if (x < 0 || x >= region.first) return;
    if (y < 0 || y >= region.second) return;

    if (g[y][x] == 0) return;

    if (g[y][x] == 1) {
        g[y][x] = 0;
        land--;
    }

    dfs(g, x + 1, y);
    dfs(g, x - 1, y);
    dfs(g, x, y + 1);
    dfs(g, x, y - 1);
    dfs(g, x + 1, y + 1);
    dfs(g, x + 1, y - 1);
    dfs(g, x - 1, y + 1);
    dfs(g, x - 1, y - 1);
}


int main() {
    string N;
    cin >> N;
    auto matsubi = N[N.size() - 1];

    if (matsubi == '2' || matsubi == '4' || matsubi == '5' || matsubi == '7' || matsubi == '9')
        cout << "hon" << endl;
    else if(matsubi == '0'|| matsubi == '1'|| matsubi == '6'|| matsubi == '8')
        cout << "pon" << endl;
    else cout << "bon" << endl;

}


Measured memory_bytes: 3624
k = int(input())
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[k -1])

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

int main()
{
long long int n,i,j,a,x,y;

while(1)
{
   cin>>n>>a;
   x=1;

   if(n==0 && a==0)
        break;

for(i=1;i<=n;i++)
{
    for(j=1;j<=a;j++)

    {
          if(x==1)
          {
            cout<<"#";
            x=0;
          }

          else{
          cout<<".";
          x=1;
          }
    }
    if(a%2==0)
    {
    if(x==0)
        x=1;
    else
        x=0;
    }
cout<<endl;
}
cout<<endl;
}



}



Measured memory_bytes: 3052
//
//  main.cpp
//  词语接龙
//
//  Created by 姚欣 on 2020/7/28.
//  Copyright © 2020 任奕霏. All rights reserved.
//

#include <iostream>
using namespace std;
int main()
{
    int n,i,j,judge = 0;
    cin >> n;
    string s[n];
    for(i = 0; i < n; i ++)
        cin >> s[i];
    for(i = 1; i < n; i ++)
    {
        if(s[i][0] == s[i - 1][s[i - 1].size() - 1])
            judge ++;
        else
        {
            judge = 0;
        }
        for(j = 0; j < n; j ++)
        {
            if(j == i)
                continue;
            if(s[j] == s[i])
            {
                judge = 0;
                break;
            }
        }
        if(judge == 0)
        {
            cout << "No" << endl;
            break;
        }
    }
    if(judge != 0)
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

vector<pair<int, int> > func(int x) {
    vector<pair<int, int> > v;
    for (int i = 2; i * i <= x; i++) {
        int tmp = 0;
        if (x % i == 0) {
        while (x % i == 0) {
            x /= i;
            tmp++;
        }
        v.push_back(pair<int,int>(i, tmp));
        }
    }
    if (x > 1)
        v.push_back(pair<int,int>(x, 1));

    return v;
}

int gcd(int x, int y) { //x > y
    if (y == 0)
        return x;
    else 
        return gcd(y, x%y);
}

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

    int g = a[0];
    for (int i = 1; i < n; i++) {
        g = gcd(g, a[i]);
    }

    if (g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    map<int, int> mp;

    vector<vector<pair<int,int> > > v(n);
    for (int i = 0; i < n; i++) {
        v[i] = func(a[i]);
        
        for (int j = 0; j < v[i].size(); j++) {
            mp[v[i][j].first] += v[i][j].second;
            
        }
    }
    

    

    for (int i = 0; i < n; i++) {
        if (a[i] == 1)
            continue;
        for (int j = 0; j < v[i].size(); j++) {
            mp[v[i][j].first] -= v[i][j].second;
        }

        for (int j = 0; j < v[i].size(); j++) {
            if(mp[v[i][j].first] != 0) {
                cout << "setwise coprime" << endl;
                return 0;
            }
        }

        for (int j = 0; j < v[i].size(); j++) {
            mp[v[i][j].first] += v[i][j].second;
        }
    }

    cout << "pairwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 76824
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin >> n;
    int b[n];
    REP(i,n-1) cin >> b[i];
    b[n-1] = b[n-2];
    int ans = b[0];
    REP(i,n-1){
        ans += min(b[i],b[i+1]);
    }
    PRINT(ans);
}


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

int main()
{
    int M, N, solved;
    cin >> M >> N;
    int score[M];
    fill_n(score, M, 0);
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> solved;
            score[i] += solved;
        }
    }
    cout << *max_element(score, score+M) << endl;
}

Measured memory_bytes: 1160
N,A,B = map(int, input().split())

def Nsum(N):
    Ns = str(N)
    return sum(list(map(int,Ns)))

count = 0
for i in range(1,N+1):
    if Nsum(i)>=A and Nsum(i)<=B:
        count += i

print(count)

Measured memory_bytes: 42988
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int max = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (min > x) {
		        min = x;
		    } else {
		        int sub = x - min;
		        if (max < sub) {
		            max = sub;
		            count = 1;
		        } else if (max == sub) {
		            count++;
		        }
		    }
		}
		System.out.println(count);
   }
}




Measured memory_bytes: 48700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

long long int gcd(long long int g_a,long long int g_b){
	if(g_a<g_b)gcd(g_b,g_a);
	if(g_b==0)return g_a;
	return gcd(g_b,g_a%g_b);
}

long long int divide(long long int d_a,long long int d_b,long long int d_p=1e9+7){
	// d_a/d_b mod d_p
	// prime:d_p is prime
	if(d_a>=d_p)d_a%=d_p;
	if(d_a<0)d_a+=d_p;
	if(d_b>=d_p)d_b%=d_p;
	if(d_b<0)d_b+=d_p;
	d_a*=pow_mod(d_b,d_p-2,d_p);
	return d_a%d_p;
}

LL rui[2][1100000];
LL kai[2100000];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	rui[0][0]=1,rui[1][0]=1;
	for(j=0;j<2;j++){
		for(i=1;i<=1e6+7;i++){
			rui[j][i]=rui[j][i-1]*(25+j);
			rui[j][i]%=MAX;
		}
	}
	kai[0]=1;
	for(i=1;i<=2e6+7;i++){
		kai[i]=kai[i-1]*i;
		kai[i]%=MAX;
	}
	cin>>n;
	string sa;
	cin>>sa;
	m=sa.size();
	LL s=0;
	for(i=0;i<=n;i++){
		a=kai[m-1+i];
		b=kai[m-1]*kai[i]%MAX;
		a=divide(a,b);
		a=a*rui[0][i]%MAX*rui[1][n-i]%MAX;
		s+=a;
	}
	cout<<s%MAX<<endl;
}

Measured memory_bytes: 36592
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n;
    
    ll x=0,y=0,z=0;
    cin>>n;
    x=n/500;
    n=n%500;
    y=n/5;
    n=n%5;
    cout<<(1000*x + 5*y )<<endl;
}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())
mod = 10**9 + 7
N = 200001
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

ans = 0
for i in range(1, H-A+1):

    ans += (cmb(B+i-2, B-1, mod)) * cmb((W-B-1) + (H-i), W-B-1, mod)
    ans %= mod


print(ans)


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

void solve(){
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
}


int main(){
  cin>>s;

  solve();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
t = []
 
for i in range(0,n):
    s.append(input())
m = int(input())
for i in range(0,m):
    t.append(input())
 
 
answer = 0
for i in range(0,n):
    if s.count(s[i]) - t.count(s[i]) >= answer:
        answer = s.count(s[i]) - t.count(s[i])
 
print(answer)
 
    

Measured memory_bytes: 3064
#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; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll n,k;
        cin>>n>>k;
        cout<<min(n%k, k-(n%k))<<el;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }


// https://atcoder.jp/contests/abc132/tasks/abc132_f

signed main() {

	int N, K;
	int num[100000];	// layer iのの個数
	cin >> N >> K;

	int idx = 0;
	for (int i=1;;) {
		if (i * i <= N) {
			num[idx] = 1;
			idx++;
			i++;
		}
		else {
			num[idx] = N / (N / i) - i + 1;
			idx++;
			i = N / (N / i) + 1;
		}
		if (i > N) break;
	}

	int dp[100000][101];
	int sum[100001];

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int k = 0; k < K; k++) {
		memset(sum, 0, sizeof(sum));
		for (int j = 0; j < idx; j++) (sum[j + 1] = sum[j] + dp[j][k])%=mod;
		for (int j = 0; j < idx; j++) (dp[j][k+1] = sum[idx - j] * num[j])%=mod;
	}

	int ans = 0;
	for (int j = 0; j < idx; j++) (ans += dp[j][K])%=mod;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 80768
object Main extends App{
  import scala.io.StdIn._
  import scala.math._
  val n = readLine().trim().toInt
  var sum:Long = 0
  var minB = 1000000001
  for (_ <- 0 until n){
    val (a::b::_) = readLine().trim().split(' ').map(_.toInt).toList
    sum += a
    if (a > b){
      if (minB > b){
        minB = b
      }
    }
  }
  if (minB == 1000000001){
    println(0)
  }else{
    println(sum - minB)
  }
}

Measured memory_bytes: 38996
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,a,b,c,d = li_()
n += 1
s = ns()


if c < d:
    if "##" in s[a:c+1] or "##" in s[b:d+1]:
        print("No")

    else:
        print("Yes")

else:
    if (not "..." in s[b-1:d+2]):
        print("No")

    elif "##" in s[a:c + 1] or "##" in s[b:d + 1]:
        print("No")

    else:
        print("Yes")



Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const int INF = 2e9;
int N;
bool F[103][10];
int P[103][10];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) rep(j, 10) cin >> F[i][j];
  rep(i, N) rep(j, 11) cin >> P[i][j];
  
  int ans = -INF;
  rep(bit, 1<<10) {
    int tmp = 0;
    if (bit==0) continue;
    rep(j, N) {
      int cnt=0;
      rep(k, 10) {
        if (F[j][k] && (1<<k & bit)) cnt++; //  その店がやっているかつ自分も営業する
      }
      tmp+=P[j][cnt];
    }
    
    ans=max(tmp, ans);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3636
import bisect

n=int(input())
a1=int(input())
alist=[]
for al in range(n-1):
    alist.append(-2)
alist.append(a1)

for i in range(n-1):
    an=int(input())
    #print(alist,an)
    index = bisect.bisect_left(alist, an)
    alist[index-1]=an

#print(alist)
index = bisect.bisect_left(alist, -1)
#print(index)
print(len(alist)- index)

Measured memory_bytes: 7080
from collections import*
from functools import*
from fractions import*
def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    # divisors.sort()
    return Counter(divisors)

n,*a=map(int,open(0).read().split())
if n<1000:
    ans=Counter()
    for i in range(n):
        ans+=dv(a[i])
    l=[]
    for k,v in ans.items():
        if v==n-1 or v==n:
            l.append(k)
    print(max(l))
else:
    print(max(reduce(gcd,a[n//4:]),reduce(gcd,a[:n//4]+a[n//2:]),reduce(gcd,a[:n//2]+a[3*n//4:]),reduce(gcd,a[:3*n//4])))

Measured memory_bytes: 16152
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < n; ++i)

using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

    vector<int> b(n-1);
    vector<int> a(n);
    rep(i, n-1) cin >> b[i];

    // else i=0 
    int ans = 0;
    int pre_bi = 1001001;
    for(int i = n-1; i>0; i--) {
        int bi;
        bi = b[i-1];
        ans += min(b[i-1], pre_bi);
        pre_bi = bi;
    }
    ans += b[0];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long int
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2(x,y) scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%lld",n)
#define prln(n) printf("%lld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)

#define TC(n) printf("Case %d:\n",n)


int main()
{

    int n;
    read(n);

    string x,y;
    cin>>x;
    cin>>y;

    int cnt=0;
    for(int i=0;i<n;i++)
    {
        string p="";
        fo(k,i,n)p+=x[k];
        string q="";
        fo(k,0,sz(p))
        q+=y[k];
        if(p==q)
        {
            cnt=p.size();
            break;
        }
    }

    prn( (n+n)-cnt );


    return 0;
}














Measured memory_bytes: 256
N=int(input())
p = list(map(int,input().split()))
buf = 0
count = 0
for i in range(N):
    if i+1==p[i]:
        buf+=1
    else:
        count+=int((buf+1)/2)
        buf=0
count+=int((buf+1)/2)   
print(count)

Measured memory_bytes: 14008
#include <iostream>

using namespace std;

int main(){
	unsigned long long int a, b, c;
	cin >> a >> b >> c;
	
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);
	
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0	){
		cout << 0 << endl;
	} else {
		cout << a * b << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
for i in range(n):
    x,y=map(int,input().split())
    l=[[0 for i in range(y+1)] for j in range(x+1)]
    m=int(input())
    l1=[]#マタタビの落ちている区間のリスト
    if m!=0:
        for j in range(m):
            l2=list(map(int,input().split()))
            l1.append(l2)
    for i in range(1,x+1):
        if [i,0,i-1,0] in l1 or [i-1,0,i,0] in l1:
          break
        l[i][0]=1
    for i in range(1,y+1):
        if [0,i,0,i-1] in l1 or [0,i-1,0,i] in l1:
          break
        l[0][i]=1
    for i in range(1,y+1):
        for j in range(1,x+1):#2重ループで各点の到達方法の場合の数を記録
            if ([j,i-1,j,i] in l1 or [j,i,j,i-1] in l1) and ([j,i,j-1,i] in l1 or [j-1,i,j,i] in l1):
                l[j][i]=0
            elif ([j,i,j-1,i] in l1 or [j-1,i,j,i] in l1):
                l[j][i]=l[j][i-1]
            elif ([j,i-1,j,i] in l1 or [j,i,j,i-1] in l1):#マタタビの落ちている区間は除く
                l[j][i]=l[j-1][i]
            else:
                l[j][i]=l[j-1][i]+l[j][i-1]
    if l[x][y]==0:
      print("Miserable Hokusai!")
    else:
      print(l[x][y])


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    set<char>s;
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        s.insert(str[i]);
    }
    if(s.size()==1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  int scores[2] = {};
  for (int i = 0; i < n; ++i) {
    string a, b;
    cin >> a >> b;
    transform(a.begin(), a.end(), a.begin(), ::tolower);
    transform(b.begin(), b.end(), b.begin(), ::tolower);
    if (a == b) {
      ++scores[0];
      ++scores[1];
    } else if (lexicographical_compare(a.begin(), a.end(), b.begin(), b.end())) {
      scores[1] += 3;
    } else {
      scores[0] += 3;
    }
  }
  cout << scores[0] << " " << scores[1] << endl;
}

Measured memory_bytes: 3152
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int x[300 * 300 + 1] = {};
int y[300 * 300 + 1] = {};

ll a[200001] = {};
ll b[200001] = {};

int main(void)
{
	int n;
	INPUT(n);

	for (int i = 0; i < n; i++) {
		int p;
		INPUT(p);
		p--;
		a[p] += i;
		a[n + 1] -= i;
		b[0] += i;
		b[p + 1] -= i;
	}

	for (int i = 0; i < n; i++) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}

	for (int i = 0; i < n; i++) {
		a[i] += i + 1;
		b[i] += n - i;
	}

	for (int i = 0; i < n - 1; i++) {
		PUT(a[i]);
		puts(" ");
	}
	PUT(a[n-1]);
	puts("\n");

	for (int i = 0; i < n - 1; i++) {
		PUT(b[i]);
		puts(" ");
	}
	PUT(b[n - 1]);
	puts("\n");



	return 0;
}



Measured memory_bytes: 1024
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L=[[] for i in range(4)]
L2=[[0] for i in range(4)]
for i in range(n):
  L[l[i][0]-l[0][0]].append(l[i][1])
for i in range(4):
  L[i].sort()
  L[i].reverse()
for i in range(4):
  for j in range(len(L[i])):
    L2[i].append(L2[i][len(L2[i])-1]+L[i][j])
ansL=[]
for i1 in range(len(L2[0])):
  for i2 in range(len(L2[1])):
    for i3 in range(len(L2[2])):
      for i4 in range(len(L2[3])):
        if l[0][0]*i1+(l[0][0]+1)*i2+(l[0][0]+2)*i3+(l[0][0]+3)*i4<=w:
          ansL.append(L2[0][i1]+L2[1][i2]+L2[2][i3]+L2[3][i4])
print(max(ansL))

Measured memory_bytes: 9844
H, W = map(int, input().split())
a = [input() for _ in range(H)]
temp = []
for i in range(H):
    if a[i] == ('.' * W):
        pass
    else:
        temp.append(a[i])
a = temp
temp = []
for i in range(W):
    flg = True
    for j in range(len(a)):
        if not a[j][i] == '.':
            flg = False
        if not flg:
            break
    else:
        temp.append(i)

for i in range(len(a)):
    for j in range(W):
        if j in temp:
            pass
        else:
            print(a[i][j], end='')
    print()


Measured memory_bytes: 4468
N=int(input())
A=list(map(int,input().split()))
number=[0]*(N+1)
all_sum=0
for i in A:
    number[i]+=1
for i in number:
    all_sum+=i*(i-1)/2
for i in range(N):
    print(int(all_sum-(number[A[i]]-1)))



Measured memory_bytes: 26268
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <numeric>

int main() {
  std::int_fast64_t n, a, b;
  std::cin >> n >> a >> b;
  std::vector<std::int_fast64_t> v(n);
  for (std::int_fast64_t& v_i : v) {
    std::cin >> v_i;
  }

  std::sort(v.rbegin(), v.rend());
  std::int_fast64_t prev_v_i = 0;
  std::int_fast64_t y = 0;
  for (std::int_fast64_t i = 0; i < a; ++i) {
    if (prev_v_i == v[i]) {
      ++y;
    } else {
      y = 1;
      prev_v_i = v[i];
    }
  }
  std::int_fast64_t x = y;
  for (std::int_fast64_t i = a; i < n; ++i) {
    if (prev_v_i == v[i]) {
      ++x;
    } else {
      break;
    }
  }

  std::vector<std::int_fast64_t> x_c(b + 1);
  x_c[0] = 1;
  for (std::int_fast64_t i = 1; i <= y; ++i) {
    x_c[i] = x_c[i - 1] * (x - i + 1) / i;
  }
  std::int_fast64_t result = x_c[y];
  if (y == a) {
    for (std::int_fast64_t i = a + 1; i <= b; ++i) {
      x_c[i] = x_c[i - 1] * (x - i + 1) / i;
      result += x_c[i];
    }
  }
  std::cout << std::fixed << std::setprecision(6) << std::accumulate(v.begin(), v.begin() + a, 0.0, [](const double sum, const double v_i) { return sum + v_i; }) / a << std::endl;
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
import System.IO (hFlush, stdout)
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = do
  putStrLn "?aaaaa"
  hFlush stdout
  solve S.empty

solve :: Set String -> IO ()
solve st = do
  ss <- getLine
  if head ss == 'a' && S.notMember ss st
    then do
      putStrLn $ "?" ++ reverse ss ++ "aa"
      hFlush stdout
      solve (S.insert ss st)
    else do
      putStrLn "!OUT"
      hFlush stdout



Measured memory_bytes: 3640
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();


		double sec = (H*3600+H*60);

		double jikanKakudo = H*30+M*0.5;
		double hunKakudo = M*6;
		double kakudo = Math.abs(hunKakudo- jikanKakudo);
		double ans = 0;

		if(kakudo == 0){
			ans = Math.abs(A-B);
		}else if(kakudo == 180){
			ans = A+B;
		}else if(kakudo>180) {
			kakudo = 360 - kakudo;
			ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(kakudo)));
		}else {

			ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(kakudo)));
		}

			System.out.println(ans);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35764
#include<iostream>
#include<string>

using namespace std;

int main() {
	char s[10];
	string n;
	for (int i = 0;i < 10;++i)cin >> s[i];
	if (s[5] == '0' && (s[6] == '1' || s[6] == '2' || s[6] == '3')) {
		n = "Heisei";
	}
	else if (s[6] == '4'&&s[8] != '3')n = "Heisei";
	else if (s[6] == '4'&&s[8] == '3'&&s[9] == '0')n = "Heisei";
	else n = "TBD";
	cout << n << endl;

	return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc012.contest.atcoder.jp/tasks/agc012_a>
問題文============================================================
 AtCoder Group Contestの参加者に 3N 人が参加します。
 i 番目の参加者の 強さ は整数 ai で表されます。
 参加者が 3 人 1 組となるようにチームを N 組作ることにしました。
 1 人の参加者が複数のチームに所属することはできません。
 
 チームの強さはチームメンバーの強さのうち 2 番目に大きい値で表されます。
 例えば、強さが 1,5,2 のメンバーからなるチームの強さは 2 になり、
 強さが 3,2,3 のメンバーからなるチームの強さは 3 になります。
 
 N 組のチームの強さの和としてありうる値のうち、最大の値を求めてください。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(3*N); for(auto& in:a) cin >> in;
    sort(a.begin(),a.end());
    ll ans = 0;
    ll idx = 3*N-2;
    while(N--){
        ans += a[idx];
        idx -= 2;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;

int main(){
  string S;cin>>S;
  int N=S.size();
  int num,sum=0,ans=0;
  num=0;
  rep(i,N){
    if(num==(S[i]-'0')){sum++;}
    num=1-num;
  }
  ans=sum;
  num=1;sum=0;
  rep(i,N){
    if(num==(S[i]-'0')){sum++;}
    num=1-num;
  }
  ans=min(ans,sum);
  cout<<ans;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

    void run() {
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] t = new int[N];
        for (int i = 0; i < N; i++) t[i] = sc.nextInt();
        int res = T;
        for (int i = 0; i < N - 1; i++) res += (t[i + 1] - t[i] >= T) ? T : t[i + 1] - t[i];
        System.out.println(res);
    }

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

Measured memory_bytes: 64680