akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  int ans=0;
  rep(i,n) {
      int cnt=0;
      for (int j = 0; j <= i; j++) cnt += a[j]; 
      for(int k = i; k < n; k++) cnt += b[k];
      ans = max(ans,cnt);
  }
  cout << ans << endl;
}

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

const ll inf = 1e9+5;

int32_t main(){
	ll n,w;
    cin>>n>>w;
    ll p[n], wt[n];
    for(ll i = 0;i < n;i++) cin>>wt[i]>>p[i];
    ll dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    for(ll i = 1;i <= n;i++) {
        for(ll j = 1;j <= w;j++) {
            if(wt[i-1] <= j) dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt[i-1]] + p[i-1]);
            else dp[i][j] = dp[i-1][j];
        } 
    }
    cout<<dp[n][w]<<endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    vector<int> l(n);
    REP(i, n) { cin >> l[i]; }
    int a, b, c;
    int ans=0;
    sort(ALL(l));
    REP(i,n-2)FOR(j,i+1,n-1)FOR(k,j+1,n){
        a = l[i], b = l[j], c = l[k];
        ans+=(a + b > c);
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



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



	//数字の文字列をint型に一文字ずつ変換するラムダ式
	auto strTOint = [&](char c){
		return c - '0';
	};
	vector<int> a(s.size());
		REP(i,s.size()){
	     a[i] = strTOint(s[i]);
	}

  int ans = 0;
  REP(key,1000){
    bool ok = false;
    int key1 = key/100;
    int key2 = (key-key1*100)/10;
    int key3 = key-key1*100-key2*10;
    //cout << key << endl;
    //cout << key1 << key2 << key3 << endl;
    int f1 = find(a.begin() , a.end(), key1) - a.begin();
    if (f1 == n) continue;
    int f2 = find(a.begin() + f1 +1, a.end(), key2) -  a.begin();
    if (f2 == n) continue;
    int f3 = find(a.begin() + f2 + 1, a.end(), key3) - a.begin();
    if(f3 != n){
      ++ans;
    }
}

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


Measured memory_bytes: 3708
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Measured memory_bytes: 3060
n, m = map(int,input().split())

k = []
s_l = []
for _ in range(m):
    l = list(map(int, input().split()))
    k.append(l[0])
    s_l.append(l[1:])

p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    valid = 1
    for j in range(m):
        on = 0
        for s in s_l[j]:
            on += (i >> (s-1) & 1)
        if on % 2 == p[j]:
            valid *= 1
        else:
            valid *= 0
    ans += valid

print(ans)





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

int main()
{
	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
#include <bits/stdc++.h>

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int a,b;
    cin>>a>>b;

    int ans=ceil(a*1.0/b);

    cout<<ans;


    return 0;
}


Measured memory_bytes: 3728
import itertools

n = int(input())
cnts = {}
for c in list('MARCH'):
  cnts[c] = 0
for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    cnts[s[0]] += 1

answer = 0
for a,b,c in itertools.combinations(list('MARCH'), 3):
  answer += cnts[a] * cnts[b] * cnts[c]

print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    vector<int> v(n);
    rep(i, n) v[i] = i + 1;

    int a, b;
    int cnt = 0;
    do {
        bool pp = true,qq=true;
        rep(i, n) {
            if (p[i] != v[i]) pp = false;
            if (q[i] != v[i]) qq = false;
        }
        if (pp) a = cnt;
        if (qq) b = cnt;
        cnt++;
    } while (next_permutation(all(v)));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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



int n, cnt[100005];


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

    cin>>n;
    while(n--){
    	int a;
    	cin>>a;
    	cnt[a]++;
    }

    int ans = 0, z = 0;;
    for(int i=1;i<=100000;i++){
    	if(cnt[i] == 0)	continue;
    	ans++;
    	cnt[i] %= 2;
    	if(cnt[i] == 0)	z++;
    }

    if(z % 2 == 1)	ans--;
    cout<<ans;
    return 0;
}








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

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

    map<string,int> mp;
    while(t--){
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int i;
		int j;
		int k;
		long sum = 0;
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				for (k = 1; k <= n; k++) {
					sum += gcd(gcd(i,j),k);
				}

			}

		}

		System.out.println(sum);

	}

	public static int gcd(int m, int n) {
		int r;
		while (n > 0) {
			r = m % n;
			m = n;
			n = r;
		}
		return m;
	}
}


Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main(void)
{
    map<ull, ull> cnt;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        cnt[t]++;
    }

    ull rem = 0;
    for (auto const &p: cnt) {
        if (p.second < p.first) rem += p.second;
        else                    rem += p.second - p.first;
    }

    cout << rem << endl;
    
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector <pair <int, int>> vp(n);
    
    int a = 0;
    int b = 0;
    for (int i = 0; i < n; ++i){
//        cin >> a >> b;
//        vp[i] = make_pair(a, b);
        cin >> vp[i].first >> vp[i].second; //price, num
    }

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

    long now_price = 0;
    int now_num = 0;
    bool end_flag = false;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < vp[i].second; ++j){
            now_price += vp[i].first;
            now_num += 1;

            if (now_num>=m){
                cout << now_price << endl;
                end_flag = true;
                break;
            }
        }
        if (end_flag){
            break;
        }
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
#define PI 3.14159265359
 
int main(){
    int n;
    bool ans = false;
    cin >> n;
    rep(i,n/4 + 1){
        if((n - 4*i)%7 == 0) ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// sando: 0+N
// katsu: 100000+N
// karee: 200000+N
// katsusan: 300000+N
// katsukare: 400000+N

int         x, y, z, n, m, s, t;
vector<int> G[500005];
int         dist[500005];

void addedge(int u, int v) {
    G[u].push_back(v), G[v].push_back(u);
    // cout << u << "<->" << v << endl;
}

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

    cin >> x >> y >> z >> n >> m >> s >> t;
    s = 300000 + s - 1;
    t = 400000 + t - 1;

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        addedge(0 + a, 300000 + i);
        addedge(100000 + b, 300000 + i);
    }
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        addedge(100000 + b, 400000 + i);
        addedge(200000 + c, 400000 + i);
    }
    for (int i = 0; i < 500000; i++)
        dist[i] = 0x3f3f3f3f;
    dist[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int t = q.front();
        // cout << "Vis " << t << endl;
        q.pop();
        for (int h : G[t])
            if (dist[h] > dist[t] + 1) {
                dist[h] = dist[t] + 1;
                q.push(h);
            }
    }
    if (dist[t] == 0x3f3f3f3f)
        cout << -1 << endl;
    else
        cout << dist[t] / 2 << endl;
}


Measured memory_bytes: 30744
n = gets.chomp.to_i

def me(a)
  (a.size % 2).zero? ? a[a.size/2 - 1, 2].inject(:+) / 2.0 : a[a.size/2]
end

aa = []
bb = []

n.times do
  aaa, bbb = gets.chomp.split.map(&:to_i)
  aa.push(aaa)
  bb.push(bbb)
end

aa.sort!
bb.sort!

ac = me(aa)
bc = me(bb)

if n.odd?
  p (bc - ac + 1)
  exit
end

ac *= 2
bc *= 2
p (bc - ac + 1).to_i


Measured memory_bytes: 20488
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  namespace mp = boost::multiprecision;
  cpp_dec_float_1000 a, b, c; cin >> a >> b >> c;
  cpp_dec_float_1000 ma = mp::sqrt(a);
  cpp_dec_float_1000 mb = mp::sqrt(b);
  cpp_dec_float_1000 mc = mp::sqrt(c);
  auto res = (ma + mb) < mc;
  auto ans = res ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 512
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

#ifdef __GNUC__
#define int128_t __int128
#else
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::int128_t int128_t;
#endif

typedef long long LL;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL _t1 = -1, _t2, _a1, _a2, _b1, _b2;
		cin >> _t1 >> _t2 >> _a1 >> _a2 >> _b1 >> _b2;
		if (_t1 < 0) return 0;
		int128_t t1 = _t1, t2 = _t2, a1 = _a1, a2 = _a2, b1 = _b1, b2 = _b2;
		int128_t p = (a1 - b1) * t1, q = (a2 - b2) * t2;
		if (p < 0) {
			p = -p, q = -q;
		}
		if (p + q == 0) {
			cout << "infinity" << endl;
		} else {
			LL ans = 0;
			if (p + q < 0) {
				int128_t r = p / -(p + q), s = p % -(p + q);
				ans = (LL)r * 2 + (s != 0);
			}
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
//#define random_shuffle(r...) random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
ll prime[1000000];bool visprime[10000000];
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}
int myrandom (int i) { return std::rand()%i;}

bool checkbit(int mask,int bit) {return (mask & (1<<bit));}

int main()
{

   int n;
   cin>>n;
   string x;
   cin>>x;
   bool flag=true;
   if(n&1) return cout<<"No"<<endl,0;
   for(int i=0,j=n/2;j<n;i++,j++)
   {
       if(x[i]!=x[j]) {flag=false; break;}
   }
   if(flag==true) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}
















Measured memory_bytes: 256
chars = [chr(i) for i in range(ord('a'), ord('z') + 1)]

arr = []

x = int(input())

while True:
    s = x % 26
    arr.append(s)

    t = (x - 1) // 26
    # print("s,t", s, t)
    if t == 0:
        break
    x = t

# print('arr', arr)

ans = ""
for t in arr:
    if t == 0:
        ans += 'z'
    else:
        ans += chars[t - 1]

ans = ans[::-1]
print(ans)


Measured memory_bytes: 9104
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
char s[N];

int main()
{
	scanf("%s",s);
	int len = strlen(s);
	int cnt = len - 2;
	if (s[0] == s[len - 1])
	{
		if (cnt % 2) puts("Second");
		else puts("First");
	}
	else
	{
		if (cnt % 2 == 0) puts("Second");
		else puts("First");
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

#define REP(i, n) for(int i=0; i<n; i++)
#define VREP(v, vec) for(auto& v : vec)
#define ALL(vec) vec.begin(), vec.end()
#define SUM(vec) accumulate(ALL(vec), 0)

using namespace std;
typedef long long ll;


int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> A;

	REP(i, N) {
		ll tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

	ll total = SUM(A);
	vector<ll> candidate;

	for (ll i = 1; i * i <= total; i++) {
		if (total % i == 0) {
			candidate.push_back(i);
			candidate.push_back(total / i);
		}
	}

	ll ans = 0;

	VREP(v, candidate) {
		vector<ll> d;
		VREP(a, A) d.push_back(a % v);
		sort(ALL(d));
		ll j = N - SUM(d) / v;
		ll t = 0;
		REP(i, j) t += d[i];
		if (t <= K) ans = max(ans, v);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  vector<Int> xs(n),ys(n);
  vector<char> us(n);
  for(Int i=0;i<n;i++)
    cin>>xs[i]>>ys[i]>>us[i];

  const Int INF = 1e18;
  Int ans=INF;

  const Int MAX = 5e5;
  // > <
  {
    set<Int> ss[MAX];
    for(Int i=0;i<n;i++)
      if(us[i]=='L') ss[ys[i]].emplace(xs[i]);

    for(Int i=0;i<n;i++){
      if(us[i]!='R') continue;
      auto it=ss[ys[i]].upper_bound(xs[i]);
      if(it==ss[ys[i]].end()) continue;
      chmin(ans,(*it-xs[i])*10/2);
    }
  }


  // v
  // ^
  {
    set<Int> ss[MAX];
    for(Int i=0;i<n;i++)
      if(us[i]=='D') ss[xs[i]].emplace(ys[i]);

    for(Int i=0;i<n;i++){
      if(us[i]!='U') continue;
      auto it=ss[xs[i]].upper_bound(ys[i]);
      if(it==ss[xs[i]].end()) continue;
      chmin(ans,(*it-ys[i])*10/2);
    }
  }


  // >
  //   ^
  {
    set<Int> ss[MAX];
    for(Int i=0;i<n;i++)
      if(us[i]=='U') ss[xs[i]+ys[i]].emplace(xs[i]);

    for(Int i=0;i<n;i++){
      if(us[i]!='R') continue;
      auto it=ss[xs[i]+ys[i]].upper_bound(xs[i]);
      if(it==ss[xs[i]+ys[i]].end()) continue;
      chmin(ans,(*it-xs[i])*10);
    }
  }


  // v
  //   <
  {
    set<Int> ss[MAX];
    for(Int i=0;i<n;i++)
      if(us[i]=='L') ss[xs[i]+ys[i]].emplace(xs[i]);

    for(Int i=0;i<n;i++){
      if(us[i]!='D') continue;
      auto it=ss[xs[i]+ys[i]].upper_bound(xs[i]);
      if(it==ss[xs[i]+ys[i]].end()) continue;
      chmin(ans,(*it-xs[i])*10);
    }
  }


  //   v
  // >
  {
    const Int OFS = MAX/2;
    set<Int> ss[MAX];
    for(Int i=0;i<n;i++)
      if(us[i]=='D') ss[OFS+xs[i]-ys[i]].emplace(xs[i]);

    for(Int i=0;i<n;i++){
      if(us[i]!='R') continue;
      auto it=ss[OFS+xs[i]-ys[i]].upper_bound(xs[i]);
      if(it==ss[OFS+xs[i]-ys[i]].end()) continue;
      chmin(ans,(*it-xs[i])*10);
    }
  }


  //  <
  // ^
  {
    const Int OFS = MAX/2;
    set<Int> ss[MAX];
    for(Int i=0;i<n;i++)
      if(us[i]=='L') ss[OFS+xs[i]-ys[i]].emplace(xs[i]);

    for(Int i=0;i<n;i++){
      if(us[i]!='U') continue;
      auto it=ss[OFS+xs[i]-ys[i]].upper_bound(xs[i]);
      if(it==ss[OFS+xs[i]-ys[i]].end()) continue;
      chmin(ans,(*it-xs[i])*10);
    }
  }


  if(ans==INF) drop("SAFE");
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 39304
function main(input) {
    const row = input.split("\n")
    const ary = row[0].split(" ").map(v => parseInt(v))
    if (ary[0] === ary[1] && ary[1] === ary[2]) {
        console.log("Yes")
    } else {
        console.log("No")
    }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21952
#include <iostream>
using namespace std;
int main(void)
{
    int x;
    int y;
    while(1){
    cin>>x>>y;
    if(x==0&&y==0)  break;
    else if(x>y)    cout<<y<<" "<<x<<endl;
    else    cout<<x<<" "<<y<<endl;
    }
}


Measured memory_bytes: 3004
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n; cin >> n;
  lint ans= 0;
  for (lint a = 1; a <= n; a++) {
    for (lint b = 1; b * a <= n; b++) {
      lint c = n - a * b;
      if (c > 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3192
nlist =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(nlist[k-1])

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

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

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

using namespace std;

typedef long long int lint;

const int NMAX = 100000 + 5;

int N;
int A[NMAX];
int _A[NMAX];
map <int, bool> color;

int main()
{
    cin >> N;
    for (int i = 1; i <= N; ++ i) {
        cin >> A[i];
        _A[i] = A[i];
    }
    sort(_A + 1, _A + N + 1);
    for (int i = 1; i <= N; ++ i)
        color[_A[i]] = i % 2;
    for (int i = 1; i <= N; ++ i)
        A[i] = color[A[i]];

    int ans = 0;
    for (int i = 1; i <= N; ++ i)
        ans += ((i % 2) ^ A[i]);
    cout << ans / 2 << '\n';
    return 0;
}


Measured memory_bytes: 5760
coin=[]
for i in range(4):
	coin.append(int(input()))
count=0
for i in range(coin[0]+1):
	for j in range(coin[1]+1):
		for k in range(coin[2]+1):
			if i*500+j*100+k*50==coin[3]:
				count+=1
print(count)
	

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

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

	map<string, int> appeareance_time;
	vector<string> siritori;
	rep(i, N) {
		string s;
		cin >> s;

		if (appeareance_time[s] != 0) {
			cout << "No" << endl;
			return 0;
		}

		appeareance_time[s]++;
		siritori.push_back(s);
	}

	REP(i, 1, N) {
		if (siritori[i][0] != siritori[i-1][siritori[i-1].size()-1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

long long choose2(long long n) {
    return (n*(n-1)/2);
}

int main() {
    long long n;
    cin >> n;
    vector<int> s(n);
    map<int, int> cnt;
    long long total = 0;

    for (int i=0; i<n; i++) {
        cin >> s[i];
        s[i]--;
    }

    for (int i=0; i<n; i++)
        cnt[s[i]]++;

    for (int i=0; i<n; i++)
        total += choose2(cnt[i]);

    for (int i=0; i<n; i++) {
        long long ans = total;
        ans -= choose2(cnt[s[i]]);
        ans += choose2(cnt[s[i]]-1);
        cout << ans << endl;
    }
    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

lint gcd(lint a, lint b)
{
    if (a < b)
        return gcd(b, a);
    lint r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main()
{

    lint a,b;
    cin >> a >> b;


    lint ans=0, g;

    g = gcd(a, b);

    map<lint, lint> c;
    lint m = g,n=g;
    lint i = 2;

    while (m >= i * i)
    {
        if (n % i == 0)
        {
            if (c.count(i))
            {
                c[i] = c.at(i) + 1;
            }
            else
            {
                c[i] = 1;
            }
            n /= i;
        }
        else
        {
            i++;
        }
    }
    if(n!=1){
        if (c.count(i))
        {
            c[n] = c.at(n) + 1;
        }
        else
        {
            c[n] = 1;
        }
    }
    i = 0;
    int x = 0;
    while (m >= i * i)
    {
        if (c.count(i))
        {
            //cout << i << c.at(i) << "\n";
            //ans += c.at(i)-1;
            x += 1;
            //tmp = (pow(i, c.at(i) + 1) - 1) / (i - 1);
            //ans *= tmp;
        }
        i++;
    }
    if (n != 1)
    {
        //cout << n << c.at(n) << "\n";
        x += 1;
    }


    cout << x  +1<< "\n";

    return 0;
}

Measured memory_bytes: 256
#![allow(dead_code)]
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    // idx[p[i]] = i
    let idx = {
        let mut idx: Vec<usize> = vec![0; n];
        for i in 0..n {
            let p: usize = sc.read();
            idx[p - 1] = i;
        }
        idx
    };
    
    let mut p_i = 0;

    // l_i[j] = max{k| k<j, p[k]>p_i}
    // r_i[j] = min{k| k>j, p[k]>p_i}
    let mut l_i: Vec<_> = vec![None];
    l_i.extend((0..n - 1).map(Some));
    let mut r_i: Vec<_> = (1..n).map(Some).collect();
    r_i.push(None);

    let mut ans = 0;
    while p_i < n {
        let i = idx[p_i];

        let mut l  = -1;
        let mut l2 = -1;
        if let Some(_l) = l_i[i] {
            if let Some(_l2) = l_i[_l] {
                l2 = _l2 as isize;
            }
            l = _l as isize;
        }

        let mut r  = n as isize;
        let mut r2 = n as isize;
        if let Some(_r) = r_i[i] {
            if let Some(_r2) = r_i[_r] {
                r2 = _r2 as isize;
            }
            r = _r as isize;
        }

        let i = i as isize;
        let c_i = (l-l2) * (r-i) + (r2-r) * (i-l);
        ans += (p_i+1) * c_i as usize;

        p_i += 1;

        // l_i <- l_(idx[p_i+1])
        // r_i <- r_(idx[p_i+1])
        if l >= 0 {
            r_i[l as usize] = if r < n as isize {
                Some(r as usize)
            } else {
                None
            }
        }
        if r < n as isize {
            l_i[r as usize] = if l >= 0 {
                Some(l as usize)
            } else {
                None
            }
        }
    }

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
   assert_eq!(solve("3\n2 3 1\n"), "5\n");
   assert_eq!(solve("5\n1 2 3 4 5\n"), "30\n");
   assert_eq!(solve("8\n8 2 7 3 4 5 6 1\n"), "136\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}


Measured memory_bytes: 12540
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);

		long ans = 0;
		for (int i = 0; i < n; i++) {
			long idxa = binarySearch(a, b[i] - 0.5);
			long idxc = binarySearch(c, b[i] + 0.5);
			ans += idxa * (n - idxc);
		}
		System.out.println(ans);
	}

	static int binarySearch(int[] array, double val) {
		int ng = -1;
		int ok = array.length;

		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] >= val) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		return ok;
	}
}


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

using namespace std;

const int N = 105;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int x, y;
    cin >> x >> y;
    if(y & 1) return cout << "No\n", 0;
    for(int i = 0; i <= y / 2; ++i) {
        int u = y - i * 2;
        if(u % 4) continue;
        u /= 4;
        if(u + i == x) return cout << "Yes\n", 0;
    }
    cout << "No\n";
}


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

int selectionSort(int A[], int N) {
    int swap_cnt = 0;

    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(A[i], A[minj]);
            swap_cnt++;
        }
    }
    return swap_cnt;
}

int main() {
    int A[100], N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int swap_cnt = selectionSort(A, N);

    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i < N-1) cout << " ";
    }
    cout << "\n";
    cout << swap_cnt << endl;
    return 0;
}


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

char a[51][51], b[51][51];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, n)scanf("%s", a[i]);
	rep(i, m)scanf("%s", b[i]);
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool ok = true;
			rep(k, m)rep(l, m) {
				if (b[k][l] != a[i + k][j + l])ok = false;
			}
			if (ok) {
				puts("Yes"); return 0;
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

judge :: Int -> Bool
judge n
    | even n    = False
    | otherwise = (((==) 8) . length) $ filter ( \x -> n `mod` x == 0 ) [1..n]

solver :: Int -> Int
solver n = length $ filter (\x -> judge x) [1..n]

main :: IO ()
main = do
    n <- read <$> getLine
    print $ solver n


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

int main() {
	int n;
	cin>>n;
	vector<vector<pair<int,int>>> vec(n);
	for(int i=0;i<n-1;++i)
	{
	    int temp1,temp2,temp3;
	    cin>>temp1>>temp2>>temp3;
	    vec[temp1-1].push_back(make_pair(temp2-1,temp3));
	     vec[temp2-1].push_back(make_pair(temp1-1,temp3));
	}
	
	vector<int> ans(n,0);
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	vector<int> visited(n,0);
	visited[0]=1;
	while(!q.empty())
	{
	    int temp=q.front().first;
	    int cost=q.front().second;
	    q.pop();
	    if(cost%2==0)
	    {
	        ans[temp]=0;
	    }
	    else
	    {
	        ans[temp]=1;
	    }
	    for(int i=0;i<vec[temp].size();++i)
	    {
	        if(!visited[vec[temp][i].first])
	        {
	            visited[vec[temp][i].first]=1;
	            q.push(make_pair(vec[temp][i].first,cost+vec[temp][i].second));
	        }
	    }
	}
	
	for(int i=0;i<n;++i)
	{
	    cout<<ans[i]<<" ";
	}
	
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    int ans=0;
    vector<int>a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end(),greater<int>());
    if((a[0]-a[1])%2==1&&(a[0]-a[2])%2==1){
        ans+=(a[0]-a[1]-1)/2;
        ans+=(a[0]-a[2]-1)/2;
        ans++;
    }
    else if((a[0]-a[1])%2==0&&(a[0]-a[2])%2==0){
        ans+=(a[0]-a[1])/2;
        ans+=(a[0]-a[2])/2;
    }
    else{
        ans+=(a[0]-a[1])/2;
        ans+=(a[0]-a[2])/2;
        ans+=2;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import math

d,g = map(int,input().split())

l = [list(map(int,input().split())) for i in range(d)]
ans = float("inf")

for bit in range(1<<d):
  sum = 0
  count = 0
  f = set(range(1,d+1))
  
  for i in range(d):
    if bit & (1<<i):
      sum += (i+1)*l[i][0]*100 + l[i][1]
      count += l[i][0]
      f.discard(i+1)
      
  if sum < g:
    x = max(f)
    n = min(l[x-1][0], math.ceil((g-sum)/(x*100)))
    sum += n*100*x
    count += n
    
  if sum >= g:
    ans = min(ans,count)
    
print(ans)   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    int ans[N];
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        ans[a - 1] = i + 1;
    }
    array_output(ans, ans + N);
}


Measured memory_bytes: 1920
#include <stdio.h>

int  Sort(int n, int *a){
	int f = 1, i, cou = 0, j = 0;
	
	for(j = 0; n-1 > j; j++){
		int minp, min = 101;
		for(i = j; n > i; i++){
			if(a[i] < min){
				min = a[i];
				minp = i;
			}
		}
		if(j != minp){
		int buf = a[j];
		a[j] = a[minp];
		a[minp] = buf;
		cou++;
		}
	}
	return cou;
}
int main(void) {
	int n, a[100], i;
	
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%d", &a[i]);
	}
	
	int cou = Sort(n, a);
	
	for(i = 0; n > i; i++){
		printf("%d", a[i]);
		if(n - 1 > i) printf(" ");
	}
	printf("\n%d\n", cou);
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
vector<int> a[500];
int n,m,u,v,dep,ans,dfn[500],low[500];
void tarjan(int u,int fa)
{
    dfn[u]=low[u]=++dep;
    for(int i=0;i<a[u].size();i++)
    {
        int v=a[u][i];
        if(!dfn[v])
        {
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u])
            {
                ans++;
            } 
        }else{
        	if(v!=fa)
        	{
        		low[u]=min(low[u],dfn[v]);
            }
        }
    }
}
int main()
{
    while(cin>>n>>m)
    {
        dep=ans=0;
   	 	for(int i=0;i<=n;i++)
        {
            a[i].clear();
        } 
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&u,&v);
            a[u].push_back(v);
            a[v].push_back(u);
        }
        tarjan(1,-1);
        printf("%d\n",ans);
        memset(dfn,0,sizeof(dfn));
  	 	memset(low,0,sizeof(low));
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


const int lim = 80;

int main()
{
	int n;
	cin >> n;
	rep(i, n)
	{
		int ans[128];
		memset(ans, 0, sizeof(ans));
		string a, b;
		cin >> a >> b;

		int ai = a.size()-1, bi = b.size()-1;
		for(int i = 0; ai >= 0 || bi >= 0; ai--, bi--, i++)
		{
			int as = (ai >= 0 ? a[ai] - '0' : 0), bs = (bi >= 0 ? b[bi] - '0' : 0);

			ans[i] += as + bs;
			ans[i+1] += 9 < ans[i];
			if(9 < ans[i]) ans[i] -= 10;

			if(i == lim + 4) break;
		}


		if(ans[lim] != 0 ||(lim < a.size() || lim < b.size()))
		{
			cout << "overflow" << endl;
		}
		else
		{
			int index = 0;
			rep(i, lim)
				if(ans[i] != 0)
					index = i;

			for(int i = index; i >= 0; i--)
				cout << ans[i];

			cout << endl;
		}
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
 
int main(){
    int n,m;
	int field[128000]={0};
	scanf("%d%d",&n,&m);
	rep(i,n-1){
		scanf("%d",&field[i]);
	}
	int mod = 100000;
	int res = 0;
	int now = 0;
	rep(i,m){
		int x;
		int j;
		scanf("%d",&x);
		if(x > 0){
			for(j = now;j < now+x; j++){
				if(res+field[j] >= mod)res=(res+field[j])%mod;
				else res += field[j];
			}
			now += x;
		}
		else{
			for(j = now-1;j > now+x-1; j--){
				if(res+field[j] >= mod)res=(res+field[j])%mod;
				else res += field[j];
			}
			now += x;
		}
	}
	printf("%d\n",res);
    return 0;
}

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

bool Dis[10];
int main(){
    int N, K;
    cin >> N >> K;
    for(int i=0;i<K;i++){
        int j;
        cin >> j;
        Dis[j]=true;
    }
    for(int i=N;i<10*N;i++){
        bool flg = true;
        int ii = i;
        while(ii){
            if(Dis[ii%10]) flg = false;
            ii /= 10;
        }
        if(flg){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

int N;
int A, B, C, D;
ll dp[1010];
ll comb[1010][1010];
ll t[1010][1010];

inline void add(ll &x, ll y)
{
	x += y;
	if (x >= MOD) x -= MOD;
}

int main() {
	rep(i, 1010) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
		}
	}

	cin >> N >> A >> B >> C >> D;
	dp[0] = 1;

	for (int i = A; i <= B; ++i) {
		t[i][0] = 1;
		for (int j = 1; j * i <= N; ++j) {
			t[i][j] = t[i][j-1] * comb[i * j - 1][i - 1] % MOD;
		}

		for (int j = N; j >= 0; --j) {
			if (dp[j] > 0) {
				for (int k = C; k <= D; ++k) {
					int nj = j + i * k;
					if (nj > N) {
						break;
					}
					add(dp[nj], dp[j] * comb[nj][j] % MOD * t[i][k] % MOD);
				}
			}
		}
	}

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;


void solve(long long N, long long K, std::vector<long long> A){
    map<long long, long long> cnts;
    for(auto a:A)cnts[a]++;
    auto k = (long long)cnts.size()-K;

    if(k <= 0){
        cout << 0 << endl;
    }else{
        vector<long long> values;
        for(auto &kv: cnts)values.push_back(kv.second);
        sort(values.begin(), values.end());
        cout << accumulate(values.begin(), values.begin()+k, 0l) << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 16500
#include<stdio.h>
#define lp(i,n) for(i=0;i<n;i++)
int main(){
  int i;
  int j;
  int h;
  int w;
  while(1){
    scanf("%d %d",&h, &w);
    if(h == 0 && w == 0) {break;}
    lp(i,h){
      lp(j,w){
	if(i == 0 || j == 0 || i == h - 1 || j == w - 1) {
	  printf("#");
	}
	  else {
	     printf(".");
	  }
	}
	printf("\n");
      }
      printf("\n");
    }
    return 0;
  }
    



Measured memory_bytes: 2032
#include<stdio.h>

int main(void){
    int n,i,p[21],count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(i=1;i<n-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i-1]>p[i]&&p[i]>p[i+1])){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int H,W;
string s[100];
int V;
struct edge{int to,cost;};
vector<edge> G[SIZE];
int d[SIZE];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d,d+V,INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first)continue;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

void add_edge(int i,int j,int y,int x){
	G[i*W+j].push_back((edge){y*W+x,1});
}

int main()
{
	cin >> H >> W;
	V = H*W;
	int m[4][2] = {1,0,-1,0,0,1,0,-1};
	rep(i,0,H)cin >> s[i];
	int blk = 0;
	rep(i,0,H) rep(j,0,W) {
		if(s[i][j] == '#'){
			blk++;
			continue;
		}
		rep(k,0,4) {
			int y = i+m[k][0];
			int x = j+m[k][1];
			if(y < 0 || y >= H)continue;
			if(x < 0 || x >= W)continue;
			if(s[y][x] == '.')add_edge(i,j,y,x);
		}
	}

	dijkstra(0);

	if(d[H*W-1] >= INF){
		cout << -1 << endl;
		return 0;
	}

	cout << (H*W - d[H*W-1] - 1 - blk) << endl;

	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

typedef long long ll;

void print() { std::cout << std::endl; }
template<class H> void print(H&& head) { std::cout << head << std::endl; }
template<class H, class... T> void print(H&& head, T&&... tail) {
  std::cout << head << std::endl; print(std::forward<T>(tail)...);
}

void fail() { print(0LL), std::exit(0); }

int main()
{
  ll N, K;
  std::cin >> N >> K;

  std::vector<ll> vh(N, 0LL);
  for (ll i = 0; i < N; i++) { std::cin >> vh[i]; }

  if (K >= N) fail();

  std::sort(vh.begin(), vh.end(), std::greater<>());
  ll sum = std::accumulate(vh.begin() + K, vh.end(), 0LL);
  print(sum);

  return 0;
}


Measured memory_bytes: 1920