akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[m],c[m];
    vector<pair<int,int>>p(m);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<m;i++){
        cin>>b[i]>>c[i];
        p[i]={c[i],b[i]};
    }
    sort(p.begin(),p.end(),greater<pair<int,int>>());
    for(int i=0;i<m;i++){
        c[i]=p[i].first;
        b[i]=p[i].second;
    }
    //cが降順にソートされている
    long long X=0;//合計
    int x=0;//pointer
    for(int i=0;i<n;i++){
        if(a[i]>=c[x] || x==m){
            for(int j=i;j<n;j++)X+=a[j];
            break;
        }
        X+=c[x];
        b[x]--;
        if(b[x]==0)x++;
    }
    cout<<X<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

#define _CRT_SECURE_NO_WARNINGS

int main(void) {
	int a, b,c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	if (a < b && b < c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
    ll X = 0,w = 0 ;
    char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}
ll dat[1000005];
ll z,c2,c1;
ll l1[1000005],r1[1000005],r2[1000005];
ll l2[1000005];
ll pre[1000005];
ll mn1,mn2;
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>dat[i];
        pre[i]=pre[i-1]+dat[i];
        if(!dat[i])
        {
            z++;
        }
        if(dat[i]%2)
        {
            c1++;
        }
        else
        {
            c2++;
        }
        mn1=min(pre[i]-2*z-c1,mn1);
        l1[i]=2*z+c1+mn1;
        mn2=min(l1[i]-c2,mn2);
        l2[i]=c2+mn2;
    }
    z=c1=c2=mn1=mn2=0;
    ll ans=INF;
    for(ll i=n;i>=0;i--)
    {
        pre[i]=pre[i+1]+dat[i];
        if(!dat[i])
        {
            z++;
        }
        if(dat[i]%2)
        {
            c1++;
        }
        else
        {
            c2++;
        }
        mn1=min(pre[i]-z-z-c1,mn1);
        r1[i]=z+z+c1+mn1;
        mn2=min(r1[i]-c2,mn2);
        r2[i]=c2+mn2;
        ans=min(ans,min(l1[i]+r2[i],l2[i]+r1[i]));
    }
    for(ll i=1;i<=n;i++)
    {
        ans=min(ans,min(l1[i-1]+r2[i],l2[i-1]+r1[i]));
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    a[x][y] = a[y][x] = 1;
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j && a[i][j] == 0) {
        g[i].push_back(j);
      }
    }
  }
  vector<int> color(n, -1);
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    if (color[i] != -1) {
      continue;
    }
    vector<int> que = {i};
    color[i] = 0;
    int cnt[2] = {0, 0};
    for (int b = 0; b < int(que.size()); b++) {
      int v = que[b];
      cnt[color[v]]++;
      for (int u : g[v]) {
        if (color[u] == -1) {
          color[u] = 1 - color[v];
          que.push_back(u);
        } else if (color[u] == color[v]) {
          cout << -1 << "\n";
          return 0;
        }
      }
    }
    v.emplace_back(cnt[0], cnt[1]);
  }
  vector<int> dp(n + 1);
  dp[0] = 1;
  int sm = 0;
  for (auto& p : v) {
    vector<int> ndp(n + 1);
    for (int i = sm; i >= 0; i--) {
      ndp[i + p.first] |= dp[i];
      ndp[i + p.second] |= dp[i];
    }
    dp = ndp;
    sm += p.first + p.second;
  }
  int ans = 1e9;
  for (int i = 0; i <= n; i++) {
    if (dp[i] == 1) {
      ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);    
    }
  }
  cout << ans << "\n";
  return 0;
}


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

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

int main() { 
  int n;
  cin >> n;
  ll a[n];
  ll z = pow(10, 18);
  __int128 s = 1;
  bool ss = true;

  rep(i, n){
    cin >> a[i];
    if (a[i] == 0){
      ss = false;
    }
  }
  if (ss){
    rep(i, n){
      s *= a[i];
      // cout << s << endl;
      if(s > z || s < 0){
        s = -1;
        break;
      }
    }
  }
  if (ss){
    cout << s << endl;
  } else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 4384
using System;
 
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] Inp=Console.ReadLine().Split(' ');
            int N = int.Parse(Inp[0]);
            int A = int.Parse(Inp[1]);
            int B = int.Parse(Inp[2]);
            int C = int.Parse(Inp[3]);
            int D = int.Parse(Inp[4]);
 
 
            if (A > B)
            {
                int ABCD = A;
                A = B;
                B = ABCD;
                ABCD = C;
                C = D;
                D = ABCD;
            }
 
            String S = Console.ReadLine();
            bool Ans = true;
 
            String betS;
            if (C < B)
            {
                betS = S.Substring(A - 1, C - A);
                if(betS.Contains("##"))
                {
                    Ans = false;
                }
                betS = S.Substring(B - 1, D - B);
                if (betS.Contains("##"))
                {
                    Ans = false;
                }
            }
            else if (C < D)
            {
                betS = S.Substring(A - 1, D - A);
                if (betS.Contains("##"))
                {
                    Ans = false;
                }
 
            }
            else if (C > D)
            {
                betS = S.Substring(A - 1, C - A);
                if (betS.Contains("##"))
                {
                    Ans = false;
                }
                betS = S.Substring(B - 2, D - B +3);
                if (betS.Contains("...") == false)
                {
                        Ans = false;
                    
                }
            }
 
            if(Ans == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
 
 
 
 
            
 
        }
    }
}

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    cout << setprecision(16) << fixed;

    ll n;
    cin >> n;

    vector<double> xm(4, 1e15), xM(4, -1e15);
    vector<double> ym(4, 1e15), yM(4, -1e15);
    while(n--) {
        double x, y;
        string d;
        cin >> x >> y >> d;

        ll di;
        switch(d[0]) {
            case 'R':
                di = 0;
                break;
            case 'L':
                di = 1;
                break;
            case 'U':
                di = 2;
                break;
            case 'D':
                di = 3;
                break;
        }
        xm[di] = min(xm[di], x);
        xM[di] = max(xM[di], x);
        ym[di] = min(ym[di], y);
        yM[di] = max(yM[di], y);
    }

    double vx[4] = {1, -1, 0, 0};
    double vy[4] = {0, 0, 1, -1};

    vector<double> ts;
    for(ll di=0; di<4; di++)
        for(ll dj=di+1; dj<4; dj++) {
            // x[di] + t vx[di] == x[dj] + t vx[dj]
            // (vx[di] - vx[dj]) t == b - a
            if(abs(vx[di] - vx[dj])>0) {
                ts.push_back(1.0 * (xm[dj] - xm[di]) / (vx[di] - vx[dj]));
                ts.push_back(1.0 * (xm[dj] - xM[di]) / (vx[di] - vx[dj]));
                ts.push_back(1.0 * (xM[dj] - xm[di]) / (vx[di] - vx[dj]));
                ts.push_back(1.0 * (xM[dj] - xM[di]) / (vx[di] - vx[dj]));
            }
            if(abs(vy[di] - vy[dj])>0) {
                ts.push_back(1.0 * (ym[dj] - ym[di]) / (vy[di] - vy[dj]));
                ts.push_back(1.0 * (ym[dj] - yM[di]) / (vy[di] - vy[dj]));
                ts.push_back(1.0 * (yM[dj] - ym[di]) / (vy[di] - vy[dj]));
                ts.push_back(1.0 * (yM[dj] - yM[di]) / (vy[di] - vy[dj]));
            }
        }

    auto f = [&](double t) {
        double _xm = 1e18, _xM = -1e18, _ym = 1e18, _yM = -1e18;
        for(ll di=0; di<4; di++) {
            _xm = min(_xm, xm[di] + vx[di]*t);
            _xM = max(_xM, xM[di] + vx[di]*t);
            _ym = min(_ym, ym[di] + vy[di]*t);
            _yM = max(_yM, yM[di] + vy[di]*t);
        }
        return (_xM - _xm) * (_yM - _ym);
    };

    double r = f(0);
    for(auto &t: ts)
        if(t > 0)
            r = min(r, f(t));

    cout << r << endl;
}


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

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

    int A, B;
    cin >> A >> B;
    int ret = max(A+B, A-B);
    ret = max(ret, A*B);

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#include<algorithm>
using namespace std;
const int N=2e5+10;
int n,a[N],L,R,ANS,MID;
map<int,int>cnt;
stack<pair<int,int> >st;
bool check(int nw)
{
	map<int,int>cnt;
	stack<pair<int,int> >st;
	if (nw==1){for (int i=2;i<=n;i++)if (a[i]<=a[i-1])return 0;return 1;}
	if (a[1]!=1) st.push(make_pair(1,1));
	for (int i=1;i<=n;i++)
	{	
		int t=0;
		while (!st.empty())
			if (a[i]<st.top().first) st.pop(),t=1;else break;
		int cur=a[i];
		if (!st.empty()){
			bool ok=0;
			while (!ok)
			{
				if (!st.size()) return 0;
				int x=st.top().first;
				if (x<cur) st.push(make_pair(cur,t+1)),ok=1;else
				{
					int y=st.top().second+1;
					if (y>nw) cur--,st.pop();			
					else st.pop(),st.push(make_pair(x,y)),ok=1;
					t=1;
				}
			}
		}else st.push(make_pair(1,1));
	}
	return 1;
}
int main()
{
	scanf("%d",&n);for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	L=1,R=n;
	while (L<R){MID=L+R>>1;if (check(MID)) R=MID;else L=MID+1;}
	cout<<R;
}

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

int N, A[2000];
long long sum_all = 0;
bitset<4000000> dp;

int main(){
    cin >> N;
    dp.set(0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum_all += A[i];
        dp |= (dp << A[i]);
    }
    for(int i = (sum_all + 1) / 2; i <= sum_all; i++){
        if(dp[i]){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
N = int(input())
SS = [input() for _ in range(N)]

dict = {}
for S in SS:
    cnt = {}
    for c in list(S):
        if c in cnt:
            cnt[c] += 1
        else:
            cnt[c] = 1
    if len(dict) == 0:
        for c in cnt:
            dict[c] = cnt[c]
    else:
        for c in dict:
            if c in cnt:
                dict[c] = min(dict[c], cnt[c])
            else:
                dict[c] = 0

ans = ''
for i in range(26):
    c = chr(ord('a') + i)
    if c in dict:
        ans += c * dict[c]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
using ll = long long;

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

	int ans = 1;
	rep(i, 0, n - 1) {
		if (s[i] == s[i + 1]) continue;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

int s[10] = {-1,2,5,5,4,5,6,3,7,6};
class Solution {
public:
	void solve() {
		int n, m;
		cin >> n >> m;
		vector<int> a(m, 0);
		for(int i=0; i<m; i++)cin >> a[i];
		sort(a.begin(), a.end(), greater<int>());
		vector<int> dp(n+1, -1);
		dp[0] = 0;
		for(int i=0; i < n; i++){
			if(dp[i] == -1)continue;
			for(int j=0; j < m; j++){
				if(i+s[a[j]] <= n)updmax(dp[i+s[a[j]]], dp[i]+1);
			}
		}
		string ret;
		int i = n;
		while(i){
			for(int j=0; j < m; j++){
				if(i-s[a[j]] >= 0 && dp[i]-1 == dp[i-s[a[j]]]){
					ret += '0' + a[j];
					i -= s[a[j]];
					break;
				}
			}
		}
		cout << ret << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    String s = sc.next();
    if (s.length() <= k) {
      System.out.println(s);
    } else {
      System.out.println(s.substring(0, k) + "...");
    }
    sc.close();
  }
}

Measured memory_bytes: 38644
"""
配列Aの中で仕切りを設けて、前半候補と後半候補に分ける。
仕切りを設ける位置は、N番目の要素の後ろから、2N-1番目の要素の後ろまで。
仕切りから左側が前半候補で仕切りから右側が後半候補。
最初、仕切りがN番目の要素の後ろにある状態から始める。
この次点では前半候補の数はN個なので、前半候補すべてが正規の前半メンバー(?)となる。
仕切りがこの初期位置からどんどん右側にずれていっても、前半の総和がこの初期値より小さくなることはない。
なぜなら、仕切りの移動に伴って増えていく前半候補の値が、もとの前半メンバーのどの値よりも小さければ、
そいつを正規メンバーに入れなければいい話だからだ。
逆に、新しく増えた前半候補の値が、もとの前半メンバーのどれかよりも大きければ、もとの前半メンバーの中で最も小さい要素を取り除き、
新しく増えた前半候補を正規メンバーに取り込む。
これはheapqを使うことで効率的に実装できる。

次に後半部分について考えてみよう。基本的な考え方は前半部分と同じ。
違うのは、前半部分はできるだけ大きくしなくては行けなかったのに対し、後半部分はできるだけ小さくしなくては行けないということ。
最初は仕切りを2N-1の後ろに設けておく。このとき、仕切りより右側にある要素が初期の後半メンバーである。
仕切りをどんどん左側にずらしていって、新しく増えた要素が元のどの後半メンバーよりも大きければ後半メンバーとして採用しない。
後半メンバーのどれかより小さければ、もとの後半メンバーの中で最も大きい要素を取り除き、新しく増えた後半候補を後半メンバーに加えればいい。
これは通常のheapqでは実装できないので、後半の値に-1を乗じることで、heapqに対応できるようにする。
"""
import heapq
N = int(input())
A = list(map(int,input().split()))
firstMember = A[:N]
firstSum = sum(firstMember)
memo1 = [firstSum]
heapq.heapify(firstMember)
for i in range(N,2*N):
    heapq.heappush(firstMember,A[i])
    firstSum += A[i] - heapq.heappop(firstMember)
    memo1.append(firstSum)

A = A[::-1]
for i in range(3*N):
    A[i] = -1*A[i]
latterMember = A[:N]
latterSum = sum(latterMember)
memo2 = [latterSum*-1]
heapq.heapify(latterMember)
for i in range(N,2*N):
    heapq.heappush(latterMember,A[i])
    latterSum += A[i] - heapq.heappop(latterMember)
    memo2.append(latterSum*-1)

memo2 = memo2[::-1]

ans = -1*float("INF")
for i in range(N+1):
    ans = max(ans,memo1[i]-memo2[i])
print(ans)

Measured memory_bytes: 121916
import scala.io.{StdIn => in}

object Main extends App {
  val btc = 380000.0
  val n = in.readInt
  val ans = Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" "))
    ./:(0.0)((acc, e) => {
      val v = if(e(1) == "JPY") e(0).toDouble else e(0).toDouble * btc
      acc + v
    })
  println(ans)
}

Measured memory_bytes: 27200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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

template<typename T>
T gcd(T x, T y) {
    if(x<y) gcd(y,x);
    while(y>0) {
        T tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int g = 0;
    int m = 0;
    REP(i,n) {
        g = gcd(g,a[i]);
        chmax(m,a[i]);
    }
    bool ans = (k%g==0 && k<=m);
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c, vector<int>(c));
    vector<vector<int>> e(n, vector<int>(n));
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> e[i][j];
            e[i][j]--;
        }
    }
    vector<vector<lint>> diff(c, vector<lint>(3));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < c; ++k) {
                diff[k][(i + j) % 3] += d[e[i][j]][k];
            }
        }
    }
    lint ret = inf;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            for (int k = 0; k < c; ++k) {
                if (i == j || j == k || k == i)
                    continue;
                chmin(ret, diff[i][0] + diff[j][1] + diff[k][2]);
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

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

using LL = long long;
const LL maxn = 11;
LL a, b, c;

signed main() {
  // freopen("in", "r", stdin);
  while(~scanf("%lld%lld%lld",&a,&b,&c)) {
    LL ret = 0;
    ret += 2 * min(b, c);
    c -= ret / 2, b -= ret / 2;
    if(!c) ret += b;
    else ret += min(a, c) == c ? min(a, c) : min(a, c) + 1;
    cout << ret << endl;
  }
  return 0;
}


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

using namespace std;

int main(){
        string a,b,c;
        cin>>a>>b>>c;
        cout<<(char)((int)a[0]-32);
        cout<<(char)((int)b[0]-32);
        cout<<(char)((int)c[0]-32);
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,M;
int main(){
    cin>>N>>M;
    int cnt=0;
    
    int sol[M];
    for(int i=0;i<M;i++)sol[i]=0;
    
    vector<pair<int ,int>> con(M);
    for(int i=0;i<M;i++)cin>>con.at(i).second>>con.at(i).first;
    sort(con.begin(),con.end());
    for(int i=0;i<M;i++){
        if(sol[i]==0){
            sol[i]++;
            cnt++;
            for(int j=i;j<M;j++){
                if(con.at(j).second<con.at(i).first) sol[j]++;
            }
        }
    }
    cout<<cnt<<endl;
} 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second

int main(){
    ll i,j;
    ll n,p;
    cin>>n>>p;
    ll ans=1;
    ll cnt;
    if(n==1) {
        cout<<p<<endl;
        return 0;
    }
    for(i=2;i*i<=p;i++){
        cnt=0;
        while(p%i==0){
            p=p/i;
            cnt++;
            if(cnt%n==0) ans*=i;
        } 
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 113, maxl = 503, mod = 1e9 + 7;
int n, x, dp[maxn][maxn][2*maxl], sm[maxn][maxn][2*maxl], ssm[maxn][maxn][2*maxl];
int fact[maxn], ifact[maxn];
vi l;
int add(int x, int y) {
	x+=y;
	if(x>=mod) x -= mod;
	return x;
}
int sub(int x, int y) {
	if(y)
		y = mod-y;
	return add(x, y);
}
int mul(int x, int y) {
	return x*1ll*y%mod;
}
int setup() {
	fact[0] = ifact[0] = 1;
	for(int i = 1; i < maxn; i++) {
		fact[i] = mul(fact[i-1], i);
		if(i==1) ifact[i]  = 1;
		else ifact[i] = (mod - mul(ifact[mod%i], mod/i));
	}
	for(int i = 2; i < maxn; i++) ifact[i] = mul(ifact[i], ifact[i-1]);
}
int nck(int n, int k) {
	if(k>n) return 0;
	return mul(fact[n], mul(ifact[k], ifact[n-k]));
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	setup();
	cin >> n >> x;
	l.resize(n);
	for(auto &i : l) cin >> i;
	sort(rall(l));
	dp[0][0][0] = 1;
	int &X = x;
	for(int i = 0; i <= n; i++) {
		for(int k = 0; k <= n; k++) {
			int running = 0;
			for(int s = 0; s <= x; s++) {
				running = add(running, sm[i][k][s]);
				dp[i][k][s] = add(dp[i][k][s], running);
				if(!dp[i][k][s]) continue;
				if(i==n) continue;
				dp[i+1][k+1][s+l[i]] = add(dp[i+1][k+1][s+l[i]], dp[i][k][s]);
				int t;
				if(k>1) {
					t = mul(mul(k,(k-1)), dp[i][k][s]);
					for(int x = 0; x < l[i]-1 && s+x <= X; x++) {
						dp[i+1][k-1][s+x] = add(dp[i+1][k-1][s+x], mul(t, l[i]-x-1));
					}
				}
				if(k) {
					t = mul(k, dp[i][k][s]);
					t = mul(t, 2);
					sm[i+1][k][s+1] = add(sm[i+1][k][s+1], t);
					sm[i+1][k][s+l[i]] = sub(sm[i+1][k][s+l[i]], t);
					dp[i+1][k][s] = add(dp[i+1][k][s], mul(dp[i][k][s], sub(s, mul(k, l[i]-1))));
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i++) ans = add(ans, mul(dp[n][i][x], fact[i]));
	cout << ans << '\n';
}


Measured memory_bytes: 92416
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
ans = 0
for i in range(N):
  tmp = sum(A1[0:i+1])
  tmp = tmp + sum(A2[i:N])
  ans = max(ans,tmp)
print(str(ans))

Measured memory_bytes: 9184
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string a;
  cin>>a;
  int check=0;
  rep(i,0,a.length()){
    if(i%2){
      if(a[i]=='R'){
        check++;
        break;
      }
    }else{
      if(a[i]=='L'){
        check++;
        break;
      }
    }
  }
  cout<<(check?"No":"Yes");
    
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
A = list(map(int, input().split()))

total_votes = sum(A)
threshold = total_votes * (1 / (4 * M))

chooseable = 0

for a in A:
  if a >= threshold:
    chooseable += 1
    if chooseable >= M:
      print("Yes")
      sys.exit(0)

print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	while(cin >> a >> b){
		int ans=0;
		a+=b;
		while(a!=0){
			ans++;
			a/=10;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3044
"use strict";
    
const lower_bound = (array, target) => {
    var min = 0;
    var max = array.length - 1;
    while (min <= max) {
        var middle = min + Math.floor((max - min) / 2);
        if (array[middle] < target) {
            min = middle + 1;
        }
        else {
            max = middle - 1;
        }
    }
 
    return min;
}
 
const upper_bound = (array, target) => {
    var min = 0;
    var max = array.length - 1;
    while (min <= max) {
        var middle = min + Math.floor((max - min) / 2);
        if (array[middle] <= target) {
            min = middle + 1;
        }
        else {
            max = middle - 1;
        }
    }
 
    return min;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const top = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const mid = arg[2].split(" ").map(n=>parseInt(n));
    const low = arg[3].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    let cnt = 0;
    
    for(let i in mid) {
        let topNum = lower_bound(top, mid[i]);
        let lowNum = low.length - upper_bound(low, mid[i]);

        cnt += topNum * lowNum;
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 60144
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  vector< vector<long long> > edges(N, vector<long long>(0));
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edges[a].push_back(H[b]);
    edges[b].push_back(H[a]);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    long long h = H[i];
    bool flag = true;
    for (auto tgt_h : edges[i]) {
      if (tgt_h >= h) flag = false;
    }
    if (flag) ans++; 
  }

  cout << ans << endl;
}


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, K; cin >> N >> K;
	ll ans = K;
	for (int i = 1; i < N;i++) {
		ans *= (K - 1);
	}
	cout << ans << endl;
}



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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll n,h,w;
  ll ans = 0;
  cin >> n >> h >> w;
  rep(i,n)rep(j,n){
    if(i+h <= n && j+w <= n) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

double mdistance(vector<int> x, vector<int> y, double p) {
    /* Minkowski distance */
    double d=0;
    size_t n=x.size();

    if (p < INFINITY) {
        for (size_t i=0; i<n; ++i)
            d += pow(abs(x[i]-y[i]), p);

        d = pow(d, 1.0/p);
    } else {
        // Chebyshew distance
        for (size_t i=0; i<n; ++i)
            d = max(d, 1.0*abs(x[i]-y[i]));
    }

    return d;
}

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

    vector<int> x(n), y(n);

    for (size_t i=0; i<n; ++i)
        scanf("%d", &x[i]);

    for (size_t i=0; i<n; ++i)
        scanf("%d", &y[i]);

    for (size_t i=1; i<=3; ++i)
        printf("%.12f\n", mdistance(x, y, i));

    printf("%.12f\n", mdistance(x, y, INFINITY));
    return 0;
}

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

using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){
		int map[5][5];
		int i = 25;
		while(i--){
			cin >> *(*map+i);
		}
		cin.ignore();
		int smax = 0;
		for(int j = 0; j < 25; ++j){
			for(int k = 0; k < 25; ++k){
				int x,y,u,v;
				x = j/5;
				y = j%5;
				u = k/5;
				v = k%5;
				bool f = 0;
				for(int _x = min(x,u); _x <= max(x,u); ++_x){
					for(int _y = min(y,v); _y <= max(y,v); ++_y){
						if(map[_x][_y] == 0){
							f = 1;
						}
					}
				}
				if(!f){
					smax = max(smax, abs((x-u+1)*(y-v+1)));
				}
			}
		}
		cout << smax << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
string S;

void solve(){
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

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

  int len = 0;
  char c;
  for (int i = 0; i < s.length(); ++i)
  {
    if (s[i] != '1')
    {
      c = s[i];
      break;
    }
    ++len;
  }

  int k;
  cin >> k;

  if (k > len)
    cout << c << endl;
  else
    cout << '1' << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

int main() {
    int N;
    cin >> N;
    map<int, int> cnt;
    rep(i, N) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    if (cnt.find(0) == cnt.end()) {
        if (cnt[1] != 2) {
            cout << 0 << endl;
            return 0;
        }

        int prev = 1;
        for (auto c: cnt) {
            if (c.first == 1) continue;
            if (c.first != prev + 2 || c.second != 2) {
                cout << 0 << endl;
                return 0;
            }
            prev = c.first;
        }
    } else {
        if (cnt[0] != 1) {
            cout << 0 << endl;
            return 0;
        }

        int prev = 0;
        for (auto c: cnt) {
            if (c.first == 0) continue;
            if (c.first != prev + 2 || c.second != 2) {
                cout << 0 << endl;
                return 0;
            }
            prev = c.first;
        }
    }

    mint ans = 1;
    for (auto c :cnt) {
        if (c.first == 0) continue;
        ans *= 2;
    }

    cout << ans.x << endl;
}

Measured memory_bytes: 4736
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll a, b; cin >> a >> b;
	if (b >= a) {
		cout << "unsafe";
	} else {
		cout << "safe";
	}

	return 0;
}

/*

*/

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		System.out.println(z + " " + x + " " + y );
	}
}


Measured memory_bytes: 39340
Ans_list = []
Ans = 0

N,M = map(int, input().split())
for i in range(N):
  KA = list(map(int, input().split()))
  Mylist = KA[1:]
  for j in range(len(Mylist)):
      Ans_list.append(Mylist[j])
for i in range(M+1):
  if Ans_list.count(i)==N:
    Ans += 1
print(Ans)
  


Measured memory_bytes: 3060
mat = []
 
for i in range(3):
  a = list(map(int, input().split()))
  mat.append(a)

ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] and mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True
 
if ans:
  print("Yes")
else:
  print("No")


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

void solve()
{
	ll n, k;
	cin >> n >> k;
	
	int a[n];
	for(int i = 0; i<n; i++) 
	{
		cin >> a[i];
		a[i]--;
	}
	
	set<int> visited;
	visited.insert(0);
	int nx = a[0], turns = 0;
	int t[n], cycle = 1;
	t[0] = 0;
	int e = k;
	
	while(e--)
	{
		if(visited.find(nx) == visited.end())
			visited.insert(nx);
		else
		{
			cycle = turns - t[nx] +1;
			break;
		}
		turns++;
		t[nx] = turns;
		nx = a[nx];
	}
	//for(int x :t) cout << x << endl;
	if(k<=turns)
	{
		nx = a[0];
		k--;
		while(k--)
		{
			nx = a[nx];
		}
		cout << nx+1 << "\n";
	}
	else
	{
		nx = a[0];
		k-=turns; k%=cycle;
		turns--;
		while(turns-->0)
		{
			nx = a[nx];
		}
		while(k-->0)
		{
			nx = a[nx];
		}
		cout << nx+1 << "\n";	
	}
}

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



Measured memory_bytes: 12632
#include <iostream>
using namespace std;
struct Dice {
	int V[6];
	void role(char c) {
		int a;
		if (c == 'E') {
			a = V[0];
			V[0] = V[3];
			V[3] = V[5];
			V[5] = V[2];
			V[2] = a;
		}
		if (c == 'N') {
			a = V[0];
			V[0] = V[1];
			V[1] = V[5];
			V[5] = V[4];
			V[4] = a;
		}
		if (c == 'S') {
			a = V[0];
			V[0] = V[4];
			V[4] = V[5];
			V[5] = V[1];
			V[1] = a;
		}
		if (c == 'W') {
			a = V[0];
			V[0] = V[2];
			V[2] = V[5];
			V[5] = V[3];
			V[3] = a;
		}
		if (c == 'R') {
			a = V[1];
			V[1] = V[2];
			V[2] = V[4];
			V[4] = V[3];
			V[3] = a;
		}
	}
	int top() {
		return V[0];
	}
	int right() {
		return V[2];
	}
	int left() {
		return V[3];
	}
	int front() {
		return V[1];
	}
	int back() {
		return V[4];
	}
	int bottom() {
		return V[5];
	}
};

int main() {
	Dice d;
	for (int i = 0; i < 6; i++)
		cin >> d.V[i];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (d.left() == x)
			d.role('E');
		if (d.right() == x)
			d.role('W');
		while (d.top() != x)
			d.role('S');
		while (d.front() != y)
			d.role('R');
		cout << d.right() << endl;
	}
}


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

const int mod=1e9+7;
int main()
{
//	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	int n,m;
	cin>>n>>m;
	vector<string> mat(n);
	for(int i=0;i<n;i++)
	{
		cin>>mat[i];
	}
	vector<vector<int>> dp(n,vector<int> (m));
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(mat[i][j]=='.')
			{
				if(i-1>=0)
					dp[i][j]=(dp[i][j]%mod+(dp[i-1][j])%mod)%mod;
				if(j-1>=0)
					dp[i][j]=(dp[i][j]%mod+(dp[i][j-1])%mod)%mod;
			}
		}
	}
	cout<<dp[n-1][m-1]%mod<<'\n';
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;
    
    string s;
    cin >> s;
    set<char> se;

    for (auto c : s)
        se.emplace(c);

    if (se.size() == 26)
        cout << "None" << endl;
    else
        for (char c = 'a'; c <= 'z'; ++c)
        {
            if (se.count(c) == 0)
            {
                cout << c << endl;
                break;
            }
        }

}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip> 
typedef long long ll;

using namespace std;

int main()
{
	int n;

	cin>>n;
  double ans = 0;
  for (size_t i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      ans += 1;
    }
  }

	cout << setprecision(15) << ans / n;

	return 0;
}


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

struct card {
	char suit;
	int num;
};

void BubbleSort(card *B, int N);
void SelectionSort(card *S, int N);


int main()
{
	int N;
	cin >> N;
	card C[N];
	for (int i = 0; i < N; i++) {
		cin >> C[i].suit >> C[i].num;
	}

	card B[N];
	card S[N];
	for (int i = 0; i < N; i++) {
		B[i] = C[i];
		S[i] = C[i];
	}

	bool isstable = true;

	BubbleSort(B,N);
	SelectionSort(S,N);


	for (int i = 0; i < N; i++) {
		if (B[i].suit != S[i].suit)
			isstable = false;

		cout << B[i].suit << B[i].num;
		if (i != N-1)
			cout << ' ';
		else
			cout << '\n';
	}

	cout << "Stable\n";

	for (int i = 0; i < N; i++) {
		cout << S[i].suit << S[i].num;
		if (i != N-1)
			cout << ' ';
		else
			cout << '\n';
	}

	if (isstable)
		cout << "Stable\n";
	else
		cout << "Not stable\n";

	return 0;
}

void BubbleSort(card *B, int N)
{
	bool flag = true;

	while (flag) {
		flag = false;
		for (int i = N-1; i >= 1; i--) {
			if (B[i].num < B[i-1].num) {
				swap(B[i],B[i-1]);
				flag = true;
			}
		}
	}

	return;
}

void SelectionSort(card *S, int N)
{
	int min;

	for (int i = 0; i <= N-1; i++) {
		min = i;
		
		for (int j = i; j <= N-1; j++) {
			if (S[min].num > S[j].num)
				min = j;
		}
		if (min != i)
			swap(S[min],S[i]);
	}
	return;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

int main()
{
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;

  if (S == U) --A;
  else --B;

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        cout<<"ACL";
    }
    cout<<"\n";
}

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

int main(){
	string s;

	cin >> s;

	int len = (int)(s.length());
	if(s[len-1] != 's'){
		cout << s << "s";
	}
	else{
		cout << s << "es";
	}

	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
    long i,j,t,a,b,n,c,temp,m;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>n;
       temp=0;
       long arr[n];
       long e=0;
       for(i=0;i<n;i++)
       {
         cin>>arr[i];
         if(arr[i]%4==0)temp++;
         else if(arr[i]%2==0)e++;
       }
       e=e/2;
       temp=temp+e;
       if(temp>=n/2)cout<<"Yes";
       else cout<<"No";
      
    }
}

Measured memory_bytes: 1024
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* (ls)
    (push (read) ls)
    (push (read) ls)
    (push (read) ls)
    (setf ls (sort ls #'<))
    (println (* 1/2 (first ls) (second ls)))))

#-swank(main)


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

const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;

int N, M;
int a[MAXN], b[MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
	for (int i = 0; i < M; i++)
		scanf("%d", b + i);
}

void move(int *arr, int &ptr, int val) {
	while (ptr && arr[ptr - 1] >= val)
		ptr--;
}

void mult(int &x, int y) {
	x = (long long)x * y % MOD;
}

bool bad(int *arr, int n) {
	for (int i = 1; i < n; i++)
		if (arr[i] == arr[i - 1])
			return true;
	return false;
}

int solve() {
	sort(a, a + N);
	sort(b, b + M);
	
	if (bad(a, N) || bad(b, M))
		return 0;
	
	int sol = 1;
	int ptrA = N, ptrB = M;
	for (int i = N * M; i; i--) {
		move(a, ptrA, i);
		move(b, ptrB, i);
		if (a[ptrA] < i || b[ptrB] < i)
			return 0;
		if (a[ptrA] > i && b[ptrB] > i)
			mult(sol, (N - ptrA) * (M - ptrB) - N * M + i);
		else if (a[ptrA] > i)
			mult(sol, N - ptrA);
		else if (b[ptrB] > i)
			mult(sol, M - ptrB);
	}
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int hour=0, minute=0, second=0;
    int inSecond = scan.nextInt();

    minute = inSecond / 60;
    second = inSecond % 60;
    hour   = minute / 60;
    minute = minute % 60;

    System.out.println(hour+":"+minute+":"+second);
    
  }
}

Measured memory_bytes: 26240
nk = input().rstrip().split(" ")
n = int(nk[0])
k = int(nk[1])
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
res = h[-1] - h[0]
for i in range(n - k + 1):
    res = min(res, h[i + k - 1] - h[i])
print(res)


Measured memory_bytes: 7384
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int[] ans=new int[s.length()];
		int count=1;
		int in=0;
		for(int i=0; i<s.length()-1; i++){
			if(s.charAt(i)=='L' && s.charAt(i+1)=='R'){
				ans[in]=count;
				count=1;
				continue;
			}
			if(s.charAt(i)=='R' && s.charAt(i+1)=='L'){
				ans[i]=count;
				in=i+1;
				count=1;
			}else{
				count++;
			}
		}
		ans[in]=count;
		for(int i=0; i<s.length()-1; i++){
			if(s.charAt(i)=='R' && s.charAt(i+1)=='L'){
				if(ans[i]!=ans[i+1]){
					int t=(ans[i]+ans[i+1])/2;
					int y=ans[i]+ans[i+1]-t;
					if(ans[i]>ans[i+1]){
						if(ans[i]%2==0){
							ans[i]=t;
							ans[i+1]=y;
						}else{
							ans[i]=y;
							ans[i+1]=t;
						}
					}else{
						if(ans[i+1]%2==0){
							ans[i+1]=t;
							ans[i]=y;
						}else{
							ans[i+1]=y;
							ans[i]=t;
						}
					}
				}
			}
			System.out.print(ans[i]+" ");
		}
		System.out.print(ans[s.length()-1]);
	}
}


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

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

  if (S[0] == S[1]){
    cout << "Bad" << endl;
  } else if(S[1] == S[2]){
    cout << "Bad" << endl;
  } else if(S[2] == S[3]){
    cout << "Bad" << endl;
  } else{
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
ans = 'WA'
if(S[0] == 'A' and S[2:-1].count('C') == 1):
  index_C = S.find('C')
  if(S[1:index_C].islower() and S[index_C+1:].islower()):
    ans = 'AC'
print(ans)

Measured memory_bytes: 3060
def calc(S, T):
    U = [(S[0], 1)]
    un = 0
    for i in range(1, len(S)):
        if U[un][0] == S[i]:
            U[un] = (U[un][0], U[un][1] + 1)
        else:
            U += [(S[i], 1)]
            un += 1
    if un == 0:
        return (U[0][1] * T) // 2
    else:
        if U[0][0] != U[un][0]:
            return sum([u[1] // 2 for u in U]) * T
        else:
            return U[0][1] // 2 + U[un][1] // 2 \
                + (U[0][1] + U[un][1]) // 2 * (T - 1) \
                + sum([u[1] // 2 for u in U[1:un]]) * T


S = input()
T = int(input())
print(calc(S, T))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

class UnionFind
{
public:
    ll n;
    lvector uf;
    UnionFind(ll N);
    //~UnionFind();
    ll find(ll x);
    ll size(ll x) {return -(*this).uf[(*this).find(x)];}
    void unite(ll x, ll y);
};

UnionFind::UnionFind(ll N)
{
  (*this).n=N;
  rep(i,n) (*this).uf.emplace_back(-1);
}

ll UnionFind::find(ll x)
{
  if((*this).uf[x]<0) return x;
  (*this).uf[x]=(*this).find((*this).uf[x]);
  return (*this).uf[x];
}

void UnionFind::unite(ll x, ll y)
{
  x=(*this).find(x);
  y=(*this).find(y);
  if(x==y) return;
  if((*this).size(x)>(*this).size(y)) swap(x,y);
  (*this).uf[y]+=(*this).uf[x];
  (*this).uf[x]=y;
  (*this).n-=1;
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,x,y,z,ans=n;cin>>n>>m;
  UnionFind un(n);
  rep(i,m) {
    cin>>x>>y>>z;x--,y--;
    un.unite(x,y);
  }
  set<ll> st;
  rep(i,n) st.insert(un.find(i));
  print(st.size());
  return 0;
}

Measured memory_bytes: 5748