akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;



int main(){

	int n, m, H, K;
	while (cin >> n >> m >> H >> K && n){

		int dc[101][101];
		int dh[101][101];
		int dr[101][101];

		rep(i, 101)rep(j, 101)dc[i][j] = -1;
		rep(i, m){
			int a, b, c, h, r;
			cin >> a >> b >> c >> h >> r;
			dc[a][b] = dc[b][a] = c;
			dh[a][b] = dh[b][a] = h;
			dr[a][b] = dr[b][a] = r - 1;
		}
		int s, t;
		cin >> s >> t;
		int p;
		cin >> p;

		int pd[1000];
		int pt[1000];
		rep(i, p){
			int l;
			cin >> l >> pd[i];
			pt[i] = 0;
			rep(j, l){
				int dt;
				cin >> dt; dt--;
				pt[i] |= (1 << dt);
			}
		}

		int ans = INF;

		int dval[1024];
		rep(i, 1024)dval[i] = INF;
		dval[0] = 0;
		for (int i = 0; i <= (1 << K); i++)if (dval[i] != INF){
			for (int k = 0; k < p; k++){
				dval[i | pt[k]] = min(dval[i | pt[k]], dval[i] + pd[k]);
			}
		}
		int d[101][25];

		for (int f = 0; f <= (1 << K); f++){

			int val = dval[f];
			if (val != INF){

				rep(i, 101)rep(k, 25)d[i][k] = INF;
				d[s][0] = 0;

				queue<T> q;
				q.push(T(s, 0, 0));
				while (q.size()){
					int nw = get<0>(q.front()), c = get<1>(q.front()), h = get<2>(q.front());
					q.pop();

					For(i, 1, n + 1){
						if (dc[nw][i] != -1){

							int tc, th = h + dh[nw][i];
							if (!(f >> dr[nw][i] & 1))
								tc = c + dc[nw][i];
							else
								tc = c;

							if (th <= H && val + tc < ans){
								if (d[i][th] > tc){
									d[i][th] = tc;
									if (i != t){
										q.push(T(i, tc, th));
									}
									else{
										ans = min(ans, val + tc);
									}
								}
							}
						}
					}
				}
			}
		}

		if (ans == INF)ans = -1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1400
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,n,maxi=INF,f=0,mini=INF,sum=INF;
    string str,stra;
    cin>>stra;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    //map<ll,ll> m;
    set<char> s;
    rep(i,stra.length())     s.insert(stra[i]);
    for(auto itr=s.begin();itr!=s.end();++itr){
      char key=*itr;
      //cout<<key<<endl;
      str=stra;
      ll po=str.length()-1;
      sum=0;
      c=1;
      while(c){
        rep(i,str.length()){
          if(str[i]!=key) f=1;
        }
        if(f==0){
          mini=min(mini,sum);
          c=0;
        }
        f=0;
        rep(i,str.length()-1) {
          if(str[i]==key||str[i+1]==key) str[i]=key;
        }
        str[po]=key;
        po--;
        sum++;
      }
    }
    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 3644
N = int(raw_input())
a = [0]
for i in range(N):
  a.append(int(raw_input()))
i = 0
j = 1
while True:
  nj = a[j]
  i += 1
  if nj==2:
    print i
    break
  elif nj==j or a[nj]==0:
    print -1
    break
  else:
    a[j]=0
    j = nj

Measured memory_bytes: 8964
#include<bits/stdc++.h>
#define rep(i,n) for(int 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

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=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[100001][4]={};

int main() {

	int n;
	int a[100001],b[100001],c[100001];
	cin>>n;

	rep(i,n){
		cin>>a[i+1]>>b[i+1]>>c[i+1];
	}
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];
	for(int i=2; i<n+1; i++){
		dp[i][1]=max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
		dp[i][2]=max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
		dp[i][3]=max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
	}
	dp[n][1]=max(dp[n][1],dp[n][2]);
	cout<<max(dp[n][3],dp[n][1])<<endl;

	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll div = Y / X;
    int cnt = 0;
    while (div) {
        div >>= 1;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)
	ar := make([]int, x)
	br := make([]int, y)
	cr := make([]int, z)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	for i := range br {
		fmt.Scan(&br[i])
	}
	for i := range cr {
		fmt.Scan(&cr[i])
	}
	dr := make([]int, 0, x*y)
	for _, a := range ar {
		for _, b := range br {
			dr = append(dr, a+b)
		}
	}
	sort.Ints(dr)
	ds := k
	if 3000 < k {
		ds = 3000
	}
	er := make([]int, 0, 3000)
	var s int
	for i := len(dr) - 1; i >= 0; i-- {
		er = append(er, dr[i])
		s++
		if s == ds {
			break
		}
	}
	fr := make([]int, 0, len(er)*z)
	for _, e := range er {
		for _, c := range cr {
			fr = append(fr, e+c)
		}
	}
	sort.Ints(fr)
	for i := 0; i < k; i++ {
		fmt.Println(fr[len(fr)-1-i])
	}
}


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

string s[10];

int main() {
	while(1){
		int t = 0;
		int r = 0;
		bool flag = false;
		for (int i = 0; i < 8; i++) {
			if (!(cin >> s[i]))return 0;
		}
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++)
			{
				if (s[i][j] == '1') {
					if (flag == false) { t = 8 * i + j; flag = true; };
					r += 8 * i + j;
				}
			}
		}
		r -= 4 * t;
		if (r == 18)cout << 'A' << endl;
		else if (r == 48)cout << 'B' << endl;
		else if (r == 6)cout << 'C' << endl;
		else if (r == 30)cout << 'D' << endl;
		else if (r == 20)cout << 'E' << endl;
		else if (r == 34)cout << 'F' << endl;
		else if (r == 16)cout << 'G' << endl; }
}

Measured memory_bytes: 1176
#undef _GLIBCXX_DEBUG
 
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, s, t;
  cin >> n >> k >> s >> t;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if ((t & s) != s) {
    cout << 0 << '\n';
    return 0;
  }
  vector<vector<long long>> C(n + 1, vector<long long>(n + 1));
  for (int i = 0; i <= n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
    }
  }
  vector<long long> ways(n + 1);
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= min(i, k); j++) {
      ways[i] += C[i][j];
    }
  }
  vector<int> b;
  long long ans = 0;
  for (int mask = 0; mask < (1 << 18); mask++) {
    if ((mask & (t ^ s)) != mask) {
      continue;
    }
    int sign = (__builtin_popcount(mask) % 2 == 0 ? 1 : -1);
    b.clear();
    for (int i = 0; i < n; i++) {
      if ((a[i] & s) != s) {
        continue;
      }
      if ((a[i] | t) != t) {
        continue;
      }
      b.push_back(a[i] & mask);
    }
    sort(b.begin(), b.end());
    int beg = 0;
    while (beg < (int) b.size()) {
      int end = beg;
      while (end + 1 < (int) b.size() && b[end + 1] == b[end]) {
        ++end;
      }
      ans += sign * ways[end - beg + 1];
      beg = end + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#define ll long long
#define p (ll)(1e9+7)

ll n,f[23000001],ans;

inline ll pow10(ll x){
	ll res=1,tmp=10;
	 while(x){
        if(x&1)
            res=res*tmp%p;
        tmp=tmp*tmp%p;
        x>>=1;
    }
    return res;
}

int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=23000000;i++)
		f[i]=f[i/10]+1;
	for(ll i=1,j=1,s=0;i<1e7;i++){
		while(s<n)
			s+=f[j++];
		if(s==n)
			ans++;
		s-=f[i];
	}
	for(ll i=1;i<=n/8;i++)
		if(n%i!=0)
			ans++;
		else
			ans=(ans+9*pow10(n/i-1)-i+1)%p;
	printf("%lld",ans);
}

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

int main(){
  std::string N;
  cin >> N;
  int L=N.size();
  int sum=0;
  for(int i=0; i<L; i++){
    sum += N.at(i)-'0';
  }
  int num = std::stoi(N);
  if(num % sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>
#include <random>
#include <stack>

using namespace std;

#define endl '\n'

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

using lld = long double;
using ull = unsigned long int;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  const ll mod = 1e9 + 7;
  int n; ll k; cin >> n >> k;
  vector<ll> a(n);
  for (auto& it : a) cin >> it;

  vector<vector<ll>> dp(2, vector<ll>(k+1));
  fill(dp[1].begin(), dp[1].end(), 1);

  for (int i = 0; i < n; ++i) {
    int cur = i&1;
    int prev = cur^1;
    for (ll c = 0; c <= k; ++c) {
      ll acc = dp[prev][c] - (a[i] < c ? dp[prev][c - a[i] - 1] : 0ll);
      dp[cur][c] = acc + (c > 0 ? dp[cur][c-1] : 0ll) + mod;
      dp[cur][c] %= mod;
    }
  }

  int cur = (n-1)&1;
  ll ans = dp[cur][k] - (k > 0 ? dp[cur][k-1] : 0);

  cout << (ans + mod) % mod << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c;cin>>a>>b>>c;
  ll d=max(a,max(b,c)),e=min(a,min(b,c)),f=a+b+c-d-e;
  ll g=d-e,h=d-f,i=g+h,j=i/2;
  if(j*2!=i)j+=2;
  cout<<j;
  }


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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int MAXN = 2e5 + 10;
int n, k;
int a[MAXN];

bool check(int mid)
{
    int num = 0;
    for (int i = 1; i <= n; i++)
    {
        num += a[i] / mid;
        if (a[i] % mid == 0)
        {
            num--;
        }
    }
    return num <= k;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int l = 1, r = 1e9, ans = 1e9;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid))
        {
            ans = mid;
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
        debug(l, r, ans);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4392
#include "bits/stdc++.h"
using namespace std;
const int maxn = 1<<18;
int arr[maxn];
struct node{
  int ind, value;
};
vector<node> u[maxn];
vector<node> merge(vector<node> & a, vector<node> & b){
  vector<node> ans = a;
  for(node nd : b){
    bool bad = false;
    for(node ians : ans) if(ians.ind == nd.ind) bad = true;
    if(!bad){
      ans.push_back(nd);
    }
  }
  sort(ans.begin(), ans.end(), [](node r, node s){
    return r.value > s.value;
  });
  ans.resize(2);
  return ans;
}
int main(){
  int n;
  scanf("%d", &n);
  for(int e = 0; e < 1<<n; e++) scanf("%d", arr + e);
  for(int e = 0; e < 1<<n; e++) u[e].push_back({e, arr[e]});
  for(int e = n - 1; e >= 0; e--){
    for(int f = 0; f < 1<<n; f++){
      if(f & (1<<e)){
        u[f] = merge(u[f], u[f ^ (1<<e)]);
      }
    }
  }
  int now = 0;
  for(int e = 1; e < 1<<n; e++){
    assert(u[e].size() == 2);
    now = max(now, u[e][0].value + u[e][1].value);
    printf("%d\n", now);
  }
  return 0;
}


Measured memory_bytes: 22528
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cassert>
namespace boost {template <class T>struct integer_iterator {T a;bool operator != (integer_iterator const & it) const { return a != it.a; }T operator * () const { return a; }integer_iterator & operator ++ () { ++ a; return *this; }integer_iterator operator ++ (int) { return { a ++ }; }};template <class T>struct integer_range {T l, r;typedef integer_iterator<T> iterator;iterator begin() const { return { l }; }iterator end  () const { return { r }; }};template <class T>integer_range<T> irange(T l, T r) { return { l, r }; }template <class T>struct integer_iterator_with_step {T a, d, i;bool operator != (integer_iterator_with_step const & it) const { return a != it.a or d != it.d or i != it.i; }T operator * () const { return a+d*i; }integer_iterator_with_step & operator ++ () { ++ i; return *this; }integer_iterator_with_step operator ++ (int) { return { a, d, i ++ }; }};template <class T>struct strided_integer_range {T l, r, s;typedef integer_iterator_with_step<T> iterator;iterator begin() const { return { l, s, 0 }; }iterator end  () const { return { l, s, (r - l) / s }; }};template <class T>strided_integer_range<T> irange(T l, T r, T s) { return { l, r, s }; }}
typedef long long ll;
using namespace std;
using namespace boost;
#define endl "\n"
struct edge_t { int from, to; int dist, lim; };
struct state_t { int cur, prv, velc; double time; };
bool operator < (state_t const & a, state_t const & b) {
    return a.time > b.time;
}
#define MAX_VELOCITY 30
#define V(...) vector<__VA_ARGS__ >
#define INF 1e20
int main() {
    while (true) {
        int n, m; cin >> n >> m;
        if (n == 0 and m == 0) break;
        int start, goal; cin >> start >> goal; -- start; -- goal;
        V(V(edge_t)) g(n);
        for (int i : irange(0,m)) {
            int x, y, d, c;
            cin >> x >> y >> d >> c; -- x; -- y;
            g[x].push_back({ x, y, d, c });
            g[y].push_back({ y, x, d, c });
        }
        // current-node, prev-node, velocity -> elapsed-time
        V(V(V(double))) memo(n, V(V(double))(n, V(double)(MAX_VELOCITY+1, INF)));
        priority_queue<state_t> q;
        q.push({ start, start, 0, 0.0 });
        while (not q.empty()) {
            state_t s = q.top(); q.pop();
            if (memo[s.cur][s.prv][s.velc] != INF) continue;
            memo[s.cur][s.prv][s.velc] = s.time;
            if (s.cur == goal and s.velc == 1) {
                printf("%.5lf\n", s.time);
                goto next;
            }
            for (edge_t e : g[s.cur]) {
                if (e.to == s.prv) continue;
                for (int dv : { -1, 0, 1 }) {
                    int nv = s.velc + dv;
                    if (nv <= 0 or e.lim < nv) continue;
                    if (memo[e.to][e.from][nv] != INF) continue;
                    q.push({ e.to, e.from, nv, s.time + (e.dist /(double) nv) });
                }
            }
        }
        cout << "unreachable" << endl;
next:;
    }
    return 0;
}

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

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	
	
	int cnt = 0;
	int res = max(a,b);
	while(cnt < k){
		if(a%res==0 && b%res==0) cnt++;
		if(cnt==k) break;
		res--;
		
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  ll H;
  cin >> H;
  ll ans = 0;
  ll cur = 1;
  while(H >= 1) {
    ans += cur;
    cur *= 2;
    H /= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "stdio.h"

int N;
int flag[100000] = {};
int ans;

int main() {
	
	scanf("%d", &N);
	while (N != 0) {
		ans = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &flag[i]);
			if (i % 2 == 1) {
				for (int j = i - 1; j >= 0; j--) {
					if (flag[j] == flag[i])break;
					flag[j] = flag[i];
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (flag[i] == 0)ans++;
		}
		printf("%d\n", ans);
		scanf("%d", &N);
	}

	return 0;
}

Measured memory_bytes: 1416
def gcd(a: int, b: int)->int:
    if a < b:
        a, b = b, a
    return a if b == 0 else gcd(b, a % b)


def gcd_on_blackboard(N: int, A: list)->int:
    L, R = [0] * N, [0] * N

    L[0] = A[0]
    for i, a in enumerate(A[1:]):
        L[i+1] = gcd(L[i], a)

    R[-1] = A[-1]
    for i, a in enumerate(reversed(A[:-1])):
        R[N-i-2] = gcd(R[N-i-1], a)

    max_diff = max(R[1], L[-2])
    for i in range(1, N-1):
        max_diff = max(gcd(L[i-1], R[i+1]), max_diff)

    return max_diff


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    ans = gcd_on_blackboard(N, A)
    print(ans)


Measured memory_bytes: 14052
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    const char BL = '#';
    const char WH = '.';
    static int H;
    static int W;

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        H = h;
        W = w;

        var tbl = new char[h][];
        var ri = new int[h][];
        var rj = new int[h][];
        var rc = new int[h][];

        for (int i = 0; i < h; i++) {
            tbl[i] = input.ReadLine().ToCharArray();
            ri[i] = new int[w];
            rj[i] = new int[w];
            rc[i] = new int[w];
        }

        f(tbl, rc, ri, rj, 0, 0, -1, -1);
        if(rc[h-1][w-1] == 0) {
            return -1;
        }

        var wsum = tbl.Sum(xx => xx.Where(x => x == WH).Count());
        return wsum - rc[h - 1][w - 1];
    }

    static void f(char[][] tbl,int[][] rc, int[][] ri, int[][] rj, int i, int j, int fromi, int fromj) {
        if (i < 0 || j < 0 || i > H - 1 || j > W - 1) return;
        if (tbl[i][j] == BL) return;

        var changed = false;

        if (i == 0 && j == 0) {
            rc[i][j] = 1;
            changed = true;
        } else {
            if (rc[i][j] == 0 || rc[i][j] > rc[fromi][fromj] + 1) {
                rc[i][j] = rc[fromi][fromj] + 1;
                ri[i][j] = fromi;
                rj[i][j] = fromj;
                changed = true;
            }
        }

        if (changed) {
            f(tbl, rc, ri, rj, i - 1, j, i, j);
            f(tbl, rc, ri, rj, i + 1, j, i, j);
            f(tbl, rc, ri, rj, i, j - 1, i, j);
            f(tbl, rc, ri, rj, i, j + 1, i, j);
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13524
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

int n,q,dp[N],timer,tin[N],tout[N];
vector <int> g[N];
inline void dfs(int v, int pr=0) {
    tin[v]=++timer;
    for (int to : g[v]) {
        if (to!=pr) dfs(to,v);
    }
    tout[v]=timer;
}
main() {
    file("walk");
    ios;
    cin>>n >> q;
    fo(i,1,n-1,1) {
        int u,v;
        cin>>u>>v;
        g[u].eb(v);
        g[v].eb(u);
    }
    dfs(1);
    while (q--) {
        int a,b;
        cin>>a>>b;
        dp[tin[a]]+=b;
        dp[tout[a]+1]-=b;
    }
    fo(i,1,timer,1) dp[i]+=dp[i-1];
    fo(i,1,n,1) cout<<dp[tin[i]]<<' ';
    return 0;
}
/**

*/


Measured memory_bytes: 23296
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
 
typedef long long llong;
typedef pair<int, int> pii;
 
void solve(){
 
	string s;
	cin >> s;
 
	int n = (int)s.size();

	for(int i = 0; i + 1 < n; i++){
		if(s[i] == s[i + 1]){
			cout << i + 1 << ' ' << i + 2 << endl;
			return;
		}
	}

	for(int i = 0; i + 2 < n; i++){
		if(s[i] == s[i + 1]){
			cout << i + 1 << ' ' << i + 2 << endl;
			return;
		}else if(s[i + 1] == s[i + 2]){
			cout << i + 2 << ' ' << i + 3 << endl;
			return;
		}else if(s[i] == s[i + 2]){
			cout << i + 1 << ' ' << i + 3 << endl;
			return;
		}
	} 

	cout << "-1 -1";
}
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
 
	solve();
 
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=tuple(map(int,input().split(' ')))
r,ans,tsum,txor=0,0,0,0
for l in range(n):
    while r<n and txor^a[r]==tsum+a[r]:
        txor = txor^a[r]
        tsum = tsum+a[r]
        r += 1
    ans += r-l
    if l==r:
        r+=1
    else:
        txor = txor^a[l]
        tsum -= a[l]
print(ans)

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

using namespace std;

using ll=long long;

int n;
vector<int> a;

ll calc() {
    ll dp[3];
    dp[1] = dp[2] = -(1ll<<60);
    dp[0] = 0;
    for (int x: a) {
        dp[0] += x;
        dp[1] -= x;
        dp[2] += x;
        if (x < 0) {
            dp[2] = max(dp[2], dp[1]);
            dp[1] = max(dp[1], dp[0]);
        }
        dp[0] = max(dp[0], dp[1]);
        dp[1] = max(dp[1], dp[2]);
    }
    return dp[0];
}
ll calc2() {
    ll base = 0;
    ll pos = 0;
    ll neg = 0;
    ll mx = 0;
    for (int i = n-1; i >= 0; i--) {
        int x = a[i];
        base += x;
        if (x < 0) {
            mx = max(mx, (-neg-pos)*2);
            pos = 0;
            neg += x;
        } else pos += x;
    }
    return base + mx;
}

void solve() {
    cin >> n; a.resize(n);
    for (int i = 0; i < n; i++) {
        char c = '+';
        if (i) cin >> c;
        cin >> a[i];
        if (c=='-') a[i]*=-1;
    }
    ll x = calc();
    ll y = calc2();
    assert(x == y);
    cout << y << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> p(N);
    for (int i = 0; i < N; i++) {
        double tmp;
        cin >> tmp;
        p[i] = (tmp + 1) / 2;
    }

    vector<double> dp(N);
    for (int i = 0; i < K; i++) {
        dp[0] += p[i];
    }
    for (int i = 1; i < N - K + 1; i++) {
        dp[i] = dp[i - 1] - p[i - 1] + p[i + K - 1];
    }

    sort(dp.begin(), dp.end());
    printf("%f\n", dp[dp.size() - 1]);

    return 0;
}


Measured memory_bytes: 6476
#include<iostream>

int main(){

	int h, w;
	while (std::cin >> h >> w, h || w){

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)std::cout << "#";
				else std::cout << ".";
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    int n;
    cin >> n;
    set<int> a;
    int p;
    rep(i,n){
        cin >> p;
        a.insert(p);
    }
    if(a.size() == n) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define all(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chmax(T &a, const T &b) {  //aよりbが大きければaに代入
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //aよりbが小さければaに代入
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

//
//
//

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;

    if(op=='+'){
        cout << a + b << endl;
    }else{
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
vector<int> G[SIZE];
bool used[SIZE];
int p,q;

void dfs(int s,int d){
  if(p < d){
    p = d;
    q = s;
  }
  used[s] = true;
  for(auto e : G[s]){
    if(!used[e]){
      dfs(e,d+1);
    }
  }
}


int main(){
  p=q=-1;
  cin >> n;
  int a,b;
  rep(i,0,n-1){
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1,0);
  int v1 = q;//v
  p=q=-1;
  rep(i,0,SIZE) used[i] = false;
  dfs(v1,0);
  int v2 = q;
  //p
  //
  if(p%3==1){
    cout << "Second" << endl;
  }else{
    cout << "First" << endl;
  }

  return 0;
}


Measured memory_bytes: 17664
N = int(input())
A = input()
B = input()
C = input()

count = 0
for i in range(N):
    if A[i] == B[i]:
      if A[i] == C[i]:
        pass
      else:
        count += 1
    elif A[i] == C[i]:
      count += 1
    elif B[i] == C[i]:
      count += 1
    else:
      count += 2

print(count)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        int a = sc.nextInt();
        int b = sc.nextInt();
        double tax1 = 0.08,tax2=0.1;
        for(int i=1; i<=10000; i++){
            int check = (int)(i*tax1);
            int check2 = (int)(i*tax2);
            if(check==a && check2==b){
                out.println(i); return;
            }
        }
        out.println(-1);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair {
   int x,y;
   Pair(int x, int y){
       this.x = x;this.y = y;
   }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> col(H,vector<char>(W));
    for (int h=0;h<H;h++){
        for (int w=0;w<W;w++){
            cin >> col[h][w];
        }
    }
    int ans = 0;
    for (int i=0;i<(1<<H);i++){
        vector<bool> r(H,false);
        for (int bit=0;bit<H;bit++){
            if ((i>>bit)&1) r[bit] = true;
        }
        for (int j=0;j<(1<<W);j++){
            vector<bool> c(W,false);
            for (int bit=0;bit<W;bit++){
                if ((j>>bit)&1) c[bit] = true;
            }
            int black = 0;
            for (int h=0;h<H;h++){
                for (int w=0;w<W;w++){
                    if (r[h]) continue;
                    if (c[w]) continue;
                    if (col[h][w] == '#') black++;
                }
            }
            if (black == K) ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3672
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    double n,m;
    cin >> n >> m;
    vector<int> v(n);
    double sum;
    sum =0;
    for(int i=0;i<n;i++){
        cin >> v[i];
        sum = sum + v[i];
    }
    sort(v.begin(),v.end(),greater<int>());
    if(v[m-1]>=sum/(4.0*m)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;


class CColon {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
    long double PI = 3.14159265358979323846264338327950L;

	void solve(std::istream& in, std::ostream& out) {
        long double A, B, H, M;
        in >> A >> B >> H >> M;
        long double degree = (M / 30.0l * M_PIl) - (H  / 6.0l * M_PIl + M / 360.0l * M_PIl);
        out << setprecision(64)  << sqrtl(A * A + B * B - 2L * A * B * cosl(degree)) << endl;
	}
};


int main() {
    ios::sync_with_stdio(false);
	CColon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4196
module DoublyChainedTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable child : int;
    mutable bro : int;
    mutable depth : int;
  }

  let make () = { parent = nil; child = nil; bro = nil; depth = nil }
end

module T = DoublyChainedTree

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let t = Array.init n (fun _ -> T.make ()) in
  let rec read_tree i =
    if i < n then begin
      let id, k = Scanf.scanf "%d %d " (fun id k -> id, k) in
      let rec read_node j left_child =
        if j < k then begin
          let c = Scanf.scanf "%d " (fun c -> c) in
          t.(c).T.parent <- id;
          if j = 0 then t.(id).T.child <- c else t.(left_child).T.bro <- c;
          read_node (j + 1) c
        end
      in
      read_node 0 0;
      read_tree (i + 1)
    end
  in
  read_tree 0;
  let rec search_root i =
    if i = n then T.nil
    else if t.(i).T.parent = T.nil then i
    else search_root (i + 1)
  in
  let root = search_root 0 in
  let rec set_depth i p =
    t.(i).T.depth <- p;
    if t.(i).T.bro <> T.nil then set_depth t.(i).T.bro p;
    if t.(i).T.child <> T.nil then set_depth t.(i).T.child (p + 1);
  in
  set_depth root 0;
  let print_node i =
    print_string "node "; print_int i; print_string ": parent = "; print_int t.(i).T.parent; print_string ", depth = "; print_int t.(i).T.depth;
    print_string (if t.(i).T.parent = T.nil then ", root, " else if t.(i).T.child = T.nil then ", leaf, " else ", internal node, ");
    print_string "[";
    let rec print_children c =
      if c <> T.nil then begin
        if c <> t.(i).T.child then print_string ", ";
        print_int c;
        print_children t.(c).T.bro
      end
    in
    print_children t.(i).T.child;
    print_endline "]"
  in
  let rec print i =
    if i < n then (print_node i; print (i + 1))
  in
  print 0

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

#define INF 1E18


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

    int first = -1;
    int last = -1;

    rep(i,s.length()){
        if(first == -1 && s[i] == 'A') first = i;
        if(first != -1 && s[i]=='Z') last = i;
    }
    cout<< last - first + 1 <<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
int main() {
  int in(N);

  vector<double> p(N);
  rep(i, N)
    cin >> p[i];

  vector<vector<double>> dp(N+1, vector<double>(N+1, 0));
  dp[0][0] = 1;
  rep(i, N) {
    dp[i+1][0] = (1-p[i]) * dp[i][0];
    rep(j, N)
      dp[i+1][j+1] += (1-p[i]) * dp[i][j+1] + dp[i][j] * p[i];
  }

  double ans = 0;
  rep(i, N)
    if (i <= N-i)
      ans += dp[N][N-i];
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
#include "bits/stdc++.h"

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	int N, A, B; cin >> N >> A >> B;

	if (N*A<B) {
		cout << N * A << endl;
	}
	else {
		cout << B << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
bool isPrime(int x){
	if(x<=1)return false;
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0)return false;
	}
	return true;
}
//--main function
int main(){
	int x;cin>>x;
	int p=x+1;
	if(isPrime(x))cout<<x;
	else{
		while(!isPrime(p))p++;
		cout<<p;
	}
	
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_c
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> s(H, vector<char>(W));
    vector<int> scnth(H, 0), scntw(W, 0);
    vector<vector<int>> a(H, vector<int>(W, 0));
    int num = 1;
    REP(i, H) REP(j, W)
    {
        cin >> s[i][j];
        if ('#' == s[i][j])
        {
            ++scnth[i];
            ++scntw[j];
            a[i][j] = num++;
        }
    }

    REP(i, H)
    {
        // 左から右へ走査
        int left = a[i][0];
        REP(j, W)
        {
            // 0 の場合は左の数を採用する
            if (0 == a[i][j])
            {
                a[i][j] = left;
            }
            else
            {
                left = a[i][j];
            }
        }

        // 右から左へ走査(左から右への走査だけでは左側が埋まらない場合があるため)
        int right = a[i][W - 1];
        for (int j = W - 1; j >= 0; --j)
        {
            if (0 == a[i][j])
            {
                a[i][j] = right;
            }
            else
            {
                right = a[i][j];
            }
            
        }
    }

    REP(j, W)
    {
        // 上から下へ走査
        int up = a[0][j];
        REP(i, H)
        {
            if (0 == a[i][j])
            {
                a[i][j] = up;
            }
            else
            {
                up = a[i][j];
            }
            
        }

        // 下から上への走査
        int down = a[H - 1][j];
        for (int i = H - 1; i >= 0; --i)
        {
            if (0 == a[i][j])
            {
                a[i][j] = down;
            }
            else
            {
                down = a[i][j];
            }
            
        }
    }

    // 答えを出力
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            printf("%d", a[i][j]);
            if (j != W - 1) printf(" ");
            else printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 4132
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int f(int &n, std::map<int, bool> &map, int &cnt){
  if(n%2==0)
    n /= 2;
  else
    n = 3*n + 1;
  cnt++;
  if(map[n]){
    return cnt;
  }

  else
    map[n] = true;
  f(n,map,cnt);
}

int main(){
  int s;
  std::cin >> s;
  int cnt = 1;
  std::map<int, bool> map;
  map[s] = true;
  f(s,map,cnt);
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        if (a <= 0 && 1 <= b)
        {
            Console.WriteLine("Zero");
            return;
        }
        if (0 < a)
        {
            Console.WriteLine("Positive");
        }
        else
        {
            Console.WriteLine((a + b + 1) % 2 == 0 ? "Positive" : "Negative");
        }
    }
}

Measured memory_bytes: 11092
n,k=gets.split.map(&:to_i)
array=gets.split.map(&:to_i)

leftarray=Array.new(n,0)
rightarray=Array.new(n,0)


n.times{|i|
    n.times{|j|
      if array[j]<array[i] && j<i
            leftarray[i]+=1 
      elsif array[j]<array[i] && i<j
            rightarray[i]+=1
      end
    }
}

ans=0

n.times{|s|
    first=rightarray[s]
    last=(k-1)*(rightarray[s]+leftarray[s])+first
    result=(first+last)*k/2
    ans+=result%1000000007
}

puts ans%1000000007

Measured memory_bytes: 1916
#include<stdio.h>
int main(){
	int n,a[36],i,k;
	scanf("%d",&n);
	if(n==0){
		printf("0");
		return 0;
	}
	for(i=0;;i++){
		if(n==1){
			a[i]=1;
			for(k=i;k>=0;k--){
				printf("%d",a[k]);
			}
			return 0;
		}
		if(n%2!=0){
			a[i]=1;
			n=n-1;
		}
		else a[i]=0;
		n=n/-2;
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

 
int main() {
    int A, B, C; cin >> A >> B >> C;
    if(A == B && B == C) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	ss := make([]int, m)
	cs := make([]string, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&ss[i], &cs[i])
		ss[i]--
	}

	for i := 0; i <= 999; i++ {
		if n != len(fmt.Sprintf("%d", i)) {
			continue
		}
		str := fmt.Sprintf("%0"+fmt.Sprint(n)+"d", i)

		ok := true
		for j := 0; j < m; j++ {
			s, c := ss[j], cs[j]
			if string(str[s]) != c {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 512