akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            char[] chars = sc.next().toCharArray();
            if(chars.length == 1 && chars[0] == '0') break;
            int ans = 0;
            for (char c : chars) {
                ans+= c -'0';
            }
            System.out.println(ans);

        }
        sc.close();
    }
}


Measured memory_bytes: 26084
# 2019/6/25
import sys
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
if not 2 in a:
    print(-1)
    sys.exit()
s = set()
cur = 1
ans = 0
while not cur in s:
    if a[cur-1] == 2:
        print(ans+1)
        sys.exit()
    else:
        s.add(cur)
        cur = a[cur-1]
        ans += 1
print(-1)

Measured memory_bytes: 13220
n, m = tuple(map(int, input().split()))
x = list(map(int, input().split()))
x = sorted(x)

diff = []

for i in range(len(x) - 1):
    diff.append(x[i + 1] - x[i])

diff = sorted(diff)

diff_sum = 0
diff_len = m - 1

for i in range(diff_len - (n - 1)):
    diff_sum += diff[i]

print(diff_sum)

Measured memory_bytes: 13960
n = gets.to_i
p = gets.split.map(&:to_i).first(n)

# 前方から比較しながら一番小さな値を保持しておく
min = (2 * 10**5) + 1
ans = 0

n.times do |i|
  next if p[i] > min
  min = p[i]
  ans += 1
end

puts ans


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

template <typename T>
struct Heap {
	Heap *l, *r;
	T val;
	Heap() {}
	Heap(int v) : l(nullptr), r(nullptr), val(v) {}
	void Init(int v) {
		l = nullptr; r = nullptr; val = v;
	}
};

template <typename T>
Heap<T>* meld(Heap<T>* a, Heap<T>* b) {
	if (a == nullptr) return b;
	if (b == nullptr) return a;
	if (a->val < b->val) swap(a, b);
	a->r = meld(a->r, b);
	swap(a->l, a->r);
	return a;
}

template <typename T>
Heap<T>* pop(Heap<T>* a) {
	return meld(a->l, a->r);
}

Heap<int> pool[2000000];
int it;

int main()
{
	int val;
	string S;
	Heap<int>* pq = nullptr;

	while (cin >> S, S != "end") {
		if (S == "extract") {
			printf("%d\n", pq->val);
			pq = pop(pq);
		}
		else {
			cin >> val;
			pool[it].Init(val);
			pq = meld(pq, &pool[it++]);
		}
	}
	return 0;
}

Measured memory_bytes: 38336
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	ll n,m;
    cin >> n >> m;
    vector<pair<ll,bool>> a(n,MP(1,false));
    a.at(0)=MP(1,true);
    for(ll i=0;i<m;i++){
    	ll x,y;
      	cin >> x >> y;
        a.at(x-1).F--;
      	a.at(y-1).F++;
        if(a.at(x-1).S){
        	a.at(y-1).S=true;
        }
        if(a.at(x-1).F==0){
        	a.at(x-1).S=false;
        }
    }
    ll ans=0;
  	for(ll i=0;i<n;i++){
    	if(a.at(i).S) ans++;
    }
  	cout << ans;
}


Measured memory_bytes: 1792
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

vector<ll> dijkstra(const WGraph &G, const int s) {
    int n = (int)G.size();
    std::vector<long long> dis(n, LINF);
    dis.at(s) = 0;
    using P = std::pair<long long, int>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    que.push(std::make_pair(0, s));

    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (dis.at(v) < p.first) {
            continue;
        }
        for (auto e : G.at(v)) {
            if (dis.at(e.first) > dis.at(v) + e.second) {
                dis.at(e.first) = dis.at(v) + e.second;
                que.push(std::make_pair(dis.at(e.first), e.first));
            }
        }
    }
    return dis;
}

void solve(){
    int n;
    cin >> n;
    WGraph G(n);
    for (int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        G.at(a-1).push_back(make_pair(b-1, 1));
        G.at(b-1).push_back(make_pair(a-1, 1));
    }
    vector<ll> fennec = dijkstra(G, 0), snuke = dijkstra(G, n-1);
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (fennec.at(i) <= snuke.at(i)) cnt++;
        else cnt--;
    }
    if (cnt > 0) cout << "Fennec" << "\n";
    else cout << "Snuke" << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);	
    int h, w, m, r, c;
    cin >> h >> w >> m;
    vector<int> r_cnt(h), c_cnt(w);
    vector<pair<int, int>> targets(m);
    for (int i = 0; i < m; ++i) {
    	cin >> r >> c; --r, --c;
    	r_cnt[r]++;
    	c_cnt[c]++;
    	targets[i] = {r, c};
    }
   	int b_row = (max_element(r_cnt.begin(), r_cnt.end()) - r_cnt.begin());
   	int b_col = (max_element(c_cnt.begin(), c_cnt.end()) - c_cnt.begin());
   	ll cnt = 0;
   	if (r_cnt[b_row] > c_cnt[b_col]) {
   		cnt += r_cnt[b_row];
	   	vector<int> nc_cnt = c_cnt;
	   	for (auto t: targets)
	   		if (t.first == b_row) nc_cnt[t.second]--;
	   	cnt += *max_element(nc_cnt.begin(), nc_cnt.end());

   	} else {
   		cnt = c_cnt[b_col];
	   	vector<int> nr_cnt = r_cnt;
	   	for (auto t: targets)
	   		if (t.second == b_col) nr_cnt[t.first]--;
	   	cnt += *max_element(nr_cnt.begin(), nr_cnt.end());
   	}
   	cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 9016
section = gets.chomp.split( "" )
area = 0
depthArr = []
areaArr = []
depth = 0
section.each_with_index { |ground, i|
	if "\\" == ground
		depth += 1
		depthArr.push( i )
	elsif 0 < depth && "/" == ground
		if !depthArr.empty?
			j = depthArr.pop
			pool =  i - j
			area += pool
			
			while !areaArr.empty?
				preJ, prePool = areaArr.last
				if j <= preJ
					pool += prePool
					preJ, prePool = areaArr.pop
				else
					break
				end
			end
			areaArr.push( [ j, pool ] )
		end
	end
}
puts( area )
output = []
output.push( areaArr.length )
areaArr.each{ |arr|
	output.push( arr[1] )
}
puts( output.join( " " ) )

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	int maxCnt = 0;
	map<string, int> anstmp;
	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S;
		anstmp[S]++;
		maxCnt = max(maxCnt, anstmp[S]);
	}

	vector<string> ans;
	for (auto i : anstmp) {
		if (i.second == maxCnt) {
			ans.push_back(i.first);
		}
	}

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

	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 27232
n = int(input())
a = list(map(int, input().split()))

inf = float('inf')

# 累積和
if n % 2 == 0:
    l_even = [0]
    l_odd = [0]
    for i in range(n):
        if i % 2 == 0:
            l_even.append(l_even[-1] + a[i])
        else:
            l_odd.append(l_odd[-1] + a[i])
    ans = -inf
    for i in range(n // 2 + 1):
        if ans < l_even[i] + l_odd[-1] - l_odd[i]:
            ans = l_even[i] + l_odd[-1] - l_odd[i]
    print(ans)
    exit()

# dp[i] = i回ずらしを使った時の最大値
# 1個ずつdpを更新
# i = 0, 1, 2
dp = [a[0], a[1], a[2]]
for i in range(2, n-2, 2):
    dp[2] = max([dp[2] + a[i+2], dp[1] + a[i+2]])
    dp[1] = max([dp[1] + a[i+1], dp[0] + a[i+1]])
    dp[0] += a[i]

print(max(dp))

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

int	main()
{
  int	s1s2s3;
  int	nb;
  
  cin >> s1s2s3;
  
  nb = 0;
  if (s1s2s3 == 0)
  {
    cout << nb << endl;
  	return (0);
  }
  
  if (s1s2s3 == 100 || s1s2s3 == 10 || s1s2s3 == 1)
  {
    nb++;
    cout << nb << endl;
  	return (0);
  }

  if (s1s2s3 == 110 || s1s2s3 == 11 || s1s2s3 == 101)
  {
    nb += 2;
    cout << nb << endl;
  	return (0);
  }
  
  if (s1s2s3 == 111)
  {
    nb += 3;
    cout << nb << endl;
  	return (0);
  }
  return (0);
}


Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ld a;
    ld b;
    ld x;
    cin>>a>>b>>x;
//    x=x/a;
//    ld be = 0.0;
//    ld en = pi/2.0;
//    ld E = 1.0e-7;
//    ld ans = pi/2.0;
//    while((en-be)>E)
//    {
//        ld mid  = (be+en)/2.0;
//        ld lefth = b*cos(mid);
//        ld righth = a*sin(mid);
//        if((lefth-righth)>E)
//        {
//            ld vol = b*a;
//            vol -= (a*a*1.0/tan(mid));
////            vol = vol*(a*1.0/sin(mid));
//            if(vol>=x)
//            {
//                ans = mid;
//                en = mid;
//            }
//            else
//            {
//                be = mid;
//            }
//        }
//        else if(abs(righth-lefth)<=E)
//        {
//            ld vol = (a*b);
//            if(vol >= x)
//            {
//                ans = mid;
//                en=mid;
//            }
//            else
//            {
//                be = mid;
//            }
//        }
//        else
//        {
//            ld vol = b*b*tan(mid);
//            if(vol>=x)
//            {
//                ans = mid;
//                en=mid;
//            }
//            else
//            {
//                be=mid;
//            }
//        }
//    }
//    ans = (be+en)/2.0;
//    ans = (ans*(180.0)/pi);
    ld vol = a*a*b;
    ld temp = 2.0*x;
    ld ans;
    if(temp >= vol)
    {
        ld exp = (a*a*a);
        exp /= (a*a*b-x);
        exp /= 2.0;
        ans = atan(exp);
    }
    else
    {
        ld exp = (2.0*x/(a*b*b));
        ans = atan(exp);
    }
    ans = (180.0*ans/pi);
    ans = (90.0-ans);
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}































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

vector<P> edge[110000];
int color[110000];

void dfs(int v, int par = -1, int c = 0) {
	color[v] = c;
	for (auto p : edge[v]) {
		int x = p.first;
		int w = p.second;
		if (x == par) continue;
		if (w % 2 == 0)
			dfs(x, v, c);
		else
			dfs(x, v, c ^ 1);
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--;
		edge[u].push_back(P(v, w));
		edge[v].push_back(P(u, w));
	}
	dfs(0);
	for (int i = 0; i < n; i++) {
		cout << color[i] << endl;
	}
}

Measured memory_bytes: 12560
#include <iostream>
using namespace std;
int main(){
	long long n;
	cin >> n;
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		if(i % 5 == 0 || i % 3 == 0) continue;
		ans += i;
	}
	cout << ans << endl;
}

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

int main(){

  char a,b;

  cin >> a >> b;

  if(a == 'H'){
    if(b == 'H'){
      cout << 'H' << endl;
    }else{
      cout << 'D' << endl;
    }
  }else{
    if(b == 'D'){
      cout << 'H' << endl;
    }else{
      cout << 'D' << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, T;
    cin >> N >> T;
    vector<P> data(N);
    for(int i = 0; i < N; ++i)  cin >> data[i].first >> data[i].second;
    sort(data.begin(), data.end());
    vector<int> dp(T + 3005, -1);
    dp[0] = 0;
    for(auto& p : data){
        int A = p.first, B = p.second;
        for(int i = T - 1; i >= 0; --i){
            if(dp[i] != -1) chmax(dp[i + A], dp[i] + B);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;



int main() {
    
    int a=-1,b=-1,c=-1,N,Y;
    cin>>N>>Y;
    rep(i,Y/10000+1){
        rep(j,(Y-10000*i)/5000+1){
            if(10000*i+5000*j+1000*(N-i-j)==Y){
                a=i;b=j;c=N-i-j;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    
    

    
   
return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,sum=0,max=0;
	cin>>n;
	char s[n];
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(i=0;i<n;i++)
	{
		if(s[i]=='I')
		{
			max++;
		}
		else
		{
			if(max>sum)
			{
				sum=max;
			}
			max--;
		}
	}
	if(max>sum) sum=max;
	cout<<sum<<endl;
 	return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    frag = [0] * 4
    for i in range(len(S)):
        for j in range(len(S)):
            if S[i] == S[j]:
                frag[i] += 1
    fragp = 0
    for i in range(len(frag)):
        if frag[i] != 2:
            fragp = 1
    if fragp == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
mod = 10**9 + 7
ans = [1] + [0]*N
j = 0
for i in range(1,N+1):
    if j < M and i == a[j]:
        j += 1
    elif i > 1:
        ans[i] = (ans[i-1] + ans[i-2]) % mod
    else:
        ans[i] = ans[i-1]
print(ans[N])

Measured memory_bytes: 8568
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    ll ans;

    if(abs(a - b) % 2 == 0){
        ans = abs(a - b) / 2;
    }else{

        ans = min(min(a - 1, b - 1), min(n - a, n - b));

        ans++;

        ans += (abs(a - b) - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
line = map(int, input().split())

five_count = 0
seven_count =0

for i in line:
    if i == 5:
        five_count += 1
    elif i == 7:
        seven_count += 1

if five_count ==2 and seven_count == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
from sys import stdin
readline = stdin.readline



def lt(a, b):
    if a.real != b.real:
        return a.real < b.real
    return a.imag < b.imag


def main():
    x1, y1, x2, y2 = map(int, readline().split())
    p1, p2 = x1 + y1 * 1j, x2 + y2 * 1j
    q = int(readline())
    for i in range(q):
        xi, yi = map(int, readline().split())
        pi = xi + yi * 1j

        s = cross(p2 - p1, pi - p1)
        if abs(s) < 1e-10:
            if (lt(p1, p2) and lt(p2, pi)) or (lt(pi, p2) and lt(p2, p1)):
                print('ONLINE_FRONT')
            elif (lt(pi, p1) and lt(p1, p2)) or (lt(p2, p1) and lt(p1, pi)):
                print('ONLINE_BACK')
            else:
                print('ON_SEGMENT')
        elif s < 0:
            print('CLOCKWISE')
        else:
            print('COUNTER_CLOCKWISE')


def projecter(a, b):
    return dot(a, b) / dot(a, a)


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def cross(a, b):
    return a.real * b.imag - a.imag * b.real
main()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

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

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    string w;
    cin >> w;

    map<char,char> mp;
    for (int i = 0; i < (int)w.length(); i++) {
        mp[w[i]]++;
    }

    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second % 2 != 0) {
            cout << "No"<< endl;
            return;
        }

    }

    cout << "Yes" << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		Card []C1 = new Card[N];
		Card []C2 = new Card[N];
		for(int i = 0; i < N; i++) {
			String s = scan.next();
			int t = Integer.parseInt(s.substring(1, 2));
			C1[i] = new Card(s.substring(0, 1), t);
			C2[i] = new Card(s.substring(0, 1), t);
		}
		scan.close();
		bubbleSort(C1, N);
		for(int i = 0; i < N; i++) {
			if(i == N - 1) {
				System.out.println(C1[i].getSuit() + C1[i].getN());
			}else {
				System.out.print(C1[i].getSuit() + C1[i].getN() + " ");
			}
		}
		System.out.println("Stable");
		selectionSort(C2, N);
		for(int i = 0; i < N; i++) {
			if(i == N - 1) {
				System.out.println(C2[i].getSuit() + C2[i].getN());
			}else {
				System.out.print(C2[i].getSuit() + C2[i].getN() + " ");
			}
		}
		for(int i = 0; i < N; i++) {
			if(!C1[i].getSuit().equals(C2[i].getSuit())) {
				System.out.println("Not stable");
				System.exit(0);
			}
		}
		System.out.println("Stable");
	}
	static void bubbleSort(Card[]C, int N) {
		for(int i = 0; i < N; i++) {
			for(int j = N - 1; j >= i + 1; j--) {
				if(C[j].getN() < C[j - 1].getN()) {
					Card v = C[j];
					C[j] = C[j - 1];
					C[j - 1] = v;
				}
			}
		}
	}
	static void selectionSort(Card[]C, int N) {
		for(int i = 0; i < N - 1; i++) {
			int min_j = i;
			for(int j = i; j < N; j++) {
				if(C[j].getN() < C[min_j].getN()) {
					min_j = j;
				}
			}
			Card v = C[i];
			C[i] = C[min_j];
			C[min_j] = v;
		}
	}
}

class Card{
	String suit;
	int n;
	public Card(String suit, int n) {
		this.suit = suit;
		this.n = n;
	}
	String getSuit() {
		return suit;
	}
	int getN() {
		return n;
	}
}


Measured memory_bytes: 26400
a,b,c,d=map(int,input().split())
s=0
while (a>0 and c>0) or s==1:
    c=c-b
    if c<=0:
        s+=1
    else:
        a=a-d
if a<=0:
    print("No")
elif c<=0:
    print("Yes")

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

int keta(int x){
	int i=0;
	while (x/pow(10,i)>=1){
		i++;
	}
	if (x==0){
		return 1;
	}
	else
	return i;
	}


int main(){
double min;
while (cin>>min){
	double y;
	int N;
	y=4.9*(min/9.8)*(min/9.8);
	N=ceil((y+5)/5);
	cout<<N<<endl;

}

}

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

ll func(ll h){
  	if(h==1)
      return 1;
  	return 1+2*func(h/2);
}

int main(){
  	ll h;
  	cin>>h;
  	cout<<func(h);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int l;
  cin >> l;
  int ans = 0,ans_i = 0,ans_j = 0,ans_k = 0;
  rep(i,l + 1)REP(j,0,l + 1){
    if(ans < (i * j * (l - i - j))){
      ans = (i * j * (l - i - j));
      ans_i = i;
      ans_j = j;
      ans_k = l - i - j;
    }
  }
  cout << (l / 3.0) * (l / 3.0) * (l / 3.0) << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B, K;
signed main() {
    cin >> A >> B >> K;
    cout << max(0LL, A - K) << endl;
    cout << min(B, max(0LL, B - (K - A))) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";
 
int main(){
  ll n, p1, p2, p3, count;
  cin >> n;
  cin >> p1;
  cin >> p2;
  rep(i, 2, n){
    cin >> p3;
    if(p1 < p2 && p2 < p3){
      count++;
    }else if(p1 > p2 && p2 > p3) count++;
    p1 = p2; p2 = p3;
  }
  print(count)
  
  return 0;
}

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

int main()
{
  int n;
 scanf("%d",&n);
  long long int h[n];
  int i;
  long long int ctr=0 , x;
  long long int a[n];
  for(i=0;i<n;i++)
    scanf("%lld" , &h[i]);
  for(i=0;i<n;i++)
  {
      if (h[i] >= h[i+1])
            ctr++;
        if(h[i] < h[i+1])
            ctr=0;
        a[i]=ctr;
  }
  x=a[0];
  for(i=0;i<n;i++)
  {
      if (x < a[i])
        x=a[i];
  }
    printf("%lld",x);
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;
    int X;
    vector<int> vs;
    for (int i = 0; i < N; ++i) {
        cin >> X;
        vs.push_back(X);
    }
    
    sort(vs.begin(), vs.end());


    int m = 1000000000;

    for (int i = vs[0]; i <= vs[N - 1]; ++i) {
        int tmpSum = 0;
        for (int j = 0; j < N; ++j) {
            tmpSum += (vs[j] - i) * (vs[j] - i);
        }
        m = min(tmpSum, m);
    }

    cout << m << endl;


    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		
		int q = sc.nextInt();
		
		for(int i=0;i<q;i++){
			System.out.println(lengthOfLCS(sc.next().toCharArray(),sc.next().toCharArray()));
		}
		
	}
	
	//Longest Common Subseqence（最長共通部分列）
	static int lengthOfLCS(char[] x, char[] y){
		int[][] dp = new int[x.length+1][y.length+1]; //xのi+1文字目とyのj+1文字目までを使ったときのLCSの長さ
		
		for(int i=0;i<x.length+1;i++){
			dp[i][0] = 0;
		}
		for(int i=0;i<y.length+1;i++){
			dp[0][i] = 0;
		}
		
		for(int i=1;i<x.length+1;i++){
			for(int j=1;j<y.length+1;j++){
				if(x[i-1] == y[j-1]){ //indexがテーブルとズレている
					dp[i][j] = dp[i-1][j-1] + 1;
				}
				else{
					dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				}
			}
		}
		
		return dp[x.length][y.length];
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 63468
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	geta := 10000
	aa := make([][]int, h)
	for i := 0; i < h; i++ {
		aa[i] = make([]int, w)
		for j := 0; j < w; j++ {
			aa[i][j] = getNextInt(scanner)
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			aa[i][j] = absint(aa[i][j] - getNextInt(scanner))
		}
	}
	grid := makeGrid(h, w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			grid[i][j] = big.NewInt(0)
		}
	}
	grid[0][0].SetBit(grid[0][0], geta+aa[0][0], 1)
	grid[0][0].SetBit(grid[0][0], geta-aa[0][0], 1)
	for i := 1; i < w; i++ {
		grid[0][i].Or(grid[0][i], lshifted(grid[0][i-1], uint(aa[0][i])))
		grid[0][i].Or(grid[0][i], rshifted(grid[0][i-1], uint(aa[0][i])))
	}
	for i := 1; i < h; i++ {
		grid[i][0].Or(grid[i][0], lshifted(grid[i-1][0], uint(aa[i][0])))
		grid[i][0].Or(grid[i][0], rshifted(grid[i-1][0], uint(aa[i][0])))
	}
	for i := 1; i < h; i++ {
		for j := 1; j < w; j++ {
			grid[i][j].Or(grid[i][j], lshifted(grid[i-1][j], uint(aa[i][j])))
			grid[i][j].Or(grid[i][j], rshifted(grid[i-1][j], uint(aa[i][j])))
			grid[i][j].Or(grid[i][j], lshifted(grid[i][j-1], uint(aa[i][j])))
			grid[i][j].Or(grid[i][j], rshifted(grid[i][j-1], uint(aa[i][j])))
		}
	}

	for i := 0; i < geta; i++ {
		if grid[h-1][w-1].Bit(geta+i) == 1 {
			fmt.Fprintln(writer, i)
			return
		}
		if grid[h-1][w-1].Bit(geta-i) == 1 {
			fmt.Fprintln(writer, i)
			return
		}
	}
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func makeGrid(h, w int) [][]*big.Int {
	index := make([][]*big.Int, h, h)
	data := make([]*big.Int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func lshifted(b *big.Int, i uint) *big.Int {
	return big.NewInt(0).Lsh(b, i)
}
func rshifted(b *big.Int, i uint) *big.Int {
	return big.NewInt(0).Rsh(b, i)
}


Measured memory_bytes: 27392
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n,x;
    cin >> n >> x;
    ll d = 0;
    rep(i, n + 2) {
        int l;
        cin >> l;
        d += l;
        if (d > x)
        {
            cout << i + 1 << endl;
            break;
        }
        if (i == n)
        {
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N, M;
vector<P> d;

int main () {
  cin >> N >> M;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    d.emplace_back(a, b);
  }

  sort(All(d));

  ll ans = 0;
  int ct = M;

  for (auto p: d) {
    if (ct <= 0) {
      break;
    }

    ll a = p.first;
    ll b = p.second;

    if (ct >= b) {
      ans += a * b;
      ct -= b;
    } else {
      ans += a * ct;
      ct = 0;
    }
  }

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

Measured memory_bytes: 2420
#include <iostream>

const char TABLE[6][5] = {
	{'a', 'b', 'c', 'd', 'e'}, 
	{'f', 'g', 'h', 'i', 'j'},
	{'k', 'l', 'm', 'n', 'o'},
	{'p', 'q', 'r', 's', 't'},
	{'u', 'v', 'w', 'x', 'y'},
	{'z', '.', '?', '!', ' '}
};


int main()
{
	std::string input;
	while (getline(std::cin, input)) {
		std::string ans;
		bool na = (input.length() & 1) == 1;
		for (int i=0; !na && i<input.length(); i+=2) {
			int c = input[i] - '0';
			int d = input[i+1] - '0';
			if (c < 1 || 6 < c || d < 1 || 5 < d) {
				na = true;
			}
			else ans += TABLE[c-1][d-1];
		}
		if (na) std::cout << "NA" << std::endl;
		else std::cout << ans << std::endl;
	}
	return 0;
}




Measured memory_bytes: 3124
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#define rr register
using namespace std;
inline int read(){
	int s=0,m=0;
	char ch=getchar();
	while(!isdigit(ch)){m|=ch=='-';ch=getchar();}
	while(isdigit(ch)){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
	return m?-s:s;
}
inline int f_swap(int &a,int &b){
	int l=a;
	a=b;
	b=l;
}
long long a,b,k;
main(){
    scanf("%lld%lld%lld",&k,&a,&b);
    if(k<=a)return puts("1"),0;
    else if(a<=b)return puts("-1"),0;
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;

int main() {
	int n;
	cin >> n;
	int ans = n;
	REP(i, n + 1) {
		int tmp = 0;
		int t = i;
		while (t > 0)tmp += t % 6, t /= 6;
		t = n - i;
		while (t > 0)tmp += t % 9, t /= 9;
		if (ans > tmp)ans = tmp;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


N,T = map(int,input().split())
t = [int(i) for i in input().split()]
ans = 0
difference = [0 for i in range(N-1)]
for i in range(N-1):
    difference[i] = t[i+1]-t[i]

# print(difference)
for i in range(N-1):
    if difference[i] >= T:
        ans += T
    else:
        ans += difference[i]

ans += T
print(ans)


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

int main()
{
	int n;
	std::cin >> n;
	bool cards[4][13];
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			cards[i][j] = false;
		}
	}
 	for (int i = 0; i < n; i++)
	{
		char mark;
		int num;
		std::cin >> mark >> num;
		switch (mark)
		{
		case 'S':
			cards[0][num-1] = true;
			break;
		case 'H':
			cards[1][num-1] = true;
			break;
		case 'C':
			cards[2][num-1] = true;
			break;
		case 'D':
			cards[3][num-1] = true;
			break;
		default:
			break;
		}
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (cards[i][j] == false)
			{
				switch (i)
				{
				case 0:
					printf("S %d\n", j+1);
					break;
				case 1:
					printf("H %d\n", j+1);
					break;
				case 2:
					printf("C %d\n", j+1);
					break;
				case 3:
					printf("D %d\n", j+1);
					break;
				default:
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<bool> ip(N+1,true);
  long long ans=1;
  for (int i=2;i<N+1;i++){
    if (ip[i]){
      int count=1;
      int n=N;
      while (n>0){
        n=n/i;
        count+=n;
      }
      ans=ans*count%1000000007;
      for (int j=i;j<N+1;j+=i){
        ip[j]=false;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#124_C
S=input()
def Count(S,x):
    res=0
    for i in range(len(S)):
        if i%2==x:
            if S[i]=='0':
                res+=1
        else:
            if S[i]=='1':
                res+=1
    return res

print(min(Count(S,0),Count(S,1)))

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

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

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

    // aa-, bb, ab
    if(a == b){
        cout << (a + b);
    } else if (a > b){
        cout << (a + a -1);
    } else {
        cout << (b + b -1);
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100010];
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	m=n-m;
	if(n==m)
	{
		printf("0");
		return 0;
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int ans=inf;
	for(i=0;i<=m;i++)
	{
		ans=min(ans,a[n-1-(m-i)]-a[i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  int count = 0;
  int currentbutton = 1;
  int nextbutton;
  while (1) {
    count++;
    nextbutton = v[currentbutton - 1];
    if (nextbutton == 2) {
      cout << count << endl;
      break;
    } else if (nextbutton == 1 || count > N) {
      cout << -1 << endl;
      break;
    } else {
      currentbutton = nextbutton;
    }
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
  
public class Main {
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	  int a=Integer.parseInt(sc.next());
	  int b=Integer.parseInt(sc.next());
	 
	  if(a<b){
		  System.out.println("a < b");
	  }
	  else if(a>b){
		  System.out.println("a > b");
	  }
	  else{
		  System.out.println("a == b");
	  }
	
    
  }
}

Measured memory_bytes: 17120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr ll INF = 1e18;

void chmax(ll &x, ll y) {
  x = max(x, y);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  vector<ll> LF(N + 1, -INF);
  vector<ll> RF(N + 1, -INF);
  vector<ll> LB(N + 1, -INF);
  vector<ll> RB(N + 1, -INF);
  LF[0] = 0;
  for (int i = 0; i + 2 <= N; i += 2) {
    chmax(LF[i + 2], LF[i] + A[i]);
    chmax(RF[i + 2], LF[i] + A[i + 1]);
    chmax(RF[i + 2], RF[i] + A[i + 1]);
  }
  RB[N] = 0;
  for (int i = N; i - 2 >= 0; i -= 2) {
    chmax(RB[i - 2], RB[i] + A[i - 1]);
    chmax(LB[i - 2], RB[i] + A[i - 2]);
    chmax(LB[i - 2], LB[i] + A[i - 2]);
  }
  ll ans = LLONG_MIN;
  if (N % 2 == 1) {
    for (int i = 0; i < N; i += 2) {
      chmax(ans, max(LF[i], RF[i]) + max(LB[i + 1], RB[i + 1]));
    }
  } else {
    for (int i = 0; i <= N; i += 2) {
      chmax(ans, LF[i] + LB[i]);
      chmax(ans, LF[i] + RB[i]);
      chmax(ans, RF[i] + RB[i]);
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int N, M;
vector<int> a(55), b(55);
vector<vector<bool>> G(55, vector<bool>(55, false));
vector<bool> visited(55, false);
queue<int> que;

int main(){
    cin >> N >> M;
    rep(i, M){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }

    int ans = 0;

    rep(i, M){
        G[a[i]][b[i]] = G[b[i]][a[i]] = false;
        rep(j, N) visited[j] = false;
        
        visited[0] = 0;
        que.push(0);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            visited[v] = true;

            rep(j, N){
                if( visited[j] || !G[v][j]) continue;
                que.push(j);
            }
        }

        bool flag = false;
        rep(j, N){
            if(!visited[j]){
                flag = true;
                break;
            }
        }
        if(flag) ans++;

        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int l = s.length();
		int K = scan.nextInt();
		scan.close();
		ArrayList<String> list = new ArrayList<String>();
		for(int i = 0; i < l; i++) {
			for(int j = 1; j <= K; j++) {
				if(i + j <= l) {
					list.add(s.substring(i, i + j));
				}else {
					break;
				}
			}
		}
		//System.out.println(list.size());
		Collections.sort(list);
		String ans = list.get(0);
		if(K==1) {
			System.out.println(ans);
			System.exit(0);
		}
		int cnt = 1;
		for(int i = 0; i < list.size(); i++) {
			if(!list.get(i).equals(list.get(i + 1))) {
				cnt ++;
				if(cnt == K) {
					ans = list.get(i + 1);
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

signed main()
{
    string a="CODEFESTIVAL2016";
    string S;cin >> S;
    int ans=0;
    rep(i,16){ans+=a[i]!=S[i];}
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define rep(p,q) for(int i = p;i < q;i++)

#define LL long long int

#define inf 10000000000

//15
int main(void) {
	LL n;
	cin >> n;
	int count = 0;
	count += n / 25;
	n %= 25;
	count += n / 10;
	n %= 10;
	count += n / 5;
	n %= 5;
	count += n;
	cout << count << endl;
}


Measured memory_bytes: 3100
dice = gets.split.map(&:to_i)
label = [4, 3, 5, 2, 1]		# 西, 東, 北, 南, 中央（上面）

gets.chomp.chars do |move|
	if move == "N"
		temp_n = label[4]		# 中央→北
		temp_c = label[3]		# 南→中央
		temp_s = 7 - label[4]	# 中央の裏（7-中央） → 南
		label[2] = temp_n
		label[3] = temp_s
		label[4] = temp_c
	elsif move == "S"
		temp_n = 7 - label[4]	# 中央の裏（7-中央） → 北
		temp_c = label[2]		# 北→中央
		temp_s = label[4]		# 中央→南
		label[2] = temp_n
		label[3] = temp_s
		label[4] = temp_c
	elsif move == "W"
		temp_w = label[4]		# 中央→西
		temp_c = label[1]		# 東→中央
		temp_e = 7 - label[4]	# 中央の裏（7-中央） → 東
		label[0] = temp_w
		label[1] = temp_e
		label[4] = temp_c
	else
		temp_w = 7- label[4]	# 中央の裏（7-中央） → 西
		temp_c = label[0]		# 西→中央
		temp_e = label[4]		# 中央→東
		label[0] = temp_w
		label[1] = temp_e
		label[4] = temp_c
	end
end

puts dice[label[4] - 1]






Measured memory_bytes: 6880