akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: "List[int]"):
    if sum(A) >= 22:
        print('bust')
    else:
        print('win')
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    solve(A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    int tgt, N;
    cin >> tgt >> N;
    unordered_set<int> nums;
    rep(i, 0, N)
    {
        int p;
        cin >> p;
        nums.insert(p);
    }

    int diff = 0;
    for(;;)
    {
        if (nums.count(tgt-diff)==0)
        {
            cout << tgt-diff << endl;
            return 0;
        }
        if (nums.count(tgt+diff)==0)
        {
            cout << tgt+diff << endl;
            return 0;
        }
        ++diff;
    }
    return 0;
}



Measured memory_bytes: 3600
n = int(input())
s_li = [input() for x in range(n)]
from collections import Counter
c = Counter(s_li)
c = c.most_common()
tmp = c[0][1]
res = []
for x in c:
    if tmp > x[1]:
        break
    res.append(x[0])
res.sort()
for x in res:
    print(x)

Measured memory_bytes: 45068
#include <string>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int a,e,f;
	cin >> a;
	int b[a];
	int c = 0;
	double d=0,g=a;
	while (a > c) {
		cin >> b[c];
		c = c + 1;
	}
	c = 0;
	while (a > c) {
		d = d + b[c];
		c = c + 1;
	}
	d = d / g;
	f = round(d);
	c = 0;
	while (a > c) {
		e = e + (b[c] - f)*(b[c] - f);
		c = c + 1;
	}
	cout << e << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	double x[3], y[3], p, q;
	while (cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>p>>q) {
		bool f[3];
		for (int i = 0; i < 3; i++) {
			if ((x[i % 3] - p)*(y[(i + 1) % 3] - q) - (y[i % 3] - q)*(x[(i + 1) % 3] - p) <= 0)f[i] = false;
			else f[i] = true;
		}
		if (f[0]==f[1]&&f[1]==f[2])puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 3008
A, B = list(map(int, input().split()))


ans = None
for i in range(100000):
    a = int(i * 0.08)
    b = int(i * 0.1)
    if a == A and b == B:
        ans = i
        break

if ans is None:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n, k;
Vi va;
Vi divisors;

void init()
{
	cin >> n >> k;
	va.resize(n);
	REP(i, n) cin >> va[i];

	int all = accumulate(ALL(va), 0);
	int lim = (int)ceil(sqrt(all));
	REP1C(d, lim)
		if (!(all % d))
		{
			divisors.PB(d);
			divisors.PB(all / d);
		}
	sort(ALL(divisors), greater<>());
}


int main()
{
	init();

	for (int d : divisors)
	{
		Vi tmp(n);
		int s = 0;
		REP(i, n)
		{
			tmp[i] = va[i] % d;
			s += tmp[i];
		}

		if (!s)
		{
			cout << d << endl;
			return 0;
		}

		sort(ALL(tmp), greater<>());
		int piles = s / d;
		int a = 0;
		for (int i = 0; i < piles && i < SZ(tmp); ++i)
		{
			a += d - tmp[i];
		}
		if (a <= k)
		{
			cout << d << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

class DisjointSet
{
public:
    std::vector<int> rank, p;

    DisjointSet()
    {}

    DisjointSet(int size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    void makeSet(int x)
    {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)
    {
        if (rank[x] > rank[y]) {
            p[y]  =x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x)
    {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main()
{
    int n, a, b, q;
    int t;

    scanf("%d %d", &n, &q);
    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++) {
        scanf("%d %d %d", &t, &a, &b);
        if (t == 0) {
            ds.unite(a, b);
        } else if (t == 1) {
            printf("%d\n", ds.same(a, b) ? 1 : 0);
        }
    }
}


Measured memory_bytes: 2840
#include <iostream>
using namespace std;
int main(){
  int H = 0;
  int A = 0;
  cin >> H;
  int HP = H;
  cin >> A;
  int count = 0;
  while(HP > 0){
      HP = HP - A;
      count = count + 1;
  }
  cout << count << endl;
}

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

int w,h;
int d[20][20]; //y,x
int n;
int a,b;
int ans;

void solve(int x,int y){

  if(d[y][x] == -1) return;

  if(y == h && w == x){
    ans++;
    return;
  }

  if(x > w || y > h) return;

  solve(x+1,y);
  solve(x,y+1);

}

int main(){

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    memset(d,0,sizeof(d));
    ans = 0;

    cin >> n;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      d[b][a] = -1;
    }

    solve(1,1);

    cout << ans << endl;

  }
  
}

Measured memory_bytes: 1160
#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() {
    vector<int> v;
    for (int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; i++) {
        v.push_back(i * (i + 1) * (i + 2) / 6);
    }
    vector<int> dp0(1001001, INF), dp1(1001001, INF);
    dp0[0] = 0, dp1[0] = 0;
    for (int i = 1; i < 1001001; i++) {
        for (int x : v) {
            if (i - x < 0) break;
            chmin(dp0[i], dp0[i - x] + 1);
            if (x % 2 == 1) chmin(dp1[i], dp1[i - x] + 1);
        }
    }
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        cout << dp0[n] << " " << dp1[n] << endl;
    }
}


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

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

  double per = n / 2;
  if (n % 2 == 1) per++;
  per /= n;

  cout << per << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<bool> vb;

const int MAXN = 101;
const int W = 1e5+1;

ll num[MAXN][2];

ll matrix[MAXN][W]={0};

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

    int n,w; cin >> n >> w;
    for(int i=1; i<=n; i++)
        cin >> num[i][0] >> num[i][1];

    for(int i=0; i<w; i++){
        matrix[0][i] = 0;
    }
    
    for(int i=1; i<=n; i++){
        for(int j=0; j<=w; j++){
            if(num[i][0] > j){
                matrix[i][j] = matrix[i-1][j];
            }else{
                matrix[i][j] = max(matrix[i-1][j], 
                        matrix[i-1][j-num[i][0]] + num[i][1]);
            }
        }
    }

    cout << matrix[n][w] << '\n';

    return 0;
}



Measured memory_bytes: 79232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOZ
{
	class MainClass
	{
		static void call(int n)
		{
			for (int i = 1; i <= n; i++)
			{
				int? x = i;
				if (x % 3 == 0) { Console.Write(" " + i); continue; }
				while (x > 0)
				{
					if (x % 10 == 3) { Console.Write(" " + i); break; }
					else { x /= 10; }
				}
			}
		}
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			call(n);
			Console.WriteLine();
		}
	}
}



Measured memory_bytes: 15952
def main():
    X = input()
    cs, ct = 0, 0
    for x in X:
        if x == 'T':
            if cs == 0:
                ct += 1
            else:
                cs -= 1
        else:
            cs += 1
    print(ct * 2)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S;

void input() {
  cin >> S;
}

void solve() {
  int max_ = 0;
  int count = 0;
  for (auto&& c: S) {
    if (c == 'A' or c == 'T' or c == 'G' or c == 'C') {
      count++;
      chmax(max_, count);
    } else count = 0;
  }
  cout << max_ << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    bool v[110000];
    int x;
    cin >> x;
    
    v[100] = true;
    v[101] = true;
    v[102] = true;
    v[103] = true;
    v[104] = true;
    v[105] = true;
    
    for (int i =106; i < x+1; i++){
        if(v[i-100] == true)
            v[i] = true;
        
        if(v[i-101] == true)
            v[i] = true;
        
        if(v[i-102] == true)
            v[i] = true;
        
        if(v[i-103] == true)
            v[i] = true;
        
        if(v[i-104] == true)
            v[i] = true;
        
        if(v[i-105] == true)
            v[i] = true;
        
    }
    if (v[x] == true)
        cout << "1" << endl;
    else
        cout << "0" << endl;
    return 0;
}


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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

vector< int64 > divisor(int64 n) {
  vector< int64 > ret;
  for(int64 i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solver() {
  int N = input(), K = input();

  vector< int64 > A(N);
  cin >> A;

  int64 ans = 1;
  auto div = divisor(whole(accumulate, A, 0ll));

  for (auto d : div) {
    int k = 0;

    vector< int64 > a = A;
    for (auto &s : a) s %= d;
    whole(sort, a);

    int l = 0, r = N - 1;
    while (true) {
      while (a[l] == 0) l++;
      while (a[r] == d) r--;

      if (l >= r) break;

      int diff = min(a[l], d - a[r]);
      k += diff;
      a[l] -= diff;
      a[r] += diff;
    }

    if (k <= K) ans = d;
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
a = []

A = input().split()
for f in range(0,3):
    a.append(int(A[f]))

c = 0


while a[0] != a[1] or a[1] != a[2] or a[0] != a[2]:
    a.sort()
    b = []
    for i in range(0,3):
        d = a[i]%2
        if d == 0:
            b.append("o")
        else:
            b.append("e")
    if b.count("o") == 3 or b.count("e") == 3:
        a[0] = a[0] +2
        c = c + 1
        continue
    elif b.count("o") == 2:
        n = b.index("e")
        if n == 2:
            a[0] = a[0] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 0:
            a[2] = a[2] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 1:
            a[0] = a[0] + 1
            a[2] = a[2] + 1
            c = c+1
    elif b.count("e") == 2:
        n = b.index("o")
        if n == 2:
            a[0] = a[0] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 0:
            a[2] = a[2] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 1:
            a[0] = a[0] + 1
            a[2] = a[2] + 1
            c = c+1        

print(c)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint 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)
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<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, A;
int main() {
	lint cnt = 0;
	cin >> N;
	REP(i, N) {
		cin >> A;
		if (i % 2 == 1) continue;
		if (A % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}


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


int main() {

  int N, M;
  cin >> N >> M;

  int day, res_days=N;
  
  for (int i=0; i<M; i++){
    cin >> day;
    res_days = res_days - day;
  }

if (res_days < 0) cout << "-1" << endl;
else cout << res_days << endl;

}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

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

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; }


int main()
{
    int X,Y,Z,K;

    cin >> X >> Y >> Z >> K;

    vector<ll> A(X);
    priority_queue<ll> que_A;
    rep(i,X)
    {
        cin >> A[i];
        que_A.push(A[i]);
    }

    vector<ll> B(Y);
    priority_queue<ll> que_B;
    rep(i,Y)
    {
        cin >> B[i];
        que_B.push(B[i]);
    }

    vector<ll> C(Z);
    priority_queue<ll> que_C;
    rep(i,Z)
    {
        cin >> C[i];
        que_C.push(C[i]);
    }
    
    sort(all(A),greater<ll>());
    sort(all(B),greater<ll>());
    sort(all(C),greater<ll>());

    vector<ll> tmp;

    rep(i,min(X,K))
    {
        rep(j,min(Y,K))
        {
            tmp.push_back(A[i] + B[j]);
        }
    }

    sort(all(tmp),greater<ll>());

    vector<ll> ans;

    rep(i,min((int)tmp.size(),K))
    {
        rep(j,min(K,Z))
        {
            //cout << tmp[i] << " " << C[j] << endl;
            ans.push_back(tmp[i] + C[j]);
        }
    }
    sort(all(ans),greater<ll>());
    rep(i,K) cout << ans[i] << endl;
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
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>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}


signed main(void){
    int n,x,y;cin>>n>>x>>y;x--;y--;
    vint ans(n-1,0);
    
    rep(i,n-1){
        repi(j,i+1,n){
            int d=0;
            if(j<=x||y<=i)d=j-i;
            else if(x<i&&j<y)d=min(j-i,i-x+1+y-j);
            else if(i<=x&&y<=j)d=x-i+1+j-y;
            else if(x<i)d=min(j-i,i-x+1+j-y);
            else d=min(j-i,x-i+1+y-j);
            //cout << d << endl;
            ans[d-1]++;
        }
    }

    rfor(x,ans){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld taka_str, taka_health;
	lld aoki_str, aoki_health;
	cin >> taka_health >> taka_str;
	cin >> aoki_health >> aoki_str;
	lld count = 0;
	while (true)
	{
		if (count%2 == 0)
		{
			aoki_health -= taka_str;
		}
		else
		{
			taka_health -= aoki_str;
		}
		if (taka_health <= 0)
		{
			cout << "No";
			break;
		}
		if (aoki_health <= 0)
		{
			cout << "Yes";
			break;
		}
		count += 1;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
char s[666];
int main(void){
    scanf("%s",s);
    puts(*s==s[1]||s[2]==s[1]||s[2]==s[3]?"Bad":"Good");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using std::min;

int n,f[100005];
int b6[10]={6,36,216,1296,7776,46656};
int b9[10]={9,81,729,6561,59049};

int main()
{
    scanf("%d",&n);
    f[1]=1;
    for(int i=2;i<=n;i++)
    {
        f[i]=f[i-1]+1;
        for(int j=0;j<6&&b6[j]<=i;++j)f[i]=min(f[i],f[i-b6[j]]+1);
        for(int j=0;j<5&&b9[j]<=i;++j)f[i]=min(f[i],f[i-b9[j]]+1);
    }
    printf("%d\n",f[n]);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//挿入ソート
int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a.at(i);
    rep(k,n)cout << (k?" ":"") << a[k];
    cout << "\n";
    
    for(int i = 1;i<n;i++){
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v){
            swap(a[j+1],a[j]);
            --j;
        }
        a[j+1] = v;
        rep(k,n)cout << (k?" ":"") << a[k];
        cout << "\n";
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3100
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, m: usize,
        a: [usize; n],
        b: [usize; m],
    }
    const W: usize = 200_100;
    let mut aocc = vec![0i64; W];
    let mut bocc = vec![0i64; W];
    for a in a {
        aocc[a] += 1;
    }
    for b in b {
        bocc[b] += 1;
    }
    let mut acc = vec![0; W + 1];
    let mut macc = vec![0; W + 1];
    for i in 0..W {
        acc[i + 1] = acc[i] + aocc[i];
        macc[i + 1] = macc[i] + aocc[i] * (i as i64);
    }
    let mut tot: i64 = 0;
    for i in 1..W {
        for j in 0..(W + i - 1) / i {
            let lo = i * j;
            let hi = min(W, i * j + i);
            let tmp = macc[hi] - macc[lo];
            let tmp = tmp - (acc[hi] - acc[lo]) * lo as i64;
            tot += tmp * bocc[i];
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 18204
a,b,h,m=map(int,input().split())
import math
kakudo=min(abs(h*30+m/60*30-m*6),360-abs(h*30+m/60*30-m*6))
print((a**2+b**2-2*a*b*math.cos(math.radians(kakudo)))**0.5)

Measured memory_bytes: 9512
# coding: utf-8
# Your code here!
import sys
# = list(map(int,input().split()))	
L = int(input())

a=[]
i=L
m=0

a.append(i%4)
i-=i%4
i=i//4
while(i > 0):
    a.append(i%2)
    i=i//2
p=len(a)
n=p+1

ans=[]
for i in range(L%4):
    ans.append([1,n,L-1-i])


L=L//4

if L != 0:
    ans.append([n-1,n,0])
    ans.append([n-1,n,L])
    ans.append([n-1,n,L*2])
    ans.append([n-1,n,L*3])

j=1
while(L > 0):
    if L%2==1:
        ans.append([1,n-j,L-1])
    L=L//2
    if L != 0:
        ans.append([n-j-1,n-j,0])
        ans.append([n-j-1,n-j,L])
    j+=1


#print(ans)

print(n,len(ans))
for i in ans:
    for j in i:
        print(j, end=" ")
    print()


#print(siten,syuuten,nagasa)





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

#define endl '\n'
#define fi first
#define se second

using namespace std;

typedef pair<int,int> ii;

string s;
int a = 0, b = 0, c = 0, d = 0;

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

    cin >> s;
    for (char k : s) {
        if (k == 'N') a = 1;
        if (k == 'S') b = 1;
        if (k == 'W') c = 1;
        if (k == 'E') d = 1;
    }

    if (a == b && c == d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;cin>>n;
  string s;cin>>s;
  ll R=0,G=0,B=0;
  ll r[4000]={0},g[4000]={0},b[8000]={0};

  rep(i,0,n){
    if(s[i]=='R'){r[R]=i;R++;}
    else if(s[i]=='G'){g[G]=i;G++;}
    else {b[i]=1;B++;}
  }

  ll ng=0;

  rep(i,0,R){
    rep(j,0,G){
      ll ma=max(r[i],g[j]),mi=min(r[i],g[j]);
      ll dif=ma-mi;

      if(ma+dif<4000&&b[ma+dif]!=0)ng++;
      if(dif%2==0&&b[mi+dif/2]!=0)ng++;
      if(mi-dif>=0&&b[mi-dif]!=0)ng++;
    }
  }

  out(R*G*B-ng);

  return 0;
}


Measured memory_bytes: 3732
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	r := nextInt()
	c := ""
	if r < 1200 {
		c = "ABC"
	} else if r < 2800 {
		c = "ARC"
	} else {
		c = "AGC"
	}
	fmt.Println(c)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	ans := as[0]
	for _, a := range as {
		ans = gcd(ans, a)
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		tmp := a % b
		a, b = b, tmp
	}
	return a
}


Measured memory_bytes: 5504
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 100000000000000000
#define int long long
typedef pair<int, int> P;
vector<P> G[2][100010];
int d[2][100010];

void dijkstra(int s, int state) {
    rep(i, 100010) d[state][i] = INF2;
    d[state][s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, s});
    while(que.size()) {
        P p = que.top(); que.pop();
        int u = p.second;
        int cost = p.first;
        if(cost > d[state][u]) continue;
        for(auto& e: G[state][u]) {
            int to = e.first;
            int add = e.second;
            if(d[state][to] > d[state][u] + add) {
                d[state][to] = d[state][u] + add;
                que.push({d[state][to], to});
            }
        }
    }
}
int ans[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    rep(i, m) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        G[0][a].push_back({b, c});
        G[0][b].push_back({a, c});
        G[1][a].push_back({b, d});
        G[1][b].push_back({a, d});
    }
    dijkstra(s, 0);
    dijkstra(t, 1);
    RREP(i, n - 1, 0) {
        ans[i] = d[0][i] + d[1][i];
        if(i != n - 1) ans[i] = min(ans[i], ans[i + 1]);
    }
    rep(i, n) {
        cout << (int)(1e+15) - ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 21184
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;


int main() {
	int n, m,x;

	cin >> n >> m >> x;

	vector<vector<int> > arr(n, vector<int>(m+1));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m + 1; j++) {
			cin >> arr[i][j];
		}
	}

	int min = 100;
	int min1 = 0;
	for (int i = 0; i < n; i++) {
		min = min + arr[i][0];
		min1 = min;
	}
	for (int i = 0; i < (1 << n); i++) {

		//理解度を入れる配列
		vector<int> rikai(m);
		
		int count = 0;

		for (int h = 0; h < n; h++) {

				if (i & (1 << h)) {
					//金額を足す
					count = count+arr[h][0];
					//理解度の配列を作って入れる
					for (int k = 1; k < m + 1; k++) {
						rikai[k - 1] = rikai[k - 1] +arr[h][k] ;
					}
				}

		}

		//理解度が条件を満たすか、かつ、最小なら更新
		for (int i = 0; i < m; i++) {
			if (rikai[i] < x) {
				break;
			}
			if (i == m - 1 && count < min)min = count;
		}

	}
	
	if (min == min1)cout << -1 << endl;
	else cout << min << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  char s[n + 10];
  ll a[n], sum[3][n];
  scanf("%s", s);
  for(i = 0; i < n; ++i) {
    if(s[i] == 'R') a[i] = 0;
    else if(s[i] == 'G') a[i] = 1;
    else a[i] = 2;
  }
  for(i = 0; i < 3; ++i) sum[i][0] = 0;
  sum[a[0]][0] = 1;
  for(i = 1; i < n; ++i) {
    for(j = 0; j < 3; ++j) sum[j][i] = sum[j][i - 1];
    sum[a[i]][i]++;
  }
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(a[i] != a[j]) {
    ans += sum[3 - a[i] - a[j]][n - 1] - sum[3 - a[i] - a[j]][j];
    if(2 * j - i < n && a[2 * j - i] == 3 - a[j] - a[i]) --ans;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1804
#include"bits/stdc++.h" 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
vector<int>u;
vector<int>w;
vector<int>::iterator it;
priority_queue<int>pq;
const int N=1e5+10;
/*--------------------------hbp16@hbp16-Inspiron-3543:-$------------------------------*/
int main(int argc, char const *argv[])
{
	int x[3][3];
	memset(x,0,sizeof(x));
	typedef pair<int,int>mpair;
	std::map<int,mpair>m;

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>x[i][j];
			m.insert(make_pair(x[i][j],make_pair(i,j)));
		}
	}

	int b;
	cin>>b;
	int a;
	while(b--)
	{
		cin>>a;
		if((m[a].first == 0 and m[a].second == 0))
		{
			if(a == x[0][0])
			{
				x[0][0] = -1;
			}
		}
		else
		{
			x[m[a].first][m[a].second] = -1;
		}
	}

	int k=0;
	int fl=0;
	//for cols
	while(k<3)
	{
		for(int i=0;i<3;i++)
		{
			if(x[i][k] != -1)
			{
				fl=1;
				break;
			}
		}
		if(fl==0)
		{
			cout<<"Yes";
			return 0;
		}
		fl=0;
		k++;
	}

	//for rows
	k=0;
	fl=0;
	while(k<3)
	{
		for(int i=0;i<3;i++)
		{
			if(x[k][i] != -1)
			{
				fl=1;
				break;
			}
		}
		if(fl==0)
		{
			cout<<"Yes";
			return 0;
		}
		fl=0;
		k++;
	}
	
	//for diagonals
	if(x[0][0] == -1 and x[1][1] == -1 and x[2][2] == -1)
	{
		cout<<"Yes";
		return 0;
	}
	if(x[0][2] == -1 and x[1][1] == -1 and x[2][0] == -1)
	{
		cout<<"Yes";
		return 0;
	}

	cout<<"No";

	return 0;
}

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

using ll = long long int;

const int MAX_N = (int)(1e1 + 5);

int n, m;

vector<set<int>> graph(MAX_N);

vector<int> order;

int ans;

bool check() {
  for (int i = 0; i < n - 1; ++i) {
    int src = order[i];
    int tar = order[i + 1];
    if (graph[src].find(tar) == graph[src].end()) return false;
  }
  return true;
}

int main(void) {
    // Here your code !
    scanf("%d %d", &n, &m);

    for (int i = 0; i < m; ++i) {
      int a, b;
      scanf("%d %d", &a, &b);

      graph[a].insert(b);
      graph[b].insert(a);
    }

    for (int i = 1; i <= n; ++i) {
      order.push_back(i);
    }

    check();

    do {
      if (check()) ans += 1;
      /*
      for (auto &e: order) {
        printf("%d ", e);
      }
      printf("\n");
      */
    } while(next_permutation(order.begin() + 1, order.end()));

    printf("%d\n", ans);

    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    if(a<b) s="a < b";
    else if(a>b) s="a > b";
    else if(a==b) s="a == b";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3160
n = int(input())
s = [input() for i in range(n)]
a = [0]*n
for i in range(n):
    for j in range(10):
        a[i] += 10**(ord(s[i][j])-97)

a.sort()

cnt = 1
ans = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        cnt += 1
        if i == n-2:
            ans += cnt*(cnt-1)//2
            cnt = 0            
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
print(ans)

Measured memory_bytes: 95072
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
using Graph = vector<vector<int>>;

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

  Graph G(n+1);
  vector<pair<int,int>> p;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    p.push_back(make_pair(a,b));
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int k = 0;
  int st = 0;
  for(int i=1;i<=n;i++){
    if(G[i].size() > k){
      k = G[i].size();
      st = i;
    }
  }

  vector<int> dist(n+1,-1);
  queue<int> que;

  map<pair<int,int>,int> mp;

  //init
  dist[st] = 0;
  que.push(st);

  vector<vector<bool>> color(n+1,vector<bool>(k+1));
  while(!que.empty()){
    int v = que.front();
    que.pop();

    for(int nv:G[v]){

      if(dist[nv] != -1) continue;

      for(int i=1;i<k+1;i++){
        if(!color[v][i]){
          mp.insert(make_pair(make_pair(v,nv),i));
          color[v][i] = true;
          color[nv][i] = true;
          break;
        }
      }

      dist[nv] = dist[v] + 1;
      que.push(nv);
    }
  }

  cout << k << endl;
  for(int i=0;i<n-1;i++){
    pair<int,int> r = make_pair(p[i].first,p[i].second);
    auto itr = mp.find(r);
    if(itr == mp.end()){
      cout << mp[make_pair(p[i].second,p[i].first)] << endl;
    }else{
      cout << mp[r] << endl;
    }
  }
}


Measured memory_bytes: 320244
import operator

N = int(input())
W = []
for i in range(N):
	Ai,Bi = map(int,input().split())
	W.append((Ai,Bi))

W.sort(key = operator.itemgetter(1,0))

sum = 0
for i in range(N):
	sum += W[i][0]
	if sum > W[i][1]:
		print("No")
		exit()
print("Yes")

Measured memory_bytes: 44564
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<string> s(n);
    map<string,int> mp;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        mp[s[i]]++;
        cnt=max(cnt,mp[s[i]]);
    }
    vector<string> v;
    for(int i=0;i<n;i++){
        if(mp[s[i]]==cnt){
            mp[s[i]]--;
            v.push_back(s[i]);
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 28404
import java.util.Scanner;

public class Main {

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

        int N = Integer.parseInt(scanner.next());

        int[] h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }

        scanner.nextLine();

        int[] dp = new int[N];

        // 最小化問題なのでMaxValueで初期化
        for (int i = 0; i < N; ++i) dp[i] = Integer.MAX_VALUE;

        // 足場0 のコストは0
        dp[0] = 0;

        for (int i = 1; i < N; ++i) {
            // 一つ前から飛んだ場合
            int diff = dp[i - 1] + Math.abs(h[i] - h[i - 1]);
            int diff2 = Integer.MAX_VALUE;
            if (i > 1) {
                // 二つ前から飛んだ場合
                diff2 = dp[i - 2] + Math.abs(h[i] - h[i - 2]);
            }
            dp[i] = Math.min(diff, diff2);
        }

        System.out.println(dp[N - 1]);
    }
}


Measured memory_bytes: 47632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//ここから自動入力
		Scanner sc = new Scanner(System.in);

		 int height = sc.nextInt();
		 int weight = sc.nextInt();

		 int area = height * weight;
		 int length = (height * 2) + (weight * 2);

		 System.out.println(area + " " + length);

		 sc.close();
	}

}



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

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ll ans;

	int H, L, HN, LN;
	if (X >= Y)
	{
		H = A;
		L = B;
		HN = X;
		LN = Y;
	}
	else
	{
		H = B;
		L = A;
		HN = Y;
		LN = X;
	}

	if (A + B > C * 2)
	{
		if (H < C * 2)
		{
			ans = LN * 2 * C + (HN - LN) * H;
		}
		else
		{
			ans = HN * 2 * C;
		}
	}
	else
	{
		ans = X * A + Y * B;
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second

int main() {
    fastt;
    ll i,j,k,n;
    cin>>n;
    ll ar[n],dp[n];
    for(i=0;i<n;i++)
    cin>>ar[i];
  dp[n-1]=0;
    dp[n-2]=abs(ar[n-2]-ar[n-1]);
    for(i=n-3;i>=0;i--){
        dp[i]=min(abs(ar[i+1]-ar[i])+dp[i+1],abs(ar[i+2]-ar[i])+dp[i+2]);
    }
        cout<<dp[0]<<endl;
    return 0;
}


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

void solve(int N, vector<string> s){
    map<string, int> mp;
    rep(i,N) {
        sort(s[i].begin(), s[i].end());
        mp[s[i]]++;
    }
    ll ans = 0;
    for(auto& p : mp) {
        int s = p.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
}

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, N) {
        cin >> s[i];
    }
    solve(N, move(s));
    return 0;
}


Measured memory_bytes: 18176
#include<stdio.h>

int main(void){
        int k, s, ans=0;;
        scanf("%d %d", &k, &s);
        for(int i=0; i<=k; i++) for(int j=0; j<=k; j++) ans += (0<=s-i-j)&&(s-i-j<=k);
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt)
    val k = list[0]
    val s = list[1]
    var sum = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (0 <= z && z <= k) {
                sum += 1
            }
        }
    }
 
    println(sum)
}

Measured memory_bytes: 37952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n);
    rep(i,n){
        int t;
        cin >> t;
        x[i] = t;
        y[i] = t;
    }
    sort(y.begin(),y.end());
    int midl = y[n/2-1];
    int midr = y[n/2];
    rep(i,n){
        if(x[i]<=midl) cout << midr << endl;
        else if(x[i]>=midr) cout << midl << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;


string s;
int n;
vector<int> series;

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

    char head = s[0];
    char tail = s[s.size()-1];

    // 数え上げ
    char now = head;
    int cnt_series = 0;
    for (int i=0;i<s.size();i++) {
        if (s[i]!=now) {
            series.push_back(cnt_series);

            cnt_series = 1; // now分を数えて1
            now = s[i];
        }
        else  cnt_series++;

        // 最後尾だけ別にseriesに追加
        if(i==s.size()-1) series.push_back(cnt_series);
    }

    // コーナー
    if (series.size() == 1) {
        cout << 0 << endl;
        return 0;
    }

    // 白スタートの場合
    if (head=='.') series.erase(series.begin());

    // 黒startとする
    int sum_w = 0;
    for (auto i=begin(series)+1;i<end(series);i+=2) {
        sum_w += *i;
    }

    // ある黒のところまで和を取る．
    int sum_b = 0;
    int ans = sum_w;
    // bを1~全部までの場合について探索
    for (auto i=begin(series);i<end(series);i+=2) {
        sum_b += *i;
        if(i+1<end(series)) sum_w -= *(i+1);
        ans = min(sum_b+sum_w,ans);
    }
    cout << ans << endl;
}

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

int fun(int n){
	if(n%2){
		return 3*n + 1;
	}else{
		return n/2;
	}
}

int main(){
	/*input*/
	int s;	cin >> s;
	int m = 0;
	const int max = 1000000;
	bool flag = false;	//true:m.const false:?
	/*calculation*/
	int a[max] = {0};
	int a_m[max] = {0};
	for(int i = 0;!flag ;i++){
		if(i == 0){
			a[0] = s;
			a_m[0] = a[0];
		}else{
			a[i] = fun(a[i - 1]);
			for(int j = 0; j < i; j++){
				if(a[i] == a_m[j]){
					m = i + 1;
					flag = true;
					break;
				}else{
					a_m[i] = a[i];
				}
			}
		}
	}
	/*output*/
	cout << m << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
 
typedef long long LL;
typedef pair<int, int> PII;

const int MAX = 1 << 18;

int x[MAX];
LL a[MAX];
vector<pair<int, int> > g[MAX];
vector<pair<LL, int> > s[MAX];
int ptr[MAX];
vector<pair<int, LL> > cntr[MAX];
bool U[MAX];
int sz[MAX];
bool took[MAX];

void dfsSz(int v, int p)
{
	sz[v] = 1;
	for(auto to: g[v])
	{
		if(to.first != p && !U[to.first])
		{
			dfsSz(to.first, v);
			sz[v] += sz[to.first];
		}
	}
}

void dfsPB(int v, int p, int u, LL dist)
{
	cntr[v].push_back({u, dist});
	s[u].push_back({dist + x[v], v});
	for(auto [to, w]: g[v])
		if(to != p && !U[to])
			dfsPB(to, v, u, dist + w);
}

void go(int v)
{
	dfsSz(v, -1);
	int p = -1, totSz = sz[v];
	bool ok = false;
	while(!ok)
	{
		ok = true;
		for(auto to: g[v])
			if(to.first != p && !U[to.first] && 2 * sz[to.first] > totSz)
			{
				p = v;
				v = to.first;
				ok = false;
				break;
			}
		
	}
	s[v].reserve(totSz);
	dfsPB(v, -1, v, 0);
	U[v] = true;
	for(auto to: g[v])
		if(!U[to.first])
			go(to.first);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
	{
		cin >> x[i];
		a[i] = 1e18;
	}
	FOR(i, 0, n - 1)
	{
		int u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
	go(0);
	set<pair<LL, int> > gs;
	FOR(i, 0, n)
	{
		sort(ALL(s[i]));
		gs.insert({a[i] + s[i].begin()->first, i});
	}
	LL ans = 0;
	FOR(i, 0, n)
	{
		int bestU = gs.begin()->second;
		assert(ptr[bestU] < SZ(s[bestU]));
		int v = s[bestU][ptr[bestU]].second;
		took[v] = true;
		if(i)
			ans += gs.begin()->first;
		for(auto [u, d]: cntr[v])
		{
			gs.erase({a[u] + s[u][ptr[u]].first, u});
			while(ptr[u] < SZ(s[u]) && took[s[u][ptr[u]].second])
				ptr[u]++;
			a[u] = min(a[u], d + x[v]);
			if(ptr[u] < SZ(s[u]))
			{
				gs.insert({a[u] + s[u][ptr[u]].first, u});
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 203556
#include <stdio.h>

int main() {
 
 
  int  n;
  int  u;
 
 
 scanf("%d%d",&n,&u);
 double  m=((double)n+(double)u)/2;
 
 if(m-(int)m==0) {
   printf("%d",(int)m);
 }
  else{
    printf("IMPOSSIBLE");
  }
  return 0;

}

Measured memory_bytes: 128