akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    for (ll i = 0; i < N; i++) {
        cin >> V[i];
    }

    ll ans = 0;
    for (ll i = 0; i <= K; i++) {
        for (ll j = 0; j <= K - i; j++) {
            vector<ll> copy = V;
            vector<ll> picked;
            for (ll k = 0; k < i; k++) {
                if (copy.empty()) {
                    break;
                }
                picked.push_back(copy.front());
                copy.erase(copy.begin());
            }
            for (ll k = 0; k < j; k++) {
                if (copy.empty()) {
                    break;
                }
                picked.push_back(copy.back());
                copy.pop_back();
            }

            sort(picked.begin(), picked.end());
            ll tmp = 0;
            ll rem = K - i - j;
            for (ll e : picked) {
                if (e >= 0) {
                    tmp += e;
                } else {
                    if (rem > 0) {
                        rem--;
                    } else {
                        tmp += e;
                    }
                }
            }

            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
}

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

int main(int argc, char const *argv[]) {
    vector<vector<int> > card(3, vector<int>(3));
    vector<vector<bool> > hit(3, vector<bool>(3, false));
    for (size_t i = 0; i < 3; i++) {
        for (size_t j = 0; j < 3; j++) {
            cin >> card[i][j];
        }
    }

    int n;
    cin >> n;
    for (size_t i = 0; i < n; i++) {
        int bi;
        cin >> bi;
        for (size_t j = 0; j < 3; j++) {
            for (size_t k = 0; k < 3; k++) {
                if (bi == card[j][k]) hit[j][k] = true;
            }
        }
    }

    string ans = "No";
    if (hit[0][0] && hit[0][1] && hit[0][2]) ans = "Yes";
    if (hit[1][0] && hit[1][1] && hit[1][2]) ans = "Yes";
    if (hit[2][0] && hit[2][1] && hit[2][2]) ans = "Yes";
    if (hit[0][0] && hit[1][0] && hit[2][0]) ans = "Yes";
    if (hit[0][1] && hit[1][1] && hit[2][1]) ans = "Yes";
    if (hit[0][2] && hit[1][2] && hit[2][2]) ans = "Yes";
    if (hit[0][0] && hit[1][1] && hit[2][2]) ans = "Yes";
    if (hit[0][2] && hit[1][1] && hit[2][0]) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <iostream>
using namespace std;
char eras[110000];
int main(void){
    int X;
    cin >> X;
    eras[0] = 1;
    for (int i = 2; i < X; i++) {
        if (eras[i-1] == 0) {
            for (int j = i; j < 110000; j+=i) {
                eras[j-1] = 1;
            }
        }
    }
    int idx = X-1;
    while (eras[idx] != 0) {
        idx++;
    }
    cout << idx+1 << endl;
}

Measured memory_bytes: 384
/*input
5
3 3 3 3 3
*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
#define INF 3e18
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< ll, ll > ii;
typedef unordered_set<int> usi;
 
 
 
ll n,i,j,k,m,c;

void solve()
{ 
  cin>>n;
  int a[n];
  rep(i,n)
  cin>>a[i];

  m=a[0];
int ans=0;
  for(i=0;i<n;i++)
  {
    ans+= max(c,m-a[i]);
    m=max(m,a[i]);

  }

  cout<<ans;
}
 
 
 
signed main()
{// inputFile;


    fast;
    int T = 1;
    // cin >> T;
    ll h=T;
    while(T--){
 
        solve();
        cout<<endl;
 
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 5216
N = int(input())
A = list(map(int,input().split()))
B = {}
for i in A:
  if i not in B:
    B[i] = 0
  B[i] += 1
  
for j in range(1,N+1):
  try:
    print(B[j])
  except KeyError:
    print(0)

Measured memory_bytes: 33520
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
#include<string>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int N;
	string s;
	map<string, int> m;

	cin >> N;
	repeat(i, i < N) {
		cin >> s;
		m[s]++;
	}

	printf("AC x %d\n", m[string("AC")]);
	printf("WA x %d\n", m[string("WA")]);
	printf("TLE x %d\n", m[string("TLE")]);
	printf("RE x %d\n", m[string("RE")]);

	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 3656
#include <stdio.h>

int main()
{
    int a, b, c;
    int res=0;
    scanf("%d%d%d", &a, &b, &c);
    for(; a<=b; a++) {
        if(c%a==0) res++;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 596
import sys
input=sys.stdin.readline
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

t,k=ml()
n=ll()
ans=0
lol=0
for i in range(t):
    if(i>=k):
        lol+=((n[i]*(n[i]+1))//2)/n[i]
        lol-=((n[i-k]*(n[i-k]+1))//2)/n[i-k]
    else:
        lol+=((n[i]*(n[i]+1))//2)/n[i]
    ans=max(ans,lol)
print(ans)    

Measured memory_bytes: 102848
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    int two = 0;
    REP(i, 0, N) {
        int a; cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            two++;
        }
    }
    cout << two << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M = inputs()
if N>=2 and M>=2:
    print((N-2)*(M-2))
    exit()
else:
    if N==1 and M==1:
        print(1)
        exit()
    print(max(N-2,M-2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    std::sort(a.begin(), a.end());

    if (a.back() < 0) {
        int m = std::accumulate(a.begin(), a.end() - 1, 0) * -1 + a.back();
        int c = a.back();
        std::cout << m << std::endl;
        for (int i = 0; i < n - 1; i++) {
            std::cout << c << " " << a[i] << std::endl;
            c -= a[i];
        }
    } else if (a.front() > 0) {
        int m = std::accumulate(a.begin() + 1, a.end(), 0) - a.front();
        int c = a.front();
        std::cout << m << std::endl;
        for (int i = 1; i < n - 1; i++) {
            std::cout << c << " " << a[i] << std::endl;
            c -= a[i];
        }
        std::cout << a.back() << " " << c << std::endl;
    } else {
        int m = 0;
        for (auto e : a) m += abs(e);
        std::cout << m << std::endl;
        int c = a.front();
        auto j = std::lower_bound(a.begin() + 1, a.end(), 0) - a.begin();
        for (int i = j; i < n - 1; i++) {
            std::cout << c << " " << a[i] << std::endl;
            c -= a[i];
        }
        std::cout << a.back() << " " << c << std::endl;
        c = a.back() - c;
        for (int i = 1; i < j; i++) {
            std::cout << c << " " << a[i] << std::endl;
            c -= a[i];
        }
    }

    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<algorithm>
using ui = unsigned int;

int main(){
	ui n, m;//<=10^5
	std::cin >> n >> m;
	
	std::vector<ui> hs(n);
	for( auto&e : hs )
		std::cin >> e;


	std::vector<std::vector<ui>> graph( n, std::vector<ui>() );

	for( ui i{}; i < m; ++i )
	{
		ui a, b;
		std::cin >> a >> b;
		--a, --b;
		graph[a].emplace_back( b );
		graph[b].emplace_back( a );
	}

	auto ans = 0;
	for( ui i{}; i < n; ++i )
	{

		const auto ret = std::all_of(
			std::cbegin(graph[i])
			,std::cend(graph[i])
			, [&hs,i](const auto x)->bool
			{
				return hs[x] < hs[i];
			}
		);

		ans += ret ? 1 : 0;
	}

	std::cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 8320
#include <iostream>
using namespace std;
int N, W;
int v[110], w[110];
int dp[110][100100];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = max(dp[i][j], dp[i+1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7396
S = input()
T = input()


def match(k):
    s = S[k:k+len(T)]
    
    for j in range(len(s)):
        if s[j] not in (T[j], '?'):
            return False

    return True

def construct(k):
    ans = list(S)

    for i in range(len(T)):
        ans[k+i] = T[i]
    
    for i in range(len(S)):
        if (ans[i] == '?'):
            ans[i] = 'a'

    return ''.join(ans)

res = []
for i in range(len(S) - len(T) + 1):
    if match(i):
        s = construct(i)
        res.append(s)

if res:
    print(min(res))
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
n = gets.chomp.to_i
s = gets.chomp.split(' ').map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(' ').map(&:to_i)

def linear_search(arr, n, key)
  i = 0
  arr[n] = key
  while arr[i] != key
    i += 1
  end
  if i == n
    return false
  end
  return i
end

count = 0

t.each do |obj|
  if linear_search(s, n, obj)
    count += 1
  end
end

print "#{count}\n"



Measured memory_bytes: 7176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

const int m = 2019;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  reverse(ALL(s));
  int x = 1, tot = 0;
  vector<int> cnt(m);
  ll ans = 0;
  rep(i, n){
    cnt[tot]++;
    tot += (s[i] - '0')*x;
    tot %= m;
    ans += cnt[tot];
    x = x*10%m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;

int main()
{
    char c;
    vector<int> v('z' - 'a' + 1);

    while (cin.get(c))
        if (isalpha(c))
            v[tolower(c) - 'a']++;

    for (c = 'a'; c <= 'z'; c++)
        cout << c << " : " << v[c - 'a'] << endl;

    return 0;
}


Measured memory_bytes: 3096
n, q = map(int, input().split())
arr = []

for i in range(n):
    name, t = map(str, input().split())
    arr.append([name, t, 0])

for i in range(n):
    arr[i][1] = int(arr[i][1])

time = 0

while arr != []:
    if arr[0][1] <= 0:
        tmp = arr.pop(0)
        print("{} {}".format(tmp[0],time))
    elif arr[0][1] <= q:
        tmp = arr.pop(0)
        time += tmp[1]
        print("{} {}".format(tmp[0],time))
    elif arr[0][1] > q:
        arr[0][1] -= q
        time += q
        last = arr.pop(0)
        arr.append(last)
    else:
        print("その他")


Measured memory_bytes: 13272
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10005], b[10005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;

int h, w;
char s[25][25];

int bfs(int sx, int sy) {
	int dist[25][25];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = inf;
		}
	}
	dist[sx][sy] = 0;
	queue<P>v;
	v.push(P{ sx, sy });
	while (v.size()) {
		P now = v.front();
		v.pop();
		for (int i = 0; i < 4; i++) {
			int nextx = now.second + dx[i];
			int nexty = now.first + dy[i];
			if (0 <= nextx && nextx < w && 0 <= nexty && nexty < h) {
				if (dist[nexty][nextx]==inf && s[nexty][nextx] != '#') {
					dist[nexty][nextx] = dist[now.first][now.second] + 1;
					v.push(P{ nexty, nextx });
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (dist[i][j] != inf) {
				res = max(res, dist[i][j]);
			}
		}
	}
	
	return res;

}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	int kai = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				int ans = bfs(i, j);
				kai = max(kai, ans);
				
			}
		}
	}
	cout << kai << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  long long m;
  cin>>n>>m;
  int a[n], b[n];
  REP(i,n){
    cin>>a[i];
    b[i] = a[i]/2;
  }
  long long l = 1;
  REP(i,n){
    l = lcm_(l, b[i]);
    if(l > m){
      cout<<0<<endl;
      return 0;
    }
  }
  REP(i,n){
    if((l/b[i])%2 == 0){
      cout<<0<<endl;
      return 0;
    }
  }
  long long ans;
  if(m-l<0){
    cout<<0<<endl;
  }else{
    ans = (m-l)/(2*l);
    ans++;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        for(int j=i+1;j<s.size();j++){
            if(s[i]==s[j]){
                cout<<"no"<<endl;
                return 0;
            }
        }
    }
    cout<<"yes"<<endl;
    return 0;
}


Measured memory_bytes: 3620
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[20][150010];
 
signed main() {
    int D, G; cin >> D >> G;
    G /= 100;
    fill(dp[0], dp[20], INF);

    dp[0][0] = 0;
    for(int i=0; i<D; i++) {
        int p, c; cin >> p >> c;
        c /= 100;

        for(int k=0; k<=p; k++) {
            int is_comp = (k == p ? c : 0);

            int point = k*(i+1) + is_comp;
            for(int j=0; j<=G; j++) {
                int nj = min(G, j + point);
                chmin(dp[i+1][nj], dp[i][j] + k);
            }
        }
    }

    cout << dp[D][G] << endl;
    return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,v[200],W,w[200],k,dp[200][100009];
ll f(ll N, ll V){
	if (N==0){
		if(V==0)return 0;
		else return 1e15;
	}
	
	if(dp[N][V]!=-1)return dp[N][V];
	if (V>=v[N])dp[N][V]=min(f(N-1,V),f(N-1,V-v[N])+w[N]);
	else dp[N][V]=f(N-1,V);
	return dp[N][V];
}
 
int main(){
	cin >> n >> W;
	for(int i=1; i<=n; i++)cin >> w[i] >> v[i];
	memset(dp,-1,sizeof dp);
	ll jwb=0;
	for(ll i=0; i<=100000; i++){
		ll z=f(n,i);
		if (z<=W)jwb=max(jwb,i);
	}
	cout << jwb << endl;
}
//a

Measured memory_bytes: 156544
H, W = map(int, input().split())
Slist = [["."] * (W + 2), ]
for _ in range(H):
    line = list(input())
    line.insert(0, ".")
    line.append(".")
    Slist.append(line)
Slist.append(["."] * (W + 2))
# print(Slist)
point_tuple = ((-1, -1), (-1, 0), (-1, 1),
               (0, -1), (0, 1),
               (1, -1), (1, 0), (1, 1))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        # print(Slist[i][j], i, j)
        if Slist[i][j] == ".":
            counter = 0
            for a, b in point_tuple:
                if Slist[i - a][j - b] == "#":
                    counter += 1
            Slist[i][j] = str(counter)

for i in range(1, H + 1):
    print("".join(Slist[i][1:-1]))


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

int main() {
  int n;
  int min;
  int inp[100100];
  int kazu[100100];
  int tog[100100];
  int ans;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> inp[i];
    kazu[i] = 0;
  }
  
  for(int i = 0; i < 100010; i++){
    kazu[i] = 0;
      }

  for(int i = 0; i < n; i++){
    int a;
    a = inp[i];
    kazu[a] = kazu[a] + 1;
      }
 
 ans = kazu[0] + kazu[1];
 
 for(int i = 1; i < 100001; i++){
       int b;
       b = ans;
    if(kazu[i - 1] + kazu[i] + kazu[i + 1] > b){
       ans = kazu[i - 1] + kazu[i] + kazu[i + 1];
    }
  }
  cout << ans;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int h, w;
  cin >> h >> w;
  h += 2;
  w += 2;

  vector<vector<char>> a(h, vector<char>(w));

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i == 0 || j == 0 || i == h - 1 || j == w - 1) {
        a[i][j] = '#';
      } else {
        cin >> a[i][j];
      }
      cout << a[i][j];
    }
    cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 3668
query_num, a, b, c = gets.split.map(&:to_i)
queries = query_num.times.map{ gets.chomp }

ps = [a, b, c]

idx = Proc.new do |x|
  case x
  when "A"
    0
  when "B"
    1
  when "C"
    2
  end
end

transfer = Proc.new do |from, to|
  next false if ps[idx.call(from)] <= 0

  ps[idx.call(from)] -= 1
  ps[idx.call(to)] += 1

  true
end

res = []

queries.each_with_index do |el, i|
  p = [[ps[idx.call(el[0])], el[0]], [ps[idx.call(el[1])], el[1]]]

  p.sort_by! {|e| e[0] }

  if p[0][0] == 0 and p[1][0] == 0
    res = []
    break

  elsif p[0][0] == 0 and p[1][0] > 0
    transfer.call(p[1][1], p[0][1])
    res.push(p[0][1])

  elsif p[0][0] == 1 and p[1][0] == 1 and i + 1 < query_num
    if queries[i + 1].include? p[0][1]
      transfer.call(p[1][1], p[0][1])
      res.push(p[0][1])

    else
      transfer.call(p[0][1], p[1][1])
      res.push(p[1][1])

    end

  else
    transfer.call(p[1][1], p[0][1])
    res.push(p[0][1])

  end
end

if res.length < query_num
  puts "No"

else
  puts "Yes"
  puts res

end


Measured memory_bytes: 32640
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000009;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int a,b;cin>>a>>b;
	if(a<=b){
		cout<<a<<endl;
	}else{
		cout<<a-1<<endl;
	}
    return 0;
}


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

#define rep(n, i) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

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

    vector<int> a(n);
    for (auto & e : a) {
      cin >> e;
    }

    bool approved = true;
    for (auto e : a) {
      if ( !(e % 2) && e % 3 && e % 5 ) {
        approved = false;
        break;
      }
    }

    cout << (approved ? "APPROVED" : "DENIED") << endl;
}


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

int main(){
	int a, b, t = 0, n = 0;
	double s = 0;
	while(scanf("%d,%d", &a, &b) != EOF){
		t += a*b;s += b;n++;
		if(n == 3)break;
	}
	printf("%d\n%d\n", t, (int)(s/n+0.5));
	return 0;
}

Measured memory_bytes: 3188
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <vector>

const int MAX_N = 100;
const int MAX_V = 1000;

std::vector<int> minW(1 + MAX_N * MAX_V, INT_MAX / 2);

int main() {
  int n, W;
  scanf("%d%d", &n, &W);
  minW[0] = 0;
  for (int i = 0; i < n; i++) {
    int w, v;
    scanf("%d%d", &w, &v);
    for (int v0 = MAX_N * MAX_V - v; v0 >= 0; v0--)
      minW[v0 + v] = std::min(minW[v0 + v], minW[v0] + w);
  }
  int answer = 0;
  for (int v = 1; v <= MAX_N * MAX_V; v++)
	if (minW[v] <= W)
	  answer = v;
  printf("%d\n", answer);
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

void maxHeapify(vector<int>& heap, int ix, int size)
{
  int l = 2 * ix, r = 2 * ix + 1;
  int largest = ix;
  if (l <= size && heap[l] > heap[largest]) { largest = l; }
  if (r <= size && heap[r] > heap[largest]) { largest = r; }
  if (ix != largest) {
    swap(heap[ix], heap[largest]);
    maxHeapify(heap, largest, size);
  }
}

void buildHeap(vector<int>& heap, int size)
{
  for (int i = size / 2; i >= 1; --i) {
    maxHeapify(heap, i, size);
  }
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> heap(n + 5);
  for (int i = 1; i <= n; ++i) {
    fscanf(stdin, "%d", &heap[i]);
  }
  buildHeap(heap, n);
  for (int i = 1; i <= n; ++i) {
    fprintf(stdout, " %d", heap[i]);
  }
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 3112
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	int n, a, b;
	cin >> n;
	cin >> a >> b;
	if (a % 2 == b % 2) {
		cout << "Alice\n";
	}
	else {
		cout << "Borys\n";
	}
	return 0;
}




Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define mmod 1000000007
#define N 16
#define M (1<<15)+10
using namespace std;
int n,m,a[N],f[M],bit[M],p2[N*N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		a[x]|=1<<(y-1);
	}
	p2[0]=1;
	for(int i=1;i<=m;i++) p2[i]=p2[i-1]*2%mmod;
	int ss=(1<<n)-1;
	for(int i=1;i<=ss;i++) bit[i]=bit[i>>1]+(i&1);
	f[0]=1;
	for(int i=0;i<ss;i++)
	{
		if(f[i]==0) continue;
		int t=ss-i;
		for(int j=t;j;j=(j-1)&t)
			if((j&3)==0 || (j&3)==3)
			{
				int r=ss-i-j,cnt=0,tmp;
				for(int k=1;k<=n;k++) if(j&(1<<(k-1))) cnt+=bit[a[k]&r];
				tmp=p2[cnt];
				for(int k=1;k<=n;k++) if(r&(1<<(k-1))) tmp=1ll*tmp*(p2[bit[a[k]&j]]-1)%mmod;
				f[i+j]=(f[i+j]+1ll*f[i]*tmp)%mmod;
			}
	}
	int ans=(p2[m]-f[ss])%mmod;
	printf("%d\n",(ans+mmod)%mmod);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	for(int i=0;i<a;i++){
		if(s[i]=='-') {
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(s[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=a+1;i<a+b+1;i++){
		if(s[i]=='-'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define inf 1000000000000000000
#define iinf -1000000000000000000
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007
#define base 1949313259
#define en '\n'

ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }

ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

ll bigmod(ll n,ll pow){
if(pow==0) return 1;
if(pow==1) return n%mod;

ll ans=bigmod(n,pow/2);
ans=(ans*ans)%mod;

if(pow%2==1){ans=(ans*n)%mod;}
return ans%mod;
}

ll fact[1000005];

ll nCr(ll n,ll r){

ll ans=fact[n];
ans=(ans*bigmod(fact[r],mod-2))%mod;
ans=(ans*bigmod(fact[n-r],mod-2))%mod;
return ans;
}

string s,s1,s2;
ll n,m;
ll arr[500010];
ll brr[500010];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];

int main()
{__
        ll i,j,a,b,c,d,e,f,g,x,y,z,t,k,l,r;
        fact[0]=1;

      //  for(i=1;i<=1000000;i++) fact[i]=(fact[i-1]*i)%mod;
        ll ans=0,sum=0,temp;
        cin>>s;

        if(s[0]>='a'&&s[0]<='z') cout<<'a'<<endl;
        else cout<<'A'<<endl;
}




Measured memory_bytes: 3612
// Date: 2020-03-16

#include <bits/stdc++.h>
#include <limits>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

struct Matrix {
    int sz;
    LL a[50][50];
    void init() {
        memset(a, 0, sizeof(a));
    }
    Matrix(int SZ) {
        sz = SZ;
        this->init();
    }
    Matrix operator * (const Matrix& t) const {
        Matrix ans(sz);
        for(int k = 0; k < sz; k++)
            for(int i = 0; i < sz; i++) if(a[i][k])
                for(int j = 0; j < sz; j++)
                    ans.a[i][j] = (ans.a[i][j]+a[i][k]*t.a[k][j]) % mod;
        return ans;
    }
    void print() {
        rep(i, 0, sz-1) {
            rep(j, 0, sz-1) {
                cout<<a[i][j]<<" ";
            }
            cout<<endl;
        }
    }
};

Matrix qpow(Matrix A, LL b) {
    Matrix res(A.sz); res.init();
    for(int i = 0; i < A.sz; i++) res.a[i][i] = 1;
    while(b) {
        if(b & 1) res = res*A;
        A = A*A;
        b >>= 1;
    }
    return res;
}

int n;
LL k;

int main() {
    FIO;
    cin >> n >> k;
    Matrix m(n);
    rep(i, 0, n-1) rep(j, 0, n-1) cin >> m.a[i][j];
    m = qpow(m, k);
    LL ans = 0;
    rep(i, 0, n-1) rep(j, 0, n-1) ans = (ans + m.a[i][j]) % mod;
    cout << ans;

    return 0;
}

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


int main () {
	lli ans=0,n,amax,bmin;
	cin >> n;

	lli *a;
	lli *b;
	a = new lli[n];
	b = new lli[n]; 
	for(lli i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}

	amax = a[0];
	bmin = b[0];

	for(lli i=0;i<n;i++){
		amax = max(amax,a[i]);
		bmin = min(bmin,b[i]);
	}

	ans = amax + bmin;

	cout << ans << endl;

    return 0;
}

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

int main()
{
    double n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int power = 0, tmp = i;
        while(k > tmp)
        {
            tmp *= 2;
            ++power;
        }
        if(power == 0)
        {
            ans += (1.0 / n) * (n - i + 1);
            break;
        }
        ans += 1.0 / n * pow(0.5, power);
    }
    printf("%.12f", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
typedef struct pp{
    char name[100];
    int t;
} P;
queue<P> m;
int main()
{
    int i,n,q,ans=0;
    P u;
    cin>>n>>q;
    for(i=0;i<n;i++)
    {
        cin>>u.name>>u.t;
        m.push(u);
    }
    while(!m.empty())
    {
        u=m.front();
        if(q>=u.t)
        {
            ans+=u.t;
            m.pop();
            cout<<u.name<<" "<<ans<<endl;
        }
        else
        {
            ans+=q;
            u.t-=q;
            m.push(u);
            m.pop();
        }
    }
    return 0;
}

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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var tmp = buffer.Distinct().Count();
            if (tmp == 1 || tmp == 3)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 26560
a, b, c, d = map(int, input().split())

total = b - a + 1

c_1 = b//c - a//c if a%c!=0 else b//c - a//c + 1
d_1 = b//d - a//d if a%d!=0 else b//d - a//d + 1

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

div = int(c * d / gcd(c, d))

cd = b//div - a//div if a%div!=0 else b//div - a//div + 1

print(total - c_1 - d_1 + cd)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    int N;
    cin>>N;
    vector<ll>A(N+1);
    vector<ll>B(N),C(N);
    rep(i,N+1){
        cin>>A[i];
    }
    rep(i,N){
        cin>>B[i];
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        if(A[i]-B[i]>0){
            ans+=B[i];
        }
        else if(A[i]+A[i+1]-B[i]>0){
            ans+=B[i];
            A[i+1]=A[i]+A[i+1]-B[i];
        }
        else{
            ans+=A[i]+A[i+1];
            A[i+1]=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
import sys

input = sys.stdin.readline

N, K = map(int, input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

print(len(Base_10_to_n(N, K)))


Measured memory_bytes: 2940
#include <stack>
#include <cstdio>
using namespace std;

int main(){
    int s;
    stack<int> stk;
    while(~scanf("%d",&s)){
        if(s){
            stk.push(s);
        } else {
            printf("%d\n",stk.top());
            stk.pop();
        }
    }
}

Measured memory_bytes: 1020
#ifdef ABACABA

#include "stdc++.h"

#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define int long long

typedef long double ld;

#define all(a) a.begin(), a.end()

#define pii pair<int, int>

#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>

#define pb push_back
#define ins insert
#define ub upper_bound
#define lb lower_bound
#define mkt make_tuple
#define ff first
#define ss second

#define in(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 1000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());


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

    int n;
    cin >> n;

    vi a(n);
    vi b(n + 1);

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

    set<int> id;
    set<int> reid;

    id.ins(n);
    reid.ins(1);

    int sum = 0;

    for (int j = 1; j <= n; ++j) {
        int x = b[j];

        int l = -(*(reid.ub(-x)));
        int r = *(id.ub(x));

        ++l;
        --r;

        sum += (x - l + 1) * (r - x + 1) * j;

        id.insert(x);
        reid.insert(-x);
    }

    cout << sum;

}

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

int main()
{	
	int N,M;
	cin >> N >> M;
	priority_queue<int> A;
	rep(i,N) {
		int n;
		cin >> n;
		A.push(n);
	}
	
	rep(i,M){
		int val = A.top();
		A.pop();
		A.push(val/2);
	}

	long long sum=0;
	rep(i,N){
		sum+=A.top();
		A.pop();
	}
	cout <<sum;

}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,K;
    cin >> N >> K;
    ll sum = 0;
    for (ll i = K; i <= N+1; ++i) {
        ll m = (i-1)*(i)/2;
        ll M = N*(N + 1)/2 - (N-i)*(N-i+1)/2;
       //cout << m << "," << M << endl;
        sum += M - m+1;
        sum %= MOD7;
    }
    cout << sum << endl;

}


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

using namespace std;

int main(){

	int n;
	string s;
	bool b = false;

	cin >> n >> s;

	if(n % 2 == 0){
		for(int i = 0; i < n/2; i++){
			if(s[i] == s[i+n/2]){
				b = true;
			}
			else{
				b = false;
				break;
			}
		}
	}

	if(b == true) cout << "Yes" << endl;
	else          cout << "No" << endl;

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
const int inf = pow(2, 31) - 1;
void merge(pair<char, int> a[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    pair<char, int> l[n1+1], r[n2+1];
    rep(i,n1)l[i] = a[left + i];
    rep(i,n2)r[i] = a[mid + i];
    l[n1] = make_pair('0', inf);
    r[n2] = make_pair('0', inf);
    int i = 0, j = 0;
    REP(k,left, right){
        if(l[i].second <= r[j].second){
            a[k] = l[i];
            i++;
        }else {
            a[k] = r[j];
            j++;
        }
    }
}
void merge_sort(pair<char, int> a[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        merge_sort(a, left, mid);
        merge_sort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int partition(pair<char, int> a[], int p, int r){
    int x = a[r].second;
    int i = p - 1;
    REP(j,p,r){
        if(a[j].second <= x){
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i+1], a[r]);
    return i+1;
}
void quick_sort(pair<char, int> a[], int p, int r){
    if(p < r){
        int q = partition(a, p, r);
        quick_sort(a, p, q-1);
        quick_sort(a, q+1, r);
    }
}

int main(){
    int n;
    cin >> n;
    pair<char, int> a[n], b[n];
    rep(i,n){
        char pic;
        int num;
        cin >> pic >> num;
        a[i] = make_pair(pic, num);
        b[i] = a[i];
    }
    merge_sort(a, 0, n);
    quick_sort(b, 0, n-1);

    bool same = true;
    rep(i,n)if(a[i] != b[i]){
        same = false;
        break;
    }

    if(!same)printf("Not stable\n");
    else printf("Stable\n");

    rep(i,n){
        //printf("%c %d   ", a[i].first, a[i].second);
        printf("%c %d\n", b[i].first, b[i].second);
    }

    return 0;
}


Measured memory_bytes: 5420
from collections import Counter

N = int(input())
S = [str(input()) for i in range(N)]
X = Counter(S)
ans = X.most_common()
p = ans[0][1]

A = [i[0] for i in X.items() if i[1] == p]
A.sort()

for i in range(len(A)):
    print(A[i])

Measured memory_bytes: 121808
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

// 辺を表す構造体 {行先、容量、逆辺}
struct edge { int to; ll cap; int rev; };
#define V 1010
vector< vector<edge> > G(V, vector<edge>()); //グラフの隣接リスト表現
vl level(V); //sからの距離
vi iter(V); //どこまで調べ終わったか

			//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, ll cap) {
	edge a;
	a.to = to; a.cap = cap; a.rev = G[to].size();
	G[from].push_back(a);
	a.to = from; a.cap = 0; a.rev = G[from].size() - 1;
	G[to].push_back(a);
}

//sからの最短距離をBFSで計算する
void bfs(int s) {
	fill(level.begin(), level.end(), -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

//増加パスをDFSで探す
ll dfs(int v, int t, ll f) {
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			ll d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

//sからtへの最大流を調べる
ll max_flow(int s, int t) {
	ll flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0) return flow;
		fill(iter.begin(), iter.end(), 0);
		ll f;
		while ((f = dfs(s, t, inf)) > 0) {
			flow += f;
		}
	}
}

int main() {
	int n, i, j;
	cin >> n;
	vl a(n);
	ll sum = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum += max(a[i], 0LL);
	}
	for (i = 1; i <= n; i++) {
		for (j = 2; i*j <= n; j++) {
			add_edge(i, i*j, INF);
		}
	}
	for (i = 0; i < n; i++) {
		if (a[i] < 0) {
			add_edge(0, i + 1, -a[i]);
		}
		else {
			add_edge(i + 1, n + 1, a[i]);
		}
	}
	cout << sum - max_flow(0, n + 1) << endl;
}



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

int main(){
  unsigned long long a, b; string s; cin >> a >> s;
  b = (s[0]-'0')*100 + (s[2]-'0')*10 + s[3]-'0';
  cout << a * b / 100 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;


ll res(long long N,long long X){
    if(N == 0) return 1;
    if(X == 1) return 0;
    long long len = (1LL << (N + 1)) - 3;
    long long pty = (1LL << N) - 1;
    if(X <= len + 1) return res(N - 1, X - 1);
    else if(X == len + 2) return pty + 1;
    else if(X < 2*len + 3) return pty + 1 + res(N - 1,X - len - 2);
    else return 2*pty + 1;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N,X;
    cin >> N >> X;
    cout << res(N,X) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b;
	char s[10],t[10];

	scanf("%s%s%d%d%s",s,t,&a,&b,s);

	if(strcmp(s,t)==0)
		printf("%d %d",a,b-1);
	else
		printf("%d %d",a-1,b);
	return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
ll mod = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n + 5);
    for(ll i = 1; i <= n; ++i){
        cin >> v[i];
    }
    ll arr[200001] = {0};
    ll r = 0, ans, cur = 1, kanta = k;
    for(ll i = 1; i <= n; ++i){
        ans = cur;
        if(arr[ans] == true){
            break;
        }
        cur = v[ans];
        kanta--;
        if(kanta == 0){
            cout << cur;
            return 0;
        }
        arr[ans] = true;
    }
    memset(arr, 0, sizeof(arr));
    ll fuckme = ans;
    cur = ans; // pocetak cycle,  v1.size() cycle len
    vector<ll> v1;
    ll tmp = 0;
    for(ll i = 1; i <= n; ++i){
        ans = cur;
        if(arr[ans] == true){
            break;
        }
        v1.push_back(cur);
        cur = v[ans];
        arr[ans] = true;
    }
    cur = 1;
    for(ll i = 0; i < v.size(); ++i){
        cur = v[cur];
        if(v1[0] == cur){
            tmp = i + 1; // before cycle
            break;
        }
    }
    k -= tmp;
    k %= v1.size(); 
    cur = fuckme;
    while(k){
        cur = v[cur];
        k--;
    }
    cout << cur;
    return 0;
 
}


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

int main() {
    int n;
    cin >> n;
    int res=0;
    int first, second, third;
    cin >> first >> second;
    for (int i=0; i<n-2; i++){
        cin >> third;
        if ((first < second && second < third) || (first > second && second > third)) res++;
        first = second;
        second = third;
    }
    cout << res;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1000000007, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}
 

 
signed main(){
	int N;
	cin>>N;
	vector<int> a(N+1); for(auto& e:a)cin >> e;
	vector<int> b(N); for(auto& e:b)cin >> e;
	int ans = 0;
	REP(i,N){
		int t = min(a[i],b[i]);
		ans += t;
		b[i] -= t;
		t = min(b[i],a[i+1]);
		ans += t;
		a[i+1] -= t;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    for(int n; cin >> n, n; ){
        vector<int>vec(n);
        for(int i = 0; i < n; i++)cin >> vec[i];
        sort(vec.begin(), vec.end());
        int ans = vec[1] - vec[0];
        for(int i = 1; i < n; i++)ans = min(ans, vec[i] - vec[i - 1]);
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3156