akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

bool sor(const pair<int,int> &a, const pair<int,int> &b) {
    return a.second > b.second;
}

bool desc(const int &a, const int &b) {
    return a > b;
}

int main(){
    int N,M;cin >> N >> M;
    const int MAXN = 100001;
    // memset(Ma,0,sizeof(int)*MAXN);
    int A[MAXN];
    rep(i,N){
        cin >> A[i];
    }
    sort(A,A+N);
    pair<int,int> P[MAXN];

    rep(i,M){
        cin >> P[i].first >> P[i].second;// firstこのseconde
    }

    sort(P,P+M,sor);
    
    int tmp[MAXN+2];
    int count = 0;
    for(int i=0;i<M;i++){
        for(int j=0;j<P[i].first;j++){
            tmp[count] = P[i].second;
            count++;
            if(count>N)break;
        }
    }

    // rep(i,10)cout << i << A[i]<<" " << tmp[i] << endl;

    sort(tmp,tmp+MAXN,desc);
    ll ans = 0;
    rep(i,N){
        ans += max(tmp[i],A[i]);
    }

    cout << ans << endl;

    return 0;
}

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

int N;
vector<int>money = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049 };  //
vector<int> dp(100010, 100010);//dp[i]はiを構成ための最小要素(作業)数
int n = 1;  //次に追加できる金額の格納番号

int main(){
  cin >> N;

  /*以下、ただの貪欲法ではダメ...14の場合、9+5(1)より、6+6+2(1)の方がよい*/
  /*また、12の場合、9+1+1+1より6+6の方がよい*/
  /*従って、dp:  ex) dp[21] = min(1+dp[20], 1+dp[15], 1+dp[12])に絞られる。*/

  dp[0] = 0;  //お金操作しないよね...
  for(int i = 1; i <= N; i++){
    if(n < 12 && i >= money[n]) ++n;  //引き出し金額幅拡大
    for(int j = 0;  j < n; j++) dp[i] = min(dp[i], 1+dp[i-money[j]]); 
  }
  cout << dp[N] << endl;
    

  return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

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

ans=0
while True:
    if a%2==1 or b%2==1 or c%2==1:
        break
    if a==b==c:
        ans=-1
        break
    ans+=1
    na=(b+c)/2
    nb=(c+a)/2
    nc=(a+b)/2
    a=na
    b=nb
    c=nc
print(ans)


Measured memory_bytes: 3060
// ref: https://qiita.com/tell0120xxx/items/b32763e955e3ced8adb7

// ref: https://gotutiyan.hatenablog.com/entry/2018/02/20/235857
// ref: https://yamakasa.net/atcoder-abc-088-c/
// ref: https://img.atcoder.jp/abc088/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    vector<vector<int>> vvC(3, vector<int>(3));
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            cin >> vvC[i][j];
        }
    }
    
    vector<int> vA(3, 0);
    vector<int> vB(3, 0);
    for(int i=0; i<3; ++i){ vA[i]=vvC[i][0]-vB[0]; }
    for(int i=0; i<3; ++i){ vB[i]=vvC[0][i]-vA[0]; }
    bool TF=true;
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            if(vA[i]+vB[j]==vvC[i][j]){ continue; }
            TF=false; break;
        }
    }
    cout << (TF ? "Yes":"No") << endl;
    
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    lint h, w;
    cin >> h >> w;

    lint ans = LLINF;

    for(lint i = 1 ; i < h ; ++i){
        lint t = h - i;
        lint a = i * w;
        lint b = t * (w / 2LL);
        lint c = t * (w - w / 2LL);
        ans = min(ans, max({a, b, c}) - min({a, b, c}));
        b = (t / 2LL) * w;
        c = (t - t / 2LL) * w;
        ans = min(ans, max({a, b, c}) - min({a, b, c}));
    }
    for(lint i = 1 ; i < w ; ++i){
        lint t = w - i;
        lint a = i * h;
        lint b = t * (h / 2LL);
        lint c = t * (h - h / 2LL);
        ans = min(ans, max({a, b, c}) - min({a, b, c}));
        b = (t / 2LL) * h;
        c = (t - t / 2LL) * h;
        ans = min(ans, max({a, b, c}) - min({a, b, c}));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_NK2
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            if(n%2==0){
                WriteLine(n/2-1);
            }else{
                WriteLine(n/2);
            }

        }
    }
}


Measured memory_bytes: 11220
import java.util.*

fun main(args: Array<String>) {
    val s = Scanner(System.`in`)
    val n = s.nextInt()
    val v = IntArray(n) { s.nextInt() }
    val c = IntArray(n) { s.nextInt() }


    val ret = v.zip(c).map { p -> p.first - p.second }
        .filter { it > 0 }
        .sum()


    println(ret)
}

Measured memory_bytes: 34244
#include <bits/stdc++.h>
using  namespace std;
int main() {
  vector <int> A(3);
  cin >> A.at(0) >> A.at(1) >> A.at(2);
  sort(A.begin(),A.end());
  for(int i=0;i<3;i++) {
      cout << A.at(i) ;
      if(i!=2) cout << " ";
  }
  
  cout << endl;
    
    

}
    
   


Measured memory_bytes: 3120
#include<iostream>
using namespace std;
long mod=1e9+7,dp[22][1<<21];
int n,a[21][21];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
	dp[0][0]=1;
	for(int i=0;i++<n;)
	{
		int I=(1<<i)-1;
		while(I<1<<n)
		{
			for(int j=0;j<n;j++)
			{
				if(a[i-1][j]&&(I&1<<j))(dp[i][I]+=dp[i-1][I&~(1<<j)])%=mod;
			}
			int x=I&-I,y=I+x;
			I=(I&~y)/x>>1|y;
		}
	}
	cout<<dp[n][(1<<n)-1]<<endl;
}

Measured memory_bytes: 309504
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int N, X, Y;
inline int dist(int a, int b) {
  return min(min(abs(b-a), abs(a-X) + 1 + abs(b-Y)), abs(a-Y) + 1 + abs(b-X));
}

int hist[2020];

int main(void) {
  scanf("%d%d%d", &N, &X, &Y);
  --X;
  --Y;
  REP(i, N) REP(j, i) {
    hist[dist(i, j)]++;
  }

  for(int k = 1; k < N; ++k) {
    printf("%d\n", hist[k]);
  }
  return 0;
}


Measured memory_bytes: 3184
#define rep(i,n)for(i=0;i<n;i++)
#define swap(a,b){a^=b;b^=a;a^=b;}
char p[8][9];i,j;rotate(o){rep(i,8)rep(j,i)swap(p[i][j],p[j][i])rep(i,8)rep(j,4)swap(p[i][j],p[i][7-j])printf("%d\n",o);rep(i,8)puts(p[i]);}main(){for(;i<8;)scanf("%s",p[i++]);rotate(90);rotate(180);rotate(270);exit(0);}

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

int main(void){
	int n,i,j,ans=0,end;
	long num; 
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		num<10000?end=num:end=10000;
		for(j=2;j<end;j++) if(num%j==0&&num!=j){num=0;break;}
		num!=0?ans++:1;
	}
	cout << ans << endl;
}

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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	
	string contest;
	cin >> contest;

	if(contest=="ABC"){
		cout << "ARC";
		return 0;
	} else{
		cout << "ABC";
		return 0;
	}

}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n];
    long long ans=0,plus[n+1],all=0,sum=0,tmp;
    plus[0]=0;
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (a[i]>0){
            all+=a[i];
            plus[i+1]=plus[i]+a[i];
        } else {
            plus[i+1]=plus[i];
        }
        if (i<k){
            sum+=a[i];
        }
        
    }
    for (int i=0; i<=n-k; i++){
        if (sum>0){
            tmp=all+plus[i]-plus[i+k]+sum;
        } else {
            tmp=all+plus[i]-plus[i+k];
        }
        if (ans<tmp){
            ans=tmp;
        }
        sum=sum-a[i]+a[i+k];
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int main(){
    int n;
    while(scanf("%d",&n),n){
        cin.ignore();
        map<string,int> Data;
        while(n--){
            string str;
            getline(cin,str);
            istringstream iss(str);
            for(string temp;iss >> temp;)Data[temp]++;
        }
        char key;
        cin >> key;
        map<string,int>::iterator it = Data.begin();
        map<int, vector<string> ,greater<int> > ans;
        while(it != Data.end()){
            if((*it).first[0] == key){
                ans[(*it).second].push_back((*it).first);
            }
            ++it;
        }
        map<int, vector<string> ,greater<int> >::iterator itt = ans.begin();
        vector<string> res;
        while(itt != ans.end()){
            if(res.size() > 5)break;
            //puts("o_o");
            int len = ans[(*itt).first].size();
            rep(i,len)res.push_back((*itt).second[i]);
            ++itt;
        }
        int len = res.size();
        if(len == 0){
            puts("NA");
        }
        else if(len < 5){
            rep(i,len-1)cout << res[i] << " ";
            cout << res[len-1] << endl;
        }
        else{
            rep(i,4)cout << res[i] << " ";
            cout << res[4] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1268
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


string s;

int main() {

	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int l=0;
  
  for(int i=0;i<N;i++){
  	int x;
    cin >> x;
    if(x>K-x){
    	l+=K-x;
    }else{
    	l+=x;
    }
  } 
  
  cout << 2*l << endl;
}


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

const long long mod = 1000000007;

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

	int n, t;
	cin >> n >> t;

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

	sort(d.rbegin(), d.rend());

	int prev = 0;
	long long ans = 1;
	for(int i = 0; i < n; ++i) {
		while(d[i] + t < d[prev]) ++prev;
		ans *= i - prev + 1;
		ans %= mod;
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

vector<int> g[101010];

int main() {
        int n;
        cin >> n;
        vector<int> fav(n);
        for (int i = 0; i < n; i ++) {
                int a;
                cin >> a;
                a --;
                fav[i] = a;
        }
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                if (fav[fav[i]] == i) ans ++;
        }
        cout << ans / 2 << endl;
        return 0;
}



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

int n , a[10];
int main() {
    scanf("%d" , &n);
    for (int i = 0 ; i < n ; ++ i) {
        int x;
        scanf("%d" , &x);
        if (x % 4 == 0) {
            ++ a[2];
        } else if (x % 2 == 0) {
            ++ a[1];
        } else {
            ++ a[0];
        }
    }
    if (a[0] > a[2] + 1) {
        puts("No");
    } else {
        if (a[0] == a[2] + 1) {
            if (a[1]) {
                puts("No");
            } else {
                puts("Yes");
            }
        } else {
            puts("Yes");
        }
    }
}


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

int main(){
	int edge1, edge2, diag, courec = 0, couloz = 0;
	while(scanf("%d,%d,%d", &edge1, &edge2, &diag) != EOF){
		if(edge1 == EOF || edge2 == EOF || diag == EOF) break;
		int edge11 = edge1 * edge1, edge22 = edge2 * edge2, diagg = diag * diag;
		if(edge1 != edge2 && edge11 + edge22 == diagg) courec++;
		else if(edge1 == edge2) couloz++;
	}
	cout <<courec <<endl <<couloz <<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << "0.5" << endl;
		return 0;
	}
	auto c = (n + 1) / 2.0;
	cout << (c/n) << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) { cin >> H[i]; }
  int tmp = 0;
  int m = 0;
  for (int i = 0; i < N - 1; i++) {
    tmp++;
    if (H[i] < H[i+1]) tmp = 0;
    if (tmp > m) m = tmp;
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 640
program onecardpoker;
var
a,b : integer;
begin
readln(a,b);
if (a>b) and not(b = 1) then
begin
writeln('Alice');
end else if a=b then
begin
writeln('Draw');
end else if (a<b) and not(a = 1) then
begin
writeln('Bob');
end else if (a>b) and (b = 1) then
begin
writeln('Bob');
end else if (a<b) and (a=1) then
begin
writeln('Alice');
end
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

//ifと配列ソートで偶奇分けして第２頻値を探そうとしたけど、バグ塗れで積んだのでmapで実装　→　めちゃくちゃ楽だった
//なので、備忘録としてmapの基本的な使い方も記しておく。

//mapの使い方とは

//1,mapの概要
//  基本的に　map<int,int> とかって作る。
//  first はkey　で、second　はvalue。これはmapがpairを使ってることによるらしい。
//  mapはvectorやstringのように、indexのメモリの増え方が一定でないらしく、順番に添え字の値を増やすみたいなことができない。
//  なので、イテレータを使って、
//   for(auto itr = map.begin() ; itr != map.end() ;itr++)
//  みたいなitrループを作って、全探索する。

//2,アロー演算子
//  -> の矢印のような表記をアロー演算子といい、左側に構造体のポインタ、右側に構造体のメンバ名を用意する。
//  map　の場合は　構造体のポインタがitr、構造体のメンバが（first、second）のいずれかであると考えられる。
// なので、 cnt = itr -> second とすると、cntにはmapのitr番目のvalueが追加される。

int main(){
    int n;cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    map<int,int> even,odd;
    rep(i,n){
        if(i % 2 == 0)odd[v[i]]++;
        else even[v[i]]++;
    }
    int even_1 = 0,even_2 =0,odd_1 = 0,odd_2 = 0;
    int e1 = 0,e2 = 0,o1 = 0,o2 = 0;

    //even mode1 roop
    int cnt = 0;
    for(auto itr = even.begin();itr != even.end();itr++){       //itr は　!= end としなければならないことに注意。
        if(itr -> second > cnt){
            cnt = itr -> second;
            even_1 = itr -> first;
        }
    }
    e1 = cnt;
    
    cnt = 0;
    for(auto itr = even.begin();itr != even.end();itr++){
        if(itr -> second > cnt && itr -> first != even_1){
            cnt = itr -> second;
            even_2 = itr -> first;
        }
    }
    e2 = cnt;

    cnt = 0;
    for(auto itr = odd.begin();itr != odd.end();itr++){
        if(itr -> second > cnt){
            cnt = itr -> second;
            odd_1 = itr -> first;
        }
    }
    o1 = cnt;

    cnt = 0;
    for(auto itr = odd.begin();itr != odd.end();itr++){
        if(itr -> second > cnt && itr -> first != odd_1){
            cnt = itr -> second;
            odd_2 = itr -> first;
        }
    }
    o2 = cnt;

    if(even_1 == odd_1){
        cout << min(n-e1-o2,n-e2-o1) << endl;
    }
    else{
        cout << n-e1-o1 << endl;
    }
}

Measured memory_bytes: 5376
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>
#include <queue>
#include <memory>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>; using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; const double PI = M_PI;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream& in, ostream& out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream& in, ostream& out) {
  l n, m; in >> n >> m;
  vl v(n); F(i, 0, n) in >> v[i];
  sort(all(v));
  l z = 0;
  for (auto x : v) {
    if (x > m) {
      m = 0;
      break;
    }
    z++;
    m -= x;
  }
  if (m && z) z--;
  out << z << lf;
}


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



int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);

  int a=0;
  int b=0;
  
  for (int i =0; i < N; i++){
      cin >> vec.at(i);
  }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(), vec.end());

  for (int i =0; i < N; i++){

  if(i%2==0){
  a+=vec.at(i);
  }else{
  b+=vec.at(i);
  }
  }
  
    cout <<a-b<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
 
}

const int MAXN = 200100;
const int M = 1e9 + 7;

int cnt[MAXN];

int32_t main(){
  fastio;
  int n,k;
  cin>>n>>k;
  for(int i=k;i>=1;i--){
    int mul=0;
    for(int j=i;j<=k;j+=i)mul++;
    int tot = exp(mul,n,M);  
    for(int j=i*2;j<=k;j+=i){
      tot=mod(tot-cnt[j],M);
    }
    cnt[i] = tot;
  }
  int res=0;
  for(int i=1;i<=k;i++){
    res = mod(res + cnt[i]*i,M);
  }
  cout<<mod(res,M)<<endl;
  // Math -> gcd it all // chack MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}

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

int main() {
  string S;
  cin >> S;
 int answer=0;
  
  if(S.at(0) =='R' && S.at(1)=='R' && S.at(2)=='R'){
    answer =3;
  }
  else if(S.at(1)=='S'){
    if (S.at(0)=='R' || S.at(2)=='R'){
      answer=1;
    }
    else 
      answer=0;
  }
  else 
    if (S.at(0)=='R' || S.at(2)=='R'){
	answer=2;
    }
  	else 
      answer=1;
  
    
  
    cout << answer << endl;
  
}
  


Measured memory_bytes: 3620
from sys import stdin
N = int(stdin.readline().rstrip())
# c_ij:1<=k<=Nで、kの先頭がiに等しく、末尾がjに等しい数を考える
# 0<=i,j<=9
# sum(0<=i<=9)sum(0<j<=9)c_ij * c_jiで答えが出るみたい
c_list = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
    # for i in range(10):
        # for j in range(10):
            # if str(n)[0] == str(i) and str(n)[-1] == str(j):
            #     c_list[i][j] += 1
    int(str(n)[0])
    c_list[int(str(n)[0])][int(str(n)[-1])] += 1
output = 0
for i in range(10):
    for j in range(10):
        output += c_list[i][j] * c_list[j][i]
# print(c_list)
print(output)

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b) {
        cout << c << endl;
    } else if (a == c) {
        cout << b << endl;
    } else {
        cout << a << endl;
    }

    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dat[2 * (1 << 17) - 1]; // = 131072
class SegT{
private:
  int NN;

public:
  SegT(int n_){
	NN = 1;
	while(NN < n_) NN <<= 1;
	for(int i=0;i<2*NN-1;++i) dat[i] = 0;
  }

  void update(int idx, int a){
	idx += NN - 1;
	dat[idx] += a;
	while(idx > 0){
	  idx = (idx - 1) / 2;
	  dat[idx] = dat[idx*2+1] + dat[idx*2+2];
	}
  }

  int query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0;
	if(a <= l && r <= b) return dat[k];
	else{
	  int vl = query(a, b, k*2+1, l, (l+r)/2);
	  int vr = query(a, b, k*2+2, (l+r)/2, r);
	  return vl + vr;
	}
  }
  int query(int a, int b){
	if(a >= b) return 0;
	return query(a, b, 0, 0, NN);
  }
  int read(int i){
	return dat[NN-1+i];
  }
};

LL W, N;
int fub(int i, VL& acc){
  int lb = i+1, ub = N+1;
  while(ub-lb>1){
	int m = (lb+ub)/2;
	if(acc[m] - acc[i] + (m-i-1) <= W)
	  lb = m;
	else
	  ub = m;
  }
  return lb;
}

int xs[50010];
LL acc[50010];
int main(){
  while(scanf("%lld%lld", &W, &N),N){
	VI xs(N);
	VL acc(N+1);
	REP(i,N){
	  scanf("%d", &xs[i]);
	  acc[i+1] = acc[i] + xs[i];
	}

	VI lbu(N);
	REP(i,N) lbu[i] = fub(i, acc);
	VI ubl(N);
	
	SegT seg(N+10);
	for(int i=N;i>=0;--i){
	  LL sp = W - (acc[N] - acc[i]);
	  if(N-1-i <= sp)
		seg.update(i, 1);
	  else{
		break;
	  }
	}
	
	int lb = 0, ub = W;
	VI rev;
	while(ub-lb>1){
	  LL L = (lb + ub)/2;

	  int r = N;
	  for(int i=N-1;i>=0;--i){
		while(r >= 0 && (acc[r] - acc[i] + (r-i-1)*L >= W)) --r;
		if(seg.read(i)) continue;

		int ubl = r+1;
		if(seg.query(ubl, lbu[i]+1)){
		  seg.update(i, 1);
		  rev.PB(i);
		}
	  }
	  if(seg.read(0)){
		ub = L;

		for(int x: rev)
		  seg.update(x, -1);
		rev.clear();
	  }
	  else{
		lb = L;
	  }
	}
	printf("%d\n", ub);
  }

  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    string S;

    cin >> N >> M;
    cin >> S;

    ll now = N;
    vector<ll> ans;
    while(now != 0 && now != -1){
        // もしも残りがM以下なら終了
        if(now <= M){
            ans.push_back(now);
            now = 0;
            break;
        }
        bool check = false;
        for(ll i=M; i>=1; i--){
            // もしも移動できるなら
            if(S[now-i] == '0'){
                now = now - i;
                ans.push_back(i);
                check = true;
                break;
            }
        }
        // もしも動けなかったとき
        if(check == false){
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(ans.begin(), ans.end());

    ll L = ans.size();
    REP(i, L){
        if(i == L-1){
            cout << ans[i] << endl;
        }
        else{
            cout << ans[i] << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 4408
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef long long ll;

int k, a, b;

int main(){
	scanf("%d%d%d", &k, &a, &b);
	ll ans;
	if(b > a + 2 && k >= a - 1){
		int r = k - (a - 1);
		if(r % 2){
			ans = a + ll(r / 2) * (b - a) + 1;
		}
		else{
			ans = a + ll(r / 2) * (b - a);
		}
	}
	else{
		ans = 1 + k;
	}
	printf("%lld", ans);
	return 0;
}

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

using namespace std;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << '\n';

	return 0;
}



Measured memory_bytes: 256
import sys
from itertools import groupby
inputs = sys.stdin.readlines()
s = inputs[0].strip()

p = [len(list(t[1])) for t in groupby(s)]
p_ = []
if s[0] == '<':
    for i in range(0, len(p), 2):
        try:
            p_.append((p[i], p[i+1]))
        except IndexError:
            p_.append((p[i], 0))
else:
    p_.append((0, p[0]))
    for i in range(1, len(p), 2):
        try:
            p_.append((p[i], p[i+1]))
        except IndexError:
            p_.append((p[i], 0))

ans = 0
for r1, r2 in p_:
    if r1 > r2:
        ans += (r1+1)*r1 // 2 + r2*(r2-1) // 2
    else:
        ans += (r2+1)*r2 // 2 + r1*(r1-1) // 2
        
print(ans)

Measured memory_bytes: 14988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007

int main()
{
    int t,n,c,r,i,minc=M;
    vector<pair<int,int> > v;
    cin >> n >> t;
    while(n--)
    {
        cin >> c >> r;
        v.push_back(make_pair(r,c));
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        if(v[i].first<=t) minc=min(minc,v[i].second);
    }
    if(minc==M) cout << "TLE\n";
    else cout << minc << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int INFTY = int.MaxValue;

        static void Main(string[] args)
        {
            //StreamReader inputfile = new StreamReader("input.txt");
            int n = int.Parse(Console.ReadLine());
            int[,] table = new int[n, n];

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]) - 1;
                int k = int.Parse(input[1]);

                for (int j = 0; j < k; j++)
                {
                    int v = int.Parse(input[2 + j]) - 1;

                    table[u, v] = 1;
                }
            }

            Dijkstra(table, n);
        }

        static void Dijkstra(int[,] table, int n)
        {
            int i, minCost;
            int[] minCostArr = Enumerable.Repeat(INFTY, n).ToArray();
            bool[] isVisit = new bool[n];

            minCostArr[0] = 0;

            while (true)
            {
                minCost = INFTY;
                int u = -1;

                for (i = 0; i < n; i++)
                {
                    if (!isVisit[i] && minCost > minCostArr[i])
                    {
                        u = i;
                        minCost = minCostArr[i];
                    }
                }

                if (u == -1) break;

                isVisit[u] = true;

                for (i = 0; i < n; i++)
                {
                    int w = table[u, i];

                    if (w > 0)
                    {
                        int c = minCostArr[u] + w;

                        if (c < minCostArr[i])
                        {
                            minCostArr[i] = c;
                        }
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (i = 0; i < n; i++)
            {
                int temp = minCostArr[i] == INFTY ? -1 : minCostArr[i];
                sb.AppendLine((i + 1) + " " + temp);
            }
            Console.Write(sb);
        }
    }
}



Measured memory_bytes: 18216
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[100];
  rep(i, n) cin >> a[i];
  int cnt = 0;
  rep(i, n)
  {
    int minj = i;
    for (int j = i; j < n; j++)
    {
      if (a[j] < a[minj])
        minj = j;
    }
    if (i != minj)
    {
      swap(a[i], a[minj]);
      cnt++;
    }
  }

  rep(i, n) cout << a[i] << (i == n - 1 ? "\n" : " ");
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3184
<?php
$s = trim(fgets(STDIN));
$array[1] = $s;

$i = 1;
$num = 0;
while(true){
    if($array[$i] % 2 == 0){
        $num = $array[$i] / 2;
    }else{
        $num = 3 * $array[$i] + 1;
    }
    
    $check = in_array($num, $array);
    if($check){
        echo $i+1;
        exit;
    }else{
        $array[] = $num;
    }
    $num = 0;
    $i++;
}

?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstdlib>

#define SIZE 8
#define WIDTH 4

using namespace std;

int distances[SIZE][SIZE][SIZE][SIZE][SIZE][SIZE][SIZE][SIZE];
int way[4] = { -1, 1, -WIDTH, WIDTH };

typedef struct{
	int v[SIZE];
} field_t;

void solve(){
	queue<field_t> q;

	q.push({ { 0, 1, 2, 3, 4, 5, 6, 7 } });

	while (!q.empty()){
		field_t a = q.front();
		q.pop();

		for (int i = 0; i < SIZE; i++){
			if (a.v[i] == 0){
				for (int j = 0; j < 4; j++){
					int newpos = i + way[j];
					if (newpos < 0 || newpos >= SIZE || abs(newpos%WIDTH - i%WIDTH) > 1) continue;
					int dist = distances[a.v[0]][a.v[1]][a.v[2]][a.v[3]][a.v[4]][a.v[5]][a.v[6]][a.v[7]];
					a.v[i]		= a.v[newpos];
					a.v[newpos]	= 0;
					if (distances[a.v[0]][a.v[1]][a.v[2]][a.v[3]][a.v[4]][a.v[5]][a.v[6]][a.v[7]]) {
						a.v[newpos] = a.v[i];
						a.v[i] = 0;
						continue; 
					}
					distances[a.v[0]][a.v[1]][a.v[2]][a.v[3]][a.v[4]][a.v[5]][a.v[6]][a.v[7]] = dist + 1;
					q.push(a);
					a.v[newpos] = a.v[i];
					a.v[i] = 0;
				}
				break;
			}
		}
	}
	distances[0][1][2][3][4][5][6][7] = 0;
}

int main(){
	solve();
	
	int a[SIZE];
	while (~scanf("%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7])){
		cout << distances[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][a[7]] << endl;
	}
}

Measured memory_bytes: 65128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, L[50], ans = 0;
    cin >> N >> K;
    REP(i, N) cin >> L[i];
    sort(L, L + N);
    RFOR(i, N - 1, N - K - 1) ans += L[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
chrs = set()
cnt = []
for i in range(n):
    s = input()
    cnt.append(Counter(s))
    for c in s:
        chrs.add(c)
ans = ''
for c in sorted(list(chrs)):
    size = cnt[0][c]
    for i in range(1, n):
        size = min(size, cnt[i][c])
    ans += c * size
print(ans)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)

signed main(){
	ll n; cin>>n;
	vl vec(n);
	map<ll,ll> mp;
	set<ll> s;
	rep(i,0,n){
		cin>>vec[i];
		mp[vec[i]]++;
		s.insert(vec[i]);
	}
	ll ans=0;
	rep(i,0,n){
		bool ok=true;
		if(mp[vec[i]]>1){
			continue;
		}
		for(ll j=(s.count(1) ? 1:2);j*j<=vec[i];j++){
			if(vec[i]==j) continue;
			if(vec[i]%j==0 && s.count(j)){
				ok=false;
				break;
			}
			else if(vec[i]%j==0 && s.count(vec[i]/j)){
				ok=false;
				break;
			}
		}
		if(ok){
			ans++;
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 26588
//
//  main.c
//  procon
//
//  Created by L on 2017. 10. 17..
//  Copyright © 2017년 L. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char a[10], b[10], c[10];
    scanf("%s %s %s", &a, &b, &c);
    
    printf("%c%c%c", a[0]-32, b[0]-32, c[0]-32);
    
    
    return 0;
}


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

typedef long long lint;

int main(){
  lint n;
  cin >> n;
  vector<lint> a(n);
  for(lint i = 0 ; i < n ; i++){
    cin >> a[i];
  }
  vector<lint> sum(n+1);
  sum[0] = 0;
  for(lint i = 1 ; i < n+1 ; i++){
    sum[i] = sum[i-1] + a[i-1];
  }
  lint ans = 0;
  map<lint, lint> mp;
  for(lint i = 0 ; i < n+1 ; i++){
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
	long N;
	long long a[300000];
	long long ans = 0;

	scanf("%ld",&N);
	for(long i=0;i<3*N;i++){
		scanf("%lld",&a[i]);
	}

	sort(a,a+3*N);

	for(long i=N;i<3*N;i+=2){
		ans += a[i];
	}

	printf("%lld\n",ans);

	return 0;
}


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

const int MAX_N = 100;
const long long int INF = 1e18;
int N;
int F[MAX_N][10];
int P[MAX_N][11];

void input(){
  cin >> N;
  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];
    }
  }
}

int main(){
  input();
  long long int res = -INF;
  for(int i = 1 ; i < (1 << 10) ; i++){
    long long int sum = 0;
    for(int j = 0 ; j < N ; j++){
      int cnt = 0;
      for(int k = 0 ; k < 10 ; k++){
        if(((i >> k) & 1) && F[j][k]){
          cnt++;
        }
      }
      sum += P[j][cnt];
    }
    res = max(res, sum);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int>
#define pb push_back
#define w(t)   int t;cin>>t;while(t--)
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7
#define MAX 90000000
#define ll long long
/*ll prime[MAX];

void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
*/

 //check for boundary cases like n<=1
// use bool array instead of int array
// remember binary search
// overflow limit
// try to use prefix and suffix array
vi inp(int n)
{
	vi v; int x;
	for(int i=0;i<n;i++) {
		cin>>x; v.pb(x);
	}
	return v;
}


int main()
{
	fio
	//sieve();
	int n; cin>>n;
	n%=10;
	if(n==2|| n==4|| n==5|| n==7|| n==9) cout<<"hon\n";
	else if(n==3) cout<<"bon\n";
	else cout<<"pon\n";
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(M), Y(M);
    vector<vector<int>> city(N + 1);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        city[P[i]].push_back(Y[i]);
    }

    for (int i = 1; i <= N; i++) sort(city[i].begin(), city[i].end());

    for (int i = 0; i < M; i++) {
        int x = distance(city[P[i]].begin(), lower_bound(city[P[i]].begin(), city[P[i]].end(), Y[i])) + 1;
        printf("%06d%06d\n", P[i], x);
    }
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> inv(n);
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		inv[x-1] = i;
	}
	set<int> act;
	act.insert(-1);
	act.insert(n);
	ll res = 0;
	for (int raw = 0; raw < n; ++raw) {
		int pos = inv[raw];
		auto it = act.lower_bound(pos);
		ll right = *it - pos;
		--it;
		ll left = pos - *it;
		res += right*left*(raw+1ll);
		act.insert(pos);
	}
	cout << res << "\n";
}


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

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

int i = 0, j = s.size() - 1;
int r = 0;
for(; i < j; i++, j--) {
if(s[i] != s[j]) r++;
}

cout << r << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int H,W,h,w;
    cin>>H>>W;
    cin>>h>>w;
    cout<<H*W-h*W-w*H+h*w<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    while(cin>>n,n){
    vector<int>t(n),h;
    for(int&x:t)
        cin>>x;
    sort(t.begin(),t.end());
    for(int i=1;i<=2*n;i++)
        if(find(t.begin(),t.end(),i)==t.end())
            h.push_back(i);
    int ba=0;
    for(int i=0;;i=1-i){
        auto&x=i?h:t;
        auto it=upper_bound(x.begin(),x.end(),ba);
        if(it!=x.end()){
            ba=*it;
            x.erase(it);
            if(x.empty()){
                cout<<h.size()<<endl;
                cout<<t.size()<<endl;
                break;
            }
        }else
            ba=0;
    }}
}



Measured memory_bytes: 3064
def change_apple_peach(sentence):
    sentence = sentence.replace('apple','aaa')
    sentence = sentence.replace('peach','ppp')
    sentence = sentence.replace('aaa','peach')
    sentence = sentence.replace('ppp','apple')
    print(sentence)

def main():
    str = input()
    change_apple_peach(str)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5556
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

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

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

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> dp(n + 1, 0);
	dp[1] = 1;
	dp[0] = 1;
	for (int i = 2; i < n + 1; i++)
	{
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	std::cout << dp[n] << '\n';
	return 0;
}



Measured memory_bytes: 3112
#include <iostream>

using namespace std;
long long n,j=0;
const long long MAXN=1e5 +10;
long long o=0;
long long x[MAXN],d[MAXN];
int main() {
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>x[i];
		if(x[i]==(i+1))
		{
			d[o]=i;
			o++;
		}
	}
	for(long long i=0;i<o;i++)
	{
		if(x[d[i]]==d[i]+1)
		{
			if(i<n-1)
			swap(x[d[i]],x[d[i]+1]);
			else swap(x[d[i]],x[d[i]-1]);
			j++;
		}
	}
	cout<<j;
	return 0;
}

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

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

    int a, b;
    cin >> a >> b;

    cout << a * b - (a + b - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
  {
	int n,m,i,a,b;
	scanf("%d%d",&n,&m);
	int count[n+1];
	for(i=0;i<=n-1;i++)
		{count[i]=0;}
	for(i=1;i<=m;i++)
		{
		scanf("%d%d",&a,&b);
		count[a-1]++;
		count[b-1]++;
		}
	for(i=0;i<=n-1;i++)
		{printf("%d\n",count[i]);}
	
	return 0;
}



Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n,l int
	fmt.Scan(&n,&l)

	ans := n*(2*l+n-1)/2
	if !(l+n-1>=0 && l<=0) {
		if l>0 {
			ans -= l
		} else {
			ans -= l+n-1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_   }
#else
#define MY_NAMESPACE(ns)
#define MY_NAMESPACE_
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


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

	string ans;
	switch (n % 10)
	{
	case 0:
	case 1:
	case 6:
	case 8:
		ans = "pon";
		break;
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		ans = "hon";
		break;
	case 3:
		ans = "bon";
		break;
	}

	cout << ans << endl;
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	int i,n,x[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++) {
		scanf("%d",&x[i]);
	}
	for(i=n;i>=1;i--) {
		if(i!=1) {
			printf("%d ",x[i]);
		}
		else {
			printf("%d\n",x[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 596