akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

tree< pair< long long, int >, null_type, less< pair< long long, int > >, rb_tree_tag, tree_order_statistics_node_update > TeamInfos;
int N, C;
long long TotalScore[100001];

void update() {
	int id, score;

	cin >> id >> score;
	//cout << "id:" << id << "  score:" << score << endl;
	TeamInfos.erase(make_pair(-TotalScore[id], id));
	TotalScore[id] += score;
	TeamInfos.insert(make_pair(-TotalScore[id], id));
}

void show() {
	int ranking;

	cin >> ranking;
	//cout << "ranking:" << ranking <<  endl;
	auto pos = TeamInfos.find_by_order(ranking - 1);
	cout << pos->second << " " << -(pos->first) << endl;
}

int main() {
	int num;

	cin >> N >> C;
	for (int i = 0; i < N; ++i) {
		TeamInfos.insert(make_pair(0, i + 1));
	}
	for (int i = 0; i < C; ++i) {
		cin >> num;
		switch (num) {
			case 0: update(); break;
			case 1: show();   break;
			default:break;
		}
	}

	return 0;
}



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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if ( n <= m ) {
        ans = 1;
    }

    cout << ( ans ? "unsafe" : "safe" ) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//------------------------------------------------------------------//
typedef long long ll;
typedef vector<int> vi;
template <typename T> inline T read() {
	bool f = 1; T x = 0; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = !f;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	return f ? x : -x;
}
#define gi read<int>()
#define gl read<ll>()
//------------------------------------------------------------------//

const int N = 200000 + 5;
int n, u[N], v[N];
int main() {
	n = gi;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) ans += (ll)i * (i + 1) / 2;
	for (int i = 1; i < n; ++i) {
		int u = gi, v = gi;
		if (u > v) swap(u, v);
		ans -= (ll)u * (n - v + 1);
	}
	cout << ans << '\n';
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    int ans = 0;
    rep(i,4){
        if(s[i] == '+') ans++;
        else ans--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int sum = a+b+c;
  if(sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI(__n) for(int i = 0 ; i < __n ; i++)
#define FJ(__n) for(int j = 0 ; j < __n ; j++)
#define _FI(__n, ___n) for(int i = __n ; i < ___n ; i++)
#define _FJ(__n, ___n) for(int j = __n ; j < ___n ; j++)
using namespace std;

typedef long double ld;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int max = INT_MIN;
    int min = INT_MAX;
    FI(n)
    {
        int a, b;
        cin >> a >> b;
        if(a > max)
            max = a;
        if(b < min)
            min = b;
    }
    cout << max + min;
    return 0;
}


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

int main (void){
  int a,b,c,k;
  cin >> a >> b >> c >> k;

    for(int i = 0;i < k;i++){
      if(a >= b){
        b = b * 2;
      }else if(b >= c){
        c = c * 2;
      }
    }

    if(c > b && b > a){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;

}


Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int n,k,i,j=0,t;
    cin>>n>>k;
    set<int> s;
    vector<pair<int,int> > v,x;
    vector<int> w(n,0);
    rep(i,n)cin>>w[i];
    sort(w.begin(),w.end());
    rep(i,n){
        t=w[i];
        if(s.find(t)!=s.end()){
            v[v.size()-1].second++;
        }
        else{
            v.push_back(make_pair(t,1));
            s.insert(t);
        }
    }
    rep(i,v.size()){
        x.push_back(make_pair(v[i].second,v[i].first));
    }
    sort(x.begin(),x.end());
    int ans=0;
    t=max((int)x.size()-k,0);
    rep(i,t){
        ans+=x[i].first;
    }
    fin(ans);



    
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 15088
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

const int kINF = 1000000000;

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }

  vector<int> dp(H + 1, kINF);
  dp[H] = 0;
  for (int h = H; h > 0; --h) {
    for (int i = 0; i < N; ++i) {
      int nh = h - A[i];
      if (nh < 0) nh = 0;
      dp[nh] = min(dp[nh], dp[h] + B[i]);
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,Ans,d;
int x[20][20];
int main() {
	scanf("%d%d",&n,&d);
	for(int i=1; i<=n; i++)
		for(int j=1; j<=d; j++)
			scanf("%d",&x[i][j]);
	for(int i=1; i<=n; i++) {
		for(int j=i+1; j<=n; j++) {
			int Now=0;
			for(int k=1;k<=d;k++)Now+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			int w=sqrt(Now);
			if(w*w==Now)Ans++;
		}
	}
	printf("%d",Ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<ctime>
#define up(i,x,y) for(int i = x;i <= y;i ++)
#define down(i,x,y) for(int i = x;i >= y;i --)
#define mem(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define lson p<<1
#define rson p<<1|1
using namespace std;
typedef long long ll;
const int SIZE = 50010;
const int INF = 2147483640;
const double eps = 1e-8;

inline void RD(int &x)
{
    x = 0;  char c; c = getchar();
    bool flag = 0;
    if(c == '-')    flag = 1;
    while(c < '0' || c > '9')   {if(c == '-')   {flag = 1;} c = getchar();}
    while(c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0',c = getchar();
}
ll base = 20000;
ll a[SIZE],b[SIZE];
int in[SIZE];
int n;

int main(int argc, char const *argv[])
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&in[i]);
	}
	for(int i = 1;i <= n;i ++)
	{
		a[in[i]] = 1ll * (in[i]-1) * base + (ll)i;
		b[in[i]] = 1ll * (n-in[i]) * base + (ll)i;
	}
	for(int i = 1;i <= n;i ++)
	{
		printf("%lld%c",a[i],i == n ? '\n' : ' ');
	}
	for(int i = 1;i <= n;i ++)
	{
		printf("%lld%c",b[i],i == n ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
struct cube{
    int x,y,z;
    bool operator<(const cube& right)const{
        if(x!=right.x) return x<right.x;
        if(y!=right.y) return y<right.y;
        return z<right.z;
    }
};
ll A,B,C;
int N;
int dx[6] = {-1,1,0,0,0,0},dy[6] = {0,0,-1,1,0,0},dz[6] = {0,0,0,0,-1,1};

int main(){
    cin >> A >> B >> C >> N;
    vector<cube> v(N);
    int x,y,z;
    ll ans = 2*(A*B+B*C+C*A);
    set<cube> s;
    for(int i=0;i<N;i++){
        cin >> x >> y >> z;
        for(int k=0;k<6;k++){
            int nx = x+dx[k],ny = y+dy[k],nz = z+dz[k];
            if(nx==-1 || nx==A) ans -= 2;
            if(ny==-1 || ny==B) ans -= 2;
            if(nz==-1 || nz==C) ans -= 2; 
        }
        v[i] = {x,y,z};
        s.insert(v[i]);
    }
    for(int i=0;i<N;i++){
        for(int k=0;k<6;k++){
            int nx = v[i].x+dx[k],ny = v[i].y+dy[k],nz = v[i].z+dz[k];
            cube c = {nx,ny,nz};
            if(s.count(c)==0) ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int r;
    cin >> r ;
    cout << r*r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int parent,left,right;};

struct Node T[MAX];
int n,D[MAX];

int rec(int u , int p) {
    D[u] = p;
    if(T[u].right != NIL) rec(T[u].right,p);
    if(T[u].left != NIL) rec(T[u].left,p + 1);
}

void print(int i) {
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", " ;
    cout << "depth = " << D[i] << ", ";

    if(T[i].parent == NIL) cout << "root, ";
    else if(T[i].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << '[';
    for(int j = 0,c = T[i].left;c != NIL;j++,c = T[c].right) {
        if(j) cout << ", ";
        cout << c;
    }
    cout << ']';
}

int main() {
   int N,id,k,c,l;
   cin >> N;

    for(int i = 0; i < N; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for(int i = 0; i < N;i++) {
        cin >> id >> k;
        for(int j = 0;j < k;j++) {
            cin >> c;
            if(j == 0) {
            T[id].left = c;
            }else {
            T[l].right = c;
            }
            l = c;
            T[c].parent = id;
        }
    }

    int r;
    for(int i = 0; i < N;i++) {
        if(T[i].parent == NIL) r = i;
    }

    rec(r,0);

    for(int i = 0; i < N; i++) {
        print(i);
        cout << endl;
    }

}



Measured memory_bytes: 7760
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
//struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
string s;

int main(){
  cin >> n;
  cin >> s;
  deque<int> l, r;
  rep(i, n) if (s[i] == '<') r.push_back(i);
  int res = 0;
  rep(i, n){
    if (r.size() && r[0] == i) r.pop_front();
    if (s[i] == '>'){
      if (r.empty()) chmax(res, n - i);
      else if (l.size() >= r.size()) chmax(res, n - l[r.size() - 1]);
      else chmax(res, r[l.size()] + 1);
    }
    else {
      if (l.empty()) chmax(res, i + 1);
      else if (l.size() <= r.size()) chmax(res, r[l.size() - 1] + 1);
      else chmax(res, n - l[r.size()]);
    }
    if (s[i] == '>') l.push_front(i);
  }
  cout << res << endl;
}

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

int main() {
	int a, b, C;
	double S, L, h, pi, c, d;

	cin >> a >> b >> C;

	pi = acos(-1);

	d = C*pi / 180;

	c = sqrt(a*a + b*b - 2 * a*b*cos(d));

	S = 0.5*a*b*sin(d);

	L = a + b + c;

	h = b*sin(d);

	printf("%lf\n%lf\n%lf\n", S, L, h);

        return 0;
}

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

signed main(void)
{
	string s, t;
	int tmp;

	cin >> s;
	rep(i, s.size() - 7)
	{
		if (s.substr(i, 8) == "FESTIVAL")
			tmp = i;	
	}
	rep(i, tmp) cout << s[i];
	cout << endl;
	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (int)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N,K; cin>>N>>K;
    string S; cin>>S;
    vector<int> A;
    if(S.at(0)=='0')A.push_back(0);//A.at(odd)は1のnum
    A.push_back(1);
    rep1(i,N){
        
        if(S.at(i)!=S.at(i-1))A.push_back(1);
        else{
            A.at(A.size()-1)++;
        }
    }
    int L = A.size();
    // for(auto i:A)cout<<i;
    // cout<<endl;
    
    K = 2*K+1;
    int res = 0, tmp = 0;
    rep(i,min(K,(int)A.size()))tmp+=A.at(i);
    res = tmp;
    // cout<<res<<endl;
    
    // cout<<L<<K<<endl;
    for(int i = 2; i <= L; i += 2){
        
        tmp = tmp - A.at(i-1) - A.at(i-2);
        if(K-2+i<L)tmp += A.at(K-2+i);
        if(K+i-1<L)tmp += A.at(K-1+i);
        // cout<<tmp<<i<<endl;
        res = max(res,tmp);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <cstdio>
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define nln cout << '\n'
#define ll long long int
#define INF (ll)1e+12
#define MAX 300100
#define mp(i, j) make_pair(i, j)
#define here cout  << "here";nln;
#define mul(a, b, mod) (((a % mod) * (b % mod)) % mod)
#define add(a, b, mod) (((a % mod) + (b % mod)) % mod)
#define inf 100000
#define M 1000000000LL

using namespace std;

ll a[100100];
set <ll> b;
set <ll> c;

int main()
{
    ll n;

    ll i, ans = 0, m;

    cin >> n;

    for(i = 0; i < n; i++)cin >> a[i];

    for(i = 0; i < n;)if(++i&1)b.insert(a[i-1]);

    sort(a, a+n);

    for(i = 0; i < n;)if(++i&1)c.insert(a[i-1]);

    for(auto it = b.begin(); it != b.end(); it++){
        if(c.count(*it) == 0)ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 5760
#include <stdio.h>

int main(){

  int sheet[110][110];
  int r,c,i,j;

  scanf("%d %d",&r,&c);

  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&sheet[i][j]);
      sheet[r][j]+=sheet[i][j];
      sheet[i][c]+=sheet[i][j];
      sheet[r][c]+=sheet[i][j];
    }
  }
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      printf("%d",sheet[i][j]);
      if(j!=c){
        printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

VI g[MAX];
VI gr[MAX];

bool U[MAX];
int C[MAX];

int S[3];

int cnt;
int e;
bool ok;

void dfs(int x, int c)
{
	U[x] = true;
	cnt++;
	C[x] = c;
	S[c]++;

	e += SZ(g[x]);

	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (U[to])
		{
			if (C[to] == (C[x] + 1) % 3) continue;
			ok = false;
			continue;
		}

		dfs(to, (c + 1) % 3);
	}

	FOR (i, 0, SZ(gr[x]))
	{
		int to = gr[x][i];
		if (U[to])
		{
			if ((C[to] + 1) % 3 == C[x]) continue;
			ok = false;
			continue;
		}

		dfs(to, (c + 2) % 3);
	}
}

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

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

	FOR (i, 0, m)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;

		g[x].PB(y);
		gr[y].PB(x);
	}

	LL res = 0;
	FOR (i, 0, n)
	{
		if (U[i]) continue;

		S[0] = S[1] = S[2] = 0;
		ok = true;
		cnt = 0;
		e = 0;

		dfs(i, 0);

		if (!ok)
		{
			res += cnt * (LL)cnt;
			continue;
		}

		if (S[0] == 0 || S[1] == 0 || S[2] == 0)
		{
			res += e;
			continue;
		}

		res += S[0] * (LL)S[1] + S[0] * (LL) S[2] + S[1] * (LL)S[2];
	}

	cout<<res<<endl;


}


Measured memory_bytes: 19456
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  int n,m;
  cin >> n >> m;
  vint a(n);
  repeat(i,n){
    cin >> a[i];
    a[i]--;
  }
  vll v(2*m+1,0);
  ll L=0;
  repeat(i,n-1){
    int r=a[i+1],l=a[i];
    if(r<l)r+=m;
    L+=r-l;
    v[l+2]-=1;
    v[r+1]+=1+r-l-1;
    v[r+2]-=r-l-1;
  }
  //debugArray(v,2*m);
  repeat(i,2*m){
    v[i+1] += v[i];
  }
  //debugArray(v,2*m);
  repeat(i,2*m){
    v[i+1] += v[i];
  }
  ll tmp=0;
  repeat(i,m){
    v[i] += v[i+m];
    tmp = min(tmp,v[i]);
  }
  debugArray(v,m);
  cout << L+tmp << endl;
  return 0;
}


Measured memory_bytes: 2176
import copy

n = int(input())
cards = input().split()
#print(cards)
def bubble_sort(cards, n):
    c = copy.copy(cards)
    for i in range(n):
        for j in range(n - 1, i, -1):
            if int(c[j][1]) < int(c[j-1][1]):
                tmp = c[j]
                c[j] = c[j-1]
                c[j-1] = tmp
    return c
    
bubble = bubble_sort(cards, n)
#print(cards)
#print(bubble)
print(' '.join(bubble))

def is_stable(o, s):
    for i in range(n - 1):
        if int(s[i][1]) == int(s[i+1][1]):
            if o.index(s[i]) > o.index(s[i+1]):
                return False
    return  True

if is_stable(cards, bubble):
    print('Stable')
else:
    print('Not stable')


def selection_sort(cards, n):
    c = copy.copy(cards)
    for i in range(n):
        minj = i
        for j in range(i, n):
            if int(c[j][1]) < int(c[minj][1]):
                minj = j
        tmp = c[i]
        c[i] = c[minj]
        c[minj] = tmp
    return c

selection = selection_sort(cards, n)
print(' '.join(selection))

if is_stable(cards, selection):
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 6344
n,m = map(int,input().split())

l = [0]*m
r = [0]*m
b = [0]*(n + 2)

count = 0

for i in range(0,m):
    l[i],r[i] = map(int,input().split())

l_max = max(l)
r_min = min(r)

for i in range(1,n+1):
        if(i >= l_max and i <= r_min ):
                count += 1
        
print(count)


Measured memory_bytes: 11636
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;


int countmap[2][2000][2000];


int getScore(int i, int x, int y, int k) {
    if (x < 0 || y < 0 || x - k + 1 >= 2 * k || y - k + 1 >= 2 * k)
        return 0;

    int x1 = min(x - k, 2 * k - 1);
    int y1 = min(y, 2 * k - 1);

    int x2 = min(x, 2 * k - 1);
    int y2 = min(y - k, 2 * k - 1);

    int x3 = min(x - k, 2 * k - 1);
    int y3 = min(y - k, 2 * k - 1);

    x = min(x, 2 * k - 1);
    y = min(y, 2 * k - 1);

    int score = countmap[i][x][y];

    if (x1 >= 0 && y1 >= 0)
        score -= countmap[i][x1][y1];

    if (x2 >= 0 && y2 >= 0)
        score -= countmap[i][x2][y2];

    if (x3 >= 0 && y3 >= 0)
        score += countmap[i][x3][y3];

    return score;
}


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

    REP(i, n) {
        int xi, yi;
        string ci;
        cin >> xi >> yi >> ci;
        countmap[(ci[0] == 'W') ? 0 : 1][xi % (2 * k)][yi % (2 * k)]++;
    }

    REP(p, 2) REP(q, 2000) REP(r, 2000) {
        if (q > 0)
            countmap[p][q][r] += countmap[p][q - 1][r];
        if (r > 0)
            countmap[p][q][r] += countmap[p][q][r - 1];
        if (q > 0 && r > 0)
            countmap[p][q][r] -= countmap[p][q - 1][r - 1];
    }

    int best = 0;

    REP(p, 2 * k) REP(q, 2 * k) {
        int current = 0;

        int index = 0;
        REP(i, 5) REP(j, 5) {
            current += getScore(index, p - 2 * k + k * i, q - 2 * k + k * j, k);
            index ^= 1;
        }

        best = max(best,current);
    }
    
    cout << best << endl;
    
    return 0;
}


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

map<int,int> m;
vector<int> v;

int main(){
	int n,ans;
	cin>>n;
	for(register int i=1;i<=n;++i){
		int x;
		cin>>x;
		if(m[x]==0) v.push_back(x);
		++m[x];
	}
	for(register int i=0;i<v.size();++i) if(v[i]!=0&&m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define, typedef */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
typedef long long ll;

/* main関数 */
int main(void) {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) cout << -1;
	else cout << a * b;

	return 0;
}


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

int main() {
    int x,y;
    cin >> x >> y;

    if (y%2 == 0 && 2*x <= y && 4*x >= y) cout << "Yes" << endl;

    else cout << "No" << endl; 
}

Measured memory_bytes: 3632
//package Dynamic;
import java.io.*;
import java.util.*;
class Main 
{
    static public void main(String[] args) throws IOException 
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        
        //int t=Integer.parseInt(br.readLine());
        //long n=Long.parseLong(br.readLine());
        StringTokenizer st=new StringTokenizer(br.readLine());
        int c=0;
        long n=Long.parseLong(st.nextToken());
        long d=Long.parseLong(st.nextToken());
        
        long ar[][]=new long[(int)n][(int)d];
        for(int x=0;x<n;x++)
        {
        	st=new StringTokenizer(br.readLine());
        	for(int y=0;y<d;y++)
        	{
        		ar[x][y]=Long.parseLong(st.nextToken());
        	}
        }
        for(int x=0;x<n-1;x++)
        {
        	//st=new StringTokenizer(br.readLine());
        	
        	for(int y=x+1;y<n;y++)
        	{
        		double s=0.0;
        		for(int z=0;z<d;z++)
            	{
            	s+=(ar[x][z]-ar[y][z])*(ar[x][z]-ar[y][z]);
            	}
        		s=Math.sqrt(s);
        		if(s==(double)((int)s))
        		{
        			c++;
        		}
        	}
        }
        //long d=Long.parseLong(br.readLine());
//        while(st.hasMoreTokens())
//        {
//        	long aa=Long.parseLong(st.nextToken());
//        	
//        }
        System.out.println(c);
    }
}

Measured memory_bytes: 21460
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <cstring>
using namespace std;


char p[4][2] = {
    {-1,0},{1,0},{0,-1},{0,1}
};

int main(){
    
    int h,w;
    scanf("%d%d",&h,&w);
    char square[h][w];
    for(int i=0;i<h;i++){
        scanf("%s",square[i]);
    }
    bool flag = true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int x;
            int y;
            if(square[i][j]=='#'){
                for(int k=0;k<4;k++){
                    x = i + p[k][0];
                    y = j + p[k][1];
                    if(0 <= x && x < h && 0 <= y && y < w && square[x][y] == '#')break;
                    if(k==3)flag = false;
                }
            }
            if(!flag)break;
        }
        if(!flag)break;
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int top, S[1000];

int pop();
void push(int);

int main() {
  int a, b;
  top = 0;
  char s[100];


  while( scanf("%s", s) != EOF) {
    if(s[0] == '+' ) {
      a = pop();
      b = pop();
      push(a + b);
    }
    else if( s[0] == '-' ) {
      a = pop();
      b = pop();
      push(b - a);
    }
    else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      push(atoi(s));
    }
  }

  printf("%d\n", pop());

  return 0;
}

int pop() {
  top--;
  return S[top+1];
}

void push(int x) {
  S[++top] = x;
}

Measured memory_bytes: 548
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class F
{
	public static void Main()
	{
		string S = GetString();
		string T = GetString();

		int[,] dp = new int[S.Length + 1, T.Length + 1];
		for(int i = 0; i < S.Length; i++)
		{
			for(int j = 0; j < T.Length; j++)
			{
				if(S[i] == T[j])
					dp[i + 1, j + 1] = dp[i, j] + 1;
				else
					dp[i + 1, j + 1] = Math.Max(dp[i + 1, j], dp[i, j + 1]);
			}
		}

		int len = dp[S.Length, T.Length];
		char[] ans = new char[len];
		int iS = S.Length;
		int iT = T.Length;
		int num = 0;
		while(num < len)
		{
			if(dp[iS, iT] == dp[iS - 1, iT])
				iS--;
			else if(dp[iS, iT] == dp[iS, iT - 1])
				iT--;
			else
			{
				ans[num] = S[iS - 1];
				num++;
				iS--;
				iT--;
			}
		}
		Array.Reverse(ans);

		Console.WriteLine(new String(ans));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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

using namespace std;

using ll = long long;

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

    vector<int> a(3);
    for (int i = 0; i < 3; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<x+k-1;i++){
        cout<<i<<' ';
    }
    cout<<x+k-1<<'\n';
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'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'};
//vc Alp ={'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'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi A(N);rep(i,N)cin>>A[i];
  sort(all(A));
  vi num(N);
  rep(i,N)num[A[i]]++;
  bool ans=true;
  ll cnt=1;
  if(N%2==0){
    for(int i=0 ; i<N;i++){
      if(num[A[i]]!=2){ans =false;break;}
    }
    if(ans)cout<<modpow(2,N/2,MOD);
  }
  else{
    if(num[0]!= 1)ans=false;
    for(int i=0 ; i<N;i++){
      if(A[i]!=0&&num[A[i]]!=2){ans =false;break;}
    }
    if(ans)cout<<modpow(2,N/2,MOD);
  }
  if(!ans)cout<<0<<endl;
}





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

long long mygcd(long long a, long long b) {
    long long r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long mylcm(long long a, long long b) {
    long long gcd = mygcd(a, b);

    return a / mygcd(a, b) * b;
}

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

    long long res;
    long long time;
    for (int i = 0; i < n; ++i) {
        cin >> time;
        if (i == 0) {
            res = time;
            continue;
        }
        res = mylcm(res, time);
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

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


int dfs(int cur, int a, int b, int c) {
    if (cur == N) {
        if (min({a, b, c}) > 0) {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        } else {
            return INT_MAX - 10;
        }
    }
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    
    return min({ret0, ret1, ret2, ret3});
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; ++i) {
        cin >> l[i];
    }

        
    int res = dfs(0, 0, 0, 0);

    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int n;
    static int[] a;

    static void input()
    {
        cin = new Scanner();

        n = cin.nextInt();
        a = cin.ArrayInt(n);
    }
    static void solve()
    {
        input();
        int sum = 0;
        long count = 0;
        long ans = 0;
        //even is plus
        for(int i = 0; i < n; i++)
        {
            sum += a[i];
            if(i % 2 == 0 && sum <= 0)
            {
                count += Abs(1 - sum);
                sum = 1;
            }

            if(i % 2 == 1 && sum >= 0)
            {
                count += Abs(-1 - sum);
                sum = -1;
            }
        }
        ans = count;
        sum = 0;
        count = 0;
        for (int i = 0; i < n; i++)
        {
            sum += a[i];
            if (i % 2 == 1 && sum <= 0)
            {
                count += Abs(1 - sum);
                sum = 1;
            }

            if (i % 2 == 0 && sum >= 0)
            {
                count += Abs(-1 - sum);
                sum = -1;
            }
        }
        ans = Min(ans, count);
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

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

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

        public int nextInt()
        {
            return int.Parse(next());
        }

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

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

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

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

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

Measured memory_bytes: 24924
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

void solve(void)
{

  string X,S;
  cin>>X>>S;

  string X2 = X + X;


  for (int i = 0; i < X2.size() - S.size(); i++)
  {
    bool check = 1;
    for (int j = 0; j < S.size(); j++)
    {
      if(X2[i+j] != S[j])
      {
        check = 0;
      }
    }

    if(check == 1)
    {
      cout<<"Yes"<<endl;
      return;
    }
  }

  cout<<"No"<<endl;
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    int n, d;
    cin >> n >> d;

    int x[n][d];
    rep (i, 0, n) {
	rep (j, 0, d) {
	    cin >> x[i][j];
	}
    }

    int res = 0;
    rep (i, 0, n - 1) {
	rep (j, i + 1, n) {
	    double dist = 0;
	    rep (k, 0, d) {
		dist += pow((x[i][k] - x[j][k]), 2);
	    }
	    dist = sqrt(dist);
	    if (ceil(dist) == floor(dist))
		res++;
	}
    }

    cout << res << endl;

    
    return 0;
}



Measured memory_bytes: 384
"""
b > g > r

"""

r, g, b = list(map(int, input().split()))
k = int(input())
flag = False
for i in range(k):
    if r >= b and b > 2 * g :
        g *= 2
    elif r >= g and b > 2 * g:
        g *= 2
    else:
        b *= 2

if r < g < b:
    flag = True
print("Yes") if flag else print("No")

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

int main() {
    long long N,M;
    cin >> N >> M;
    int l = 0;
    int r = N;
    for(int i = 0; i < M; i++){
        int L,R;
        cin >> L >> R;
        l = max(l,L);
        r = min(r,R);
    }
    cout << max(0,r-l + 1) << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define MOD 998244353
using namespace std;
int mul_inv(int a, int b=MOD)
{
	int b0 = b, t, q;
	int x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

int bitlength(int exor){
	int ans = 0;
	while(exor)
	{
		exor = exor >> 1;
		ans += 1;
	}
	return ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<int> v(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	vector<int> dp(n+1);
	dp[1] = 0;
	dp[2] = abs(v[2] - v[1]);
	// cout<<dp[1]<<' '<<dp[2]<<' ';
	for(int i=3;i<=n;i++)
	{
		dp[i] = min( abs(v[i] - v[i-1]) + dp[i-1], abs(v[i] - v[i-2]) + dp[i-2]);
		// cout<<dp[i]<<' ';
	}
	// cout<<'\n';
	cout<<dp[n];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; i < (i64)(n); ++i)
#define WHOLE(x) std::begin(x), std::end(x)
#define LEN(a) int((a).size())

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

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
istream &operator>>(istream &is, vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
template <typename Container>
ostream &pprint(const Container &a, string_view sep = " ",
                string_view ends = "\n", ostream *os = nullptr) {
  if (os == nullptr) os = &cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
  return pprint(a, ", ", "", &(os << "[")) << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<string> S(N);
  REP(i, N) { cin >> S[i]; }
  int count = 0;
  REP(k, N) {
    REP(i, N) REP(j, N) {
      int sj = (j + k) % N;
      int si = (i + k) % N;
      if (S[i][sj] != S[j][si]) {
        goto bad;
      }
    }
    count++;
  bad:
    continue;
  }
  cout << (count * N) << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int d[n];
    for (int i=0; i<n; i++) {
        d[i] = -1;
    }

    for(int i=0; i<m; i++)  {
        int s, c;
        cin >> s >> c;
        if (d[s-1] != -1 && d[s-1] != c) {
            cout << "-1" << endl;
            return 0;
        } else {
            d[s-1] = c;
        }
    }

    if (m == 0) {
        if (n == 1) cout << "0" << endl;
        else if (n == 2) cout << "10" << endl;
        else cout << "100" << endl;

        return 0;
    }

    if (n != 1 && d[0] == 0) {
        cout << "-1" << endl;
    } else {
        if (d[0] == -1) {
            cout << "1";
        } else {
            cout << d[0];
        }
        for (int i=1; i<n; i++) {
            if (d[i] == -1) cout << "0";
            else cout << d[i];
        }
        cout << endl;
    }

    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long> B(N - 1);
  rep(i, N - 1)
  {
    cin >> B[i];
  }
  int ans = 0;
  A[0] = B[0];
  rep(i, N - 2)
  {
    A[i + 1] = min(B[i], B[i + 1]);
  }
  A[N - 1] = B[N - 2];
  rep(i, N)
  {
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int S,h,m,s;
   scanf("%d",&S);
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
   printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2112
from math import gcd
from copy import copy
a, b = map(int, input().split())

def div(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
    return ret

def judge_prime(x):
    cnt = 0
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
    return True

div_a = div(a)
div_b = div(b)

data = list(set(div_a) & set(div_b))

ans = 0
for x in data:
    if judge_prime(x):
        ans += 1
print(ans)

Measured memory_bytes: 11360
N = int(input())
P = list(map(float,input().split()))
P.insert(0,0)
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[1][0] = 1-P[1]
dp[1][1] = P[1]
for i in range(2,N+1):
    for j in range(N+1):
        dp[i][j] += dp[i-1][j]*(1-P[i])
        if j>=1:
            dp[i][j] += dp[i-1][j-1]*P[i]
cnt = 0
for i in range(N//2+1,N+1):
    cnt += dp[N][i]
print(cnt)

Measured memory_bytes: 257800
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int m[15][15]={0};
    int x=n/2,y=n/2+1;
    for(int i=1; i<=n*n; i++){
      m[x][y] = i;
      x++;
      y++;
      x%=n;
      y%=n;
      if(m[x][y]!=0){x+=n-1;y++;x%=n;y%=n;}
    }
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
	printf("%4d",m[j][i]);
      }
      cout <<endl;
    }
  }
  return 0;
}

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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }

        
         public static long gcd(long x, long y)
        {
            if (x < y) gcd(y, x);
            while (y != 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long lcm(long x, long y)
        {
            return x * y / gcd(x, y);
        } 

        public static long C(long n, long k)
        {
            long x = 1;
            for (long i = 1; i <= k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var s = ReadLine().ToArray();
            var d = new Dictionary<char,long>();
            for (int i = 0; i < n; i++)
            {
                if (d.ContainsKey(s[i]))d[s[i]]++;
                else d.Add(s[i],1);
            }
            long ans = 1;
            foreach (var item in d)
            {
                ans *= item.Value + 1;
                ans %= (long)Math.Pow(10, 9) + 7;
            }
            WriteLine(ans-1);



            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 19536
#include <stdio.h>
#include <math.h>

double r;
//int w,h,x,y,r;

int main(void) {
  scanf("%lf", &r);
    //printf("%d %d\n",num[1][k],num[2][k]);
    //r_d=(double)r;
  printf("%.6f %.6f\n",M_PI*r*r,2*M_PI*r);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

bool comp(queue<char> G,queue<char> H){
    if(G.size()>H.size())swap(G,H);
    int F=G.size();
    REP(i,F){
        char g=G.front(),h=H.front();
        G.pop();H.pop();
        if(g<h){
            return true;
        }else if(g>h){
            return false;
        }
    }
    return true;
}

signed main(){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    int e=1;
    
    REP(k,K-1){
        string U;
        queue<char> O,P;
        REP(i,N){
            O.push(S[i]);
        }
        P=O;
        REP(i,N){
            P.pop();
            P.push(S[N-i-1]);
            if(comp(P,O)){
                O=P;
            }
        }
        REP(i,N){
            U.push_back(O.front());
            O.pop();
        }
        reverse(U.begin(),U.end());
        S=U;
        e*=2;
        //cout << S << endl;
        if(e>=2*N)break;
    }
    
    string U;
    queue<char> O,P;
    REP(i,N){
        O.push(S[i]);
    }
    P=O;
    REP(i,N){
        P.pop();
        P.push(S[N-i-1]);
        if(comp(P,O)){
            O=P;
        }
    }
    REP(i,N){
        U.push_back(O.front());
        O.pop();
    }
    S=U;
    cout << S << endl;
    
    return 0;
}   


Measured memory_bytes: 256