akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

ll lcm(ll a1,ll b1){
	if(a1*b1==0){return 0;}
	return (a1*b1/gcd(a1,b1));
}
int main() {

	rep(i,200){
		ll a,b;
		cin>>a>>b;
		if(cin.eof())break;
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	}

	return 0;
}



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

int main()
{
    ll n;
    cin>>n;
    ll arr[n+1][3];
    ll dp[n+1][3];

    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        dp[i][0] = 10e15;
        dp[i][1] = 10e15;
        dp[i][2] = 10e15;
    }

    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    for(ll i=1;i<=n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + arr[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + arr[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + arr[i][2];
    }

    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll n;
    string S;
    cin >> n;
    cin >> S;
    vector<ll> W(n);
    vector<ll> E(n);
    // Eは右を、Wは左を見ている。
    for (int i = 0; i < S.size() - 1; i++)
    {
        if (S[i] == 'W')
        {

            W[i + 1] = W[i] + 1;
        }

        else
        {
            W[i + 1] = W[i];
        }
    }
    for (int i = n - 1; i >= 1; i--)
    {
        if (S[i] == 'E')
        {
            E[i - 1] = E[i] + 1;
        }
        else
        {
            E[i - 1] = E[i];
        }
    }
    ll min1 = INF;
    rep(i, n)
    {
        ll count = E[i] + W[i];
        min1 = min(min1, count);
    }
    cout << min1 << endl;
}


Measured memory_bytes: 5380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[200010],b[2000010],n,m;
int qzl[200010],qzr[200010],hzl[200010],hzr[200010]; 
int calc(int L,int R){
	return a[L]==min(hzl[L],qzl[R])&&
	a[R]==max(hzr[L],qzr[R]);
}
int main(){
	scanf("%d%d",&n,&m);
	int tag=-1;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i>0&&a[i]>a[i-1])b[i]=b[i-1]+1;
		else b[i]=1;
		if(b[i]>=m)tag++;
	}
	for(int i=0;i<n;i++){
		if(i%m==0)qzl[i]=qzr[i]=a[i];
		else qzl[i]=min(qzl[i-1],a[i]),qzr[i]=max(qzr[i-1],a[i]);
	}
	for(int i=n-1;i>=0;i--){
		if(i==n-1||(i+1)%m==0)hzl[i]=hzr[i]=a[i];
		else hzl[i]=min(hzl[i+1],a[i]),hzr[i]=max(hzr[i+1],a[i]);
	}
	int ans=n-m+1;
	for(int i=m-1;i<n-1;i++)
	if(b[i]<m&&b[i+1]<m&&calc(i-m+1,i+1))ans--;
	ans-=max(0,tag);cout<<ans;
	return 0;
}


Measured memory_bytes: 5120
n = gets.chomp.to_i

playlist = []
sleep = ""
while line = gets
  splited = line.split(" ")
  if splited.size != 2
    sleep = splited[0]
    break
  end

  name = splited[0]
  len = splited[1].to_i

  playlist << {name: name, len: len}
end

t = 0
neteru = false
playlist.each do |song|
  t += song[:len] if neteru
  neteru = true if song[:name] == sleep
end

puts t

Measured memory_bytes: 1916
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string n = Console.ReadLine();
        for (int i = 0; i < n.Length; i++)
            Console.Write(n[i] == '1' ? '9' : '1');
        Console.WriteLine();
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(){
  int n;
  int h;
  int p;
  int ans;
  ans=0;
  p=0;
  scanf("%d",&n);
  int i=0;
  for(i=0;i<n;i++){
    scanf("%d",&h);
    if (p<=h){
      ans+=1;
      p=h;
    }
  }
  printf("%d\n",ans);
}
  


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
    string t;
    cin>>s>>t;
    if(s==t.substr(0,s.size())) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3656
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int h,w;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> h>>w>>n;
    vector<vector<bool>>board(h,vector<bool>(w,false));
    for (int i = 0; i < n; i++)
    {
        int x,y,a;
        cin >>x>>y>>a;
        if(a==1){
            for(int i=0;i<x;i++){
                for(int j=0;j<w;j++){
                    board[i][j]=board[i][j]|true;
                }
            }
        }
        else if(a==2){
            for (int i = x; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    board[i][j] = board[i][j] | true;
                }
            }
        }
        else if(a==3){
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    board[i][j] = board[i][j] | true;
                }
            }
        }
        else{
            for (int i = 0; i < h; i++)
            {
                for (int j = y; j < w; j++)
                {
                    board[i][j] = board[i][j] | true;
                }
            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(board[i][j])ans++;
        }
    }
    cout << h*w-ans << "\n";
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int ans;
	if (a <= b) {
		ans = a;
	}
	else{
		ans = a-1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(){
    int i,flag=0;
    char s[5];
    scanf("%s\n", &s);

    for(i=0;i<3;i++){
        if(s[i] == s[i+1]){
            flag=1;
            break;
        }
    }

    if(flag==1){
        printf("Bad\n");
    }

    else{
        printf("Good\n");
    }
}

Measured memory_bytes: 1600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, x, y, a, b, min;

    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> count(n + 1, 0);

    rep(i, n)
    {
        for (int j = i + 1; j < n; j++)
        {
            a = j - i;
            b = abs(i - x) + abs(j - y) + 1;
            min = a < b ? a : b;
            // cout << min << endl;
            count[min]++;
        }
    }
    // cout << endl;
    rep(i, n - 1)
    {
        cout << count[i + 1] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve()
{
	COMinit();
	ll s;
	cin>>s;
	ll ans=0;
	rep(i,700){
		if(s-3*i>=0){
			ans+=COM(s-3*i+i-1,i-1);
		}
		ans%=M;
	}
	cout<<ans<<endl;
}

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


Measured memory_bytes: 15564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	forn(i, n - 2){
		if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
	}
	cout << ans << endl;
}		


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

#define i64 long long 

i64 POW(i64 x,i64 n, i64 MOD = 1000000007){
    i64 res = 1;
    while(n){
        if(n%2) res = (res * x) % MOD;
        x = (x*x) % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; i++) cin >> D[i];
    bool ok = true;

    if(D[0] != 0) ok = false;

    vector<long long> d(N, 0);
    for(int i = 0; i < N; i++) d[ D[i] ]++;
    if(d[0] != 1) ok = false;

    int depth = 0;
    for(int i = 1; d[i] != 0 && i < N; i++) depth = i+1;
    for(int i = 1; i < N; i++){
        if(d[i] != 0 && depth < i) ok = false;
    }

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

    const long long MOD = 998244353;
    long long ans = 1;
    for(int i = 2; i < depth; i++){
        ans = (ans*POW(d[i-1], d[i], MOD)) % MOD;
    }

    cout << ans << endl;
}

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

using namespace std;

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

  string s, t;
  cin >> s >> t;

  int start = -1;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == t[0]) {
      start = i;
      break;
    }
  }
  if (start < 0) {
    cout << "No" << endl;
    return 0;
  }

  const string buf = s.substr(start) + s.substr(0, start);
  if (buf == t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

using vint = vector<int>;
using pint = pair<int, int>;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline void debug(T a) { cout << "[ "; for (const auto e : a) { cout << e << ", "; } cout << "]" << endl; }

int ceil(int a, int b) { return (a + (b - 1)) / b; }

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// }}}

signed main() {
	int n;
	cin >> n;
	vint d(n);
	rep (i, n) cin >> d[i];

	int sum = 0;

	FOR (i, 0, n) {
		FOR (j, i + 1, n) {
			sum += d[i] * d[j];
		}
	}

	cout << sum << endl;
}



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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=1e5+5;

int main()
{
    int k,z;cin>>z>>k;
    string s;cin>>s;

    s[k-1]+=32;
    cout<<s;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<bool> vb;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	int N, K; cin >> N >> K;
	vi D(K); FOR(i, 0, K) cin >> D[i];
	int ans;
	for (int n = N; n <= 99999; n++) {
		bool ok = true;
		for (int d : D) {
			string ns = to_string(n);
			string ds = to_string(d);
			int pos = ns.find(ds);
			if (pos != string::npos) {
				ok = false;
				break;
			}
		}

		if (ok) {
			ans = n;
			break;
		}
	}

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


Measured memory_bytes: 256
#include <stdio.h>

/*---????????????????????????????????£?????????---*/
void shuffle(char *st)
{
	char ch;
	ch = *st;

	while (*(st + 1)) {
		*st = *(st + 1);
		st++;
	}

	*st = ch;
}

int main(void)
{
	char a[201];
	int h, i, m, j;

	while (1) {
		scanf("%s\n", a);
		if (a[0] == '-')	break;
		scanf("%d", &m);
		for (i = 0; i < m; i++) {
			scanf("%d", &h);
			for (j = 0; j < h; j++)
				shuffle(a);
		}
		printf("%s\n", a);
	}

	return 0;
}

Measured memory_bytes: 588
n = int(input())
clist = list(map(list, input().split()))

def BubbleSort(C, n):
    for i in range(n-1):
        for w in range(i+1, n):
            j = n-w+i
            if (C[j][1] < C[j-1][1]):
                a = C[j]
                C[j] = C[j-1]
                C[j-1] = a
def SelectionSort(C, n):
    for i in range(n):
        mini = i
        for j in range(i+1,n):
            if (C[j][1] < C[mini][1]):
                mini = j
        if(mini != i):
            a = C[i]
            C[i] = C[mini]
            C[mini] = a
## l[1]이 str 이라는것에 주의 int(l[1])을 해줘야함 --> 이거 때문에 20분 디버깅 소비
def stable(A,B):
    count = [0 for i in range(9)]
    for l in A:
        count[int(l[1]) - 1] += 1
    ilist = [] ##安定なiのリスト
    for i in range(1,10):
        if (count[i-1] > 1):
            awlist = []
            for l in A:
                if(int(l[1]) == i):
                    awlist.append(l[0])
            bwlist = []
            for l in B:
                if(int(l[1]) == i):
                    bwlist.append(l[0])
            if (awlist == bwlist):
                ilist.append(i)
            
        else:
            ilist.append(i)
    if (len(ilist) == 9):
        print('Stable',end = '')
    else:
        print('Not stable', end = '')
                  

Blist = list(clist)
BubbleSort(Blist, n)
for i in range(n):
    if (i == n-1):
        print('{}{}'.format(Blist[i][0],Blist[i][1]), end = '')
    else : 
        print('{}{}'.format(Blist[i][0],Blist[i][1]), end = ' ')
print()
stable(clist, Blist)
print()

Slist = list(clist)
SelectionSort(Slist, n)
for i in range(n):
    if(i == n-1):
        print('{}{}'.format(Slist[i][0],Slist[i][1]), end = '')
    else:
        print('{}{}'.format(Slist[i][0],Slist[i][1]), end = ' ')
print()
stable(clist, Slist)
print()


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  vector<int> S(150, 0), T(150, 0);
  REP(i, s.size()) S[int(s[i])]++;
  REP(i, t.size()) T[int(t[i])]++;
  sort(S.rbegin(), S.rend());
  sort(T.rbegin(), T.rend());
  REP(i, S.size()) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

int main(void){
    string A,B;cin>>A>>B;
    if(A.size()>B.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }
    if(A.size()<B.size()){
        cout<<"LESS"<<endl;
        return 0;
    }
    for(int i=0;i<A.size();i++){
        if((int)A[i]>(int)B[i]){
             cout<<"GREATER"<<endl;
            return 0;
        }
        if((int)A[i]<(int)B[i]){
            cout<<"LESS"<<endl;
            return 0;
        }
    }
    cout<<"EQUAL"<<endl;
    return 0;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};


int main(){
  int total_lines;
  while(~scanf("%d",&total_lines)){
    if(total_lines == 0) break;

    vector<string> responses;
    int parent[1024];
    int depth_log[1024];
    memset(parent,-1,sizeof(parent));

    for(int line_idx = 0; line_idx < total_lines; line_idx++){
      string buf;
      cin >> buf;
      responses.push_back(buf);
      int depth = count(buf.begin(),buf.end(),'.');
      depth_log[line_idx] = depth;
      for(int prev_idx = line_idx - 1; prev_idx >= 0; prev_idx--){
        if(depth_log[prev_idx] < depth){
          parent[line_idx] = prev_idx;
          break;
        }
      }
    }

    int connect[1024];
    memset(connect,-1,sizeof(connect));
    for(int first_idx = 0; first_idx < total_lines; first_idx++){
      for(int last_idx = first_idx + 1; last_idx < total_lines; last_idx++){
        if(parent[first_idx] == parent[last_idx]){
          connect[first_idx] = last_idx;
          break;
        }
      }
    }
    for(int line_idx = 0; line_idx < total_lines; line_idx++){
      if(depth_log[line_idx] != 0){
        responses[line_idx][depth_log[line_idx] - 1] = '+';
      }

      if(connect[line_idx] != -1){
        int last_idx = connect[line_idx];
        for(int i = line_idx + 1; i < last_idx; i++){
          if(responses[i][depth_log[line_idx] - 1] != '+'){
            responses[i][depth_log[line_idx] - 1] = '|';
          }
        }
      }
    }

    for(int line_idx = 0; line_idx < total_lines; line_idx++){
      for(int i = 0; i < (int)responses[line_idx].size(); i++){
        if(responses[line_idx][i] == '.'){
          responses[line_idx][i] = ' ';
        }
      }
      printf("%s\n",responses[line_idx].c_str());
    }
  }
}

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

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

  int n;
  cin >> n;

  set<string> appear;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;

    appear.emplace(s);
  }

  cout << appear.size() << '\n';

  return (0);
}

Measured memory_bytes: 19224
#include<cstdio>
int n,m,a[105],sum=0;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    scanf("%d",&m);
    while(m--){
        int p,x;
        scanf("%d%d",&p,&x);
        printf("%d\n",sum-a[p]+x);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

template<class In>
void print_array(In begin, In end) {
  cout << (*begin);
  begin++;
  for (; begin != end; begin++)
  {
    cout << " " << (*begin);
  }
  cout << endl;
}

int main()
{
  ll N, X;
  cin >> N >> X;

  ll d = 0;
  ll res = 1;
  for (auto i = 0; i < N; i++)
  {
    ll l;
    cin >> l;

    d += l;
    if (d <= X)
      res++;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

MOD = 1000000007

def smax(a,b):
    if a>b:
        return a
    else:
        return b

def smin(a,b):
    if a<b:
        return a
    else:
        return b

def main():
    N = int(readline())
    N=str(N)
    flag=False
    for i in range(3):
        if N[i]=="7":
            flag=True
    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 61716
// AOJ 1367: Rearranging a Sequence
// 2017.10.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int id, a; } T;
T tbl[200002];

char buf[35], *p;

int cmp(T *a, T *b) { return b->id - a->id; }	// for qsort()

int main()
{
	int n, m, i, j;
	register T *tp;

//	scanf("%d%d", &n, &m);
	fgets(p = buf, 32, stdin);
	n = atoi(p); while (*p >= '0') p++;
	m = atoi(p); 

	for (tp = tbl+1, j = n, i = 1; j; tp++) tp->id = j--, tp->a = i++;

	while (m--) {
//		scanf("%d", &j);
		fgets(p = buf, 32, stdin);
		j = 0; 	while (*p >= '0') j = (j<<3) + (j<<1) + (*p++ & 0xf);

		tbl[j].id = i++;
	}
	qsort(tbl+1, n, sizeof(T), cmp);
	tp = tbl; while (n--) tp++, printf("%d\n", tp->a);
	return 0;
}

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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  string str;
  cin >> str;
  vector<char> v;

  for (int i = 0; i < str.length(); i++)
  {
    v.push_back(str[i]);
  }

  sort(v.begin(), v.end());
  unique(v.begin(), v.end());

  int i = 0;

  for (char c = 'a'; c <= 'z'; c++)
  {
    if (v[i] != c)
    {
      cout << c << endl;
      exit(0);
    }
    i++;
  }
  cout << "None" << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

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 rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

int main() {
    ll A;
    string B;

    cin >> A >> B;

    ll ans = A * ((B[0]-'0')*100 + (B[2]-'0')*10 + (B[3]-'0')) / 100;

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<cstdio>

int a[100000];
int main()
{
	int i,n,c=1e9,f=0;scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",a+i),a[i]<c&&(c=a[i]);
	for(i=0;i<n;i++)if(a[i]-c>1)return puts("No"),0;else f+=a[i]==c;
	if(f==n)return puts(n==a[0]+1||n>=a[0]<<1?"Yes":"No"),0;
	return puts(n-f>=c+1-f<<1&&c>=f?"Yes":"No"),0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n;
    cin>>n;
    if(n==1){cout << 1 << endl;return 0;}
    ll ans=INF;
    set<pair<ll,ll>> s;
    vector<pair<ll,ll>> v(n);
    for(ll i=0;i < n;i++)
    {
        cin>>v.at(i).fi>>v.at(i).se;
        s.emplace(v.at(i).fi,v.at(i).se);
    }

    for(ll i=0;i < n-1;i++)
    {
        for(ll j=i+1;j < n;j++)
        {
            ll p=v.at(j).fi-v.at(i).fi;
            ll q=v.at(j).se-v.at(i).se;
            ll cnt=1;
            for(ll k=0;k < n;k++)
            {
                if(s.count({v.at(k).fi+p,v.at(k).se+q})){
                
                }else{
                    cnt++;
                }
            }
            
            ans=min(ans,cnt-1);
        }
    }

    cout << ans << endl;
}

            







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

int main() {
  string t;
  cin >> t;
  for(int i; i < t.length(); i++) {
    if(t[i] == '?') {
      t[i] = 'D';
    }
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3716
N = int(input())

for h in range(1,3501):
    for n in range(h,3501):
        wd = 4*h*n - n*N - h*N
        wu = N*h*n
        if wd > 0 and wu % wd == 0:
            w = wu // wd
            print(h,n,w)
            exit()


Measured memory_bytes: 40556
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

vector<long long >v;
long long a;
int N;
cin>>N;

for(int i=0;i<N;i++){
    cin>>a;
    v.push_back(a);
}

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

long long ans=0;

//M型
int k=0;
while(N-k-1>k){
    ans+=v[N-k-1]*2;
    ans-=v[k]*2;
    k++;
}

if(N%2==0){
    ans-=v[k];
    k--;
    ans+=v[k];

}
else{
    ans-=v[k];
    k--;
    ans+=v[k];
}
long long Ans=0;
k=0;
//W型
while(N-k-1>k){
    Ans+=v[N-k-1]*2;
    Ans-=v[k]*2;
    k++;
}
if(N%2==0){
    k--;
    Ans+=v[k];
    k++;
    Ans-=v[k];
}
else{
    Ans+=v[k];
    k++;
    Ans-=v[k];
}
long long Answer=max(Ans,ans);

cout<<Answer<<endl;

 return 0;
}

Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main() {
    int n,k,r;
    cin >> n >> k;
    if (n % 2 == 1){
        r = n / 2 + 1;
    }else{
        r = n / 2;
    }
    if (r >= k){
        cout << "YES" << endl;
    }else{
        cout << "NO"<< endl;
    }
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
V = list(map(int,input().split()))

v1 = V[0::2]
v2 = V[1::2]

c1 = Counter(v1).most_common()
c2 = Counter(v2).most_common()

# 数字が1つしかない場合に"2番目"をダミーで追加
c1.append((0,0))
c2.append((0,0))

if c1[0][0]==c2[0][0]:
    print(min(N-(c1[0][1]+c2[1][1]), N-(c1[1][1]+c2[0][1])))
else:
    print(N- (c1[0][1]+c2[0][1]))

Measured memory_bytes: 21084
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
if p == q:
    print(0)
    exit()
import itertools
def permutation_all(seq, choice):
    return list(itertools.permutations(seq, choice))
s = [i for i in range(1, n+1)]
s_p = permutation_all(s, n)
p = tuple(p)
q = tuple(q)
a = b = -1
for i in range(len(s_p)):
    if p == s_p[i]:
        a = i+1
    elif q == s_p[i]:
        b = i+1
print(abs(a-b))



Measured memory_bytes: 8052
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename F>
void all_permutations(int n,F f){
  vector<int> vs(n);
  iota(vs.begin(),vs.end(),0);
  do f(vs); while(next_permutation(vs.begin(),vs.end()));
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed ABC054_C(){
  int n,m;
  cin>>n>>m;
  int es[10][10]={};
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    es[a][b]=es[b][a]=1;
  }
  int ans=0;
  auto f=
    [&](const auto &vs){
      if(!es[0][vs[0]+1]) return;
      for(int i=0;i+1<n-1;i++)
        if(!es[vs[i]+1][vs[i+1]+1]) return;
      ans++;
    };
  all_permutations(n-1,f);
  cout<<ans<<endl;
  return 0;
}
/*
  verified on 2019/12/09
  https://atcoder.jp/contests/abc054/tasks/abc054_c
*/

signed main(){
  ABC054_C();
  return 0;
}
#endif


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

struct Dice {
	int top;
	int north;
	int east;
	int south;
	int west;
	int bottom;
};

void rotn(Dice& d);
void rote(Dice& d);
//void rots(Dice& d);
//void rotw(Dice& d);
void rotc(Dice& d);
bool judge(Dice& d1, Dice& d2);

Dice d1, d2;
int tmp;
bool flag = false;

int main() {
	int i, j;
	cin >> d1.top >> d1.south >> d1.east >> d1.west >> d1.north >> d1.bottom;
	cin >> d2.top >> d2.south >> d2.east >> d2.west >> d2.north >> d2.bottom;
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			if (judge(d1, d2) == true) {
				cout << "Yes\n";
				return 0;
			} else {
				rotc(d2);
			}
		}
		rotn(d2);
	}
	rote(d2);
	for (j = 0; j < 4; j++) {
		if (judge(d1, d2) == true) {
			cout << "Yes\n";
			return 0;
		} else {
			rotc(d2);
		}
	}
	rote(d2); rote(d2);
	for (j = 0; j < 4; j++) {
		if (judge(d1, d2) == true) {
			cout << "Yes\n";
			return 0;
		} else {
			rotc(d2);
		}
	}
	cout << "No\n";
	return 0;
}



void rotn(Dice& d) {
	tmp = d.top;
	d.top = d.south;
	d.south = d.bottom;
	d.bottom = d.north;
	d.north = tmp;
}

void rote(Dice& d) {
	tmp = d.top;
	d.top = d.west;
	d.west = d.bottom;
	d.bottom = d.east;
	d.east = tmp;
}

/*
void rots(Dice& d) {
	tmp = d.top;
	d.top = d.north;
	d.north = d.bottom;
	d.bottom = d.south;
	d.south = tmp;
}

void rotw(Dice& d) {
	tmp = d.top;
	d.top = d.east;
	d.east = d.bottom;
	d.bottom = d.west;
	d.west = tmp;
}

*/

void rotc(Dice& d) {
	tmp = d.north;
	d.north = d.west;
	d.west = d.south;
	d.south = d.east;
	d.east = tmp;
}

bool judge(Dice& d1, Dice& d2) {
	if (d1.top == d2.top && d1.north == d2.north && d1.east == d2.east
		&& d1.south == d2.south && d1.west == d2.west && d1.bottom == d2.bottom)return true;
	else return false;
}

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

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int a[q];
	for (int i = 0; i < q; i++) {
		cin >> a[i];
	}

	int win_num[n] = {};
	for (int i = 0; i < q; i++) {
		win_num[a[i]-1]++;
	}

	for (int i = 0; i < n; i++) {
		if (k - (q - win_num[i]) < 1) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	private class DisjointSet {
		
		int[] p, rank;
		
		public DisjointSet(int size) {
			p = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

		private int findSet(int x) {
			List<Integer> list = new ArrayList<>();
			
			while (x != p[x]) {
				list.add(x);
				x = p[x];
			}
			
			for (int i : list) {
				p[i] = p[x];
			}
			
			return p[x];
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] > rank[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x= Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 63768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
  int a;
  cin >> a;
  int a2 = a*a;
  int a3 = a*a*a;
  int ans = a+a2+a3;
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数 - テスト用
#ifdef D_TEST
	static FILE *szpFpT;
#endif

// 素数判定
int
fChk(
	int piVal					// <I> 値
)
{
	int i, liRet;

	// 上限値
	double ldLimit = sqrt((double)piVal);
	int liLimit = (int)ldLimit;

	// 割り切れるかチェック
	for (i = 2; i <= liLimit; i++) {
		liRet = piVal % i;
		if (liRet == 0) {
			return -1;
		}
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, liRet;
	char lc1Buf[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
#endif

	// 出力数取得
	int liCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liCnt);

	// 表示 - 5n+1 AND 素数
	int liOut = 0;
	for (i = 11; ; i+=5) {

		// 素数チェック
		liRet = fChk(i);
		if (liRet != 0) {
			continue;
		}

		// 表示
		if (liOut > 0) {
			printf(" ");
		}
		printf("%d", i);
		liOut++;

		// 終了チェック
		if (liOut == liCnt) {
			printf("\n");
			break;
		}
	}

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var n = sc.nextInt();
        var p = sc.ArrayInt(n);
        int ans = 0;
        for (int i = 1; i < n - 1; i++) {
            if (p[i - 1] > p[i] && p[i] > p[i + 1] ||
                p[i - 1] < p[i] && p[i] < p[i + 1]) {
                ans++;
            }
        }
        WriteLine(ans);
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n, k);
	VEC(int, a, n);
	int d = 0;
	REP(i, n) {
		if (a[i] == 1) d = i;
	}
	int ans = 1;
	ans += (n-2) / (k-1);
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 81;
const ll LINF = 1e18 + 5;
int h, w;
vector<vector<int>> a(N,vector<int>(N)), b(a);
vector<vector<bitset<N*N*2>>> dp(N,vector<bitset<N*N*2>>(N));
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h >> w;
 	for(int i=1;i<=h;i++)
 		for(int j=1;j<=w;j++)
 			cin >> a[i][j];
 	for(int i=1;i<=h;i++)
 		for(int j=1;j<=w;j++)
 			cin >> b[i][j];
 	dp[1][1][abs(a[1][1]-b[1][1])] = 1;
 	for(int i=1;i<=h;i++)
 	{
 		for(int j=1;j<=w;j++)
 		{
 			int v = abs(a[i][j]-b[i][j]);
 			for(int k=0;k<=(i+j)*80;k++)
 			{	
 				if(dp[i-1][j][k])
				{
					dp[i][j][k+v] = dp[i-1][j][k];
	 				dp[i][j][abs(k-v)] = dp[i-1][j][k];
 				}
 				if(dp[i][j-1][k])
 				{
	 				dp[i][j][k+v] = dp[i][j-1][k];
	 				dp[i][j][abs(k-v)] = dp[i][j-1][k];
	 			}
 			}
 		}
 	}
 	for(int i=0;i<=(h+w)*80;i++) if(dp[h][w][i]) return cout << i, 0;
	return 0;
}


Measured memory_bytes: 13052
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
s += 'a'
n = len(s)
t = 'AKIHABARAb'
l = len(t)
a = b = 0
while True:
    if s[a] == t[b]:
        a += 1; b += 1
    elif t[b] == 'A':
        b += 1
    else:
        break
if a == n-1 and b == l-1:
    print('YES')
else:
    print('NO') 

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


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N, M, X;
  cin >> N >> M >> X;

  vector<long long> C(N);
  vector<vector<long long>> A(N, vector<long long>(M));

  for(long long i = 0; i < N; i++){
    cin >> C[i];

    for(long long j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }

  long long mymin = LLONG_MAX;

  for(long long i = 0; i < (1<<N); i++){
    vector<long long> acc(M);
    long long costacc = 0;

    for(long long j = 0; j < N; j++){
      if(i & 1<<j) {
        for(long long k = 0; k < M; k++) {
          acc[k] += A[j][k];
        }
        costacc += C[j];
      }
    }



    if(all_of(acc.begin(), acc.end(), [&](auto a){ return X <= a; })) mymin = min(mymin, costacc);
  }

  cout << ((mymin == LLONG_MAX) ? -1 : mymin) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n, m;
    cin >> n >> m;
    int edge[100];
    rep(i, n) edge[i] = 0;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a]++;
        edge[b]++;
    }
    rep(i, n) cout << edge[i] << endl;
}

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

int main()
{
		int H[10000], W[10000], n, i, j, k, m;
		while (1) {
				cin >> H[n] >> W[n];
				if (H[n]==0 && W[n]==0) break;
				n++;
		}

		for (i=0; i<n; i++) {
				for (j=0; j<H[i]; j++) {
						if (j==0 || j==H[i]-1) {
								for (k=0; k<W[i]; k++) {
										cout << "#";
								}
						} else {
								cout << "#";
								for (k=1; k<W[i]-1; k++) {
										cout << ".";
								}
								cout << "#";
						}
						cout << "\n";
				}
				cout << "\n";
		}
}

Measured memory_bytes: 3092
n, a, b = map(int,input().split())
V = list(map(int,input().split()))

V.sort(reverse=True)

print(sum(V[:a]) / a)

D = {}
Da = {}

for i in range(n):
    try:
        D[V[i]] += 1
    except:
        D[V[i]] = 1

for i in range(a):
    try:
        Da[V[i]] += 1
    except:
        Da[V[i]] = 1



def C(x, y):
    ans = 1
    for i in range(x, x-y, -1):
        ans *= i
    for i in range(1, y+1):
        ans //= i
    return ans

#print(C(5,3))

if len(set(V[:a])) > 1:
    ans = 1
    for i in set(V[:a]):
        ans *= C(D[i], Da[i])

else:
    ans = 0
    for i in range(a, b+1):
        #print(D[V[0]], i)
        ans += C(D[V[0]], i)

print(ans)

Measured memory_bytes: 38896
L,R =map(int,input().split())

mod=2019
ans=mod

l=L%mod
r=R%mod
if r<=l:
    ans=0
elif (R-L)>=2019:
    ans=0
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans=min(ans,i*j%mod)
print(ans)

Measured memory_bytes: 40684
package main

import (
	"fmt"
	"math"
)

func max(nums ...int) int {
    if len(nums) == 0 {
        panic("funciton max() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Max(float64(res), float64(nums[i])))
    }
    return res
}

func main() {
	var a int
	var b int
	var c int
	fmt.Scan(&a,&b,&c)
	fmt.Println(max(b+c-a,0))
}

Measured memory_bytes: 512
#include <iostream>
#define rep(i, n) for(int i=0;i<n;++i)
using namespace std;

int main(){
  char c[2][3];
  rep(i, 2) rep(j, 3) cin >> c[i][j];
  if(c[0][0]==c[1][2]
    &&c[0][1]==c[1][1]
    &&c[0][2]==c[1][0])
        cout<< "YES" <<endl;
  else  cout << "NO" <<endl;  
}

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

int main() {
	int i, a, b, n, ap, bp;

	while (1) {
		cin >> n;
		if (n == 0)break;
		ap = bp = 0;
		for (i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b) {
				ap += a + b;
			} else if (a < b) {
				bp += a + b;
			} else {
				ap += a;
				bp += b;
			}
		}
		cout << ap << " " << bp << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    if (n < 1200)
        cout << "ABC" << endl;
    else
    {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {

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

        int k = s.nextInt();
        int n = s.nextInt();
        int[] a=new int[n];
        int[] d=new int[n];
        for (int i = 0; i <n ; i++) {
             a[i] = s.nextInt();
             if(i==0){
             }else{
                 d[i]=a[i]-a[i-1];
             }
        }
        d[0]=k-a[n-1]+a[0];

        int max=-1;
        int sum=0;
        for (int i = 0; i <n ; i++) {
            sum+=d[i];
            if(max<d[i]){
                max=d[i];
            }
        }
        System.out.println(sum-max);
    }

}

Measured memory_bytes: 82784