akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int a[5] = {}, k;
  rep(i, 5)
  {
    cin >> a[i];
  }
  cin >> k;

  for (int i = 0; i < 5; i++)
  {
    for (int j = i + 1; j < 5; j++)
    {
      if (a[j] - a[i] > k)
      {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}

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


using namespace std;

int main() {
    int H, W;
    
    cin >> H >> W;
    
    string s[H];
    
    for(int i = 0; i < H; ++i){
        cin >> s[i];
    }
    
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
    
    for(int x = 0; x < H; ++x){
        for(int y = 0; y < W; ++y){
            bool flag = false;
            if(s[x][y] == '#'){
                for(int i = 0; i < 4 && !flag; ++i){
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if(nx >= 0 && nx < H && ny >= 0 && ny < W){
                        if(s[nx][ny] == '#'){
                            flag = true;
                            continue;
                        }
                    }
                }
                if(!flag){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import collections

N=int(input())
S=[]
for i in range(N):
	S.append(input())
M=collections.Counter(S)
A=max(M.values())
tmp=[]
for i,j in M.items():
	if j==A:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])

Measured memory_bytes: 35572
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ii = pair<int, int>;
 
void solve();
 
clock_t start_time;
double get_current_time() {
	return (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
 
int main() {
	// freopen("substring.in", "r", stdin);
	// freopen("substring.out", "w", stdout);
 
	ios_base::sync_with_stdio(false);
	solve();
}
 
/* ========== actual code starts here ========== */
 
#define fi first
#define re return
#define se second
#define in insert
#define pb push_back
#define eb emplace_back
#define y1 y123123123123
#define all(x) x.begin(), x.end()
#define hash hash123s
#define index ind123
 
#define repx(i, x, n) for (int i = x; i < (n); i++)
#define repd(i, n, d) for (int i = 0; i < (n); i += d)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepd(i, n, d) for (int i = (n) - 1; i >= 0; i -= d)
#define rep(i, n) for (int i = 0; i < (n); i++)
 
template<class t>
void print(t x, int end = 1) {
	cout << x << (end == 1 ? "\n" : " ");
}
 
template<class T>
void print(const vector<T> &v, int end = 1) {
	rep(i, (int) v.size()) {
		print(v[ i ], 0);
	}
	cout << endl;
}

template<class T>
void print(const int *a, int sz, int end = 1) {
	rep(i, sz) {
		print(a[ i ], 0);
	}
	cout << endl;
}
 
template<class T>
void print(const set<T> &v, int end = 1) {
	for(auto to = v.begin(); to != v.end(); to++) {
		print(*to);
	}
	cout << endl;
}
 
template<class T>
void print(const map<T, T> &v, int end = 1) {
	for(auto to : v) {
		print(to.fi, 0);
		cout << ": ";
		print(to.se);
	}
}
 
template<class t>
void errprint(t x, int end = 1) {
	cerr << x << (end == 1 ? "\n" : " ");
}
 
#ifdef artem
	#define debug(x) x
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(x)
#endif

const int limit = 100500;
int n;
int a[ limit ];

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

	ll ans = a[ 0 ] - 1;
	int it = 2;
	set<int> have;
	have.in(1);

	repx(i, 1, n) {
		for(; it < 1e9; it++) {
			if(!have.count(it)) break;
		}

		// cout << i << ' ' << << endl;

		if(it >= a[ i ]) {
			have.in(a[ i ]);
			continue;
		}
		ans += a[ i ] / it - !(a[ i ] % it);
		// cout << " i = " << i << ", impact = " << a[ i ] / it << endl;
	}

	print(ans);
}

Measured memory_bytes: 8644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main (void){
    int n;
    cin >> n;
    vector<int> num_subord(n, 0);
    rep(i, n-1) {
        int a;
        cin >> a;
        a--;
        num_subord.at(a)++;
    } 
    rep(i, n) cout << num_subord.at(i) << endl;
    
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll tmp=n;
  ll x=0;
  while(n>0){
    x+=n%10;
    n/=10;
  }
  if(tmp%x) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
  int n,m,s,g1,g2,a,b,cost,mi;
  int map[101][101];
  while(1){
    cin>>n>>m>>s>>g1>>g2;
    if(n==0 && m==0 && s==0 && g1==0 && g2==0)break;
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1;j++){
    if(i==j)map[i][j]=0;
    else map[i][j]=1000000;
      }
    }
    for(int i=0;i<m;i++){
      cin>>a>>b>>cost;
      map[a-1][b-1]=cost;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
    for(int k=0;k<n;k++){
      map[j][k]=min(map[j][k],map[j][i]+map[i][k]);
    }
      }
    }
    mi=1000000;
    for(int i=0;i<n;i++)mi=min(mi,map[s-1][i]+map[i][g1-1]+map[i][g2-1]);
    cout<<mi<<endl;
  }
  return 0;
}


Measured memory_bytes: 3040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        const int WHITE = -10;
        const int GRAY = -9;
        //const int BLACK = 2;
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            string[] szarr = Console.ReadLine().Split(' ');
            int n = int.Parse(szarr[0]);
            int m = int.Parse(szarr[1]);
            List<int>[] g = new List<int>[n];
            for(int i = 0; i < n; ++i)
            {
                g[i] = new List<int>();
            }
            for(int i=0;i<m;++i)
            {
                szarr = Console.ReadLine().Split(' ');
                int v0 = int.Parse(szarr[0]);
                int v1 = int.Parse(szarr[1]);
               
                g[v0].Add(v1);
                g[v1].Add(v0);
            }
            int q = int.Parse(Console.ReadLine());

            int[] color = new int[n];
            for(int i = 0; i < color.Length; ++i) { color[i] = WHITE; }
            int[] d = new int[n];
            var queue = new Queue<int>();
            for(int i=0;i<n;++i)
            {
                if (color[i] == WHITE)
                {
                    BFS(i, i, color, d, queue, g);// 色付け
                }
            }

            for (int i=0;i<q;++i)
            {
                szarr = Console.ReadLine().Split(' ');
                int v0 = int.Parse(szarr[0]);
                int v1 = int.Parse(szarr[1]);
                // ２人はフレンド？

                
                if(color[v0] == color[v1])
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }


        }
        static void BFS(int s, int c, int[] color, int[] d, Queue<int> q, List<int>[] g)
        {
            color[s] = GRAY;
            d[s] = 0;
            q.Enqueue(s);
            while(q.Count >= 1)
            {
                int u = q.Dequeue();
                for(int i = 0;i<g[u].Count;++i)
                {
                    int v = g[u][i];
                    if(color[v] == WHITE)
                    {
                        color[v] = GRAY;
                        d[v] = d[u] + 1;
                        q.Enqueue(v);
                    }
                }
                color[u] = c;
            }
         }
    }

}



Measured memory_bytes: 22872
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>



using ll = long long;


using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}
	
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int factorial(ll n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else
		return 1;
}
int main()
{/*12日目*/
	long a, v, b, w, t;cin >> a >> v >> b >> w >> t;
	long kyori;
	long ky;
	if (b >= a)
		kyori = b - a;
	else
		kyori = a - b;
	if (v <= w) {
		cout << "NO";
			return 0;
	}
	else
		ky = v-w;
	if (ky * t >= kyori and v)
		cout << "YES";
	else
		cout << "NO";

}
	

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
    cin >> n >> k;
    set < pair < int, int > > s;
    For (i, 1, n) {
        cin >> a[i];
        cnt[a[i]] ++;
    }
    
    For (i, 1, n) {
        s.insert(mp(cnt[a[i]], a[i]));
    }
    
    while (s.size() > k) {
        ans += s.begin() -> F;
        s.erase(s.begin());
    }
    
    cout << ans;
	return Accepted;
}

// Coded By OB

Measured memory_bytes: 28032
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    if(b/k-(a-1)/k != 0) cout << "OK" << endl;
    else cout << "NG" << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

template<typename T>
class BIT2D {
private:
  vector<vector<T> > bit;
  int x,y;
public:
  BIT2D(int _x, int _y) : x(_x), y(_y) {
    bit = vector<vector<T> >(x+1, vector<T>(y+1, 0));
  }
  void add(int _a, int _b, T w){ //0-indexed
    for(int a=_a+1; a<=x; a += a&(-a)) {
      for(int b=_b+1; b<=y; b += b&(-b)) {
        bit[a][b] += w;
      }
    }
  }
  T sum(int _a, int _b){ //0-indexed
    T ret=0;
    for(int a=_a+1; a>0; a -= a&(-a)) {
      for(int b=_b+1; b>0; b -= b&(-b)) {
        ret += bit[a][b];
      }
    }
    return ret;
  }
};

int main(){
  int n,k;
  cin>>n>>k;
  vector<pair<pair<int,int>,char>> v(n);
  rep(i,n){
    int x,y; string s;
    cin>>x>>y>>s;
    x %= 2*k;
    y %= 2*k;
    if(y>=k){
      y -= k;
      x = (x+k)%(2*k);
    }
    v[i] = {{x,y},s[0]};
  }

  BIT2D<int> bit(2*k,k);
  int x = 0;
  rep(i,n){
    if(v[i].se=='W') bit.add(v[i].fi.fi, v[i].fi.se, 1);
    else {
      bit.add(v[i].fi.fi, v[i].fi.se, -1);
      x++;
    }
  }

  int mx = bit.sum(k-1,k-1);
  int mn = mx;
  auto f = [&](int lx, int ux, int ly, int uy){
    if(lx==0 && ly==0) return bit.sum(ux,uy);
    if(lx==0) return bit.sum(ux,uy) - bit.sum(ux, ly-1);
    if(ly==0) return bit.sum(ux,uy) - bit.sum(lx-1, uy);
    return bit.sum(ux,uy) - bit.sum(lx-1, uy) - bit.sum(ux, ly-1) + bit.sum(lx-1, ly-1);
  };
  rep(j,1,k){
    int val = bit.sum(k-1, j-1) + f(k, 2*k-1, j, k-1);
    mx = max(mx ,val);
    mn = min(mn, val);
  }
  rep(i,1,k){
    int val = bit.sum(i+k-1,k-1) - bit.sum(i-1, k-1);
    mx = max(mx, val);
    mn = min(mn, val);
    rep(j,1,k){
      int tmp = f(0,i-1,0,j-1) + f(i, i+k-1, j, k-1) + f(i+k, 2*k-1, 0, j-1);
      mx = max(mx, tmp);
      mn = min(mn, tmp);
    }
    val = bit.sum(2*k-1, k-1) - bit.sum(i+k-1,k-1) + bit.sum(i-1, k-1);
    mx = max(mx, val);
    mn = min(mn, val);
  }

  cout << max(x+mx, n - (x+mn)) << endl;

  return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int a[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	int appear = 0; // ibit: ibit目が1それ以降0がa[i]があるか
	REP(i, N) {
		REP(j, 32) if ((a[i] >> j & 1)) {
			appear |= 1<<j;
			break;
		}
	}
	
	int xx = 0;
	REP(i, N) xx ^= a[i];
	
	int ans = 0;
	for (int i = 31; i >= 0; i--) {
		if (xx >> i & 1) {
			if (!(appear >> i & 1)) {
				ans = -1;
				break;
			}
			ans++;
			xx ^= (1 << i+1) - 1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int a, b; cin >> a >> b;
        cout << max(0, a - 2 * b);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3568
import numpy as np
N = int(input())
P = list(map(int, input().split()))
P.append(0)
P = np.array(P)
ans = 1
tmp = P[0]
for i in range(1,N):
  if P[i] < tmp:
    ans += 1
    tmp = P[i]
print(ans)

Measured memory_bytes: 34156
import collections

n = int(input())
s = input()

# c = collections.Counter(s)
# print(c)

ans = 0
for i in range(1, n):
    a = s[:i]
    b = s[i:]
    ca = list(collections.Counter(a).keys())
    cb = list(collections.Counter(b).keys())
    c = 0
    for cai in ca:
        if cai in cb:
            c += 1
    if ans < c:
        ans = c

print(ans)


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  bool a=true;
  for(int i=0;i<N-1;i++){ 
    if(A.at(i)==A.at(i+1)){
      a=false;
      break;
    }
  }
  if(a){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    string ans;
    for(int i = 0;i<n;i++)cin >> s[i];
    for(int c = 'a';c <= 'z';c++){
        int small = 100;
        for(int i = 0;i<n;i++){
            int cnt = 0;
            for(int j = 0;j < (int)s.at(i).size();j++){
                if(c == s.at(i).at(j))cnt++;
            }
            small = min(small,cnt);//出てくる単語の最小値的なやつか
        }
        for(int i = 0;i<small;i++){
            ans += c;//a , b , c.....の場合で全部計測してる
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
ll mod(ll a,ll b){
    return abs(a)%b;
}
int main(){
    ll n;
    std::cin >> n;
    string s;
    
    rep(i,100){
        ll d=1;
        rep(j,i){
            d*=-2ll;
        }
       // std::cout << n << std::endl;
        if(mod(n,d*2)!=0){
            n-=d;
            s.pb('1');
        }
        else s.pb('0');
        if(n==0)break;
    }
    reverse(all(s));
    std::cout << s << std::endl;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    cout << fixed << setprecision(6) << 3.1415926535 * 2 * n << "\n";
    return 0;
}

Measured memory_bytes: 3800
n = int(input())

if n <= 104:
    print(0)
elif 105 <= n <= 134:
    print(1)
elif 135 <= n <= 164:
    print(2)
elif 165 <= n <= 188:
    print(3)
elif 189 <= n <= 194:
    print(4)
else:
    print(5)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>

int main() {
	int h, w;
	std::cin >> h >> w;
	bool bomb[55][55];
	for (int i = 0; i < 55; ++i) {
		for (int j = 0; j < 55; ++j) {
			bomb[i][j] = false;

		}
	}


	for (int i = 1; i <= h; ++i) {

		std::string s;
		std::cin >> s;
		for (int j = 0; j < w; ++j) {
			if (s[j] == '.') bomb[i][j+1] = false;
			else bomb[i][j+1] = true;
		}
	}

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (!bomb[i][j]) {
				int count = 0;
				if (bomb[i - 1][j - 1])count++;
				if (bomb[i - 1][j])count++;
				if (bomb[i - 1][j + 1])count++;
				if (bomb[i][j - 1])count++;
				if (bomb[i][j + 1])count++;
				if (bomb[i + 1][j - 1])count++;
				if (bomb[i + 1][j])count++;
				if (bomb[i + 1][j + 1])count++;

				std::cout << count;
				if (j == w) {
					std::cout << "\n";
				}
			}

				else {
					std::cout << "#";
					if (j == w ) {
						std::cout << "\n";
					}
				}
			
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
using namespace std;

string s;
int k;
set<string> vc;

int main() {
	cin >> s >> k;
	int size = s.size();
	for (int i = 0; i < size; i++) {
		for (int j = i; j < i + 5; j++) {
			vc.insert(s.substr(i, j - i + 1));
		}
	}
	set<string>::iterator iter = vc.begin();
	for (int i = 0; i < k - 1; i++) iter++;
	cout << *iter << endl;
}
	

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

int main() {
	ios_base::sync_with_stdio( false );

	int a[5], k;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

	string result = "Yay!";
	for( int i = 0; i < 4; ++i ) {
		for( int j = i+1; j < 5; ++j ) {
			if( a[j] - a[i] > k ) {
				result = ":(";
				break;
			}
		}

		if( result == ":(" ) { break; }
	}

	cout << result << endl;

	return 0;
}


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

using namespace std;
const int N = 1e5 + 5;

int nn, n;
int a[N << 1];

int small(int x, int y, int k) {
	return (a[x] <= k && a[y] <= k);
}

int big(int x, int y, int k) {
	return (a[x] > k && a[y] > k);
}

bool check(int k) {
	if (small(n, n - 1, k) || small(n, n + 1, k)) return 0;
	if (big(n, n - 1, k) || big(n, n + 1, k)) return 1;
	for (int i = 1; i < n - 1; i ++) {
		if (small(n - i, n - i - 1, k) || small(n + i, n + i + 1, k)) return 0;
		if (big(n - i, n - i - 1, k) || big(n + i, n + i + 1, k)) return 1;
	}
	return !small(1, 1, k);
}

int main() {
	scanf("%d", &n);
	nn = 2 * n - 1;
	for (int i = 1; i <= nn; i ++) scanf("%d", &a[i]);
	int l = 1, r = nn, pos;
	while (l < r) {
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid + 1;
		else r = mid;
	}
	printf("%d\n", r);
	return 0;	
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 1000000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
struct edge {
	ll from, to, cost;
};

int n, m;
long long k, a[20005] = { 0 };
long long dp[20005] = { 0 };
long long c = 0;
int main() {
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i] = LLINF;
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		long long ma = a[i];
		long long mi = a[i];
		for (int j = 1; j <= m; j++) {
			if (i - j+1 >= 1) {
				ma = max(ma, a[i - j+1]);
				mi = min(mi, a[i - j+1]);
			}
			c = k + j*(ma-mi);
			if (i - j < 0) continue;
			dp[i] = min(dp[i], dp[i - j] + c);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3424
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Map<String, Integer> a = new HashMap<>();
    a.put(sc.next(),0);
    a.put(sc.next(),1);
    int[] b = new int[2];
    b[0] = sc.nextInt();
    b[1] = sc.nextInt();
    b[a.get(sc.next())] -= 1;
    System.out.println(b[0] + " " + b[1]);
  }
}

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

using namespace std;

using ll = unsigned long long;

int main() {
    int n;
    cin >> n;
    
    vector<int> stick(n);
    for (int i = 0; i < n; i ++) {
        cin >> stick[i];
    }
    sort(stick.begin(), stick.end());

    int sum  = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = lower_bound(stick.begin(), stick.end(), stick[i] + stick[j]) - stick.begin();
            sum += max(k - (j + 1), 0);
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(float, input().split()))
    m = sum(s) / n

    a_2 = sum([(x - m) ** 2 for x in s]) / n
    print(a_2 ** 0.5)


Measured memory_bytes: 5728
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<ll>> V;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, ll> P;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

ll pow_mod(ll a, ll n, ll mod) {
    ll res = 1;

    ll base = a;
    while (n) {
        if (n & 1) res = res * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll m, n; cin >> m >> n;
    cout << pow_mod(m, n, 1000000007) << endl;
	return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)

void solve()
{
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    rep(i, M) cin >> s[i] >> c[i];

    vector<int> ans(N + 1, -1);
    bool is_exist = true;
    rep(i, M)
    {
        if (ans[s[i]] == -1)
        {
            ans[s[i]] = c[i];
        }
        else if (ans[s[i]] != c[i])
        {
            is_exist = false;
        }
    }
    if (N > 1 && ans[1] == 0)
    {
        is_exist = false;
    }

    if (!is_exist)
    {
        cout << "-1" << endl;
        return;
    }

    rep1(j, N)
    {
        if (ans[j] != -1)
            continue;

        if (N > 1 && j == 1)
        {
            ans[j] = 1;
        }
        else
        {
            ans[j] = 0;
        }
    }

    rep1(j, N)
    {
        cout << ans[j];
    }
    cout << endl;
}

int main()
{
    solve();
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int INF = 1<<29;

int dp[256][16][128];
vector<P> stones[256];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
  
    REP(i, N) {
      stones[i].clear();
      int k;
      cin >> k;
      REP(j, k) {
	int x, d;
	cin >> x >> d;
	stones[i].push_back(P(x, d));
      }
    }

    REP(i, N) REP(j, stones[i].size()) REP(k, M+1) dp[i][j][k] = INF;
    REP(j, stones[0].size()) dp[0][j][0] = 0;
    REP(j, stones[1].size()) dp[1][j][1] = 0;
    REP(i, N-1) {
      REP(j, stones[i].size()) {
	int x_now = stones[i][j].first, d_now = stones[i][j].second;
	REP(k, stones[i+1].size()) {
	  int x_next = stones[i+1][k].first, d_next = stones[i+1][k].second;
	  int safe = (d_now + d_next) * abs(x_now - x_next);
	  REP(m, M+1) {
	    dp[i+1][k][m] = min(dp[i+1][k][m], dp[i][j][m] + safe);
	  }
	}
	if (i < N-2) {
	  REP(k, stones[i+2].size()) {
	    int x_next = stones[i+2][k].first, d_next = stones[i+2][k].second;
	    int safe = (d_now + d_next) * abs(x_now - x_next);
	    REP(m, M) {
	      dp[i+2][k][m+1] = min(dp[i+2][k][m+1], dp[i][j][m] + safe);
	    }
	  }
	}
      }
    }

    int ans = INF;
    REP(j, stones[N-1].size()) REP(m, M+1) ans = min(ans, dp[N-1][j][m]);
    REP(j, stones[N-2].size()) REP(m, M) ans = min(ans, dp[N-2][j][m]);
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  using ll =long long;
  ll N;
  cin >> N;
  vector<ll> v(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  int ans=0;
  int count=0;
  for (int i=0;i<N-1;i++){
    if ( v.at(i) >= v.at(i+1) ){
      count++;
      if (count > ans){
        ans=count;
      }
    }
    else{
      count=0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    ll mini=a*(n-1)+b,maxi=b*(n-1)+a;
    ll res=max((ll)0,maxi-mini+1);
    cout<<res<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Diagnostics;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var minos = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var I = minos[0];
        var O = minos[1];
        var J = minos[3];
        var L = minos[4];
        long res = (I / 2 + J / 2 + L / 2) * 2;
        if (J != 0 && L != 0 && I != 0) res = Max(res, ((I - 1) / 2 + (J - 1) / 2 + (L - 1) / 2) * 2 + 3);
        res += O;
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13396
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    if ( n & 1 ) {
        cout << 0 << endl;
        return 0 ;
    }
    int den = 10 ;
    int ans = 0 ;
    while(n / den > 0){
        ans += n / den ;
        den *= 5 ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'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'};

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

int main(){
    ll n, z, w; cin >> n >> z >> w;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    vector<vector<ll> > dp(n+1, vector<ll>(2));
    for(int i = n-1; i >= 0; i--){
        dp[i][0] = -1 * 1e9;
        ll a = (i ? lis[i-1] : w);
        chmax(dp[i][0], abs(a - lis[n-1]));
        REP(l, i+1, n) chmax(dp[i][0], dp[l][1]);

        dp[i][1] = 1e9;
        a = (i ? lis[i-1] : z);
        chmin(dp[i][1], abs(a - lis[n-1]));
        REP(l, i+1, n) chmin(dp[i][1], dp[l][0]);
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 3752
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
   lines = lines[0].split(' ')
   console.log(lines[0] * lines[1] / 2)
});

Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define ll long long
#define SIZE 200010
using namespace std;
const long long MOD = 998244353;

long long fac[SIZE], inv[SIZE]; // fac 存储阶乘  inv 存储阶乘逆元

ll qpow(ll x, ll e, ll mod) {
	ll r = 1;
	while (e) {
		if (e & 1) r = r * x % mod;
		x = x * x % mod;
		e >>= 1;
	}
	return r;
}

long long getInv(long long n, long long p) { // 求 n mod p 意义下的逆元
	return qpow(n, p - 2, p);
}

void getFacInv(int n, long long p) { // 阶乘逆元
	fac[0] = 1;
	for (long long i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % p;
	inv[n] = getInv(fac[n], p);
	for (long long i = n - 1; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % p;
}

long long C(long long n, long long m) {
	if (m < 0 || m > n) return 0;
	return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	getFacInv(200000, MOD);
	long long N, M, K, ans = 0;
	cin >> N >> M >> K;
	
	for (long long i = 0; i <= K; ++i) {
		ans += M * C(N - 1, i) % MOD * qpow(M - 1, N - i - 1, MOD) % MOD;
		ans %= MOD;
	}

	cout << (ans % MOD + MOD) % MOD;
}

Measured memory_bytes: 6816
# d,n=gets.split.map(&:to_i);p (10**d)*n

n,m=gets.split.map(&:to_i)
if m.zero?
  p 0
  exit
end
d = n.times.map{gets.split.map(&:to_i)}
ans = 0
2.times do |i|
  2.times do |j|
    2.times do |k|
      s = d.map{|a,b,c|
        a*(-1)**i + b*(-1)**j + c*(-1)**k
      }.sort.reverse[0...m].inject(:+)
      ans = [ans, s].max
    end
  end
end
p ans

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
  cin>>A>>B>>C>>D;
  int a=A/D;
  int b=C/B;
  if(A%D!=0){
  a++;
  }
  if(C%B!=0){
  b++;
  }
  for(int i=0;i<a;i++){
  for(int j=0;j<b;j++){
  C-=B;
    if(0>=C){
    cout<<"Yes"<<endl;
      return 0;
    }
    A-=D;
    if(0>=A){
    cout<<"No"<<endl;
      return 0;
    }
  }
  }
  
  
}

Measured memory_bytes: 3632
// Aizu 0212: Highway Express Bus
// 2017.9.9 bal4u@uu

#include <stdio.h>
#include <string.h>

#define INF 0x7fffffff
#define MAX 5000
typedef struct { int t, k, c; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
  int l, r;
  int smallest;

  l = LEFT(i), r = RIGHT(i);
  if (l < qsize && que[l].t < que[i].t) smallest = l; else smallest = i;
  if (r < qsize && que[r].t < que[smallest].t) smallest = r;
  if (smallest != i) {
    QUE t = que[i]; que[i] = que[smallest]; que[smallest] = t;
    min_heapify(smallest);
  }
}

int deq(int *k, int *c)
{
  if (qsize == 0) return 0;
  *k = que[0].k, *c = que[0].c;
  que[0] = que[--qsize];
  min_heapify(0);
  return 1;
}

void enq(int k, int t, int c)
{
  int i, ii;

  i = qsize++;
  que[i].t = t, que[i].k = k, que[i].c = c;
  while (i > 0 && que[ii = PARENT(i)].t > que[i].t) {
    QUE tt = que[i]; que[i] = que[ii]; que[ii] = tt;
    i = ii;
  }
}

typedef struct { int len, to[102], f[102]; } TBL;
TBL tbl[102];
int node[102][11]; int size;
int start, goal, cmax;

int search()
{
	int s, i, c, s2, f2, c2, k;
	TBL *p;

	qsize = 0;
	memset(node, -1, sizeof(node));
	node[start][cmax] = 0;
	enq(start, 0, cmax);
	while(deq(&s, &c)) {
		if (s == goal) return node[goal][c];
		for (p = tbl+s, i = 0; i < p->len; i++) {
			s2 = p->to[i], f2 = p->f[i];
			k = node[s][c] + f2;
			if (node[s2][c] < 0 || k < node[s2][c]) node[s2][c] = k, enq(s2, k, c);
			if (c > 0) {
				c2 = c-1;
				k = node[s][c] + f2 / 2;
				if (node[s2][c2] < 0 || k < node[s2][c2]) node[s2][c2] = k, enq(s2, k, c2);
			}
		}
	}
	return -1;
}

int main()
{
	int m, a, b, f;
	TBL *p;

	while (scanf("%d%d%d%d%d", &cmax, &size, &m, &start, &goal) && cmax) {
		memset(tbl, 0, sizeof(TBL)*(size+1));
		while (m-- > 0) {
			scanf("%d%d%d", &a, &b, &f);
			p = tbl + a, p->to[p->len] = b, p->f[p->len] = f, p->len++;
			p = tbl + b, p->to[p->len] = a, p->f[p->len] = f, p->len++;
		}
		printf("%d\n", search());
	}
	return 0;
}

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

using namespace std;
int n,m,a[1005][1005],x,y,curx,cury,maks=0;
int gx[4]={1,-1,0,0};
int gy[4]={0,0,1,-1};
char c;
queue<pair<int,int> > q;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>c;
			if(c=='#'){
				a[i][j]=0;
				q.push(make_pair(i,j));
			}
			else{
				a[i][j]=-1;
			}
		}
	}
	while(!q.empty()){
		x=q.front().first;
		y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			curx=x+gx[i];cury=y+gy[i];
			if(a[curx][cury]==-1){
				a[curx][cury]=a[x][y]+1;
				if(maks<a[curx][cury]) maks=a[curx][cury];
				q.push(make_pair(curx,cury));
			}
		}
	}
	cout<<maks<<endl;
}



Measured memory_bytes: 12432
#include<stdio.h>
int main(){
  int i,j,n,tmp[100][2],a,b,c,d,tmp2,k,l;
  for(i=0;i<100;i++)tmp[i][1]=i+1,tmp[i][0]=0;
  scanf("%d",&n);
  for(i=0;i<n*(n-1)/2;i++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(c==d)tmp[a-1][0]++,tmp[b-1][0]++;
    else if(c>d)tmp[a-1][0]+=3;
    else tmp[b-1][0]+=3;
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(tmp[j][0]>tmp[j-1][0]){
	tmp2=tmp[j][1];
	tmp[j][1]=tmp[j-1][1];
	tmp[j-1][1]=tmp2;
	tmp2=tmp[j][0];
	tmp[j][0]=tmp[j-1][0];
	tmp[j-1][0]=tmp2;
      }
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
    if(tmp[j][1]==i+1){
      for(l=1;tmp[j][0]==tmp[j-l][0];l++);
      if(j+2-l==0)l--;
    printf("%d\n",j+2-l);
    }
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;

int main(){
  ;;
    string s;
    cin >> s;
    ;
    string t = s;;
    int i_0_ = 0;
    while(i_0_<t.size()/2){;
        char tp_ = t[i_0_];
        t[i_0_] = t[t.size()-i_0_-1];
        t[t.size()-i_0_-1] = tp_;
        ++i_0_;
    };;
    if(s == t) {;cout << "Yes" << endl;;}
    else {;cout << "No" << endl;;};
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>

using lli=long long int;
const lli mod=1000000007;

constexpr lli mod_inv(lli a){
  lli b=mod, u=1, v=0, tmp=0;
  while(b){
    lli t = a/b;
    a -= t*b;
    tmp = a; a = b; b = tmp; //swap(a, b);
    u -= t*v;
    tmp = u; u = v; v = tmp; //swap(u, v);
  }
  return ((u%mod)+mod)%mod;
}

constexpr lli fac_pre_num = 100100;
struct fac_pre_struct{
  lli fac[fac_pre_num], finv[fac_pre_num];
  constexpr fac_pre_struct() : fac{}, finv{} {
    fac[0] = fac[1] = finv[0] = finv[1] = 1;
    for(int i = 2; i < fac_pre_num; i++) fac[i] = i*fac[i-1] % mod;
    finv[fac_pre_num-1] = mod_inv(fac[fac_pre_num-1]);
    for(int i = fac_pre_num-1; i > 2; i--) finv[i-1] = i*finv[i] % mod;
  }
};
constexpr fac_pre_struct fac_pre;

std::tuple<lli, lli, lli> fac_3_mod(lli a, lli b, lli c){
  lli t = 1;
  lli tb=1, tc=1;
  for(int i = 1; i <= a; i++){
    t = (t*i)%mod;
    if(i == b) tb = t;
    if(i == c) tc = t;
  }
  return std::make_tuple(t, tb, tc);
}

class mod_comb_mul{
  std::vector<lli> fac, finv;
  public:
  mod_comb_mul() :
    fac(&fac_pre.fac[0], &fac_pre.fac[fac_pre_num]),
    finv(&fac_pre.finv[0], &fac_pre.finv[fac_pre_num]){}
  lli comb(lli n, lli k){
    if(n < k || k < 0 || n < 0) return 0;
    int pre_size = fac.size();
    if(n >= pre_size){
      fac.resize(n+1);
      finv.resize(n+1);
      for(int i = pre_size; i <= n; i++) fac[i] = i*fac[i-1] % mod;
      finv[n] = mod_inv(fac[n]);
      for(int i = n; i > pre_size; i--) finv[i-1] = i*finv[i] % mod;
    }
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
  }
} mcm;

int main(){
  int N;
  std::cin >> N;

  std::vector<int> ap_arr(N+1, -1);
  int p1, p2;
  for(int i = 0; i < N+1; i++){
    int a;
    std::cin >> a;
    if(ap_arr[a] != -1){
      p1 = ap_arr[a];
      p2 = i;
    }
    ap_arr[a] = i;
  }

  for(int k = 1; k <= N+1; k++){
    lli n_full = mcm.comb(N+1, k);
    lli n_dc = mcm.comb(N+1-(p2-p1+1), k-1);
    lli ans = (((n_full-n_dc)%mod)+mod)%mod;
    std::cout << ans << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;

int main() {
  string s; cin >> s;
  int cnt =0;
  string prev = "";
  int strlen =1;
  int pos = s.size()-1;
  while(pos>=0){
    auto sub = s.substr(pos,strlen);
    if(prev == sub){
      ++strlen;
      --pos;
    } else {
      prev = sub;
      strlen = 1;
      --pos;
      ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string s;
    ll ans = LONG_LONG_MAX;
    cin >> s;
    for(char i = 'a';i <= 'z';i++) {
        ll maxi = -1;
        ll prev = -1;
        for(ll j = 0;j < s.size();j++) {
            if(i == s[j]) {
                maxi = max(maxi, j - prev - 1);
                prev = j;
            }
        }
        if(maxi >= 0) {
            maxi = max((ll)s.size() - 1 - prev, maxi);
            ans = min(ans, maxi);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////


int N,A,B;
int main(){
    scanf("%d",&N);
    if(N==1){
        printf("Hello World");
    }else{
        scanf("%d%d",&A,&B);
        printf("%d",A+B);
    }
    return 0;
}

Measured memory_bytes: 256
import math
import decimal
a,b,h,m = map(float,input().split())




mm = 6*m
hh = 30*h+0.5*m
x = float(abs(mm-hh))

a2 = a**2
b2 = b**2

ans = math.sqrt((a2+b2)-(2*a*b*math.cos(math.radians(x))))
print(format(ans,'.15f') )



Measured memory_bytes: 10132
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,zx,xc,i,j,f[509][509],dp[509][509],ii,jj,pas,bo[509][509];
pair <int, int> p[500009];
void check(int q, int w);
void dfs(int q, int w);
void check(int q, int w, int rr){
	if(q<0||q>a||w<0||w>a) return;
	if(dp[q][w]>rr){
		dp[q][w]=rr;
		dfs(q,w);
	}
}
void dfs(int q, int w){
	check(q-1,w,dp[q][w]+bo[q][w]);
	check(q+1,w,dp[q][w]+bo[q][w]);
	check(q,w-1,dp[q][w]+bo[q][w]);
	check(q,w+1,dp[q][w]+bo[q][w]);
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(i=1; i<=a*a; i++){
		cin>>b;
		c=(b-1)/a+1;
		if(b%a==0) d=a; else d=b%a;
		p[i].first=c;p[i].second=d;
		f[c][d]=i;
	}
	for(i=1; i<=a; i++){
		for(j=1; j<=a; j++){
			dp[i][j]=min(min(i-1,a-i),min(j-1,a-j));
			bo[i][j]=1;
		}
	}
	for(i=1; i<=a*a; i++){
		c=p[i].first;d=p[i].second;
		bo[c][d]=0;
		pas+=dp[c][d];
		dfs(c,d);
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 19784