akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000000LL
#define GOLD 1.61803398874989484820458
const long long MAX_MOD = 1e6 + 3;
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long powering(long long now,long long now_go){
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
long long omote[(long long)1e7];
int main(){
#define int long long
	omote[0] = 1;
	for (long long i = 1; i < MAX_MOD; ++i) {
		omote[i] = i;
		omote[i] *= omote[i-1];
		omote[i] %= MAX_MOD;
	}
	long long query;
	cin >> query;
	REP(tea, query) {
		long long x, d, n;
		cin >> x >> d >> n;
		if (d == 0) {
			cout << powering(x, n) << endl;
			continue;
		}
		long long ans = 1;
		x *= inv(d);
		x %= MAX_MOD;
		if (x + (n - 1LL) >= MAX_MOD||x == 0) {
			ans = 0;
		}
		else {
			ans *= omote[x + (n - 1LL)] % MAX_MOD;
			ans *= inv(omote[x - 1]) % MAX_MOD;
			ans %= MAX_MOD;
			ans *= powering(d, n);
			ans %= MAX_MOD;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 9464
# multiple
line = input()
ln = 0
d = 1
counts=[0]*2019
for i in range(1,len(line) + 1):
    ti1 = (ln +(int(line[-1*i])*d))%2019
    counts[ti1] += 1
    ln = ti1
    d *= 10
    d %= 2019
total = 0
counts[0] +=1
for i in range(len(counts)):
    total += counts[i]*(counts[i] - 1)/2
print(int(total))

Measured memory_bytes: 9092
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int n, y;

int main(){
	while(cin >> n, n){
		cin >> y;
		double ans = -1;
		int ai = 0;
		
		rep(i, n){
			int b, r, t;
			cin >> b >> r >> t;
			double tmp;
			if(t == 1) tmp = 1 + 0.01 * r * y;
			else tmp = pow(1 + 0.01 * r, y);
			
			if(ans < tmp){
				ai = b;
				ans = tmp;
			}
		}
		cout << ai << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> dif;
	map<int, int> sum;
	forn(i, n) {
		cin >> a[i];
		if (sum.find(i + 1 + a[i]) == sum.end()) {
			sum[i + 1 + a[i]] = 0;
		}
		sum[i + 1 + a[i]]++;
		if (dif.find(i + 1 - a[i]) == dif.end()) {
			dif[i + 1 - a[i]] = 0;
		}
		dif[i + 1 - a[i]]++;
	}
	int ans = 0;
	for (auto [x, amount] : sum) {
		if (dif.find(x) != dif.end()) {
			ans += amount * dif[x];
		}
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 27972
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 600000;
vector < int > g[N];
int used[N], a[N], b[N], cnt1[N], cnt2[N];
map < int, int > m;
void dfs(int v){
    used[v] = 1;
    for (auto u: g[v]){
        if (!used[u]) dfs(u);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int x = 0;
    vector < int > v1, v2;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        v1.pb(a[i]);
        x ^= a[i];
    }
    v1.pb(x);
    a[n + 1] = x;
    x = 0;
    for (int i = 1; i <= n; i++){
        cin >> b[i];
        v2.pb(b[i]);
        x ^= b[i];
    }
    b[n + 1] = x;
    int ok = 1;
    for (int i = 1; i <= n; i++){
        if (a[i] != b[i]) ok = 0;
    }
    if (ok){
        cout << 0;
        return 0;
    }
    v2.pb(x);
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    if (v1 != v2){
        cout << -1;
        return 0;
    }
    set < int > s;
    for (auto i: v1) s.insert(i);
    for (auto i: v2) s.insert(i);
    int cnt = 0;
    for (auto i: s){
        cnt++;
        m[i] = cnt;
    }
    for (int i = 1; i <= n + 1; i++){
        a[i] = m[a[i]];
        b[i] = m[b[i]];
        cnt1[a[i]]++;
        cnt2[b[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (a[i] != b[i]){
            g[a[i]].pb(a[i] + n + 1);
            g[b[i] + n + 1].pb(a[i]);
            g[a[i]].pb(b[i] + n + 1);
            g[a[i] + n + 1].pb(a[i]);
            ans++;
        }
    }
    for (int i = n; i >= 1; i--){
        if (!used[a[i] + n + 1] && a[i] != b[i]){
            dfs(a[i] + n + 1);
            ans++;
        }
    }
    cout << ans - (g[a[n + 1] + n + 1].size() != 0);
}


Measured memory_bytes: 48500
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use rand::Rng;


fn main() {
    input! {
        D: usize,
        C: [i64; 26],
        S: [[i64; 26]; D],
    }

    let score = |sol: &Vec<i64>| -> i64 {
        let mut sat: i64 = 0;
        let mut last = vec![0; 26];
        for (d, v) in sol.iter().enumerate() {
            let j: usize = (v - 1) as usize;
            last[j] = d + 1;
            for i in 0..26 {
                sat -= (d + 1 - last[i]) as i64 * C[i];
            }
            sat += S[d][j];
        }

        return sat;
    };

    let mut ans:Vec<i64> = vec![1; D];
    // let mut last = vec![0; 26];
    // for d in 0..D {
    //     let mut ma = 0;
    //     let mut mai = 0;
    //     for j in 0..26 {
    //         let a = (d + 1 - last[j]) as i64 * C[j] + S[d][j];
    //         if a > ma {
    //             ma = a;
    //             mai = j;
    //         }
    //     }
    //     last[mai] = d + 1;
    //     ans.push((mai+1) as i64);
    // }

    let mut rng = rand::thread_rng();
    let mut s = score(&ans);
    for _ in 0..350000 {
        let c = rng.gen_range(1, 27);
        let d = rng.gen_range(0, D);
        let b = ans[d];
        ans[d] = c;
        let ss = score(&ans);
        if ss > s{
            s = ss;
        }else{
            ans[d] = b;
        }
    }

    for c in ans {
        println!("{}", c);
    }
}


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

int main(void){
    int n,p;
    cin >> n;
    vector< pair<int,int> > a(n);
    for(int i=1;i<=n;i++){
        cin >> p;
        a[i-1]=make_pair(p,i);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout << a[i].second << ' ';
    }
    return 0;
}

Measured memory_bytes: 1664
n = int(input())

board = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    board[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        print("", *board[i][j])
    if i < 3:
        print("#" * 20)



Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll H, N;
  cin >> H >> N;
  vll A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }

  vll dp(H + 1);
  rep(i, H + 1) {
    dp[i] = INF;
  }

  rep(i, H + 1) {
    if (i == 0) {
      dp[i] = 0;
      continue;
    }

    rep(j, N) {
      ll a = A[j];
      ll b = B[j];
      if (i - a < 0) {
        chmin(dp[i], b);
      } else {
        chmin(dp[i], dp[i - a] + b);
      }
    }
  }

  ll ans = dp[H];
  COUT(ans);

  return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    vector<int> deg(n, 0);
    for (int _ = 1; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
        deg[x]++;
        deg[y]++;
    }
    if (n <= 3) {
        for (int i = 1; i <= n; i++) {
            cout << i << ' '; return;
        }
    }
    vector<int> d(n);
    function<void(int,int)> dfs = [&](int u,int p){
        for (int v: g[u]){
            if (v == p) continue;
            d[v] = d[u] + 1;
            dfs(v,u);
        }
    };
    d[0]=1; dfs(0,-1);
    int root = max_element(d.begin(),d.end())-d.begin();
    vector<int> pa(n,-1);
    function<void(int,int)> find = [&](int u, int p){
        for (int v:g[u]){
            if (v==p) continue;
            d[v] = d[u]+1;
            pa[v] = u;
            find(v, u);
        }
    };
    d[root]=1; find(root, -1);
    int tail = max_element(d.begin(),d.end())-d.begin();
    vector<bool> is_body(n,false);
    vector<int> des;
    {
        int v = tail;
        while (v != -1) {
            des.emplace_back(deg[v]);
            is_body[v] = true;
            v = pa[v];
        }
    }
    for (int i = 0; i < n; i++) {
        if (!is_body[i] && deg[i] > 1) {
            cout << -1; return;
        }
    }
    {
        int m = des.size();
        for (int i = 1; i < m-1; i++) {
            des[i]--;
        }
        auto rdes = des;
        reverse(rdes.begin(), rdes.end());
        if (rdes < des) swap(rdes, des);
    }
    vector<int> res(n);
    int pos = 0, i = 1;
    for (int x: des) {
        for (int j = 1; j < x; j++) {
            res[pos++] = i+j;
        }
        res[pos++] = i;
        i = i+x;
    }
    for (int x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 16112
import bisect
n=int(input())
A=[int(i) for i in input().split()]
A.sort()
l=A[-1]
A=A[:-1]
n=bisect.bisect_left(A,l//2)
if n==len(A):
  s=A[-1]
else:
  s=A[n]
if n>1 and abs(A[n-1]-l/2)<abs(A[n]-l/2):
  s=A[n-1]
print(l,s)

Measured memory_bytes: 14052
import sys
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func()
    top_str = input_raw.strip().split()
    [N] = [int(top_str[0])]

    min_F = sys.maxint
    digit = int(math.log10(N) + 1)
    for i in range(10 ** int((digit)/2.0 + 0.5) , 0 , -1):
        if(N % i == 0):
            A = i
            B = N/i
            F = max(int(math.log10(A) + 1), int(math.log10(B) + 1))
            if F < min_F:
                min_F = F
            #break
    print min_F



if __name__ == '__main__':
    main()


Measured memory_bytes: 34436
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)


x = [0]*3
x[0], x[1], x[2] = map(int,input().split())
x.sort()
if x[0]==5 and x[1] == 5 and x[2] == 7:
    print("YES");
else:
    print("NO");


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main()
{
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
	}

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j < s[i].size(); ++j) {
			if (s[i][j - 1] == 'A' && s[i][j] == 'B')
				++cnt;
		}
	}
	
	int a = 0, b = 0, ba = 0;
	for (int i = 0; i < N; ++i) {
		if (s[i].front() == 'B' && s[i].back() == 'A')
			++ba;
		else if (s[i].front() == 'B')
			++b;
		else if (s[i].back() == 'A')
			++a;
	}
	if (ba == 0) {
		cnt += min(a, b);
	}
	else {
		if (a >= 1 && b >= 1) {
			cnt += ba + 1 + min(a - 1, b - 1);
		}
		else if (a == 0 && b == 0) {
			cnt += ba - 1;
		}
		else if (a == 0) {
			cnt += ba + min(a, b - 1);
		}
		else if (b == 0) {
			cnt += ba + min(a - 1, b);
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
    int num;
    cin >> num;
    vector<long long> ins;
    long long temp;
    long long ans =1;
    bool flag = false;
    for(auto i=0;i<num;i++) {
        cin >> temp;
        if(temp == 0){
            cout << 0 << endl;
            return 0;
        }
        ins.push_back(temp);
    }    
    for(auto i=0;i<num;i++) {
        if(ins.at(i) <= 1000000000000000000/ans)ans *= ins.at(i);
        else{
            cout << -1 << endl;
            return 0; 
        }
    }    
    cout << ans << endl;

}

Measured memory_bytes: 4244
#include<stdio.h>
int main()
{
	int i,j;
	while (scanf("%d%d",&i,&j)!=EOF)
	{
		getchar( );
		int a,b;
		char vx[100][100];
		for(a=0;a<i;a++)
		{
			for(b=0;b<j;b++)
			{
				scanf("%c",&vx[a][b]);
			}
			getchar( );
		}
		for(a=0;a<j+2;a++)
		{
			printf("#");
		}
		printf("\n");
		for(a=0;a<i;a++)
		{
			printf("#");
			for(b=0;b<j;b++)
			{
				printf("%c",vx[a][b]);
			}
			printf("#\n");
		}
		for(a=0;a<j+2;a++)
		{
			printf("#");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int digcount( int n )
{
    int c = 0;
    while( n > 0 )
    {
        c++;
        n /= 10;
    }

    return c;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    int c = 0;
    rep(i,1,n+1)
    {
        if ( digcount(i) % 2 != 0 )
        {
            c++;
        }
    }

    cout<<c<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int data[10][10];
  string in;

  while(cin >> in){

    for(int i = 0; i < 10; i++){
      data[0][i] = in[i] - 48;
    }
    for(int i = 1; i < 10; i++){
      for(int j = 0; j < 10-i; j++){
	data[i][j] = data[i-1][j] + data[i-1][j+1];
      }
    }
    cout << data[9][0] % 10<< endl;
  }
  return 0;
}

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

int main()
{
    int N, M, C;

    cin >> N >> M >> C;

    int B[M];
    for (int m = 0; m < M; m++)
    {
        cin >> B[m];
    }

    int A[N][M];

    for (int n = 0; n < N; n++)
    {
        for (int m = 0; m < M; m++)
        {
            cin >> A[n][m];
        }
    }

    int answer = 0;
    for (int n = 0; n < N; n++)
    {
        int tmp = 0;
        for (int m = 0; m < M; m++)
        {
            tmp += A[n][m] * B[m];
        }
        if (tmp + C > 0)
            ++answer;
    }

    cout << answer << endl;
}


Measured memory_bytes: 256
#include <stdio.h> 
int main(void) 
{ 
  int i, j, tmp; 
  int number[100]; 
  int total; 
  scanf("%d", &total); 
 for (i=0; i<total; ++i) 
    scanf("%d", &number[i]); 
  for (i=0; i<total; ++i) { 
    for (j=i+1; j<total; ++j) { 
        tmp =  number[i]; 
        number[i] = number[j]; 
        number[j] = tmp; 
      } 

  } 
  for (i=0; i<total; ++i){ 
      if(i==(total-1)){
          printf("%d\n",number[i]);
      }
      else{
    printf("%d ", number[i]); 
      }
    }
    return 0;
} 


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


int main()
{
	int n;
	int point[100];
	while (cin >> n)
	{
		if (n == 0)break;
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> point[i];
		}

		sort(point,point + n);

		for (int i = 1; i < n - 1; i++)
		{
			sum += point[i];
		}

		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

int main(){
  int n,m;
  int maps[21][21];
  int cnt;
  int x,y;
  char hou;
  int kyo;
  while(cin>>n,n){
    memset(maps,0,sizeof(maps));
    cnt=n;
    for(int i=0;i<n;i++){
    cin>>x>>y;
    maps[y][x]=1;
    }
    x=10;
    y=10;
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>hou>>kyo;
      if(hou=='N'){
	for(int i=0;i<kyo;i++){
	  y++;
	  if(maps[y][x]==1){
	    cnt--;
	    maps[y][x]=0;
	  }
	}
      }
      if(hou=='E'){
	for(int i=0;i<kyo;i++){
	  x++;
	  if(maps[y][x]==1){
	    cnt--;
	    maps[y][x]=0;
	  }
	}
      }
      if(hou=='S'){
	for(int i=0;i<kyo;i++){
	  y--;
	  if(maps[y][x]==1){
	    cnt--;
	    maps[y][x]=0;
	  }
	}
      }
      if(hou=='W'){
	for(int i=0;i<kyo;i++){
	  x--;
	  if(maps[y][x]==1){
	    cnt--;   
	    maps[y][x]=0;
	  }
	}
      }
    }
 
    if(cnt)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
}

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

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

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

char c[H_MAX][W_MAX];
char d[H_MAX][W_MAX];

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int bfs() {
  queue<pii> que;
  que.push(pii(0,0));
  rep(i,H){
    rep(j,W){
      d[i][j]=-1;
    }
  }
  d[0][0]=1;
  while(que.size()) {
    pii p=que.front();
    que.pop();
    if(p.first==H-1&&p.second==W-1)
      break;
    rep(i,4) {
      int ny=p.first+dy[i],nx=p.second+dx[i];
      if(ny >= 0 && ny < H && nx >= 0 && nx < W && c[ny][nx] == '.' && d[ny][nx] == -1) {
	que.push(pii(ny,nx));
	d[ny][nx] = d[p.first][p.second]+1;
      }
    }
  }
  return d[H-1][W-1];
}
      
int main() {

  cin >> H >> W;
  int count=0;
  rep(i,H){
    rep(j,W){
      cin >> c[i][j];
      if(c[i][j] == '.')
	count++;
    }
  }
  int turns = bfs();
  if(turns == -1) {
    cout << -1 << endl;
  }
  else {
    cout << count - turns << endl;
  }

  return 0;
}
 

Measured memory_bytes: 768
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  for(int i=1;i<10;i++){
    if(n%i==0){
      if(n/i<10){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef vector<vector<char>> Field;
typedef pair<int, int> Point;

Point operator+(const Point &lhs, const Point &rhs){
	Point p = { lhs.first + rhs.first, lhs.second + rhs.second };
	return p;
}

bool operator==(const Point &lhs, const Point &rhs){
	return (lhs.first == rhs.first) && (lhs.second == rhs.second);
}

bool IsInField(int Width, int Height, const Point &p){
	const int c = p.second;
	const int r = p.first;
	return (0 <= c && c < Width) && (0 <= r && r < Height);
}

int MyBreadthFirstSearch(int Width, int Height, Field &map, const Point &start, const Point &goal){
	
	int i;

	vector<vector<int>> memo;
	for (i = 0; i < Height; ++i){
		vector<int> v(Width, 0);
		memo.push_back(v);
	}

	const Point dir[] = {
		{ -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }
	};

	queue<Point> que;
	que.push(start);
	
	Point cur, next;
	char s;
	while (!que.empty()){

		cur = que.front();	que.pop();

		if (cur == goal)
			return memo[goal.first][goal.second];

		for (i = 0; i < 4; ++i){
			next = cur + dir[i];
			if (IsInField(Width, Height, next)){
				s = map[next.first][next.second];
				if (s == '1' || s == 'g'){
					if (memo[next.first][next.second] == 0){
						que.push(next);
						memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
					}
				}
			}
		}
	}

	return -1;

}

int main()
{
	int i, j, H, W, counter = 0;

	cin >> H >> W;

	string get_s;
	Field map;
	for (i = 0; i < H; ++i){
		vector<char> v;
		cin >> get_s;
		for (j = 0; j < W; ++j){
			if (get_s[j] == '.'){
				v.push_back('1');
				++counter;
			}
			else if (get_s[j] == '#')
				v.push_back('-');
		}		
		map.push_back(v);
	}

	--counter;	//スタート地点を除く
	Point s = make_pair(0, 0), g = make_pair(H - 1, W - 1);
	
	int d = MyBreadthFirstSearch(W, H, map, s, g);

	if (d == -1)
		cout << -1 << endl;
	else
		cout << (counter - d) << endl;
	
	return 0;

}


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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
ll gcd(ll x,ll y){ return y ? gcd(y,x%y) : x;}
int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	ll a,b;
		cin>>a>>b;

	ll g= gcd(a,b);

	ll ans=1;

	for(ll i=2;i*i<=g;i++)
	{
		if(g%i==0)
		{
			ans++;
			while(g%i==0)
			{
				g/=i;
			}
		}
		
	}

	if(g!=1)
		ans++;

	cout<<ans<<"\n";
	
	return 0;
}

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

const int mod = 1e9 + 7;


int f[10101][2];
int g[10101][2];
int dp[5050][2];

int _2[5050];

int main()
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	
	if(A > B)
		swap(A, B);
	
	_2[0] = 1;
	for(int i = 1; i <= 5000; i++)
		_2[i] = _2[i - 1] * 2 % mod;
	f[0][0] = 1;	
	for(int i = 1; i < A + B; i++)
	{
		for(int j = A; j <= ((i <= B) ? i : A); j++)
		{
			f[i][0] += f[i - j][1];
			if(f[i][0] >= mod)
				f[i][0] -= mod;
		}
		if(i <= B)
		{
			for(int j = 1; j <= B; j++)
			{
				f[i][1] += f[i-j][0];
				if(f[i][1] >= mod)
					f[i][1] -= mod;
			}
		}
	}
	g[0][1] = 1;	
	for(int i = 1; i < A + B; i++)
	{
		for(int j = A; j <= ((i <= B) ? i : A); j++)
		{
			g[i][0] += g[i - j][1];
			if(g[i][0] >= mod)
				g[i][0] -= mod;
		}
		if(i <= B)
		{
			for(int j = 1; j <= B; j++)
			{
				g[i][1] += g[i - j][0];
				if(g[i][1] >= mod)
					g[i][1] -= mod;
			}
		}
	}
	dp[0][0] = dp[0][1] = 1;
	for(int i = 1; i <= N; i++)
	{
		if(i < B)
		{
			dp[i][1] += g[i][1];
			if(dp[i][1] >= mod)
				dp[i][1] -= mod;
		}
		for(int j = 1; j < min(i + 1, B); j++)
		{
			dp[i][1] += 1ll * f[j][1] * dp[i - j][0] % mod;
			if(dp[i][1] >= mod)
				dp[i][1] -= mod;
		}
		for(int j = 1; j < min(i + 1, A); j++)
		{
			dp[i][0] += dp[i - j][1];
			if(dp[i][0] >= mod)
				dp[i][0] -= mod;
		}
	}
	int ans = 0;
	for(int i = 0; i <= N; i++)
	{
		if(i == 0)
		{
			for(int j = B; j < A + B; j++)
			if(i + j <= N)
			{
				ans += 1ll * dp[i][1] * (g[j][0] + g[j][1]) % mod * _2[N - i - j] % mod;
				if(ans >= mod)
					ans -= mod;
			}
		}
		for(int j = B; j < A + B; j++)
		if(i + j <= N)
		{
			ans += 1ll * dp[i][0] * (f[j][0] + f[j][1]) % mod * _2[N - i - j] % mod;
			if(ans >= mod)
				ans -= mod; 
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3920
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<cstdio>
#include<map>
#include<unordered_map>
#include<ios>
#include<iomanip>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int main() {
	int R;
	cin >> R;
	cout << 3 * R * R << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
    int n, i, ans[1000][1000],j,p,k;
    scanf("%d", &n);
    for (i = 2; i < 1000; i++) {
        if (n * 2 == i * (i - 1)) {
            p = 1;
            for (j = 0; j < i-1; j++) {
                for (k = j; k < i-1; k++)
                    ans[j][k] = p + k-j;
                for (k = j + 1; k < i; k++)
                    ans[k][j] = p + k - j - 1;
                p = p + k - j-1;
            }
            printf("Yes\n%d\n", i);
            for (j = 0; j < i; j++) {
                printf("%d", i - 1);
                for(k=0;k<i-1;k++)
                    printf(" %d", ans[j][k]);
                printf("\n");
            }
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 4224
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


template <class T>
T lcs(const T& a, const T& b)
{
	const int n = a.size(), m = b.size();
	vector<vector<int> > dp(n + 1, vector<int>(m + 1));
	vector<vector<int> > prev(n + 1, vector<int>(m + 1));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (a[i] == b[j])
			{
				dp[i + 1][j + 1] = dp[i][j] + 1;
				prev[i + 1][j + 1] = 0;
			}
			else if (dp[i][j + 1] > dp[i + 1][j])
			{
				dp[i + 1][j + 1] = dp[i][j + 1];
				prev[i + 1][j + 1] = 1;
			}
			else
			{
				dp[i + 1][j + 1] = dp[i + 1][j];
				prev[i + 1][j + 1] = 2;
			}
		}
	}
	T res;
	for (int i = n, j = m; i > 0 && j > 0; )
	{
		if (prev[i][j] == 0)
		{
			res.push_back(a[i - 1]);
			--i, --j;
		}
		else if (prev[i][j] == 1)
			--i;
		else
			--j;
	}
	reverse(res.begin(), res.end());
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	string s;
	while (cin >> s)
	{
		string t = s;
		reverse(all(t));
		cout << lcs(s, t) << endl;
	}
}

Measured memory_bytes: 31000
#include<iostream>
#include<algorithm>
using namespace std;
int N,M;
main()
{
	while(cin>>N>>M)
	{
		N=abs(N);
		M=abs(M);
		if(N==0&&M==0)
		{
			cout<<0<<endl;
		}
		else if(N<=1&&M<=1)
		{
			cout<<1<<endl;
		}
		else if(N==0||M==0)
		{
			cout<<(N?N+1:M+1)/2*2<<endl;
		}
		else if(N%2==1&&M%2==1)
		{
			cout<<N+M-1<<endl;
		}
		else
		{
			cout<<N+M<<endl;
		}
	}
}



Measured memory_bytes: 2988
#include <stdio.h>

int main()
{	
	int L;
	scanf("%d", &L);
	L--;
	int l, N, M;
	for (N = 1, M = 0, l = L; l > 0; N++, M += 2, l = (l - 1) / 2) if (l % 2 == 0 && (l + 1) / 2 > 0) M++;
	printf("%d %d\n", N, M);
	for (l = 1; L > 0; l++, L = (L - 1) / 2) {
		printf("%d %d %d\n", l, l + 1, 0);
		if ((L + 1) / 2 > 0) printf("%d %d %d\n", l, l + 1, (L + 1) / 2);
		if (L % 2 == 0) printf("%d %d %d\n", l, N, L);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1716
#include<stdio.h>

#define MAX_FEE 100000

int input_fee(int x[], int size){
  int i, min = MAX_FEE;
  
  for(i=0; i<size; i++){
    scanf("%d", x+i);
    if(x[i] < min){
      min = x[i];
    }
  }
  
  return min;
}

int input_totalFee(int m[], int size, int a[], int b[]){
  int i, min = MAX_FEE*2;
  int x, y, c;
  
  for(i=0; i<size; i++){
    scanf("%d %d %d", &x, &y, &c);
    m[i] = a[x-1] + b[y-1] - c;
    if(m[i] < min){
      min = m[i];
    }
  }
  
  return min;
}

int main(){
  int A, B, M;
  int *a, *b, *m;
  int min_a, min_b, min_m;
  int x, y, c;
  
  scanf("%d %d %d", &A, &B, &M);
  a = (int *)malloc(sizeof(int)*A);
  b = (int *)malloc(sizeof(int)*B);
  m = (int *)malloc(sizeof(int)*M);
  
  min_a = input_fee(a, A);
  min_b = input_fee(b, B);
  min_m = input_totalFee(m, M, a, b);
  
  printf("%d", (min_a+min_b < min_m) ? min_a+min_b : min_m);
  
  return 0;
}

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

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

  int ans = 1e9;
  for (int i = 0; i < n; i++)
  {
    int s = a[i];
    int g = a[(i+n-1)%n];
    if(g<s) g+=k;
    ans = min(ans,g-s);
  }
  cout << ans << endl;
}

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

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

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

int main()
{
    ll a, b, ansA = 0, ansB = 0, ans = 1e15 ;
    cin >> a >> b ;
    ansA = ceil(double(a) / .08) ;
    ansB = ceil(double(b) / .1) ;
    if (floor(double(ansA) * .08) == a and floor(double(ansA) * .1) == b) {
        ans = min(ans, ansA) ;
    }
    if (floor(double(ansB) * .08) == a and floor(double(ansB) * .1) == b) {
        ans = min(ans, ansB) ;
    }
    if (ans == 1e15)    cout << -1 << endl ;
    else    cout << ans << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------

int main() {
  int n;
  cin >> n;
  vector<int> odd, even;
  rep(i, n) {
    int ai;
    cin >> ai;
    if(i % 2 == 0) odd.pb(ai);
    else even.pb(ai);
  }

  if(n % 2 == 1) { // odd.reverse + even
    reverse(odd.begin(), odd.end());
    cout << odd[0];
    rep1(i, odd.size()) cout << " " << odd[i];
    rep(i, even.size()) cout << " " << even[i];
    cout << endl;
  } else { // odd.reverse + even
    reverse(even.begin(), even.end());
    cout << even[0];
    rep1(i, even.size()) cout << " " << even[i];
    rep(i, odd.size()) cout << " " << odd[i];
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
int X,n;
int b[N],l[N],u[N];
int id[N];
ll sum[N];
bool cmp(int x,int y) { return sum[x]>sum[y]; }
ll get(int i,int y) {
	if(b[i]>=y) return l[i]*(ll)y;
	return l[i]*(ll)b[i]+u[i]*(ll)(y-b[i]);
}
ll cal(ll k) {
	int x=k/X,y=k%X;
	ll tot=0,ans=0;
	for(int i=1;i<=x;++i) tot+=sum[id[i]];
	if(!y) return tot;
	for(int i=1;i<=n;++i) {
		if(i<=x) ans=max(ans,tot-sum[id[i]]+sum[id[x+1]]+get(id[i],y));
		else ans=max(ans,tot+get(id[i],y));
	}
	return ans;
}
int main() {
//	freopen("in.txt","r",stdin);
	rd(n),rd(X);
	ll tot=0;
	for(int i=1;i<=n;++i) {
		rd(b[i]),rd(l[i]),rd(u[i]);
		tot-=l[i]*(ll)b[i];
		sum[i]=l[i]*(ll)b[i]+u[i]*(ll)(X-b[i]);
		id[i]=i;
	}
	sort(id+1,id+n+1,cmp);
	ll lb=0,rb=n*(ll)X;
//	cerr<<cal(2500)+tot<<endl;
	while(lb<rb) {
		ll mid=lb+rb>>1;
//		cerr<<lb<<' '<<rb<<' '<<mid<<endl;
		if(cal(mid)+tot>=0) rb=mid;
		else lb=mid+1;
	}
	printf("%lld",lb);
	return 0;
}

Measured memory_bytes: 2560
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,l = LI()
    s = [input() for i in range(n)]
    s.sort()
    for i in s:
        print(i,end = "")
    print()
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N=1e5+9;
ll n,dp[N],h[N],k;
int main(){
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>h[i];
    for(ll i=1;i<n;i++){
        dp[i]=INT32_MAX;
        for(ll j=i-1;j>=max(0LL,i-k);j--)
            dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
    }
    cout<<dp[n-1]<<"\n";
    return 0; 
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
int x1,x2,x3,x4,x5;
scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
if(x1==0)
printf("1\n");
if(x2==0)
printf("2\n");
if(x3==0)
printf("3\n");
if(x4==0)
printf("4\n");
if(x5==0)
printf("5\n");
return 0;
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n, k; scanf("%lld%lld", &n, &k);
	n %= k;

	printf("%lld\n", std::min(n, k - n));
	return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, T = LI()
    t = LI()
    t = t[::-1]
    prev_time = t[0]
    tot = T
    for i, time in enumerate(t[1:]):
        if time + T < prev_time:
            tot += T
        else:
            tot += (prev_time - time)
        prev_time = time
    print(tot)
main()



Measured memory_bytes: 27740
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long A, long long B){
    // ll ret=INF;
    for (long long i = 1; i <= 1000; i++) {
        ll ten8 = floor(i*0.08);
        ll ten10 = floor(i*0.1);
        if(ten8==A && ten10==B){
            cout << i << endl;
            // cout << ten8 << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ll a;
    cin>>a;
    ll ans = a + (a*a) + (a*a*a);
    cout<<ans<<endl;
}


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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 1e3 + 5, inf = 1e9 + 5, mod = 1e9 + 7;

int dp[N][N];
char a[N][N];

int main()
{
    VIC
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
    dp[0][0] = 1;
    for (int i = 1; i < m && a[0][i] != '#'; i++)
        dp[0][i] = 1;
    for (int i = 1; i < n && a[i][0] != '#'; i++)
        dp[i][0] = 1;
    for (int i = 1; i < n; i++)
        for (int j = 1; j < m; j++)
            if (a[i][j] == '.')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
    cout << dp[n - 1][m - 1];
    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node Ttw[MAX];
int n;


void preParse(int u){
    if(u==NIL)return;
    printf(" %d",u);
    preParse(Ttw[u].l);
    preParse(Ttw[u].r);
}


void inParse(int u){
    if(u==NIL)return;
    inParse(Ttw[u].l);
    printf(" %d",u);
    inParse(Ttw[u].r);
}


void postParse(int u){
    if(u==NIL)return;
    postParse(Ttw[u].l);
    postParse(Ttw[u].r);
    printf(" %d",u);
}

int main(){
    int i,vtw,l,r,roottw;

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

    for(i=0;i<n;i++){
        scanf("%d %d %d",&vtw,&l,&r);
        Ttw[vtw].l=l;
        Ttw[vtw].r=r;
        if(l!=NIL)Ttw[l].p=vtw;
        if(r!=NIL)Ttw[r].p=vtw;
    }

    for(i=0;i<n;i++)if(Ttw[i].p==NIL)roottw=i;

    printf("Preorder\n");
    preParse(roottw);
    printf("\n");
    printf("Inorder\n");
    inParse(roottw);
    printf("\n");
    printf("Postorder\n");
    postParse(roottw);
    printf("\n");

    return 0;


    
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	string s,t;
	cin>>s>>t;
	int l=__gcd(n,m);//考试又不能用
	//挨个查找 
	for(int i=0;i<l;i++){
		// 
		int x=n/l*i;
		int y=m/l*i;
		//不是好串 
		if(s[x]!=t[y]){
			cout<<-1<<endl;
			return 0;
		}	
	} 
	//else
	cout<<(long long)n/l*m<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;

long long n,k,res;
vector<int> a,dp;
vector<vector<int>> G;

int dfs(int i){
    int w = 0;
    for(int u:G[i])w=max(w,dfs(u));
    if(w+1>=k && a[i]!=0){
        res++;
        // cout<<i<<endl;
        return 0;
    }
    return w+1;
}

int main(int argc, char const *argv[]) {
    cin>>n>>k;
    res = 0;
    a = vector<int>(n);
    G = vector<vector<int>>(n);
    for(int i=0;i<n;++i)cin>>a[i];
    if(a[0]!=1){
        res++;
    }
    a[0] = 0;
    for(int i=1;i<n;++i){
        a[i]--;
        G[a[i]].push_back(i);
    }
    dfs(0);
    cout<<res<<endl;
    return 0;
}

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

int main(void) {
	int n, l, r, ans = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> l >> r;
		if (l == r)ans++;
		else ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256