akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  while(b>=2){
    if (a%b==0) return false;
    b--;
  }
  return true;
}

int main(void){
  ll N, M, A, B, C, D, W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  int count = 0;
  rep_s(i, 2, 55555){
    if (IsPrime(i) && i%5 == 1) {
      cout<< i << " ";
      count++;
      if (count == N) break;
    }
  }
}


Measured memory_bytes: 256
#N = int(input())
#J,K = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for _ in range(N)]
#for i in range():
import math

A,B,H,M = map(int,input().split())

Dig = abs(30*H - 5.5*M)

if Dig > 180:
    Dig = 360 - Dig

ans = A*A + B*B -2*A*B*math.cos(math.radians(Dig))

ans = ans**0.5

print(ans)

Measured memory_bytes: 62452
a= str(input())
b = a[-1]

b = int(b)
if b == 3:
    print("bon")
elif b == 0 :
    print("pon")
elif b == 1 :
    print("pon")
elif b == 6 :
    print("pon")
elif b == 8 :
    print("pon")
else:
    print("hon")


Measured memory_bytes: 9176
using System;
using System.Collections.Generic;

class Plogram
{
    static void Main()
    {

        var num = int.Parse(Console.ReadLine());
        var list = new List<int>();
        list.Add(num);
        
        while(true)
        {
            if(num % 2 == 0)
            {
                num = num / 2;
            }
            else
            {
                num = num * 3 + 1;
            }

            if(list.Contains(num))
            {
                break;
            }
            else
            {
                list.Add(num);
            }

        }
        Console.WriteLine(list.Count + 1);

    }
}


Measured memory_bytes: 11220
#include <stdio.h>

typedef enum {false, true} bool;


int main(void)
{
    int N, H1, H2;
    char c;
    int i;
    bool flag = true;
    
    
    scanf("%d%c", &N, &c);
    scanf("%d%c", &H1, &c);
    
    
    if(H1 > 1)
        H1 -= 1;
    
    
    for(i=1; i<N; i++)
    {
        scanf("%d%c", &H2, &c);
        
        
        if(H2 > 1 && H1 < H2)
            H2 -= 1;
        
        
        if(H1 > H2)
        {
            flag = false;
                
            break;
        }
        
        H1 = H2;
    }
    
    if(flag)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    
    //system("pause");
    
    return 0;
}

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

using namespace std;

long long f(int n, long long m) {
    map<tuple<int, int, int>, long long> mem;
    function<long long (int, int, int)> calc = [&](int progress, int num, int jumps) {
        if (jumps > n) return 0LL;
        if (num == 3 * n) return 1LL;
        auto p = make_tuple(progress, num, jumps);
        if (mem.find(p) != mem.end()) return mem[p];
        long long answer = 0;
        if (progress > num) {
            answer += calc(progress, num + 1, jumps) * (progress - num);
        }
        for (int i = 1; i <= 3 && progress + i <= 3 * n; ++i) {
            answer += calc(progress + i, num + 1, jumps + (i > 1));
        }
        return mem[p] = answer % m;
    };
    return calc(0, 0, 0);
}

long long g(int n, long long m) {
    vector<vector<long long>> mem(3*n + 1, vector<long long>(6*n + 3, -1LL));
    function<long long (int, int)> h = [&](int s, int d) {
        // s is the sum
        // d is #1 - #2
        if (s < abs(d)) return 0LL;
        if (s == 0) return 1LL;
        if (mem[s][3 * n + 1 + d] != -1) return mem[s][3 * n + 1 + d];
        long long answer = 0;
        answer += h(s - 1, d - 1);
        answer += h(s - 2, d + 1) * (s - 1) % m;
        answer += h(s - 3, d) * (s - 1) % m * (s - 2) % m;
        answer %= m;
        return mem[s][3 * n + 1 + d] = answer;
    };
    long long total = 0;
    for (int i = 0; i <= 3*n; ++i) {
        total += h(3 * n, i);
    }
    total %= m;
    return total;
}

long long h(int n, long long m) {
    vector<vector<long long>> xs(3*n + 1, vector<long long>(6*n + 3, 0LL));
    xs[0][3 * n + 1] = 1LL;
    for (int s = 1; s <= 3 * n; ++s) {
        for (int d = 1; d <= 6 * n + 1; ++d) {
            long long answer = 0;
            answer += xs[s - 1][d - 1];
            if (s >= 2) {
                answer += xs[s - 2][d + 1] * (s - 1);
            }
            if (s >= 3) {
                answer += xs[s - 3][d] * (s - 1) % m * (s - 2);
            }
            answer %= m;
            xs[s][d] = answer;
        }
    }
    long long total = 0;
    for (int i = 0; i <= 3*n; ++i) {
        total += xs[3 * n][3 * n + 1 + i];
    }
    total %= m;
    return total;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long m;
    cin >> n >> m;
    auto t0 = clock();
    // cout << f(n, m) << endl;
    cout << g(n, m) << endl;
    // cout << h(n, m) << endl;
    auto t1 = clock();
    cerr << "Time used: " << t1 - t0 << " ms" << endl;
    return 0;
}


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


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

  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }

  sort(p.begin(),p.end());
  ll ans =0;
  rep(i,k){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 3656
use proconio::input;

fn main() {
    input! {
        x: u128
    };
    let mut ans = 0;
    let mut n = 100_u128;
    for y in 0.. {
        if n >= x {
            ans = y;
            break;
        }
        n = n * 101_u128 / 100_u128;
    }
    println!("{}", ans);
}


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

using ll=long long; 

void solve(){
	int n,d,x;
	cin>>n>>d>>x;
	vector<int> a(n);
	for(auto&e:a)cin>>e;
	for(int i=0; i<n; i++){
		x+=(d+a[i]-1)/a[i];
	}
	cout<<x<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];
        String[] input = br.readLine().split(" ");

        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(input[i]);
        }

        int pivot = partition(arr, 0, n-1);

        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < n; i++){
            if(i == pivot){
                sb.append("[").append(arr[i]).append("] ");
            }else{
                sb.append(arr[i]).append(" ");
            }
        }

        System.out.println(sb.toString().trim());
    }

    static int partition(int[] A, int p, int r){
        int x = A[r];
        int i = p-1;

        for(int j = p; j < r; j++){
            if(A[j] <= x){
                i++;
                swap(A, i, j);
            }
        }
        
        swap(A, i+1, r);

        return i+1;
    }

    static void swap(int[] A , int x, int y){
        int tmp = A[x];
        A[x] = A[y];
        A[y] = tmp;
    }

}



Measured memory_bytes: 41908
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

double dp[310][310][310];

double dfs(int i,int j,int k,int n){
    if(dp[i][j][k]>=0)return dp[i][j][k];
    double tmp = 0.0;
    if(i>0)tmp+=dfs(i-1,j,k,n)*i/(i+j+k);
    if(j>0)tmp+=dfs(i+1,j-1,k,n)*j/(i+j+k);
    if(k>0)tmp+=dfs(i,j+1,k-1,n)*k/(i+j+k);
    tmp+=(double)n/(i+j+k);
    return dp[i][j][k]=tmp;
}

int main(){
    int N;cin >> N;
    int cnt[3]={};
    rep(i,N){
        int a;cin >> a;
        a--;
        cnt[a]++;
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0][0]=0.0;
    cout << fixed << setprecision(10) << dfs(cnt[0],cnt[1],cnt[2],N) << endl;
    return 0;
}

Measured memory_bytes: 233088
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



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

Measured memory_bytes: 3580
//怪文書

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vector<vector<int>>num(26,vector<int>(n,0));
    rep(i,0,n){
        string s;cin>>s;
        rep(j,0,s.size())num[s[j]-97][i]++;
    }
    string ans;
    rep(i,0,26){
        int a = *min_element(range(num[i]));
        rep(j,0,a)ans.pb(i+97);
    }
    if(ans.size()!=0)cout<<ans<<nnn;
    else cout<<nnn;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 998244353;//1e9+7;

struct Combinatorics {
  using int64 = long long;
  const int64 mod = 998244353;//1e9+7;
  int64 fact[302020];
  int64 invfact[302020];
  Combinatorics() {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 302020; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = minv(fact[i]);
    }
  }
  int64 mpow(int64 x, int64 n) const {
    int64 res = 1;
    while(n > 0) {
      if(n&1) res = res*x%mod;
      x = x*x%mod;
      n >>= 1;
    }
    return res;
  }
  int64 minv(int64 x) const {
    return mpow(x, mod-2);
  }
  int64 mfact(int64 x) const {
    return fact[x];
  }
  int64 C(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
  }
  int64 P(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[n-r]%mod;
  }
}C;


signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, a, b, k;
  cin >> n >> a >> b >> k;
  int ans = 0;
  rep(i, n+1) {
    int x = k-i*a;
    if(x < 0 || x % b != 0) continue;
    int j = x/b;
    ans += C.C(n, i)*C.C(n, j)%mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int x,n,min=102;
  cin >> x >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++)
    cin >> p.at(i);
  sort(p.begin(), p.end());
  int c=0;
  if(n==0){
    cout << x;
    return 0;
  }
  else{
  for(int i=0;i<102;i++){
    if(i==p.at(c)){
      if(c<n-1)	c++;
      continue;
    }
    else
      if(abs(x-i)<abs(x-min))	min = i;  
  }
  }
  cout << min;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b&&a>c){
		printf("%d\n",(b*c)/2);
	}
	if(b>a&&b>c){
		printf("%d\n",(a*c)/2);
	}
	if(c>a&&c>b){
		printf("%d\n",(a*b)/2);
	}
	return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

dp = [[0] * 3 for i in range(n + 1)]
for i in range(n):
    if i + 1 - k < 0:
        if t[i] == "r":
            dp[i + 1][0] = p
        if t[i] == "s":
            dp[i + 1][1] = r
        if t[i] == "p":
            dp[i + 1][2] = s
    else:
        if t[i] == "r":
            dp[i + 1][0] = p + max(dp[i + 1 - k][1], dp[i + 1 - k][2])
            dp[i + 1][1] = max(dp[i + 1 - k][2], dp[i + 1 - k][0])
            dp[i + 1][2] = max(dp[i + 1 - k][0], dp[i + 1 - k][1])
        if t[i] == "s":
            dp[i + 1][0] = max(dp[i + 1 - k][1], dp[i + 1 - k][2])
            dp[i + 1][1] = r + max(dp[i + 1 - k][2], dp[i + 1 - k][0])
            dp[i + 1][2] = max(dp[i + 1 - k][0], dp[i + 1 - k][1])
        if t[i] == "p":
            dp[i + 1][0] = max(dp[i + 1 - k][1], dp[i + 1 - k][2])
            dp[i + 1][1] = max(dp[i + 1 - k][2], dp[i + 1 - k][0])
            dp[i + 1][2] = s + max(dp[i + 1 - k][0], dp[i + 1 - k][1])
ans = 0
for i in range(k):
    ans += max(dp[-i - 1])
print(ans)

Measured memory_bytes: 63596
#include <iostream>
#include <algorithm>

using namespace std;

inline int adj(int x) {
  return min(max(x, 0), 255);
}
#define SQ(x) ((x)*(x))
int main() {
  int N, M, INF=1<<28;
  while(cin >> N >> M && (N|M)) {
    int C[M];
    for(int i=0; i<M; i++) cin >> C[i];
    int dp[2][256]; fill(dp[0], dp[0]+512, INF);
    dp[0][128] = 0;
    for(int k=0; k<N; k++) {
      for(int i=0; i<256; i++) dp[(k+1)%2][i] = INF;
      int in; cin >> in;
      for(int i=0; i<256; i++) {
        if(dp[k%2][i]>=INF) continue;
        for(int j=0; j<M; j++) {
          dp[(k+1)%2][adj(i+C[j])] = min(dp[(k+1)%2][adj(i+C[j])], dp[k%2][i]+SQ(in-adj(i+C[j])));
        }
      }
    }
    cout << *min_element(dp[N%2], dp[(N%2)+1]) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll a,b,c; cin>>a>>b>>c;

    cout<< ( a+b+c>=22 ? "bust" : "win" )<<"\n";

}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<queue>
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
typedef double lf;
typedef unsigned un;
typedef int in;
#define mian main
#define maxn 10000+10
#define maxm 10000+10
#define _(a) read(a)
#define non void
#define inf 2147483647
#define bre break
#define con continue
#define prq priority_queue
#define re register
#define bu bool
#define cz char
#define cst const
#define ope operator
#define inl inline
#define upp upper_bound
#define low lower_bound
#define next_per next_permutation
inl cz gc(){static cz buf[100000],*L=buf,*R=buf;return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;}
template<typename T>inl T Max(T a,T b){return a>b?a:b;}
template<typename T>inl T Min(T a,T b){return a<b?a:b;}
template<typename T>inl T Abs(T a){return a<0?-a:a;}
template<typename T>inl non read(T &a){a=0;T k=1;char c=gc();while(c<'0'||c>'9')k=c=='-'?-1:k,c=gc();while(c>='0'&&c<='9')a=a*10+(c^48),c=gc();if(c!='.'){a*=k;return;}T t=0.1;while(c<'0'||c>'9')c=gc();while(c>='0'&&c<='9')a+=t*(c^48),c=gc(),t*=0.1;a*=k;}
template<typename T>non write(T a,cz t=' '){if(a==0){putc(48,stdout),putc(t,stdout);return;}if(a<0){a=-a;putc('-',stdout);}cz c[30];in le=0;while(a){c[++le]=a%10+48;a/=10;}for(re in i=le;i>=1;--i)putc(c[i],stdout);putc(t,stdout);}
in a,b,c;
in main()
{
	read(a),read(b),read(c);
	if(b-a==c-b)cout<<"YES\n";
	else cout<<"NO\n";
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

vector<int> g[2000];

void dfs(int cur, int k, vector<bool> &used){
	used[cur] = true;
	for(auto to : g[cur]){
		if(used[to] || k == 0) continue;
		dfs(to, k - 1, used);
	}
}

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

	vector<pair<int, int>> v(n - 1);
	rep(i,n - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[i] = make_pair(a,b);
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	int ans = 1e8;
	if(k % 2){
		rep(i,n - 1){
			vector<bool> used1(n,0), used2(n,0);
			dfs(v[i].first, k / 2, used1);
			dfs(v[i].second, k / 2, used2);
			int cnt = 0;
			rep(i,n){
				if(not used1[i] && not used2[i]) cnt++;
			}
			ans = min(ans, cnt);
		}
	}else{
		rep(i,n){
			vector<bool> used(n,0);
			dfs(i,k / 2,used);
			int cnt = 0;
			rep(i,n){
				if(not used[i]) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最小公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最大公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[100000];
    int b[100000];
    REP(i,n){
      cin >> a[i];
      b[i] = a[i];
    }
    sort(b,b+n);
    //REP(i,n)cout << a[i] << ":" << b[i] << endl;
    int c=0;
    REP(i,n)if(a[i]!=b[i])c++;
    //cout << c << endl;
    cout << (c<3?"YES":"NO") << endl;
}


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

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

    int n = s.size();
    int temp = 0;
    rep (i, n)
        temp = (temp + s[i] - '0') % 9;

    cout << (temp % 9 ? "No" :"Yes") << endl;
    return 0;
}


Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	struct P
	{
		public int i, j;
		public P(int _i, int _j) { i = _i; j = _j; }
		public bool IsInRange => 0 <= i && i < h && 0 <= j && j < w;
		public P[] Nexts() => new[] { new P(i, j + 1), new P(i + 1, j) };
	}

	static int h, w;
	static string[] c;

	static void Main()
	{
		var z = Console.ReadLine().Split().Select(int.Parse).ToArray();
		h = z[0]; w = z[1];
		c = new int[h].Select(_ => Console.ReadLine()).ToArray();

		var sp = new P();
		var gp = new P(h - 1, w - 1);
		Console.WriteLine(Search(sp, gp));
	}

	static int Search(P sp, P gp)
	{
		var u = new int[h, w];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				u[i, j] = 1 << 30;
		var q = new Queue<P>();
		u[sp.i, sp.j] = c[sp.i][sp.j] == '.' ? 0 : 1;
		q.Enqueue(sp);

		while (q.Any())
		{
			var p = q.Dequeue();
			foreach (var x in p.Nexts())
			{
				if (!x.IsInRange) continue;
				// '#' < '.'
				var t = u[p.i, p.j] + (c[p.i][p.j] <= c[x.i][x.j] ? 0 : 1);
				if (u[x.i, x.j] <= t) continue;
				u[x.i, x.j] = t;
				q.Enqueue(x);
			}
		}
		return u[gp.i, gp.j];
	}
}


Measured memory_bytes: 29296
// https://atcoder.jp/contests/abc079/tasks/abc079_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  ll n;

  cin >> n;

  ll a = 2, b = 1, c = 3;

  if (n == 1)
    c = 1;
  else
  {
    REP(i, n - 1)
    {
      c = a + b;
      a = b;
      b = c;
    }
  }

  cout << c << '\n';

  return 0;
}


Measured memory_bytes: 256
import time
time0=time.time()

N,M=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(M)]

EDGELIST=[[] for i in range(N+1)]
EDGEINV=[[] for i in range(N+1)]

for a,b,c in EDGE:
    EDGELIST[a].append([b,c])
    EDGEINV[b].append(a)

SCORE=[float("inf")]*(N+1)


from collections import deque

QUE=deque([N])
while QUE:
    x=QUE.pop()
    SCORE[x]=-float("inf")

    for to in EDGEINV[x]:
        if SCORE[to]==-float("inf"):
            continue
        QUE.append(to)

SCORE[1]=0

QUE=deque([1])

while QUE:

    x=QUE.pop()

    for to,plus in EDGELIST[x]:
        if SCORE[to]<SCORE[x]+plus:
            SCORE[to]=SCORE[x]+plus
            QUE.appendleft(to)

    if time.time()-time0>1.8:
        print("inf")
        break

else:
    print(SCORE[-1])
            
        


Measured memory_bytes: 16368
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    double p=(a.at(0)+a.at(1))/2;
    rep(i,n-2){
        p=(p+a.at(i+2))/2;
    }
   cout << fixed << setprecision(10) << p << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,i;
	b=0;
	for(i=0;i<5;i++){
		scanf("%d",&a);
		if(a<40){
			b=b+40;
		}else{
			b=b+a;
		}
	}
	printf("%d\n",b/5);
	return 0;
}

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

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

    vector<int> d(N,0);
    for (int i = 0; i < N; ++i){
        int h;
        cin >> d[i];
    }
    long int ans = 0;

    for (int i = 0; i < N; ++i){
        for (int j = i + 1; j < N; ++j){
            ans += d[i] * d[j];
        }
    }

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

Measured memory_bytes: 256
use std::io::BufRead;
use std::str::FromStr;
use std::fmt::Debug;

struct Scanner<R: BufRead> {
    buf_reader: R,
}

impl<R: BufRead> Scanner<R> {
    fn new(buf_reader: R) -> Self {
        Scanner {buf_reader: buf_reader}
    }
    fn read_line<T>(&mut self) -> Vec<T> where T: FromStr, <T as FromStr>::Err: Debug {
        let mut line = String::new();
        self.buf_reader.read_line(&mut line).unwrap();
        line.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
    }
    fn read_single_value<T>(&mut self) -> T where T: FromStr, <T as FromStr>::Err: Debug {
        let mut line = String::new();
        self.buf_reader.read_line(&mut line).unwrap();
        let sv: Vec<&str> = line.trim().split_whitespace().collect();
        sv[0].parse::<T>().unwrap()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut scanner = Scanner::new(stdin.lock());
    let n = scanner.read_single_value::<usize>();
    let mut a = scanner.read_line::<i32>();
    let mut cnt = 0;
    for i in 0..n {
        let mut min_i = i;
        for j in i..n {
            if a[j] < a[min_i] {
                min_i = j;
            }
        }
        if i != min_i {
            a.swap(i, min_i);
            cnt = cnt + 1;
        }
    }
    let v: Vec<String> = a.iter().map(|x| x.to_string()).collect();
    println!("{}", v.join(" "));
    println!("{}", cnt);
}



Measured memory_bytes: 5040
#include<stdio.h>
#include<string.h>
#include<math.h>
 
 
int main(){
   int n,k,s;
   scanf("%d%d%d", &n,&k,&s);
   for(int i=0;i<n;i++){
     if(s<1000000000){
     	if(i<k){
     		printf("%d", s);
        }else {
            printf("%d", s+1);
        }
      } else{
         if(i<k){
     		printf("%d", s);
        }else {
            printf("1");
        }	 
      }
      if(i!=n-1){
         	printf(" "); 
      }
   }
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define N 2005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum=0,t,tut[N];



int main()
{
	fast;
	cin>>n>>m;
	fo(i,0,n-1)
		cin>>ar[i];
	for(int i=0;i<n;i++)
		tut[i]=ar[i],sum+=ar[i];
	for(ll i=1;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			ll ind=j-i;
			ind+=n;
			ind%=n;
			tut[j]=min(tut[j],ar[(n-i+j)%n]);
		}

		ll top=0;
		for(ll j=0;j<n;j++)
			top+=tut[j];
		// if(top==20)
		// 	cout<<i<<endl;
		sum=min(sum,i*m+top);

	}
	cout<<sum<<endl;
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main(void){
  int N,M;
  cin>>N>>M;
  pair <long,long> p[N];
  for(int i=0;i<N;i++){
      long A,B;
      cin>>A>>B;
      p[i]=make_pair(A,B);
  }
  sort(p,p+N);
  long sum=0; long ans=0;
  for(int i=0;i<N;i++){
      if((M-sum)>=p[i].second){sum+=p[i].second; ans+=p[i].first*p[i].second;}
      else { ans+=p[i].first*(M-sum); sum+=M-sum;}
      if(sum>=M){cout<<ans; break;}
  }
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main() {
	int n, m,f=0,finish=0;
	char a[50][50], b[50][50];
	scanf("%d %d", &n, &m);
	for (int i = 0;i < n;i++) scanf("%s", a[i]);
	for (int i = 0;i < m;i++) scanf("%s", b[i]);

	for (int y = 0;y < n;y++) {
		for (int x = 0;x < n;x++) {
          if(a[y][x]==b[0][0]){
            for(int yy=0;yy<m;yy++){
              for(int xx=0;xx<m;xx++){
                if(a[y+yy][x+xx]==b[yy][xx]) f++;
                else f=0;
                if(f==m*m){
                  finish=1;
                  break;
                }
              }
              if(finish==1) break;
            }
            if(finish==1) break;
          }
          f=0;
          if(finish==1) break;
		}
      if(finish==1) break;
	}
	if (f == 0) printf("No");
	else printf("Yes");
	return 0;
}

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

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

    int N;

    cin >> N;

    for(int i=1; i<=9; ++i)
    {
       for(int j=1; j<=9; ++j)
       {
            if (i * j == N)
            {
                cout << "Yes";
                return 0;
            }
       }
    }

    cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n, d = (int(x) for x in input().split())
ls = []
for i in range(n):
    ls.append([int(x) for x in input().split()])
ls = np.array(ls)
count = 0
for i in range(n):
    for j in range(i+1, n):
        dist = np.sqrt(sum(np.square(ls[i] - ls[j])))
        if dist.is_integer():
            count = count + 1
print(count)

Measured memory_bytes: 17840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll b;
ll a;

ll n;


int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 


double w,h,x,y;
cin>>w>>h>>x>>y;

double ans=w*h/2;
if(2*x==w && 2*y==h)
cout<<fixed<<setprecision(6)<<ans<<" "<<"1"<<endl;

else
cout<<fixed<<setprecision(6)<<ans<<" "<<"0"<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
void solve() 
{
    string s; 
    cin >> s;
    vector<ll> v ;
    ll len = 0 , n = sz(s) , k ;
    char c = '*' ;
    rep( i , 0 , n ){
        if(c==s[i])len++;
        else{
            if(len>0)
                v.pb(len);
            c=s[i];
            len=1;
        }
    }
    if(len>0)v.pb(len);
    ll tot = 0 ;
    cin >> k ;
    /*for(auto i : v )
		cout << i << ' ' ;
	cout << '\n' ;*/
    if(v[0]==n){
		cout << (v[0]*k)/2 << "\n" ;return;
	}
    rep(i,1,sz(v)-1)tot+=k*(v[i]/2) ;
    if(s[0]==s[n-1]){
		tot += v[0]/2 ;
		tot += v.back()/2 ;
		tot += ((v[0]+v.back())/2)*(k-1); 
	}
	else{
		tot += k*(v[0]/2) ;
		tot += k*(v.back()/2) ;
	}
	cout << tot << "\n" ;
	//cout << 9LL*999993333 << "\n" ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>v;
    ll num;
    for(ll i=0;i<n;i++){
        cin>>num;
        v.push_back(num);
    }
    sort(v.begin(),v.end());
    ll ans=0;
    for(ll i=0;i<n-2;i++)
    {
        for(ll j=i+1;j<n-1;j++)
        {
            ll num=v[i]+v[j];
            auto it=lower_bound(v.begin(),v.end(),num);
            ll num1=it-v.begin();
            ans=ans+num1-1-j;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [0]*h
for i in range(h):
    a[i] = list(input())
b = []
for i in range(h):
    if a[i] == ["."]*w:
        pass
    else:
        b.append(a[i])
c = [[0 for j in range(w)] for i in range(h)]
for i in range(w):
    sw = 1
    for j in range(len(b)):
        if  b[j][i] == "#":
            sw = 0
            break
    if sw == 0:
        for j in range(len(b)):
            c[j][i] = b[j][i]
for i in range(len(c)):
    for j in range(len(c[0])):
        if c[i][j] != 0:
            print(c[i][j],end="")
    print("")


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(a>=k){
        cout<<k<<endl;
    }
    else if(a+b>=k){
        cout<<a<<endl;
    }
    else{
        cout<<a-(k-a-b)<<endl;
    }
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(n + 1, vector<ll>(13));
  dp[0][0] = 1;
  int mul = 1;
  for (int i = 0; i < n; i++) {
    if (s[n - i - 1] == '?') {
      for (int k = 0; k < 10; k++) {
        for (int j = 0; j < 13; j++) {
          dp[i + 1][(k * mul + j) % 13] += dp[i][j];
          dp[i + 1][(k * mul + j) % 13] %= MOD;
        }
      }
    } else {
      int k = s[n - i - 1] - '0';
      for (int j = 0; j < 13; j++) {
        dp[i + 1][(k * mul + j) % 13] += dp[i][j];
        dp[i + 1][(k * mul + j) % 13] %= MOD;
      }
    }
    mul *= 10;
    mul %= 13;
    dumpv(i, s[n-i-1], dp, n + 1, 13);
  }
  cout << dp[n][5] << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main()
{
    vector<int> a(5);
    rep(i, 5)
    {
        cin >> a[i];
    }
    rep(i, 5)
    {
        if (a[i] == 0)
        {
            cout << (i + 1) << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
       ll N,M,H[100001]={},ara[100001]={};
       ll A,B,i,j,count=0;

       cin>>N;
       cin>>M;
       for(i=0;i<N;i++){
                cin>>H[i];
       }
       for(i=0;i<M;i++){
        cin>>A>>B;
        if(H[A-1]>H[B-1]){
                ara[B-1]=1;
        }
        else if(H[A-1]<H[B-1]){
                 ara[A-1]=1;
        }
        else{
                ara[B-1]=1;
                ara[A-1]=1;
        }
       }
       sort(ara,ara+N);
       for(i=0;i<N;i++){
                if(ara[i]==0){
                        count++;
                }
                else {
                        break;
                }
       }
       cout<<count<<endl;
       return 0;
}


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

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

#define LL long long

template <typename T>
T get_gcd(T a, T b) {
  T p;
  while(b!=0) {
    p = a%b;
    a = b;
    b = p;
  }
  return a;
}

template <typename T>
T get_lcm(T a, T b) {
  if(a < b) {
    T tmp = b;
    b = a;
    a = tmp;
  }
  T gcd = get_gcd(a, b);
  T tmp = get_gcd(a, gcd);
  a /= tmp;
  b /= (gcd/tmp);
  return a*b;
}

int main() {
  int N;
  cin >> N;
  vector<LL> period(N);
  REP(i, N)
    cin >> period.at(i);
  LL tmp = 1;
  REP(i, N) {
    tmp = get_lcm(tmp, period.at(i));
  }
  cout << tmp << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,i=0,u=0,e=0,o,yama[201];
	while(scanf("%d %d",&a,&i)!=EOF){
		
		o=a+i;
		for(u=0;o!=0;u++){
			o/=10;
		}
		yama[e]=u;
		e++;
	}
	for(u=0;u<e;u++){
		printf("%d\n",yama[u]);
	}
	return 0;
	
	
}

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

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

    if( a <= c && d <= b) {
        cout << d - c << endl;
        return 0;
    }
    else if( c <= a && b <= d) {
        cout << b -a  << endl;
        return 0;
    }
    else if ( a <= c && c <= b) {
             cout << b - c << endl;
             return 0;
         }
    else if(c <= a && a <= d ) {
            cout << d - a << endl;
            return 0;
    }
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int l = sc.nextInt();

		List<String> list = new ArrayList<String>();
		for (int i = 0; i < n; i++) {
			list.add(sc.next());
		}

		Collections.sort(list);

		final StringBuilder sb = new java.lang.StringBuilder();
		for (final String item : list) {
			sb.append(item);
		}

		// 結果
		System.out.println(sb);
	}

}


Measured memory_bytes: 24020
object Main extends App {
  for (i <- 0 until 50) {
    val strn = readLine()
    if (strn.nonEmpty) {
      val n = strn.toInt
      val sumperms = for {
        a <- 0 to 9
        b <- 0 to 9
        c <- 0 to 9
        d <- 0 to 9
      } yield { a + b + c + d }
      println(sumperms.count(_==n))
    }
  }
}



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

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


Measured memory_bytes: 4260
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int main()
{
	ll a[1000010], s[1000010];
	a[0]=1, a[1]=1, a[2]=1;
	s[0]=1, s[1]=2, s[2]=3;
	repp(i, 3, 1000010)
	{
		a[i]=(s[i-3]+a[i-1])%MOD;
		s[i]=(s[i-1]+a[i])%MOD;
	}
	ll n;
	cin >> n;
	ll ans=n;
	repp(i, 2, n+1)
	{
		ans=(ans+(((a[i-2]*(n-1))%MOD)*(n-1))%MOD)%MOD;
		ans=(ans+((a[i-1]*(n-1))%MOD))%MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S += sc.next();
		sc.close();
		double num =  Math.sqrt((double)Integer.parseInt(S));

		System.out.println(num-(int)num==0?"Yes":"No");
	}

}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    
    vector<int> v1, v2, v3;
    for(int i=0; i<N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        v1.push_back(a);
        v2.push_back(b);
        v3.push_back(c);
    }
    
    for(int i=0; i<N; i++) {
        vector<int> triangle;
        triangle.push_back(v1[i]);
        triangle.push_back(v2[i]);
        triangle.push_back(v3[i]);
        
        sort(triangle.begin(), triangle.end());
        int r = triangle[0], s = triangle[1], t = triangle[2];
        if(t*t == (r*r + s*s)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3184
/*
*/

#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 337

using namespace std;

const int INF = 1e9;
const int N = 201231;

int n, m, w[N];

int get(int x)
{
	if (x == w[x])
		return x;
	return w[x] = get(w[x]);
}

void merge(int a, int b)
{
	a = get(a);
	b = get(b);
	w[a] = b;
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/input.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> m;

	for (int i = 1; i <= m + n; i++)
	{
		w[i] = i;
	}

	for (int i = 1; i <= n; i++)
	{
		int sz;
		cin >> sz;
		for (; sz; --sz)
		{
			int x;
			cin >> x;
			merge(i, x+n);
		}
	}

	int bad = 0;

	for (int i = 1; i <= n; i++)
	{
		if (get(i) != get(1))
			bad = 1;
	}

	if (bad)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;

	cin.get(); cin.get();
	return 0;
}

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

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int range = inpt[0];
        int min = inpt[1];
        int max = inpt[2];

        int ans = 0;
        for (int i = 1; i <= range; i++) {
            int total = i.ToString().Select(a => int.Parse(a.ToString())).Sum();
            if(total >= min && total <= max) {
                ans += i;
            }
        }
        Console.WriteLine(ans);
    }


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



20 2 5



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 15444
#include <iostream>
using namespace std;
int main(void){
    int i, plus=0, minus=0;
    string str;
    cin >> str;
    for(i=0;i<4;i++){
      if(str[i]=='+') {
          plus++;
      }else{
          minus++;
      } 
    }
    cout << plus - minus << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 while(1){
  ll h;
  cin>>h;
  if( h==0 ) break;
  vector<vector<ll> > a(h,vector<ll>(5,0) );
  for(ll i=h-1;i>=0;i--)
   for(ll j=0;j<5;j++) cin>>a[i][j];

  ll res = 0;
  bool flag = true;
  while(flag){
   flag = false;
   for(ll i=0;i<h;i++){
    ll num = a[i][0];
    ll cnt = 1;
    for(ll j=1;j<5;j++){
     if( num == a[i][j] ){
      cnt++;
      if( cnt >= 3 && num != 0){
       if(cnt == 3 ){
	res += num*2;
	a[i][j-1] = a[i][j-2] = 0;
	flag = true;
       }
       a[i][j] = 0;
       res += num;
      }

     }else{
      cnt = 1;
      num = a[i][j];
     }
    }
   }
 /*
   cout<<"before"<<endl;
   for(ll i=h-1;i>=0;i--){
    for(ll j=0;j<5;j++)cout<<a[i][j]<<' ';
    cout<<endl;
   }
  cout<<endl;
*/


   if( flag )
    for(ll i=h-1;i>=0;i--){
     for(ll j=0;j<5;j++){
      if(a[i][j] == 0 ){
       //for(ll k=i+1;k<h;k++) swap( a[k-1][j] , a[k][j] );
       for(ll k=i+1;k<h;k++) a[k-1][j] = a[k][j];
       a[h-1][j] = 0;
      }
     }
    }
  /* cout<<"after"<<endl;
   for(ll i=h-1;i>=0;i--){
    for(ll j=0;j<5;j++)cout<<a[i][j]<<' ';
    cout<<endl;
   }
  cout<<endl;
*/

  }
/*
  for(ll i=h-1;i>=0;i--){
   for(ll j=0;j<5;j++)cout<<a[i][j]<<' ';
   cout<<endl;
  }
  */
  cout<<res<<endl;
 }
    return 0;
}



Measured memory_bytes: 3168