akhauriyash/Code-Regression huggingface dataset:
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n, m;
    cin >> n >> m;
    print(n * (n - 1) / 2 + m * (m - 1) / 2);

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;

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

	mat dp(N + 1, vec(T + 1));
	vector<pair<int, int>> Dish;

	for (int i = 0; i < N; ++i)
	{
		pair<int, int> p;
		cin >> p.first >> p.second;
		Dish.emplace_back(p);
	}

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

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < T + 1; ++j)
		{
			int k = min(j + Dish[i].first, T);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j != T)
			{
				dp[i + 1][k] = max(dp[i + 1][j], dp[i][j] + Dish[i].second);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < T + 1; ++i)
	{
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;



int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str[2005],tmp;
	cout << fixed << setprecision(10);
    
    
    while(1){
        long long int n,paz[20][6],res=0;
        cin>>n;
        if(n==0){
            return 0;
        }
        for(int j=1;j<=5;j++){
                paz[0][j]=999;
            }
        for(int i=n;i>=1;i--){
            for(int j=1;j<=5;j++){
                cin>>paz[i][j];
            }
        }

        for(int t=1;t<=20;t++){
            for(int i=1;i<=n;i++){
                if(paz[i][1]==paz[i][2]&&paz[i][3]==paz[i][2]&&paz[i][4]==paz[i][3]&&paz[i][4]==paz[i][5]){
                    res+=paz[i][1]*5;
                    paz[i][1]=0;
                    paz[i][2]=0;
                    paz[i][3]=0;
                    paz[i][4]=0;
                    paz[i][5]=0;
                }else if(paz[i][1]==paz[i][2]&&paz[i][3]==paz[i][2]&&paz[i][4]==paz[i][3]){
                    res+=paz[i][1]*4;
                    paz[i][1]=0;
                    paz[i][2]=0;
                    paz[i][3]=0;
                    paz[i][4]=0;
                }else if(paz[i][3]==paz[i][2]&&paz[i][4]==paz[i][3]&&paz[i][4]==paz[i][5]){
                    res+=paz[i][2]*4;
                    
                    paz[i][2]=0;
                    paz[i][3]=0;
                    paz[i][4]=0;
                    paz[i][5]=0;
                }else if(paz[i][1]==paz[i][2]&&paz[i][3]==paz[i][2]){
                     res+=paz[i][2]*3;
                    paz[i][1]=0;
                    paz[i][2]=0;
                    paz[i][3]=0;
                }else if(paz[i][3]==paz[i][2]&&paz[i][4]==paz[i][3]){
                     res+=paz[i][2]*3;
                    paz[i][2]=0;
                    paz[i][3]=0;
                    paz[i][4]=0;
                }else  if(paz[i][4]==paz[i][3]&&paz[i][4]==paz[i][5]){
                    res+=paz[i][3]*3;
                    paz[i][3]=0;
                    paz[i][4]=0;
                    paz[i][5]=0;
                }
            }
            for(int k=1;k<=10;k++){
                for(int j=1;j<=5;j++){
                    for(int i=1;i<=n;i++){
                        if(paz[i-1][j]==0){
                            paz[i-1][j]=paz[i][j];
                            paz[i][j]=0;
                        }
                    }
                }
            }
            
            
        }
        cout<<res<<endl;
    }
    
} 



Measured memory_bytes: 3076
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val Array(n, m) = readInts
  val map = readLongs.zipWithIndex.map { case (h, i) => (i + 1, h) }.toMap
  var hs = scala.collection.mutable.Map((1 to n).map(i => (i, 0)): _*)

  var res = 0L
  for (_ <- 1 to m) {
    val Array(a, b) = readInts
    if (map(a) < map(b)) hs -= a
    else if (map(b) < map(a)) hs -= b
    else {
      hs -= a
      hs -= b
    }
  }
  println(hs.size)
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 83352
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int turn = 0;
	while (true)
	{
		if (turn == 0)
		{
			C -= B;
			if (C <= 0)
			{
				cout << "Yes";
				return 0;
			}
		}
		else
		{
			A -= D;
			if (A <= 0)
			{
				cout << "No";
				return 0;
			}
		}
		turn ^= 1;
	}

	return 0;
}


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

int main() {
	int K, N, * A, *dis, max;
	bool key;

	cin >> K >> N;

	A = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sort(A, A + N, less<int>());

	dis = new int[N];

	for (int i = 0; i < N-1; i++) {
		dis[i] = A[i +1]-A[i];
	}

	dis[N - 1] = K - A[N-1] + A[0];


	max = 0;

	for (int i = 0; i < N; i++) {
		if (max < dis[i]) {
			max = dis[i];
		}
	}

	cout << K - max;

	return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N, A, B, C;
int l[8];

int mp(int bit){
    int a = 0, b = 0, c = 0, m = 0;
    REP(i, N){
        int st = bit & 3;
        if(st == 0){
            if(a != 0) m += 10;
            a += l[i];
        }else if(st == 1){
            if(b != 0) m += 10;
            b += l[i];
        }else if(st == 2){
            if(c != 0) m += 10;
            c += l[i];
        }
        bit = bit >> 2;
    }
    if(a * b * c == 0){
        return INT32_MAX;
    }
    m += abs(A - a) + abs(B - b) + abs(C - c);
    return m;
}

signed main(){
    cin >> N >> A >> B >> C;
    REP(i, N) cin >> l[i];
    int m = INT32_MAX, p = (int)pow(4, N);
    REP(i, p){
        m = min(m, mp(i));
    }
    PRINT(m);
    return 0;
}

Measured memory_bytes: 256
def f(s):
    cnt = 0
    st = set()

    cnt += 1
    st.add(s)

    while True:
        cnt += 1

        if s % 2 == 0:
            tmp = s / 2
        else:
            tmp = 3 * s + 1

        if tmp in st:
            break

        st.add(tmp)
        s = tmp
    return cnt


s = int(input())
ans = f(s)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
    cin>>s;
    int k=0,ans=0;
    vector<int> a(10,0);
    for(int i=0;i<s.size();i++){
    	if (s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
        	a[k]++;
        } else k++;
    }
    for(int i=0;i<10;i++){
    	ans=max(ans,a[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e15;
const ll MOD=1e9+7;

ll N;
map<char,map<ll,set<ll>>> xPy;
map<char,map<ll,set<ll>>> xMy;
map<char,set<ll>> x[200010];
map<char,set<ll>> y[200010];
ll X[200010],Y[200010];
string U[200010];
ll Upto(set<ll>& st,ll value){
    if(st.size()==0)return INF;
    auto it=st.lower_bound(value);
    if(it==st.end())return INF;
    return (*it-value);
}
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>X[i]>>Y[i]>>U[i];
        char c=U[i][0];
        xPy[c][X[i]+Y[i]].insert(Y[i]);
        xMy[c][X[i]-Y[i]].insert(Y[i]);
        x[X[i]][c].insert(Y[i]);
        y[Y[i]][c].insert(X[i]);
    }
    ll ans=INF;
    for(ll i=0;i<N;i++){
        set<ll>& st=x[X[i]]['D'];
        if(U[i][0]=='U'){
            ans=min(ans,Upto(xPy['R'][X[i]+Y[i]],Y[i])*10);
            ans=min(ans,Upto(xMy['L'][X[i]-Y[i]],Y[i])*10);
            ans=min(ans,Upto(x[X[i]]['D'],Y[i])*5);
            
        } 
        if(U[i][0]=='R'){
            ans=min(ans,Upto(y[Y[i]]['L'],X[i])*5);
            ans=min(ans,Upto(xMy['D'][X[i]-Y[i]],Y[i])*10);
        }
        if(U[i][0]=='L'){
            ans=min(ans,Upto(xPy['D'][X[i]+Y[i]],Y[i])*10);
            if(i==3){

            }
        }
    }
    if(ans==INF) cout<<"SAFE";
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 162396
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
    char ch[10];
    scanf("%s",ch);
    if(ch[2]==ch[3]&&ch[4]==ch[5])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

template< class T >
struct CumulativeSum2D
{
  vector< vector< T > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {}

  void add(int x, int y, int z)
  {
	++x, ++y;
	if(x >= data.size() || y >= data[0].size()) return;
	data[x][y] += z;
  }

  void build()
  {
	for(int i = 1; i < data.size(); i++) {
	  for(int j = 1; j < data[i].size(); j++) {
		data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
	  }
	}
  }

  T query(int sx, int sy, int gx, int gy)
  {
	return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

signed main(){
	int H,W,K;
	cin >> H >> W >> K;
	vector<string>s(H);
	CumulativeSum2D<int>sum(H,W);
	REP(i,H){
		cin >> s[i];
		REP(j,W){
			if(s[i][j] == '1')sum.add(i,j,1);
		}
	}
	sum.build();
	auto f = [&](int bit) -> int {
		vector<pair<int,int>>v;
		int l = 0;
		REP(i,H - 1){
			if(bit & (1ll << i)){
				v.emplace_back(l,i + 1);
				l = i + 1;
			}
		}
		v.emplace_back(l,H);
		int ret = v.size() - 1;
		l = 0;
		REP(j,W){
			int t;
			REP(i,v.size()){
				t = sum.query(v[i].first,l,v[i].second,j + 1);
				if(t > K){
					if(j == l)return INF;
				}
			}
			REP(i,v.size()){
				if(j + 1 == W)continue;
				int tt = sum.query(v[i].first,l,v[i].second,j + 2);
				if(tt > K){
					l = j + 1;
					++ret;
					break;
				}
			}
		}
		return ret;
	};
	int ans = INF;
	REP(i,1ll << (H - 1)){
		CHMIN(ans,f(i));
	}
	out(ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int d[110][110] = {};
int n, m, a[1010], b[1010], c[1010], r;
bool used[1010];

void warshall_floyd(int n){
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            for (int k = 0; k < n; k++){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            d[i][j] = (i == j ? 0 : 1e9 + 7);
        }
    }
    for (int i = 0; i < m; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        a[i]--, b[i]--, d[a[i]][b[i]] = c[i], d[b[i]][a[i]] = c[i];
    }
    warshall_floyd(n);
    for (int i = 0; i < n; i++){
        for (int k = 0; k < m; k++){
            used[k] = used[k] || d[i][a[k]] + c[k] == d[i][b[k]] || d[i][a[k]] + c[k] == d[i][b[k]];
        }
    }
    for (int i = 0; i < m; i++)r += !used[i];
    printf("%d\n", r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mr make_pair
using namespace std;
int a,b,c,d,e;
int main(){
	cin>>a>>b>>c>>d>>e;
	cout<<(c-a)*60+d-b-e<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;
const int INF = 1e+9;

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

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;cin>>s;
bool b = 0,c = 0,d = 0;
if(s.length()==3){
    char x[4];
    strcpy(x,s.c_str());
    for(int i=0;i<s.length();i++){
        if(int(x[i])>=65||int(x[i])<=90)
            b = 0;
        else
            b = 1;
    }
    if(b==0)
    for(int i=0;i<s.length();i++){
            if(x[i]=='A')
                c = 1;
            else
                d = 1;
}
if(c==1&&d==1)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;}
return 0;}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
const int  M = 201;
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    map<ii, int> m;
    m[ii(1, 399)] = 1;
    m[ii(400, 799)] = 1;
    m[ii(800, 1199)] = 1;
    m[ii(1200, 1599)] = 1;
    m[ii(1600, 1999)] = 1;
    m[ii(2000, 2399)] = 1;
    m[ii(2400, 2799)] = 1;
    m[ii(2800, 3199)] = 1;
    int n;
    cin >> n;
    vector<int> arr;
    fore(i, 0, n){
        int x;
        cin >> x;
        bool flag = 1;
        fori(j, m){
            ii aux = j->F;
            if(aux.F <= x && x <= aux.S){
                m[j->F]++;
                flag = 0;
            }
        }
        if(flag)
            arr.pb(x);
    }
    int mx = 0;
    fori(i, m){
        ii a = i->F;
        if(i->S > 1)
            mx++;
        //cout << a.F << " " << a.S << " " << i->S << endl;
    }
    int mn = 0;
    if(sz(arr) == n)
        mn = 1;
    else
        mn = mx;


    //cout << mx << '\n';
    int auxi = sz(m) - mx;
    int df = sz(arr);
    mx = (mx + df);

    cout << mn << " " << mx << endl;
    return 0;
}   

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

int convert_num(char x){
  vector <char> data = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  auto it = find(data.begin(),data.end(),x);
  auto index = distance(data.begin(),it);
  return index;
}

char convert_ar(int x){
  vector <char> data = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  return data[x];
}
  

int main(){
  string S;
  cin >> S;
  vector<int> num(26,0);
  char ans;
  for(int i=0;i<S.size();i++){
    int a = convert_num(S.at(i));
    num[a]++;
  }
  bool op = false;
  for(int i=0;i<26;i++){
    if(num[i] == 0){
      ans = convert_ar(i);
      op = true;
      break;
    }
  }
  if(op==0){
    cout << "None" << endl;
  }
  else{
  cout << ans << endl;
  }
}

Measured memory_bytes: 512
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto&
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

string ans1 = "";
string ans2 = "";

int cnt = 0;
int num = 0;

void add1() {
    num++;
    string s = to_string(num);

    ans1 = ans1 + " " + s;
    ans2 = s + " " + ans2;
    cnt += 2;
}

void mul2add1() {
    num++;
    string s = to_string(num);

    if(ans1 == "") {
        ans1 = s;
        ans2 = s;
    } else {
        ans1 = ans1 + " " + s;
        ans2 = ans2 + " " + s;
    }
    cnt += 2;
}

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

    vector<int> op;
    while(n) {
        if(n%2 == 1) {
            op.push_back(1);
            n--;
            n /= 2;
        } else {
            op.push_back(0);
            n--;
        }
    }

    reverse(all(op));

    for(int x: op) {
        if(x == 0) add1();
        else mul2add1();
    }
    cout << cnt << endl;
    cout << ans1 << " "  << ans2 << endl;
}


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

ans = 0

flag = True
while flag:
  flag = False
  for i in range(1, n):
    if a[i] < a[i-1]:
      a[i], a[i-1] = a[i-1], a[i]
      ans += 1
      flag = True

print(" ".join(map(str, a)))
print(ans)


Measured memory_bytes: 5600
#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 h,w,k;
  cin >> h >> w >> k;

  vector<string> c(h);
  rep(i,h){
    cin >> c[i];
  }

  int ans = 0;

  rep(i,pow(2,h)) rep(j,pow(2,w)){
    //赤マスの情報を保持するベクターを用意
    vector<string> red_grid(h);
    string s;
    rep(a,w) s += '0';
    rep(a,h) red_grid[a] = s;

    //赤く塗りつぶす
    rep(a,h) rep(b,w){
      if((i>>a)%2==1 || (j>>b)%2==1) red_grid[a][b] = 'r';
    }

    //黒マスを数える
    int num_black = 0;
    rep(a,h) rep(b,w){
      if(c[a][b]=='#' && red_grid[a][b]!='r') num_black++;
    }

    //黒マスがちょうどK個なら
    if(num_black==k) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3996
n = int(input())
u = list(map(int,input().split()))
m = list(map(int,input().split()))
d = list(map(int,input().split()))
u.sort()
m.sort()
d.sort()

ucnt = 0
dcnt = 0
ans = 0
for i in range(n):
    for j in range(ucnt,n):
        if u[j] < m[i]:
            ucnt += 1
        else:
            break
        
    for j in range(dcnt,n):
        if d[j] <= m[i]:
            dcnt += 1
        else:
            break

    ans += ucnt * (n-dcnt)
    
print(ans)

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

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  --x;--y;
  vector<int> ans(n);
  rep(sv,n){
    vector<int> dist(n,INF);
    queue<int> q;
    auto push = [&](int v,int d){
      if(dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv,0);
    while(!q.empty()){
      int v = q.front();q.pop();
      int d = dist[v];
      if(v-1>=0) push(v-1,d+1);
      if(v+1<n) push(v+1,d+1);
      if(v == x) push(y,d+1);
      if(v == y) push(x,d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i]/=2;
  for(int i=1;i<n;i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[100];
  int n,i,oi=0;
    
  scanf("%s",s);

  n=strlen(s);
  for(i=0; i<n/2; i++) {
     if(s[i]!=s[n-1-i]) oi=1;
  }
  if(oi==1) printf("No");
  else {
     oi=0;
     for(i=0; i<n/2/2; i++) {
        if(s[i]!=s[n/2-1-i]) oi=1; 
     }
     if(oi==1) printf("No");
     else      printf("Yes");
  }
  
  return 0; 
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final DecimalFormat fmt = new DecimalFormat("0.########");
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        final double a = Double.parseDouble(sc.next());
        final double b = Double.parseDouble(sc.next());
        final double c = Double.parseDouble(sc.next())* (Math.PI/180);
        out.println(fmt.format(0.5*a*b*Math.sin(c)));
        out.println(fmt.format(a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(c))));
        out.println(fmt.format(b*Math.sin(c)));
        out.flush();
    }
}

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

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

  bool memo[300010] = {};
  int mn[300010] = {};

  int c;
  for(int i = 0;i < n;i++){
    cin >> c;
    memo[c] = true;
  }


  for(int i = 1;i <= 300000;i++){
    if(memo[i]) mn[i] = i;
    else mn[i] = mn[i-1];
  }

  int qq;
  for(int p = 0;p < q;p++){
    cin >> qq;
    int ans = mn[300000] % qq;
    for(int i = qq;i <= 300000;i += qq){
      ans = max(ans, mn[i-1] % qq);
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 4568
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[10000];
	int i;
	int sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i]-1;
	}
	printf("%d",sum);
}

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

using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);

    int n;
    scanf("%d", &n);

    if (n % 1000 == 0)
        printf("0");
    else
    {
        int t = (int)ceil(n * 1. / 1000);
        int ans = t * 1000 - n;
        printf("%d", ans);
    }

    return 0;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
   	set<int>dc;
   	cin>>n;
   	forn(i,1,n)
   	{
   		int a;
   		cin>>a;
   		dc.insert(a);
   	}
   	if(dc.size() != n)
   	{
   		cout<<"NO";
   	}
   	else cout<<"YES";
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

int main()
{
	int n;
	cin >> n;
	if (n == 1)
	{
		cout << "Hello World" << endl;
	}
	else
	{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

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

int abs(int a)
{
    if(a < 0){
        a = a * (-1);
    }
    return a;
}

int main()
{
    int n;
    int a[51];
    cin >> n;
    int abs_max = 1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(abs(a[i]) > abs(a[abs_max])){
            abs_max = i;
        }
    }
    cout << 2 * n << endl;
    if(a[abs_max] > 0){
        cout << abs_max << " " << 1 << endl;
        cout << abs_max << " " << 1 << endl;
        for(int i = 1; i <= n - 1; i++){
            cout << i << " " << i + 1 << endl;
            cout << i << " " << i + 1 << endl;
        }
        return 0;
    }
    cout << abs_max << " " << n << endl;
    cout << abs_max << " " << n << endl;
    for(int i = n; i >= 2; i--){
        cout << i << " " << i - 1 << endl;
        cout << i << " " << i - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int n;
char word[210][15], last;
bool flag = true;

int main(){
    scanf("%d", &n);

    for(int i=0; i<n; i++){
        scanf("%s", word[i]);
        if(i!=0){
            if(word[i][0]!=last){
                flag = false;
            }
            for(int j=0; j<i; j++){
                if(word[j][0] == word[i][0] && strlen(word[i]) == strlen(word[j]) ){
                    bool equals = true;
                    for(int k=0; k<strlen(word[i]); k++){
                        if(word[i][k] != word[j][k]){
                            equals = false;
                        }
                    }
                    if(equals){
                        flag = false;
                        break;
                    }
                }
            }
        }
        last = word[i][strlen(word[i])-1];

    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
int main ()
{
	int m[18][18] = {};
	int x, y, s;
	int dx1[4] = {0, 1, 0, -1}, dy1[4] = {1, 0, -1, 0};
	int dx2[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy2[8] = {1, 1, 0, -1, -1, -1, 0, 1};
	int dx3[12] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0}, dy3[12] = {2, 1, 1, 1, 0, 0, 0, 0, -1, -1, -1, -2};
	while (scanf("%d,%d,%d", &x, &y, &s) != EOF)
	{
		x += 3;
		y += 3;
		m[x][y]++;
		switch (s)
		{
		case 1:
			for (int i = 0; i < 4; i++)m[x + dx1[i]][y + dy1[i]]++;
			break;
		case 2:
			for (int i = 0; i < 8; i++)m[x + dx2[i]][y + dy2[i]]++;
			break;
		case 3:
			for (int i = 0; i < 12; i++)m[x + dx3[i]][y + dy3[i]]++;
			break;
		}
	}
	int ans1 = 0, ans2 = 0;
	for (int x = 3; x <13; x++)
	{
		for (int y = 3; y < 13; y++)
		{
			if (m[x][y] == 0)ans1++;
			ans2 = max(ans2, m[x][y]);
		}
	}
	cout << ans1 << endl << ans2 << endl;
	return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

const int N = 500009;
const int mod = 1000000007;

int n;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> n;
	for (int i = 1; i <= 9; i++)
	{
		if ((n % i == 0) && ((n/i) >= 1 && (n/i) <= 9))
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

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

const long INF = (1LL << 55);

namespace hidden {
  std::stack<void*> pstack;
};
void push(void* p) {
  hidden::pstack.push(p);
}
void pop() {
  hidden::pstack.pop();
}

template<typename TWeight = int>
class Network {
public:
  Network() {}
  std::vector< std::tuple<int, TWeight> > *edges;
  int v;
};

template<typename TWeight = int>
Network<TWeight> initNetwork(int v) {
  Network<TWeight> network;
  network.edges = new std::vector< std::tuple<int, TWeight> > [v + 3];
  network.v     = v + 3;
  return network;
}

template<typename TWeight = int>
void deleteNetwork(Network<TWeight> network) {
  if( network.edges == nullptr ) {
    delete [] network.edges;
  }
}

template<typename TWeight = int>
void addEdge(int from, int to, TWeight weight) {
  Network<TWeight> *network = (Network<TWeight>*)hidden::pstack.top();
  network->edges[from].push_back(std::tuple<int, TWeight>(to, weight));
}

template<typename TWeight = int>
std::vector<TWeight> dijkstra(Network<TWeight> network, int source) {
  std::vector<TWeight> res(network.v, INF);
  res[source] = 0;
  std::priority_queue< std::tuple<TWeight, int> > q;
  q.push(std::tuple<TWeight, int>(0, source));
  while( not q.empty() ) {
    TWeight dist; int id;
    std::tie(dist, id) = q.top(); q.pop();
    dist = -dist;
    for(auto edge : network.edges[id]) {
      int next; TWeight weight;
      std::tie(next, weight) = edge;
      TWeight nextdist = dist + weight;
      if( nextdist >= res[next] ) continue;
      res[next] = nextdist;
      q.push(std::tuple<TWeight, int>(-nextdist, next));
    }
  }
  return res;
}

int main() {
  int v, e, r;
  scanf("%d %d %d", &v, &e, &r);
  Network<long> network = initNetwork<long>(v);
  push(&network);
  for(int i = 0; i < e; ++i) {
    int s, t; long d;
    scanf("%d %d %ld", &s, &t, &d);
    addEdge(s, t, d);
  }
  pop();
  std::vector<long> dists = dijkstra(network, r);
  for(int i = 0; i < v; ++i) {
    if( dists[i] != INF ) {
      printf("%ld\n", dists[i]);
    }
    else {
      puts("INF");
    }
  }
}

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

int H, W;
int s[50][50];

int check(int x, int y){
  bool k=false;
  if(x>0 && s[x-1][y]==1){
    k=true;
    s[x-1][y]=0;
    check(x-1, y);
  }
  if(y<W && s[x][y+1]==1){
    k=true;
    s[x][y+1]=0;
    check(x, y+1);
  }
  if(x<H && s[x+1][y]==1){
    k=true;
    s[x+1][y]=0;
    check(x+1, y);
  }
  if(y>0 && s[x][y-1]==1){
    k=true;
    s[x][y-1]=0;
    check(x, y-1);
  }
  s[x][y]=-1;
  return k;
}

int main() {
  cin >> H >> W;
  
  for(int i=0 ; i<H ; i++){
    string str;
    cin >> str;
    for(int j=0 ; j<W ; j++){
      if(str[j]=='.')
        s[i][j]=-1;
      else
        s[i][j]=1;
    }
  }
  
  for(int i=0 ; i<H ;i++)
    for(int j=0 ; j<W ; j++)  
      if(s[i][j]==1)
        if(!check(i, j)){
          cout << "No" << endl;
          return 0;
        }
    
      
    
  cout << "Yes" << endl;
}

Measured memory_bytes: 3744
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

string S;
int student[100000+10];
vector<int> coding;

void solve(void) {
    int pos_r = 0;
    int num = 1;

    char prev = 'R';
    for(int i = 1;i < S.size();i++) {
        if(S[i] != prev) {
            prev = S[i];
            if(prev == 'L')
                num = -num;
            coding.push_back(num);
            num = 1;
        } else {
            num++;
        }
    }
    if(prev == 'L')
        num = -num;
    coding.push_back(num);

    int offset = 0;
    for(int i = 0;i < coding.size();i+=2) {
        int sum = abs(coding[i])+abs(coding[i+1]);
        int r = abs(coding[i]-1)/2;
        int l = abs(coding[i+1])/2;
        student[offset+abs(coding[i])-1] = (r+l);
        student[offset+abs(coding[i])] = sum-(r+l);
        offset += sum;
    }

    return;
}

int main(void) {
    cin>>S;

    solve();

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

    return 0;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
int a[3];
bool cmp(int a,int b){
    return a>b;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3,cmp);
    cout<<a[0]*10+a[1]+a[2]<<endl;
}



Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='No'
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and \
            'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and\
            'W' in s and 'E' in s:
        ans='Yes'
    print(ans)
resolve()

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

int main(){
    string s, ss;
    cin >> s >> ss;
    int t = s.size();
    int ts = ss.size();
    string ans ="Yes";
    if( t != ts - 1) ans = "No";
    for (int i = 0; i < t; i++){
      if (s.at(i) != ss.at(i)) ans = "No";
    }

    cout <<  ans  << endl;

}

Measured memory_bytes: 3572
import math
A, B, H, M = map(int, input().split())

T = (60*H+M) * 11 / 360 * math.pi
if T > math.pi:
    T = 2*math.pi - T

ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(T))
print(ans)


Measured memory_bytes: 9440
h, w, k = map(int, input().split())

MOD = 10 ** 9 + 7

if w == 1:
    print(1)
    exit()
elif w == 2:
    print(2 ** (h - 1))
    exit()


dp = [[0 for _ in range(w)] for _ in range(h + 1)]

br = [1, 2, 3, 5, 8, 13, 21, 34, 55]

def other(a, b):
    if b == 0:
        return br[a-1] * br[w-a-2]
    elif b == 1:
        if a == 1:
            return br[w-3]
        else:
            return br[a-2] * br[w-a-2]
    else:
        if a == w-2:
            return br[w-3]
        else:
            return br[j-1] * br[w-a-3]


k -= 1
dp[0][0] = 1

for i in range(1, h + 1):
    for j in range(1, w - 1):
        dp[i][j] = dp[i-1][j] * other(j, 0)
        dp[i][j] += dp[i-1][j-1] * other(j, 1)
        dp[i][j] += dp[i-1][j+1] * other(j, 2)
        dp[i][j] %= MOD
    dp[i][0] = dp[i-1][0] * br[w-2] + dp[i-1][1] * br[w-3]
    dp[i][0] %= MOD
    dp[i][w-1] = dp[i-1][w-1] * br[w-2] + dp[i-1][w-2] * br[w-3]
    dp[i][w-1] %= MOD

print(dp[h][k])



Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    long long x,a,b;
    cin>>x;
    for(b=-63;;b++){
        a=pow(b*b*b*b*b+x,0.2);
        if(a*a*a*a*a-b*b*b*b*b==x){
            cout<<a<<" "<<b;
            break;
        }
    }
    
	return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    long long int sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        int temp = 0, j = i;
        while (j)
        {
            temp += (j%10);
            j /= 10;
        }
        if (temp >= a && temp <= b)
        {
            sum += i;
        }
    }
    printf("%lld", sum);
    return 0;
    
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
 
s = input().rstrip()
k = int(input())

def check_count(s):
    cnt_list = []
    cnt = 1
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            cnt += 1
        else:
            cnt_list.append(cnt)
            cnt = 1
    if cnt>1:
        cnt_list.append(cnt)
    return cnt_list

def calc_ans(cnt_list, k):
    _ans = 0
    for c in cnt_list:
        _ans += c//2
    return(_ans * k)

if len(s)==1:
    ans = k//2
else:
    cnt_list = check_count(s)
    if len(cnt_list)==1:
        ans = (len(s)*k)//2
    else:
        ans = calc_ans(cnt_list, k)
        if s[0]==s[-1]:
            if cnt_list[0]%2==1 and cnt_list[-1]%2==1:
                ans += k - 1

print(ans)

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

int sum(int x){
    int s = 0;
    rep(i,x+1){
        s += i;
    }
    return s;
}

void solve(){
    int a,b;
    cin >> a >> b;
    cout << sum(b-a)-b << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        int[] A = new int[N];

        int idx_1 = -1;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            if (A[i] == 1) {
                idx_1 = i;
            }
        }

        int count = 0;
        if (idx_1 <= K - 1) {
            count += 1;
            N -= K;
            if (N % (K - 1) == 0) {
                count += N / (K - 1);
            } else {
                count += N / (K - 1) + 1;
            }
        } else {
            int g = idx_1 / (K - 1);
            int r = N - (g * (K - 1) + K);

            if (r < 0) {
                r = 0;
            }

            int n_r = r / (K - 1);
            if (r % (K - 1) != 0) {
                n_r++;
            }

            count = g + 1 + n_r;

        }

        System.out.println(count);
    }
}

Measured memory_bytes: 48008
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010
ll vis[M];
vll v;
ll prim(ll n){
	ll f=1;
	for(ll i=2;i*i<=n;++i)if(n%i==0)f=0;
	return f;
}
int main(){
	IOS;
	ll a,b;cin>>a>>b;
	ll x=__gcd(a,b);
	ll cnt=1,f=1;
	for(ll i=2;i*i<=x;++i){
		if(x%i==0){
		if(prim(i))cnt++;
		if(i*i!=x)if(prim(x/i))cnt++;
		f=0;
		}
	}
	if(f)cnt++;
	if(x==1)cout<<1;
	else cout<<cnt;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  cout<<setprecision(10)<<fixed;
  int n,k; cin >> n >> k;
  vector<double> p(n),pe(n);
  rep(i,n) cin >> p[i];
  rep(i,n){
    pe[i] = (p[i]+1)/2.0;
  }
  double temp = 0; double ans = 0;
  rep(i,k) temp += pe[i];
  ans = temp;
  for (int i = 1; i <= n-k; i++){
    temp -= pe[i-1];
    temp += pe[i+k-1];
    if (ans < temp) ans = temp;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

map<pair<int, int>, ll> mp;
const int maxN = 2e5;
vector<ll> fact(maxN + 1, 1);

void calc_fact()
{
    for(int i = 1; i <= maxN; i++)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }
}

ll C(ll n, ll r)
{
    if(n == 0)
    {
        return 0;
    }
    if(n == r || r == 0)
    {
        return 1;
    }
    if(mp[{n, r}])
    {
        return mp[{n, r}];
    }

    ll x, y;

    if(mp[{n - 1, r - 1}])
    {
        x = mp[{n - 1, r - 1}];
    }
    else {
        x = C(n - 1, r - 1);
        if(x >= MOD)
            x %= MOD;
        mp[{n - 1, r - 1}] = x;
    }

    if(mp[{n - 1, r}])
    {
        y = mp[{n - 1, r}];
    }
    else {
        y = C(n - 1, r);
        if(y >= MOD)
            y %= MOD;
        mp[{n - 1, r}] = y;
    }

    ll ret = mp[{n, r}] = x + y;
    
    if(ret >= MOD)
        ret %= MOD;

    return ret;
}

ll power(ll X, ll N)
{
    ll res = 1;
    
    while(N > 0)
    {
        if(N & 1)
        {
            res *= X;
            if (res >= MOD)
                res %= MOD;
        }

        X = X * X;
        if(X >= MOD)
            X %= MOD;

        N = N >> 1;
    }

    return res;
}

ll c(ll n, ll r)
{
    ll num = fact[n];
    ll den = fact[n - r] * fact[r];
    den %= MOD;

    den = power(den, MOD - 2);
    
    return (num * den) % MOD;
}

ll calc(ll N, ll M, ll K)
{
    ll ans = 1;
    ans *= M;

    ans *= power(M - 1, N - K - 1);
    if(ans >= MOD)
        ans %= MOD;

    ans *= c(N - 1, K);

    if(ans >= MOD)\
        ans %= MOD;

    return ans;

}

void solve()
{
    ll N, M, K;
    cin >> N >> M >> K;

    ll ans = 0;

    for(int i = 0; i <= K; i++)
    {
        ans += calc(N, M, i);
        if(ans >= MOD)
            ans %= MOD;
    }
    cout << ans << endl;
}

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

    calc_fact();
    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,arr[100005],occ[100005]={},ans=0;
int main()
{
	scan(n);
	for(int i=1;i<=n;i++)
		scan(arr[i]),occ[arr[i]]++;
	for(int i=2;i<=100000;i++)
		ans=max(ans,occ[i-2]+occ[i-1]+occ[i]);
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
    stack<int> si;
    char s[110];
    while (scanf("%s", s) != EOF) {
        int a, b;
        if (s[0] >= '0' && s[0] <= '9') {
            si.push(atoi(s));
        } else {
            b = si.top(); si.pop();
            a = si.top(); si.pop();

            int p;
            switch (s[0]) {
                case '+': p = a + b; break;
                case '-': p = a - b; break;
                case '*': p = a * b; break;
            }
            si.push(p);
        }
    }

    printf("%d\n", si.top());
    return 0;
}



Measured memory_bytes: 3220