akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//////////////////////////// templejt /////////////////////////////////

// krotsze nazwy dlugich typow

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

// rzeczy z io

#define endl "\n";
#define newio() ios_base::sync_with_stdio(false); cout.tie(NULL); cerr.tie(NULL); cin.tie(NULL)
#define precision(x) cout << fixed << setprecision(x)

// kontenery, które często używam

// pary
#define PR pair
#define PII PR<int, int>
#define fi first
#define se second
#define mp make_pair

// wektory
#define VEC vector
#define VL VEC<ll>
#define VI VEC<int>
#define VPI VEC<PII>
#define pb emplace_back
#define rb pop_back
#define bk back()
#define ft front()

// sety
#define SI set<int>
#define SL set<ll>

// mapy
#define umap unordered_map
#define MII map<int, int>
#define MLI map<ll, int>
#define MIL map<int, ll>
#define MSI map<string, int>
#define UMII umap<int, int>
#define UMLI umap<ll, int>
#define UMIL umap<int, ll>
#define UMIS umap<int, string>

// pętle

#define rep(N) for(auto i = 0; i < N; ++i)
#define repp(I, N) for(auto i = I; i < N; ++i)

#define repi(N) for(auto i = N - 1; i >= 0; --i)
#define reppi(I, N) for(auto i = N - 1; i >= I; --i)

#define repk(K) for(auto &v : K)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)

// funkcje do kontenerów

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

template<class T>
ostream &operator<<(ostream& os, vector<T> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

template<class T>
ostream &operator<<(ostream& os, set<T> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

template<class T, class Y>
ostream &operator<<(ostream& os, map<T, Y> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

template<class T, class Y>
ostream &operator<<(ostream& os, umap<T, Y> V) {
    repk(V)
        os << v << " ";
    return os << endl;
}

// debugowanie

#define _DEV // usuń to przed wysłaniem
#ifdef _DEV
    #define debug(x) { cerr << #x << " == " << x << endl; }
#else
    #define debug(x)
#endif

// kilka liczb pierwszych

VL primes = {
    7, 17, 33, 257, 65537, 1000000007, 1000000009
//  0,  1,  2,   3,     4,          5,          6
};

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


const int MAXN = 402;

string S;
string T;

int pref_sum[MAXN];

bool kmp() {
    string K = "#" + T + "#" + S;

    int t = 0;
    for(int i = 2; i < sz(K); ++i) {
        while(t > 0 && K[t + 1] != K[i]) t = pref_sum[t];
        if(K[t + 1] == K[i]) ++t;

        pref_sum[i] = t;

        if(i > sz(T) && t == sz(T))
            return true;
    }

    return false;
}

int main() {
    newio();

    cin >> S >> T;
    S += S;

    if(kmp())
        cout << "Yes";
    else
        cout << "No";

    cout << endl;

    return 0;
}


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

using namespace std;

int w,h,res;
vector<vector<int> > map;
vector<vector<bool> > visited;
int dx[8] = {0,1,0,-1,1,1,-1,-1};
int dy[8] = {1,0,-1,0,1,-1,1,-1};

void bfs(int y,int x){
	if(y >= h || y < 0 || x >= w || x < 0)return;
	if(map[y][x] == 0)return;
	if(visited[y][x])return;
	visited[y][x] = true;
	for(int i=0;i<8;++i){
		bfs(y+dy[i],x+dx[i]);
	}
}

int main(void){
	while(1){
		res = 0;
		cin >> w >> h;
		if(w == 0 && h == 0)break;
		map.resize(h);
		visited.resize(h);
		for(int i=0;i<h;++i){
			map[i].resize(w);
			visited[i].resize(w);
			for(int j=0;j<w;++j){
				visited[i][j] = false;
				cin >> map[i][j];
			}
		}
		for(int i=0;i<h;++i){
			for(int j=0;j<w;++j){
				if(map[i][j] == 1&& visited[i][j] == false){
					bfs(i,j);
					res++;
				}
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3196
/* ?  ?        ????????????????         ? ? ?            ????????????????               ??     ??        ? ? ?           ???????        
		?             ??              ?       ?                 ??                      ??   ??        ?       ?        ??    ??     
   		 ?            ??             ?         ?                ??                      ?? ??         ?         ?      ??     ??         
  ?????????           ??             ?         ?                ??                      ??            ?         ?     ??      ??         
		 ?            ??             ?         ?                ??                      ?? ??         ?         ?   ??????????????                    
		?             ??              ?       ?                 ??                      ??   ??        ?       ?    ??          ??         
   ?  ?               ??                ? ? ?                   ??                      ??     ??        ? ? ?     ??           ??          
 
 
    ??     ?        ??    ?   ?   ?  ?   ??          ?  ?      ??     ?    ?    ????????  ?    ?                       
   ?      ? ?      ?  ?    ???    ????  ?  ?         ????     ?  ?    ?  ? ?       ??     ?  ? ?                       
   ?     ?   ?     ?  ?    ???    ?  ?  ?  ?         ?  ?    ??????   ? ?  ?       ??     ? ?  ?                 
    ??  ?     ?     ??    ?   ?   ?  ?   ??          ?  ?   ?      ?  ?    ?       ??     ?    ?                                      
                                                                                       
     ?      ?????    ??????    ?  ?    ???           ???????     ???     ????????    ???????       ?? ??      ?? ??     ??????????    ??                                                                               
    ? ?     ?        ??        ? ?   ?     ?         ??   ??   ?     ?      ??       ??            ??  ??    ??  ??         ??        ?? 
   ?   ?    ?????    ??        ??    ?     ?         ??   ??   ?     ?      ??       ???????       ?? ??      ?? ??         ??        ?? ??                                                           
  ?     ?   ?        ??        ? ?   ?     ?         ??   ??   ?     ?      ??       ??            ??        ??  ??         ??        ??  ?? 
 ?       ?  ?????    ??        ?  ?    ???           ??   ??     ???        ??       ????????      ??       ??   ??         ??        ?? ??                         
 
 
 
 
 
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
 
#define pb push_back
#define F first
#define S second
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end() 
 
int n,m,y,cnt,l,r;
int sum[1000005];
int a[1000005];
vector <int> v;



int main () {
	cin >> n >> m;
	if (n != 1 && m != 1){
		cout << 1;
	}
	else if (n != 2 && m != 2){
		cout << 2;
	}
	else if (n != 3 && m != 3){
		cout << 3;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	string S1, S2;
	cin >> N >> S1 >> S2;
	
	int i = 0;
	bool isYoko;
	ll ans = 1;

	if (i + 1 != N && S1[0] == S1[1]) {
		i += 2;
		isYoko = true;
		ans = 6;
	} else {
		i++;
		isYoko = false;
		ans = 3;
	}

	while (i < N) {
		if (i + 1 != N && S1[i] == S1[i + 1]) {
			i += 2;
			ans *= isYoko ? 3 : 2;
			isYoko = true;
		} else {
			i++;
			ans *= isYoko ? 1 : 2;
			isYoko = false;
		}
		ans %= MOD;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
Y = [-1,-1,0,1,1,1,0,-1]
X = [0,-1,-1,-1,0,1,1,1]
rounds = []
round_hw = []

ans = []
loop do
  w, h = gets.split.map(&:to_i)
  break if w == 0 && h == 0
  round_hw << [h, w]
  rounds << []
  rounds[-1] << Array.new(w+2, 0)
  h.times do
    rounds[-1] << [0] + gets.split.map(&:to_i) + [0]
  end
  rounds[-1] << Array.new(w+2, 0)
end

# rounds.each do |round|
#   round.each do |area|
#     p area
#   end
# end

rounds.each_with_index do |areas, index|
  check = []
  stack = []
  count = 0 # 陸毎にマーキングする値
  1.upto(round_hw[index][0]) do |y|
    1.upto(round_hw[index][1]) do |x|

      if areas[y][x] == 1
        stack.push([y, x])
        count += -1
        while !stack.empty?
          now = stack.pop
          areas[now[0]][now[1]] = count # 現在のマスをチェック
          8.times do |k|
            nexy = now[0] + Y[k]
            nexx = now[1] + X[k]
            if areas[nexy][nexx] == 1
              stack.push([nexy, nexx])
            end
          end
        end
        check << count
      end

    end
  end
  ans << check.size
end

ans.each do |an|
  puts an
end


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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  sort(l.begin(), l.end());

  int lrem = 0;
  for(int i=0; i<n-1; i++) lrem+=l[i];
  if(lrem>l[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;

bool can(string str, int m){
bool ok=false;
int n=str.size();
for(int i=0;!ok&&i<n-m;i++){
    string a = str.substr(i,m);
    string b = str.substr(i+m);
    size_t found = b.find(a);
    if(found!= string::npos)
        ok=true;
}

if(ok)
    return true;
else return false;

}


void mymain(){
    int n;
    cin >> n ;
    string str;
    cin >> str;
    int s=0,e=n/2;
    int ans=0;
    while(s<=e){
        int mid = (s+e)/2;
        if(can(str,mid)){
            ans=mid;
            s = mid+1;
        }else
            e=mid-1;

    }
    cout << ans <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}


Measured memory_bytes: 256
x,n=map(int,input().split())
if n == 0:
    print(x)
else:
    p=set([int(i) for i in input().split()])
    for i in range(1000):
        if not(x-i in p):
            ans=x-i
            break
        elif not(x+i in p):
            ans=x+i
            break
    print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,p=0,c=0;
  cin >> n;
  vector<int> vec(n);
  vector<bool> check(n,false);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  while(p!=1){
    if(check.at(p)){
      break;
    }else{
      check.at(p) = true;
      p = vec.at(p)-1;
      c++;
    }
  }
  if(p==1)
    cout << c << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 3784
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47536
import sys
read = sys.stdin.read
MOD = 10**9+7

n, *C = map(int, read().split())
dp = [0]*(n+1)
dp[0] = 1
idx = [-1]*(2*10**5+1)
for i, c in enumerate(C, 1):
  dp[i] = dp[i-1]
  if idx[c] != -1 and idx[c] < i-1:
    dp[i] += dp[idx[c]]
    dp[i] %= MOD
  idx[c] = i
print(dp[-1])

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

int main() {
  int N; cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) cin >> W.at(i);
  int minD = 100000;
  for (int T = 1; T < N; T++) {
    int S1 = 0, S2 = 0;
    for (int i = 0; i < T; i++) S1 += W.at(i);
    for (int i = T; i < N; i++) S2 += W.at(i);
    if (S1 < S2) minD = min(minD, S2 - S1);
    else minD = min(minD, S1 - S2);
  }
  cout << minD << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		int flag=1;
		ll a[30]={};
		rep(i,0,n){
			char c;
			scanf(" %c",&c);
			a[c-'A']++;
			ll M1=0,M2=0;
			ll i1=0,i2=0;
			rep(j,0,26){
				if(M1<a[j]){
					M2=M1;
					i2=i1;
					M1=a[j];
					i1=j;
				}else if(M2<a[j]){
					M2=a[j];
					i2=j;
				}
			}
			if(flag&&M1>M2+(n-1-i)){
				printf("%c %lld\n",'A'+i1,i+1);
				flag=0;
			}
		}
		if(flag)puts("TIE");
	}
}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const long long Mod = 998244353LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    long long d[n];
    rep(i,n) cin >> d[i];
    if(d[0]!=0){
        cout << 0 << endl;
        return 0;
    }
    int a[n];
    rep(i,n) a[i]=0;
    rep(i,n) a[d[i]]++;
    if(a[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    long long now = 1;
    long long ans = 1;
    for(int i = 1;i<n;i++){
        rep(j,a[i]){
            ans*=now;
            ans%=Mod;
        }
        now = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int i = n;
        while(i > 0){
            String line = sc.nextLine();
            System.out.println(line.replace("Hoshino", "Hoshina"));
            i--;
        }
    }
}



Measured memory_bytes: 26008
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l[1000],r[1000];
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>l[i]>>r[i];
  }
  int ta=0;
  for(int i=0;i<n;i++){
      ta += r[i]-l[i]+1;
  }
  cout<<ta<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    long double a,b,x;
    cin >> a >> b >> x;
    long double h = (x / a) / a;
    if(h*2 >= b){
        cout << setprecision(10) << 360/(2*M_PI) * atan((b-h)*2/a) << endl;


    }else{
        cout << setprecision(10) << 360/(2*M_PI) * atan(b / (2*x/(b*a))) << endl;
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a;
    cin >> x >> a;
    if(x<a) cout << "0\n";
    else cout << "10\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
 
int main(){
  string S;cin>>S;string ABC="ABC";
  int N=S.size();

  ll dp[N+1][4];
  for (int j=0;j<4;++j) dp[N][j]=(j==3)? 1:0;

  for (int i=N-1;i>=0;--i){
    for (int j=0;j<4;++j){
      ll m=(S[i]=='?')? 3:1;
      dp[i][j]=m*dp[i+1][j];
      if(j!=3&&(S[i]==ABC[j]||S[i]=='?')) (dp[i][j]+=dp[i+1][j+1])%=MOD;
      dp[i][j]%=MOD;
    }
  }
  cout << dp[0][0]%MOD << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <unordered_map>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define MAXSILVER 50*49
#define INF pow(10,16)

using namespace std;

struct Node{
	long number;
	long time;
	long silver;
	bool operator > (const Node &node1) const {
    return node1.time > time;
	};
	bool operator < (const Node &node1) const {
    return node1.time < time;
	};
};

int main(void){
	long i,j;
	long N,M,S,A[100],B[100],C[51],D[51],U[100],V[100],change_number;
	long dp[51][MAXSILVER+1] ={};
	priority_queue<Node> q;
	
	cin >> N >> M >> S;
	
	myfor(i,M)cin >> U[i] >> V[i] >> A[i] >> B[i];
	myforFL(i,1,N+1)cin >> C[i] >> D[i];
	myfor(i,N+1)myfor(j,MAXSILVER+1){
		dp[i][j]=INF;
	}
	S = min(S,(long)MAXSILVER);
	Node node = {1,0,S};
	dp[1][S]=0;
	q.push(node);
	while(!q.empty()){
		node = q.top();
		q.pop();
		if(dp[node.number][node.silver] < node.time)continue;
		if(node.silver +C[node.number] <= MAXSILVER && dp[node.number][node.silver+ C[node.number]] > node.time+D[node.number]){
			dp[node.number][node.silver+ C[node.number]] = node.time+D[node.number];
			q.push((Node){node.number,node.time+D[node.number],node.silver+ C[node.number]});
		}
		myfor(i,M){
			if(U[i] == node.number){	
				if(node.silver >= A[i] && node.time+B[i] < dp[V[i]][node.silver-A[i]]){
					dp[V[i]][node.silver-A[i]]=node.time+B[i];
					q.push((Node){V[i],node.time+B[i],node.silver-A[i]});
				}
			}else if(V[i] == node.number){
				if(node.silver >= A[i] && node.time+B[i] < dp[U[i]][node.silver-A[i]]){
					dp[U[i]][node.silver-A[i]]=node.time+B[i];
					q.push((Node){U[i],node.time+B[i],node.silver-A[i]});
				}
			}
		}
	}
	myforFL(i,2,N+1){
		long ans = INF;
		myfor(j,MAXSILVER){
			ans = min(dp[i][j],ans);
		}
		cout << ans << endl;
	}
	return 0;
}

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

long ans;
int n, m, x, skill[15][15];
vector<int> costs;

void calcPrice(vector<int> arr, int l) 
{ 
    long algo[m] = {0}, cost = 0;
    int flag = 1;
    
    for (int i = 0; i < l; i++)
    {
        cost += costs[arr[i]];
        //printf("%d ",arr[i]);
        for(int j = 0 ; j < m ; j++)
            algo[j] +=  skill[arr[i]][j];
    }
    
    //printf(" : ");
    for(int j = 0 ; j < m ; j++)
    {
        //printf("%d ",algo[j]);
        if(algo[j] < x)
        {
            flag = 0;
            break;
        }
    }
    
    //printf("%d\n",flag);
    if(flag)
        ans = cost < ans ? cost : ans;
} 

void subsequences(vector<int> arr, int index,  
                       vector<int> subarr) 
{ 
    // Print the subsequence when reach 
    // the leaf of recursion tree 
    if (index == arr.size()) 
    { 
        int l = subarr.size(); 
  
        // Condition to avoid printing 
        // empty subsequence 
        if (l != 0)
            calcPrice(subarr, l);
    } 
    else
    { 
        // Subsequence without including 
        // the element at current index 
        subsequences(arr, index + 1, subarr); 
  
        subarr.push_back(arr[index]); 
  
        // Subsequence including the element 
        // at current index 
        subsequences(arr, index + 1, subarr); 
    } 
    return; 
} 

int main()
{
    vector<int> arr;
    scanf("%d %d %d",&n, &m, &x);
    
    for(int i = 0 ; i < n ; i++)
    {
        int ci;
        scanf("%d", &ci);
        costs.push_back(ci);
        arr.push_back(i);
        for(int j = 0 ; j < m ; j++)
        {
            scanf("%d",&skill[i][j]);
            //printf("%d ",skill[i][j]);
        }
        //printf("\n");
    }
    
    ans = LONG_MAX;
    //printf("%ld",ans);
    vector<int> b; 
    subsequences(arr, 0, b); 
    
    ans = (ans == LONG_MAX) ? -1 : ans;
    printf("%ld",ans);
    
    return 0;
  
}

Measured memory_bytes: 3720
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s;

    REP(i, n){
        string x;
        cin >> x;
        s.push_back(x);
    }

    VSORT(s);

    REP(i, n){
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
using System;

namespace _145c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] x = new int[N];
            int[] y = new int[N];
            int[] read;
            double sum = 0;
            // Console.WriteLine(tori);
            for(int i = 0; i < N ; i++){
                read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
                x[i] = read[0];
                y[i] = read[1];
            }
            for(int i = 0; i< N ;i++){
                for(int j =i+1 ; j < N; j++){
                    sum += Math.Pow(Math.Pow(x[j]-x[i],2)+Math.Pow(y[j]-y[i],2),0.5);
                }
            }
            sum = sum * (N-1)/(N*(N-1)/2);
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FORB(i,s,e,st) for (int i = int(s); i < int(e); i+=(int(st)))
#define FOR(i,s,e) FORB(i,s,e,1)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  int n,l;
  cin>>n>>l;
  int lst[n];
  int sum[n-1];
  int solvable=-1;
  REP(i,n){
    cin>>lst[i];
    if(i!=0){
      sum[i]=lst[i]+lst[i-1];
      if(sum[i]>=l) solvable=i;
    }
  }
  if(solvable==-1) cout<<"Impossible\n";
  else{
    cout<<"Possible\n";
    FOR(i,1,solvable) cout<<i<<"\n";
    for(int i=n-1;i>=solvable;i--) cout<<i<<"\n";
  }


}


Measured memory_bytes: 1536
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> P;
int read()
{
    int x=0,flag=1;
    char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

int f[10005];

int main()
{
    REP(i,1,100) REP(j,1,100) REP(k,1,100)
    {
        int x=i*i+j*j+k*k+i*j+i*k+j*k;
        if(x<=10000) f[x]++;
    }
    int N=read();
    REP(i,1,N) printf("%d\n",f[i]);

    return 0;
}


Measured memory_bytes: 3796
s=input()
x=s.count('a')
y=s.count('b')
z=s.count('c')
a=[x,y,z]
if len(s)==1:
  print('YES')
elif len(s)==2:
  if s[0]==s[1]:
    print('NO')
  else:
    print('YES')
else:
  if len(s)%3==0:
    if x==y and y==z:
      print('YES')
    else:
      print('NO')
  else:
    if max(a)-min(a)==1:
      print('YES')
    else:
      print('NO')

Measured memory_bytes: 62656
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl

#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(sz(s)==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll n, m, a[105], sum, ans;
double p;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        sum += a[i];
    }
    p = 0.25 / m * sum;
    for (int i = 1; i <= n; i ++)
        if ((double)a[i] >= p)
            ans ++;
    if (ans >= m)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  a = input_list()
  ans = 0
  for i in a:
    ans ^= i
  if ans == 0:
    print('Yes')
  else:
    print('No')
    
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 86380
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o E.exe E.cpp 
Execute: ./E
*/ 

/* Solution sketch 
E: Use (integer) binary search on the answer. Suppose the answer is X (0≤X≤10^9). Then go through all logs Ai and count how many splits Ki you need to get the length of each of them under X, using the equation Ai/(Ki+1)=X. There's some funky arithmetic with the rounding, which I'm unsure of, but it works. Code.

Code: https://atcoder.jp/contests/abc174/submissions/15619338
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
#include <queue>
using namespace std;

// Global variables for convenience 
int n, k, a[200000];
		
int find_k(int x) {
	int result = 0; 
	int k0; 
	for(int i = 0; i < n; i++) {
		// Compute using integer arithmetic: ceil(Ai/X) - 1 
		if(a[i] % x == 0) {
			k0 = a[i] / x - 1;
		} else {
			k0 = a[i] / x; 
		}
		result += k0; 
	}
	
	return result; 
}

/* Integer binary search for this problem. 
	Precondition: f(a) > target & f(b) <= target. 
	
*/ 
int binary_search(int a, int b, int target) {
	int m  = a + (b-a)/2; 
	
	if(m == 0) 
		return 1; 
	
	int fm = find_k(m); 
		
	// Base case: end of search
	if(b == a || b == a + 1) 
		return b; 
		
	// Recursive cases 
	if(fm > target)
		return binary_search(m, b, target); 
	else 
		return binary_search(a, m, target); 	
}

int main() { 
	// Input 
	cin >> n >> k;
	for(int i = 0; i < n; i++) 
		cin >> a[i]; 
		
	// Binary search 
	int a = 0, 
		b = 1000000001; 
		
	cout << binary_search(a, b, k) << endl; 
	
	return 0; 
} 


Measured memory_bytes: 4312
import java.util.Scanner;

public class Main {
	final int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t != 0) {
			int n = sc.nextInt();
			int[] h = new int[n];
			for (int i = 0; i < n; i++) {
				h[i] = sc.nextInt();
			}
			int max =0;
			int min =0;
			for(int i=0;i<n-1;i++){
				if(h[i]<h[i+1]){
					max = Math.max(max, h[i+1]-h[i]);
				}
				else{
					min = Math.min(min, h[i+1]-h[i]);
				}
			}
			System.out.println(max+" "+-min);
			t--;
		}
	}

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

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    REP(i, 0, 5) {
        int a;
        cin, a;
        if (a == 0) {
            print(i + 1);
        }
    }
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n;cin >> n;
    vector<LL> a(n);
    inc(i, 0, n) cin >> a[i];
    vector<LL> sum(n, 0);
    inc(i, 0, n){
        if(i-a[i] >= 0){
            sum[i-a[i]]++;
        }
    }

    LL ans = 0;

    inc(i, 0, n){
        if(i+a[i] < n){
            ans += sum[i+a[i]];
        }
    }

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


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N;
  cin >> N;
  vector<string> S(N);
  REP(i, N)
  {
    cin >> S[i];
  }
  
  {
    vector<bool> visited(N, false);
    vector<bool> color(N, false);

    queue<pair<LL, bool>> q;
    color[0] = false;
    q.push({0, color[0]});
    visited[0] = true;

    while(!q.empty()){
      auto node = q.front();
      q.pop();

      LL idx = node.first;

      REP(i,N){
        if(S[idx][i]=='1'){
          if(visited[i]){
            if(color[i] != !node.second){
              cout << -1 << endl;
              return 0;
            }
          }else{
            color[i] = !node.second;
            visited[i] = true;
            q.push({i, color[i]});
          }
        }
      }
    }
  }

  LL maxi = 0;

  REP(start,N){
    vector<bool> visited(N, false);
    vector<LL> color(N, -1);

    queue<pair<LL, LL>> q;
    color[start] = 1;
    q.push({start, color[start]});
    visited[start] = true;

    while(!q.empty()){
      auto node = q.front();
      q.pop();

      LL idx = node.first;

      REP(i,N){
        if(S[idx][i]=='1'){
          if(visited[i]){
            
          }else{
            color[i] = node.second+1;
            visited[i] = true;
            q.push({i, color[i]});
          }
        }
      }
    }
    
    REP(i,N){
      if(color[i]>maxi){
        maxi = color[i];
      }
    }
  }

  cout << maxi << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n;
    cin >> n;

    bool ng = true;
    int k;
    eFOR(i, 1, n * 2) {
        if (i * (i - 1) == n * 2) {
            k = i;
            ng = false;
            break;
        }
    }

    if (ng) {
        cout << "No\n";
        return 0;
    }

    int now = 1;
    vector<VI> num(k, VI(k));
    FOR(i, 0, k)FOR(j, i, k - 1) {
        num[i][j] = now;
        num[j + 1][i] = now;
        now++;
    }

    cout << "Yes\n" << k << "\n";
    FOR(i, 0, k) {
        cout << k - 1 << " ";
        FOR(j, 0, k - 1)cout << num[i][j] << (j == k - 2 ? "\n" : " ");
    }
}

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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> si(n);
    repl(i,n){
        cin >> si[i];
    }
    vector<ll> rui(n+1);
    rui[0] = 0;
    reppl(i,n+1,1){
        rui[i] = rui[i-1] + si[i-1];
    }
    ll mx = 0;
    repl(i,n+1-m){
        mx = max(mx, rui[m+i] - rui[i]);
    }
    double ans = (mx + m) / 2.0;
    cout << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
//K回以下の修行でFA(max)<=xとできるのか(つまり、FA)
bool ok_check(ll N, ll K, ll x, vector<ll> A, vector<ll> F)
{
    ll count = 0;
    loop(i, N)
    {
        ll aa = x / F[i];
        if (aa < A[i])
            count += (A[i] - aa);
    }
    if (count <= K)
        return true;
    else
        return false;
}
int main()
{
    cout << fixed << setprecision(30);
    ll N, K;
    cin >> N >> K;
    vec A(N), F(N);
    loop(i, N) cin >> A[i];
    loop(i, N) cin >> F[i];
    sort(all(A));
    sort(all(F));
    reverse(all(F));
    ll ok = 1e13, ng = -1;
    //決め打ち二分探索
    while (ok - ng > 1)
    {
        ll mid = (ok + ng) / 2;
        if (ok_check(N, K, mid, A, F))
            ok = mid;
        else
            ng = mid;
    }
    putout(ok);
    return 0;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int n;
    scanf("%d", &n);

    vector<int> as;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        as.push_back(a - (i + 1));
    }

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

    ll b1 = as[n / 2 - 1];
    ll b2 = as[n / 2];

    ll ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++) {
        ans1 += abs(as[i] - b1);
        ans2 += abs(as[i] - b2);
    }
    printf("%lld\n", min(ans1, ans2));

    return 0;
}

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

const int maxnum = 1000000001;
int cnt = 0 ;

// merge separated vectors
void merge( vector<int> &a, int left, int mid, int right ){
  int n1 = mid - left ;
  int n2 = right - mid ;
  vector<int> l1(n1+1) ;
  vector<int> l2(n2+1) ;
  for (int i = 0; i < n1; i++) {
    l1.at(i) = a.at(left+i) ;
  }
  for (int i = 0; i < n2; i++) {
    l2.at(i) = a.at(mid+ i) ;
  }
  l1.at(n1) = maxnum ;
  l2.at(n2) = maxnum ;

  int i = 0 ;
  int j = 0 ;
  for (int k = left; k < right; k++) {
    if ( l1.at(i) <= l2.at(j)) {
      a.at(k) = l1.at(i) ;
      i++ ;
    }else{
      a.at(k) = l2.at(j) ;
      j++ ;
    }
    cnt++ ;
  }
}

void merge_sort( vector<int> &a, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2 ; //分割
    merge_sort( a, left, mid ) ; // 左側ソート
    merge_sort( a, mid, right ) ; // 右側ソート
    merge(a, left, mid, right ) ; // ソートしたやつを合併
  }
}

int main()
{
  int n ;
  cin >> n ;
  vector<int> s(n) ;
  for (int i = 0; i < n; i++) {
    cin >> s.at(i) ;
  }

  merge_sort(s, 0, n) ;

  for(int i = 0; i < n-1; i++) {
    cout << s.at(i) << " " ;
  }
  cout << s.at(n-1) << endl ;
  cout << cnt << endl ;
  return 0 ;
}


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

const int maxn=2e6+7;
int w[maxn],e[maxn],a[maxn];

int main (){
    int n;cin>>n;
    ll ans=0,x;
    for(int i=0;i<n;i++) cin>>x,ans+=x;
    cout<<ans-n<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
if n < 10:
    print(n)
else:
    n -= 10
    num = [1, 0]
    while n:
        i = len(num)-1
        while i > 0 and (num[i] == 9 or num[i] > num[i-1]):
            i -= 1
        if i == 0 and num[0] == 9:
            num = [1] + [0]*len(num)
        else:
            num[i] += 1
            for j in range(i+1, len(num)):
                num[j] = max(num[j-1] - 1, 0)
        n -= 1
        # print(''.join(map(str, num)))
    print(''.join(map(str, num)))

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

int main(){
    int A, B;
    cin >> A >> B;
    bool flag = false;
    for (int i = 1; i <= 10000; i++)
    {
        long  double calA, calB;
        calA = floor((double)i * 0.08);
        calB = floor((double)i * 0.1);
        if(calA == A && calB == B){
            cout << i << endl;
            flag = true;
            break;

        }
    }
    if(flag == false){
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,K;
int T[100010],D[100010];
P p[100010];

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>T[i]>>D[i];
		p[i]=make_pair(D[i],T[i]);
	}
	sort(p,p+N,greater<>());
	int c=0;
	set<int> U;
	priority_queue<int,vector<int>,greater<int>> Q;
	REP(i,K){
		int s=U.size();
		c+=p[i].first;
		U.insert(p[i].second);
		if(s==U.size()){
			Q.push(p[i].first);
		}
	}
	int m=c+U.size()*U.size();
	for(int i=K;i<N;i++){
		if(Q.empty()){
			break;
		}
		int s=U.size();
		U.insert(p[i].second);
		if(s!=U.size()){
			c+=p[i].first;
			c-=Q.top();
			Q.pop();
			m=max(m,c+(s+1)*(s+1));
		}
	}
	cout<<m<<endl;
	return 0;
}


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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debarr(x) for (auto i : x) cout << i << " "; cout << endl;
#define debtwo(x,y) cout << #x << " " << x << ", " << #y << " " << y << endl;
#define mod 1000000007

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

	string s;
	cin >> s;

	if (s.back() == 's') {
		cout << s << "es" << endl;
	}
	else {
		cout << s << "s" << endl;
	}


}

Measured memory_bytes: 3660
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
priority_queue<ll, vector<ll>, greater<ll> > asc_que;
priority_queue<ll> desc_que;
priority_queue<ll, vector<ll>, greater<ll> > asc_que2;
priority_queue<ll> desc_que2;

ll calc(){
  ll left = asc_que.top();
  ll right = asc_que.top();
  asc_que.pop();
  bool flag = true;
  ll ans = 0;
  int cnt = 0;
  rep(i, N-1){
    ll a = 0;
    if (flag){
      a = desc_que.top();
      desc_que.pop();
    }else{
      a = asc_que.top();
      asc_que.pop();
    }
    if (cnt==0){
      ans += abs(a-left);
      left = a;
    }
    if (cnt==1){
      ans += abs(a-right);
      right = a;
    }
    cnt++;
    if (cnt==2){
      flag = !flag;
      cnt = 0;
    }
  }
  return ans;
}

ll calc2(){
  ll left = desc_que2.top();
  ll right = desc_que2.top();
  desc_que2.pop();
  bool flag = false;
  ll ans = 0;
  int cnt = 0;
  rep(i, N-1){
    ll a = 0;
    if (flag){
      a = desc_que2.top();
      desc_que2.pop();
    }else{
      a = asc_que2.top();
      asc_que2.pop();
    }
    if (cnt==0){
      ans += abs(a-left);
      left = a;
    }
    if (cnt==1){
      ans += abs(a-right);
      right = a;
    }
    cnt++;
    if (cnt==2){
      flag = !flag;
      cnt = 0;
    }
  }
  return ans;
}

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

  cin >> N;
  ll a;
  rep(i, N){
    cin >> a;
    asc_que.push(a);
    desc_que.push(a);
    asc_que2.push(a);
    desc_que2.push(a);
  }
  ll ans1 = calc();
  ll ans2 = calc2();


  cout << max(ans1, ans2) << "\n";
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S == "SUN"){
        cout << 7;
    }
    else if (S == "MON"){
        cout << 6;
    }
    else if (S == "TUE"){
        cout << 5;
    }
    else if (S == "WED"){
        cout << 4;
    }
    else if (S == "THU"){
        cout << 3;
    }
    else if (S == "FRI"){
        cout << 2;
    }
    else if (S == "SAT"){
        cout << 1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, T, count = 0;
	cin >> A >> B >> T;
	for (int i = 1; i <= T; i++) {
		if (i % A == 0) {
			count = count + B;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mod (long)(1e9+7)
signed main()
{
    int n,m;
    cin>>n>>m;
    string str[n];
    for(int i=0;i<n;++i)
    cin>>str[i];
    
    int dp[n][m];
    memset(dp,0,sizeof dp);
    for(int i=0;i<m;++i)
    if(str[0][i]=='.')
    dp[0][i]=1;
    else
    break;
    
    for(int i=0;i<n;++i)
    if(str[i][0]=='.')
    dp[i][0]=1;
    else
    break;
    
    for(int i=1;i<n;++i)
    for(int j=1;j<m;++j)
    if(str[i][j]=='.')
    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    cout<<dp[n-1][m-1];
    
    
    
    
    
    
    
}

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

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

int main() {
  int n;
  cin >> n;
  int ans;
  if (n % 2 == 0) {
    ans = n / 2;
  } else {
    ans = n/ 2 + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=0
pre=[]
m=10**9+7
for i in range(n+1):
    s+=i
    pre.append(s)
ans=0

for i in range(k,n+1):
    mn=pre[i-1]
    mx=(pre[n]-pre[n-i])
    ans+=(mx-mn+1)
print((ans+1)%m)
    
    

Measured memory_bytes: 19432