akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

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

int main() {

    int T;
    cin >> T;
    rep(i, T) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;

        bool flag = true;
        if (B > A)flag = false;//初日でNG

        if (B > C) {
            if (B == D) {
                //一回でもC以内であればよい
                if (A%B > C)flag = false;
            }
            else if (B > D) {
                //NG
                flag = false;
            }
            else if (B < D) {
                //最大公約数が絡む
                if (B - gcd(B, D) + (A%gcd(B, D)) > C) {
                    flag = false;
                }
            }
        }


        else if (B == C) {
            if (B == D) {
                //OK
            }
            else if (B > D) {
                //NG
                flag = false;
            }
            else if (B < D) {
                //OK
            }
        }


        else if (B < C) {
            if (B == D) {
                //OK
            }
            else if (B > D) {
                //NG
                flag = false;
            }
            else if (B < D) {
                //OK
            }

        }
        if (flag)cout << "Yes" << endl;
        else cout << "No" << endl;
    }//1ループ
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define inf 1000000000000000001;
#define mem(a,val) memset(a,val,sizeof(a))
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define sep(i,a,b)    for(ll int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
    string s,p;
    cin>>s>>p;
    std::vector<int> pos[26];
    rep(i,0,sz(s)){
    pos[s[i]-'a'].pb(i);    
    }
    ll ans=0,n=sz(s),cur=-1;
    ll fl=0;
    rep(i,0,sz(p)){
    ll ch=p[i]-'a';
    if(sz(pos[ch])==0){
    fl=1;
    break;    
    
    }
    ll up=ubnd(all(pos[ch]),cur)-pos[ch].begin();
   // cout<<up<<" \n";
    if(up==pos[ch].size()){
     ans+=n;
    cur=-1;
    i--;      
    }
    
    else
    {
    cur=pos[ch][up];    
    }
    // else
    // {
   
    // ans+=n;
    // cur=-1;
    // i--;    
    // }

    }
    if(fl)cout<<"-1\n";
    else
    cout<<ans+cur+1<<"\n";
    }
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 25;
bool flag;

int main(){
    CIN(x,y,a,b,c);
    priority_queue<int> p;
    priority_queue<int> q;
    priority_queue<int> r;
    int z;
    rep(i,a){cin>>z;p.push(z);}
    rep(i,b){cin>>z;q.push(z);}
    rep(i,c){cin>>z;r.push(z);}
    ll ans=0;
    
    rep(i,x){
        r.push(p.top());
        p.pop();
    }
    rep(i,y){
        r.push(q.top());
        q.pop();
    }
    rep(i,x+y){
        ans+=r.top();
        r.pop();
    }
    
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
n = int(input())
likes = list(enumerate(input().split(' '), start=1))
rev = list(likes)
rev.reverse()
pairs = 0
for n, like in rev:
	if int(like) < n and likes[int(like) - 1][1] == str(n):
			pairs += 1
print(str(pairs))

Measured memory_bytes: 20404
#include<stdio.h>
#include<stdlib.h>
typedef long long int lli;
typedef unsigned long long int llu;
int lli_compare(const void*a,const void*b){return *(lli*)a-*(lli*)b;}
int main(void)
{
    lli n;
    lli x[200000];
    lli a[200000];
    lli cen1,cen2;

    scanf("%lld",&n);
    for(lli i=0;i<n;i++){
        scanf("%lld",&x[i]);
        a[i]=x[i];
    }
    qsort(x,n,sizeof(lli),lli_compare);
    cen1=x[n/2];
    cen2=x[n/2-1];
    for(lli i=0;i<n;i++){
        if(a[i]<cen1){
            printf("%lld\n",cen1);
        }
        else {
            printf("%lld\n",cen2);
        }
    }
    return 0;
}

Measured memory_bytes: 5240
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d %d\n%d %d %d %d\n" @@ fun h w k x1 y1 x2 y2 ->
  let css = Array.init h @@ fun _ -> Scanf.scanf "%s\n" Fun.id in
  let d =
    Array.init h @@ fun _ ->
      Array.init w @@ fun _ ->
        Array.init 4 @@ fun _ -> max_int in
  let dx = [| 1; 0; -1; 0 |] in
  let dy = [| 0; 1; 0; -1 |] in
  d.(x1 - 1).(y1 - 1).(0) <- 0;
  let rec dijkstra q =
    match IntMap.min_binding_opt q with
    | None -> ()
    | Some (c, us) ->
        dijkstra @@
        List.fold_left (fun q (i, j, dir) ->
          if d.(i).(j).(dir) < c
          then q
          else
            List.fold_left (fun q (i, j, dir', d') ->
              if i < 0 || h <= i || j < 0 || w <= j || css.(i).[j] = '@' || d.(i).(j).(dir') <= d'
              then q
              else begin
                d.(i).(j).(dir') <- min d' d.(i).(j).(dir');
                IntMap.update d' (fun vs -> Some ((i, j, dir') :: Option.value ~default:[] vs)) q 
              end) q
            [(i + dx.(dir), j + dy.(dir), dir, c + 1); (i, j, (dir + 1) mod 4, c + k - 1 - (c + k - 1) mod k)]) (IntMap.remove c q) us in
  dijkstra (IntMap.singleton 0 [(x1 - 1, y1 - 1, 0)]);
  Printf.printf "%d\n" @@
  (fun x -> if max_int <= x then -1 else (x + k - 1) / k) @@
  Array.fold_left min max_int d.(x2 - 1).(y2 - 1)


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

using namespace std;

typedef long long ll;
const int nax = 1e9+7;


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(),s.end());
    for(string x : s) cout << x;
    cout << "\n";

	return 0;
}


Measured memory_bytes: 3668
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        String B = sc.next();

        StringBuilder builder = new StringBuilder();
        int pos = B.length()-1;
        for (int i = 0; i < B.length(); i++) {
            if (B.charAt(i) == '.') {
                pos = i;
            } else {
                builder.append(B.charAt(i));
            }
        }
        int BB = Integer.parseInt(builder.toString());
        int d = B.length()-1-pos;

        int dd = 1;
        for (int i = 0; i < d; i++) {
            dd *= 10;
        } 

        System.out.println(A*BB/dd);
    }
}


Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
	int n,mn=1005;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
	{
		int s1=0,s2=0;
		for(int j=0;j<i;j++)
			s1+=a[j];
		for(int k=i;k<n;k++)
			s2+=a[k];
		mn=min(mn,abs(s1-s2));
	}
	cout<<mn;

	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	a := readInt64()
	b := readFloat64()

	//e.g.
	// fmt.Println(float64(2.51) * 100) 250.99999999999997
	//fmt.Println(2.51 * 100) 251
	bTimes100 := int64(math.Round(b * 100))
	fmt.Println(a * bTimes100 / 100)
}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt64() int64 {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.ParseInt(t, 10, 64)
	if err != nil {
		log.Fatal(err)
	}

	return n

}

func readFloat64() float64 {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.ParseFloat(t, 64)
	if err != nil {
		log.Fatal(err)
	}

	return n
}

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

int n, a, b;
vector <int> l, r;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        l.push_back(a);
        r.push_back(b);
    }
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());
    if (n % 2 == 1){
        cout << r[n/2]-l[n/2]+1 << "\n";
    }
    else{
        cout << (r[n/2]+r[n/2-1])-(l[n/2]+l[n/2-1])+1 << "\n";
    }
}


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

int		output(int *num, int *op){
	if (num[0] + op[0] * num[1] + op[1] * num[2] + op[2] * num[3] == 7){
		int		i = 0;
		while (i < 3){
			cout << num[i];
			if (op[i] > 0)
				cout << '+';
			else
				cout << '-';
			i++;
		}
		cout << num[3] << "=7";
		return (1);
	}
	return (0);
}

int		rec(int *num, int *op, int	i){
	if (i == 2)
	{
		op[2] = 1;
		if (output(num, op))
			return (1);
		op[2] = -1;
		if (output(num, op))
			return (1);
	} else {
		op[i] = 1;
		if (rec(num, op, i + 1))
			return (1);
		op[i] = -1;
		if (rec(num, op, i + 1))
			return (1);
	}
	return (0);
}


int		main(void)
{
	string	s;
	cin >> s;
	int		num[4];
	int		op[3];
	int		i = 0;
	while (i < 4){
		num[i] = s[i] - '0';
		i++;
	}
	rec(num, op, 0);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long
class Triplet{
  public:
  int R;
  int B;
  int G;
};
int32_t main(){
 
  	int n;cin>>n;
  	char a[n+1];
  	for(int i=0;i<n;i++){
    	cin>>a[i];
  	}
	Triplet T[n+2];
  	if(a[0] == 'R'){ T[0].R = 1; T[0].B = 0;T[0].G = 0;}
  	else if(a[0] == 'B'){ T[0].R = 0; T[0].B = 1;T[0].G =0;}
  	else { T[0].R = 0; T[0].B = 0;T[0].G = 1;}
  	for(int i=1;i<n;i++){
    	if(a[i] == 'R'){ T[i].R =T[i-1].R+ 1; T[i].B = T[i-1].B;T[i].G = T[i-1].G;}
      	else if(a[i] == 'B'){ T[i].R =T[i-1].R; T[i].B = T[i-1].B +1;T[i].G = T[i-1].G;}
        else{ T[i].R =T[i-1].R; T[i].B = T[i-1].B;T[i].G = T[i-1].G+1;}
    }
   
  	int ans = 0;
  	for(int i=0;i<n-2;i++){
    	for(int k=i+3;k<n;k++){
        	if(a[i] != a[k]){
          	if((k+i)%2 == 0){
              	int j=(k+i)/2;
              	if(a[i] == 'R' && a[k] == 'G'){
                	ans = ans + T[k].B-T[i].B;
                	
                  if(a[j] == 'B') ans--;
                 }
              	else if(a[i] == 'G' && a[k] == 'R'){
                	ans = ans + T[k].B-T[i].B;
                  if(a[j] == 'B') ans--;
                 }
              else if(a[i] == 'R' && a[k] == 'B'){
                	ans = ans + T[k].G-T[i].G;
                  if(a[j] == 'G') ans--;
                 }
              else if(a[i] == 'B' && a[k] == 'R'){
                	ans = ans + T[k].G-T[i].G;
                  if(a[j] == 'G') ans--;
                 }
              else if(a[i] == 'G' && a[k] == 'B'){
                	ans = ans + T[k].R-T[i].R;
                  if(a[j] == 'R') ans--;
                 }
              else {
                	ans = ans + T[k].R-T[i].R;
                  if(a[j] == 'R') ans--;
                 }
            }
          else {
          		if(a[i] == 'R' && a[k] == 'G'){
                	ans = ans + T[k].B-T[i].B;
                	
                 }
              	else if(a[i] == 'G' && a[k] == 'R'){
                	ans = ans + T[k].B-T[i].B;
                  
                 }
              else if(a[i] == 'R' && a[k] == 'B'){
                	ans = ans + T[k].G-T[i].G;
                 
                 }
              else if(a[i] == 'B' && a[k] == 'R'){
                	ans = ans + T[k].G-T[i].G;
                  
                 }
              else if(a[i] == 'G' && a[k] == 'B'){
                	ans = ans + T[k].R-T[i].R;
                 
                 }
              else {
                	ans = ans + T[k].R-T[i].R;
                  
                 }
          }}
        }
    }
    cout<<ans;
  
	return 0;
}

Measured memory_bytes: 3668
M, K = gets.split.map(&:to_i)
N = (1<<M)-1

if M==1 then
  puts (if K==0 then puts '0 0 1 1' else -1 end)
  exit
end

if K>N then
  puts -1
  exit
end

L = (0..N).filter{|a| a!=K}.to_a
ans = [K] + L + [K] + L.reverse
puts ans.join(' ')


Measured memory_bytes: 20636
#include <iostream>
#include <climits>

int min(int x, int y)
{
	return x>y ? y : x;
}

int main()
{
	int n; std::cin >> n;
	
	int* r = new int[n];
	int* c = new int[n];
	for (int i=0; i<n; i++) std::cin >> r[i] >> c[i];
	
	long long int** DP = new long long int*[n];
	for (int i=0; i<n; i++) DP[i] = new long long int[n];
	
	for (int d=0; d<n; d++) {
		for (int i=0; i<n-d; i++) {
			if (d==0) DP[i][i] = 0;
			else {
				long long int opt = LLONG_MAX;
				for (int j=0; j<d; j++) {
					long long int tmp = r[i] * c[i+j] * c[i+d] + DP[i][i+j] + DP[i+j+1][i+d];
					if (opt > tmp) opt = tmp;
				}
				DP[i][i+d] = opt;
			}
		}
	}
	
	std::cout << DP[0][n-1] << std::endl;
	
	for (int i=0; i<n; i++) delete[] DP[i];
	delete[] DP;
	
	return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int X;
    cin >> X;
    int count = X / 100;
    int mo = X % 100;
    int res = ceil(mo / 5.0) ;

    //cout << count << " " << mo << " " << res << endl;
    if(count >= res){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define el cout << endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    string str;
    cin >> n >> str;
    stack<char> s;
    
    repeat(i, n) {
        char c = str[i];
        if (s.empty()) {
            s.push(c);
        }
        else {
            char b = s.top();
            if (b == '(' && c == ')') {
                s.pop();
            }
            else {
                s.push(c);
            }
        }
    }
    
    string t;
    while (!s.empty()) {
        t += s.top();
        s.pop();
    }
    
    int cnt1 = count(t.begin(), t.end(), ')');
    int cnt2 = count(t.begin(), t.end(), '(');
    
    string s1(cnt1, '(');
    string s2(cnt2, ')');
    cout << s1 << str << s2 << endl;
    return 0;
}   

Measured memory_bytes: 256
import java.util.*;
 
class process {
 
    private String name;
    private int time;
     
    public process(String name,int time){
        this.name = name;
        this.time = time;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getName() {
        return name;
    }
 
    public void setTime(int time) {
        this.time = time;
    }
 
    public int getTime() {
        return time;
    }
}
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int q = sc.nextInt();
 
        ArrayList<process> ar = new ArrayList<process>();
        ArrayList<process> result = new ArrayList<process>();
         
        for (int i = 0; i < n; i++){
            ar.add(new process(sc.next(),Integer.parseInt(sc.next())));
        }
         
        int LapsedTime = 0,i = 0;
        process p;
         
        while(true){
            if(i < n){
                if((p = ar.get(i)).getTime() - q <= 0){
                    LapsedTime += p.getTime();
                    result.add(new process(p.getName(),LapsedTime));
                    ar.remove(i);
                    n--;
                } else {
                    LapsedTime += q;
                    p.setTime(p.getTime() - q);
                    i++;
                }
            } else {
                i = 0;
            }
            if (n == 0){
                break;
            }
        }
        for(process r:result) {
            System.out.println(r.getName() + " " + String.valueOf(r.getTime()));
        }
    }
}

Measured memory_bytes: 72876
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    string s;
    cin >> s;
    char bef = '0';
    long c1 = 0;
    for(auto c: s){
        if(c == bef){
            c1++;
            bef = (c == '0')?'1':'0';
        }else{
            bef = c;
        }
    }
    bef = '1';
    long c2 = 0;
    for(auto c: s){
        if(c == bef){
            c2++;
            bef = (c == '0')?'1':'0';
        }else{
            bef = c;
        }
    }
    cout << min(c1, c2) << endl;
    return 0;
}


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

using namespace std;

const int Mod = 1e9 + 7;
const int N = 3e5 + 10;

int n;

int main() {
  scanf("%d", &n);
  if (n & 1) {
    printf("%d\n", n * (n + 1) / 2 - (n + 1) / 2 - n + 1);
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (i + j != n) {
          printf("%d %d\n", i, j);
        }
      }
    }
  } else {
    printf("%d\n", n * (n - 1) / 2 - n / 2);
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (i + j != n + 1) {
          printf("%d %d\n", i, j);
        }
      }
    }
  }
  return 0;
}

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

int main(){
 int n;cin>>n;
 int a[n],b[n];
 REP(i,n){
   cin>>a[i];
   b[i]=a[i];
 }
 int max1=0,max2=0;
 sort(b,b+n);
 REP(i,n)
 {
   if (a[i]==b[n-1])
   {
     /* code */
     cout<<b[n-2]<<endl;
   }
   else
   {
     cout<<b[n-1]<<endl;
   }
   
   
 }
}

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

int main()
{
	while (true) {
		int n, p;

		cin >> n >> p;

		if (n == 0 && p == 0) {
			break;
		}

		int ans;
		int cup = p;
		vector<int> person(n, 0);
		int count = 0;

		while (true) {
			if (cup != 0) {
				person[count]++;
				cup--;

				if (cup == 0) {
					bool flag = true;
					for (int i = 0; i < n; i++) {
						if (i == count) {
							continue;
						}

						if (person[i] != 0) {
							flag = false;
							break;
						}
					}
					if (flag == true) {
						ans = count;
						break;
					}
				}
			}
			else {
				cup += person[count];
				person[count] = 0;
			}
			count = (count + 1) % n;
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    for (int i = 0; i < N - 2; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            ans++;
            i += 2;
        }
        
    }
    cout << ans << endl;
  return 0;
}


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

int main()
{
    int n, t;
    cin >> n >> t;
    int result = 2e9;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (b <= t) {result = min(result, a);}
    }
    if (result == 2e9) {cout << "TLE" << endl;}
    else {cout << result << endl;}
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = in.nextInt();		// テストケースの個数
    String S[] = new String[N];	// ジャッジ結果を表す文字列	( AC, WA, TLE, RE )
    for(int i=0; i<N; i++)
		S[i] = in.next();
    int C[] = new int[4];			// それぞれのテストケースの個数
    for(int i=0; i<4; i++)
    	C[i] = 0;
    
    for(int i=0; i<N; i++){
		switch (S[i]){
			case "AC":
				C[0]++;
				break;
			case "WA":
				C[1]++;
				break;
			case "TLE":
				C[2]++;
				break;
			case "RE":
				C[3]++;
				break;
		}
    }
    
    System.out.println("AC x " + C[0]);
    System.out.println("WA x " + C[1]);
    System.out.println("TLE x " + C[2]);
    System.out.println("RE x " + C[3]);
  }
}

Measured memory_bytes: 64676
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    ll x, a, b;
    cin >> x >> a >> b;
    if (abs(a - x) < abs(b - x)) {
        cout << "A";
    } else {
        cout << "B";
    }
    return 0;
}

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

int main() {
   long long int h,n,sum=0,i,x;
   cin>>h>>n;
   for(i=0;i<n;i++)
   {
       cin>>x;
       sum+=x;
   }
   if(sum>=h)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
}

Measured memory_bytes: 256
lim = 10**9+7
n=int(input())
A=[int(i) for i in input().split()]
binary = [bin(i)[2:].zfill(60)[::-1] for i in A]

ans=0
for i in range(60):
    l = [s[i] for s in binary]
    #print(i,l.count("0") * l.count("1"))
    ans = (ans+ ((l.count("0") * l.count("1"))% lim * 2**i )% lim)% lim
print(ans % lim)

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

int main() {
	map<string,int> mp;
	string s;
	int i,n;
	cin>>n;
	for(i = 0;i < n;i++)
	{
	    cin>>s;
	    mp[s]++;
	}
	cout<<mp.size();
	return 0;
}

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

using namespace std;

int nextInt() {
	int r;
	scanf("%d", &r);
	return r;
}

#define N 4000000

bitset<N> a;
int shift = (N / 2);

int main() {
	int n= nextInt();
	a.set(shift);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x = nextInt();
		a = (a >> x) | (a << x);
		sum += x;
	}
	for (int z = 0; ;z++) {
		if (a[shift + z] || a[shift - z]) {
			printf("%d\n", (sum + z) / 2);
			return 0;
		}
	}
}

Measured memory_bytes: 2688
P=[]
C=[]
point=1001    #全問題数
 
D,G=map(int,input().split())
for i in range(D):
    p,c= map(int,input().split())
    P.append(p)
    C.append(c)
 
#とりあえず全部解くor解かないで目標スコアを超えるか超えないかを考える
 
 
for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  #全正解した大問をスコアに変換
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
    if score>=G :
        point=min(point,solve)
 
#ぎりぎりスコアが届いていない場合、1問も解かなかった問題の中で最も一題あたりの点が高い問題だけ解いてみる
#中途半端に大問を解ききるのが１種類以下でも目標に届く場合もあるという予想
    elif score<G :
        rest=G-score
        for j in range(D) :
            if (~i>>D-j-1) & 1 :
                needproblem=D-j
                sum=needproblem*100*(P[needproblem-1]-1)
                if rest>sum :            #1問も解かなかった問題の中で最も一題あたりの点が高い問題を解いても届かないのでやり直し
                    rest-=sum
                    solve+=P[needproblem-1]-1
                elif rest<=sum :
                    solve+=(rest//(needproblem*100)+(rest%(needproblem*100)>0))
                    rest=0
            if rest<=0 and D*100>solve :
                point=min(point,solve)               
 
print(point)

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

int main(void) {
	int N, K;
	scanf("%d%d", &N, &K);
	int H[200010];
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	sort(H, H + N, greater<int>());
	long long ans = 0;
	for (int i = K; i < N; i++) {
		ans += H[i];
	}
	printf("%lld", ans);

	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

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

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll a, b, t;
  cin >> a >> b >> t;

  cout << (b * (t / a)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  char diff = 'A' - 'a';
  cout << char(s1[0] + diff) << char(s2[0] + diff) << char(s3[0] + diff) << endl;

  return 0;
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);

		if(a>8 || b>8)System.out.println(":(");
		else System.out.println("Yay!");


	}
}

Measured memory_bytes: 24660
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
int dp[N];
int h[N];
int main()
{
    int n;
    cin>>n;

    for (int i=1; i<=n; i++)
        cin>>h[i];

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i=3; i<=n; i++)
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]) );
    cout<<dp[n]<<endl;
}


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

using namespace std;
#define ll long long
#define pb push_back

int main()
{	
	int n;
	cin >> n;
	int arr[n];
	int m = INT_MAX;
	int cnt=0;
	for(int i=0; i<n; i++) {
		cnt = 0;
		cin >> arr[i];
		if(arr[i]%2) {
			cout << 0 << endl;
			return 0;
		}
		else {
			while(arr[i]%2==0) {
				arr[i]/=2;
				cnt++;
			}
			m = min(m, cnt);
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 3556
import java.util.*;

// CODEFES_B 2017-C
// http://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c	

public class Main {
	
	static int N;

	static boolean isBipartite = true;
	static int[] color;
	static ArrayList<ArrayList<Integer>> map;

	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		N = in.nextInt();
		int M = in.nextInt();
		
		map = new ArrayList<ArrayList<Integer>>();
		color = new int[N];
		
		for (int i = 0; i < N; i++) {
			map.add(new ArrayList<Integer>());
		}
		
		for (int i = 0; i < M; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			map.get(a).add(b);
			map.get(b).add(a);
		}
		
		isBipartite(0, 1);
		if (isBipartite) {
			long numBlack = 0;
			long numWhite = 0;
			for (int i = 0; i < N; i++) {
				if (color[i] == 1) {
					numBlack++;
				} else if (color[i] == 2){
					numWhite++;
				}
			}
			System.out.println(numBlack * numWhite - M);
		} else {
			System.out.println(((long) N) * ((long) (N - 1)) / 2 - M);
		}
	}
	
	public static void isBipartite(int index, int fillColor) {
		if (!isBipartite) {
			return;
		}
		if (color[index] == 0) {
			color[index] = fillColor;
		}
		
		ArrayList<Integer> queue = new ArrayList<Integer>();
		
		for (int i = 0; i < map.get(index).size(); i++) {
			int newIndex = map.get(index).get(i);
			if (color[index] == color[newIndex]) {
				isBipartite = false;
			} else if (color[newIndex] == 0) {
				queue.add(newIndex);
			}
		}
		
		while (queue.size() > 0) {
			int newIndex = queue.remove(0);
			isBipartite(newIndex, fillColor % 2 + 1);
		}
	}
}


Measured memory_bytes: 103244
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

typedef long long ll;

const int nlimit = 1e5+1;
int n; //頂点数

class edge{
public:
  int to;
  ll weight;
  edge(int to=0, ll weight=0){
    this->to = to;
    this->weight = weight;
  }
};

void bfs(vector<edge>*, ll*, int);
ll solve(ll*, int, int);

int main(){
  cin >> n;

  vector<edge> graph[nlimit];

  //グラフ生成
  int num, to;
  ll weight;
  for(int i=0; i<n-1; i++){
    cin >> num >> to >> weight;
    graph[num].push_back(edge(to, weight));
    graph[to].push_back(edge(num, weight));
  }

  //先にBFSでKからの距離を事前算出しておく
  ll dist[nlimit];
  for(int i=1; i<=n; i++) {
    dist[i] = -1;
  }

  int q, k; cin >> q >> k;
  bfs(graph, dist, k);

  //クエリ処理
  int x, y;
  for(int i=0; i<q; i++){
    cin >> x >> y;
    ll ans = solve(dist, x, y);
    cout << ans << endl;
  }

  return 0;
}

void bfs(vector<edge>* graph, ll* dist, int k){
  queue<int> q; q.push(k);
  dist[k] = 0;

  while(!q.empty()){
    int now = q.front();
    q.pop();

    for(int i=0; i<graph[now].size(); i++){
      //まだ未探索ならば
      int next = graph[now][i].to;
      if(dist[next] == -1){
        dist[next] = dist[now]+graph[now][i].weight;
        q.push(next);
      }
    }

  }

}

ll solve(ll* dist, int start, int end){
  return dist[start]+dist[end];
}


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

N = int(input().rstrip())
a = list(map(int, input().rstrip().split()))
# print(a)

if not 1 in a:
  print(-1)
  exit()

def check(n):
  for i in range(N):
    if a[-1-i] == n:
      n -= 1
  return n == 0

r = N
left = 1
right = N
for _ in range(N):
  if (right - left) <= 2:
    if check(right):
      r = right
      break
    elif check(right-1):
      r = right - 1
      break
    else:
      r = right - 2
      break
  t = (left + right) // 2
  if check(t):
    left = t
  else:
    right = t

print(N-r)

Measured memory_bytes: 26140
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, q = map(int, input().split())
pairs = [0] * q
for i in range(q):
    pairs[i] = list(map(int, input().split()))

from collections import deque

def dfs(min_val, length):
    if length == 0:
        return list([deque()])
    if min_val == m:
        return list([deque([m]) * length])
    ans = list()
    for i in range(min_val, m+1):
        remain = dfs(i, length-1)
        for j in remain:
            j.appendleft(i)
        ans.extend(remain)
    return ans

ans = 0
for i in dfs(1, n):
    tmp = 0
    for a, b, c, d in pairs:
        if (i[b-1] - i[a-1]) == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 142888
#include <iostream>
#include <limits>

using namespace std;

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

const long long INF = numeric_limits<long long>::max();

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

    int N;
    cin >> N;

    long long dp[N + 1];
    for (int i = 0; i < N + 1; i++) {
        dp[i] = INF;
    }

    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        change_min(dp[i + 1], dp[i] + 1);
        for (int j = 6; i + j <= N; j *= 6) {
            change_min(dp[i + j], dp[i] + 1);
        }
        for (int j = 9; i + j <= N; j *= 9) {
            change_min(dp[i + j], dp[i] + 1);
        }
    }

    cout << dp[N] << '\n';
    return 0;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++) 
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout) 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

ll g[3001][3001];
ll dp[3001][3001][4];
int n,m,k;
bool chk(int x, int y){
	if(x>=0 && x<n && y>=0 && y<m)
		return true;
	return false;
}

ll fun( int x, int y,int cnt){
	if(x==n-1 && y==m-1){
		if(g[x][y]==0 || cnt==3)
			return 0;
		return g[x][y];
	}
	if(dp[x][y][cnt]!=-1)
		return dp[x][y][cnt];
	ll ans=0;
	int x1,y1,x2,y2;
	x1=x+1; y1=y;
	if(chk(x1,y1)){
		if(cnt<3)
			ans=max(ans,g[x][y]+fun(x1,y1,0));
		ans=max(ans,fun(x1,y1,0));
	}
	x2=x;y2=y+1;
	if(chk(x2,y2)){
		ans=max(ans,fun(x2,y2,cnt));
		if(cnt<3 && g[x][y]!=0){
			ans=max(ans,g[x][y]+fun(x2,y2,cnt+1));
		}
	}
	return dp[x][y][cnt]=ans;
}

int main()
{
	boost;
	cin>>n>>m>>k;
	for1(0,k,1){
		int x,y; ll val;
		cin>>x>>y>>val;
		x--, y--;
		g[x][y]=val;
	}
	fil(dp,-1);
	ll ans=fun(0,0,0);
	cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 355940
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i, a, b) for(long i = (a); i < (b); i++)
#define MAX 201000
#define NIL 'A'

int main() {
	char S[MAX], T[MAX]; scanf("%s%s", &S, &T);
	char C[26]; // memorize alphabet
	FOR(i, 0, 26) C[i] = NIL; // init

	int len = strlen(S);
	FOR(i, 0, len) {
		int j = S[i] - 'a';
		if (C[j] == NIL) {
			FOR(t, 0, 26) {
				if (C[t] == T[i]) { // 変換は全単射である必要
					printf("No\n"); return 0; 
				}
			}
			C[j] = T[i];
		}
		else {
			if (C[j] == T[i]) { ; }
			else { printf("No\n"); return 0; }
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	long double l;
	cin >> l;
	l /= 3;
	cout << fixed << setprecision(50) << (l*l*l) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 100010
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")

int a[range], per[range];
bool sort_by(int i, int j) {
	return a[i] < a[j]; 
}


int main(){
 
   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();


    int n; cin >> n;
    forn(i, n) cin >> a[i], per[i] = i;
    sort(per, per + n, sort_by);

    forn(i, n) cout << per[i] + 1 <<" ";
    

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int n, l;
  cin >> n >> l;
  string ans = "";
  vs s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i; j < n; j++) {
      if (s[i] > s[j]) {
        swap(s[i], s[j]);
      }
    }
  }

  rep(i, n) {
    ans += s[i];
  }

  D(ans);
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

typedef long long i64;
const int MAXN = 100000 + 5 ;
const i64 INF  = 1e9 * 1e5 * 10;

int N;
i64 A[MAXN], dp[MAXN][3];
char op[MAXN][3];

int main()
{
    cin >> N ;
    for(int i = 1; i < N; i++)
        cin >> A[i] >> op[i] ;
    cin >> A[N];

    dp[1][0] = A[1];
    dp[1][1] = dp[1][2] = -INF;

    for(int i = 2; i <= N; i++)
        if(op[i - 1][0] == '-')
        {
            dp[i][0] = -INF;
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]) - A[i];
            dp[i][2] = max(dp[i-1][1], dp[i-1][2]) + A[i];
        }
        else if(op[i - 1][0] == '+')
        {
            dp[i][0] = max(dp[i-1][0], dp[i-1][1]) + A[i];
            dp[i][1] = max(dp[i-1][1], dp[i-1][2]) - A[i];
            dp[i][2] = dp[i-1][2] + A[i];
        }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl ;
    return 0;
}


Measured memory_bytes: 3712
import java.util.*;
public class Main {
	static char[] l = new char[] {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int c = stdIn.nextInt();
			int x = stdIn.nextInt();
			if(a == 0 && b == 0 && c == 0 && n == 0 && x == 0) break;
			int counter = 0;
			for(int i = 0; i < n; i++) {
				int y = stdIn.nextInt();
				if(y == x && i == 0) continue;
				while(counter <= 10000) {
					x = chek(a,b,c,x);
					counter++;
					if(y == x) {
						break;
					}

				}
			}
			System.out.println((counter > 10000)?"-1":counter);
			
			
		}
	}
	public static int chek(int a, int b, int c, int xd) {
		return (a * xd + b)%c;
	}
}

Measured memory_bytes: 30056
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, m, n, t, r, k, w, l, ans, i, j;
string S, T;
vl A, B;
void solve() {
    sort(all(A));
    sort(all(B));

    if(n % 2 == 1) {
        cout << B[n / 2] - A[n / 2] + 1 << endl;
    } else {
        cout << ((B[n / 2] + B[n / 2 - 1]) - (A[n / 2] + A[n / 2 - 1])) + 1 << endl;
    }
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a >> b;
        A.pb(a);
        B.pb(b);
    }
    solve();
}

Measured memory_bytes: 6692
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

int main(void) {
  int s,w;
  cin >> s >> w;
  if(w>=s){
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0); 
	char a[3];
	cin>>a;
	if(a[0]=='S'){
	if(a[1]=='A')cout<<"1"<<endl;
	if(a[1]=='U')cout<<"7"<<endl;
}
	else if(a[0]=='M')cout<<"6"<<endl;
	else if(a[0]=='T'){
		if(a[1]=='U')cout<<"5"<<endl;
		if(a[1]=='H')cout<<"3"<<endl;
	}
	else if(a[0]=='W')cout<<"4"<<endl;
	else cout<<"2"<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int n;
	cin >> n;

	int lol = 0;

	for(int i = 1; i <= n; ++i)
	{
		int x;
		cin >> x;
		if(i != x)
			++lol;
	}

	string ans = "NO";
	if(lol <= 2)
		ans = "YES";

	cout << ans;

	return 0;
}

Measured memory_bytes: 256