akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;


void solve(long long N, long long D, std::vector<std::vector<long long>> X){
    int a=0;
    rep(i,N){
        for(int j=0;j<i;j++){
            float sum=0;
            rep(k,D){
                sum+=pow(X[i][k]-X[j][k],2);
            }
            sum=sqrt(sum);
            (floor(sum)==sum)?a++:1;
        }
    }
    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}


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

int main(void){
    int x[4],y[4];
    cin>>x[0]>>y[0]>>x[1]>>y[1];

    int a=x[1]-x[0];
    int b=y[1]-y[0];

    x[2]=x[1]-b;
    y[2]=a+y[1];
    x[3]=x[0]-b;
    y[3]=y[0]+a;
    cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
    return 0;
}


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

int main(){
int H, W;
cin >> H >> W;
  char a[H][W];
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
    cin >> a[i][j];
    }
  }

  for(int i = 0;i < W+2;i++){
  cout << '#';
}
  cout << endl;
  
    for(int i = 0;i < H;i++){
      cout << '#';
      for(int j = 0;j < W;j++){
    cout << a[i][j];
    }
      cout << '#' << endl;
  }
  
  for(int i = 0;i < W+2;i++)
  cout << '#';
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<vector<int>> e;
vector<bool> check;
vector<int> road;
vector<int> score;

int search(int start, int end){
    
    int scoreSum = 0;
    bool isOpp = false;

    check[start] = true;

    if(start == end){
        road.push_back(start);
        return -1;
    }

    for(int i = 0; i < e[start].size(); i++)
    {
        if(!check[e[start][i]]){
            int temp = search(e[start][i], end);

            if(temp > 0){
                scoreSum += temp;
            }
            else{
                isOpp = true;
            }
        }
    }
    
    score[start] = scoreSum;
    
    if(isOpp){
        road.push_back(start);
        return -1;
    }
    else{
        return scoreSum + 1;
    }
}

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

    e.assign(n + 1, vector<int>());
    score.assign(n + 1, 0);
    check.assign(n + 1, false);

    for(int i = 1; i <= n - 1; i++)
    {
        int start, end;
        scanf("%d%d", &start, &end);
        e[start].push_back(end);
        e[end].push_back(start);
    }

    search(1, n);
    search(n, 1);

    int posF = 1;
    int posS = n;
    int scoreF = 0, scoreS = 0;

    scoreF += score[posF];
    scoreS += score[posS];

    int i = 1;
    while(posF != posS){

        posF = road[road.size() - 1 - i];
        if(posF == posS){
            break;
        }
        scoreF += score[posF];

        posS = road[i];
        if(posF == posS){
            scoreS--;
            break;
        }
        scoreS += score[posS];

        i++;
    }

    if(scoreF > scoreS){
        printf("Fennec\n");
    }
    else{
        printf("Snuke\n");
    }
    
    return 0;
}

Measured memory_bytes: 13052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    queue<int> que;
    vector<int> was(n);
    vector<int> p(n);
    was[0] = 1;
    que.emplace(0);
    while (!que.empty()) {
        for (int q = que.size(); q > 0; q--) {
            int v = que.front();
            que.pop();
            for (int to : g[v]) {
                if (was[to]) {
                    continue;
                }
                was[to] = 1;
                p[to] = v;
                que.emplace(to);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (!was[i]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
    for (int i = 1; i < n; i++) {
        cout << p[i] + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 10640
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> a >> b >> c >> d >> s;
  a--;
  b--;
  c--;
  d--;
  if (c < d) {
    rrep(i, a, d + 1) {
      if (s[i] == '#' && s[i + 1] == '#') {
        Cout("No");
        return 0;
      }
    }
    Cout("Yes");
  } else {
    rrep(i, a, c + 1) {
      if (s[i] == '#' && s[i + 1] == '#') {
        Cout("No");
        return 0;
      }
    }
    int ok = 0;
    rrep(i, b - 1, d) {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ok = 1;
    }
    if (ok)
      Cout("Yes");
    else
      Cout("No");
  }
  return 0;
}

Measured memory_bytes: 592
#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() {
  ll x;
  cin >> x;
  for (int i = 0; i < 120; i++) {
    for (int j = -119; j < 119; j++)
      if (pow(i, 5) - pow(j, 5) == x) {
        printf("%d %d\n", i, j);
        return 0;
      }
  }
  return 0;
}

Measured memory_bytes: 4136
def f(s1, s2, a, b, c):
  if s1=='AB':
    if a==b==0:
      return None, None, None, 'D'
    elif a==0:
      return 1, b-1, c, 'A'
    elif b==0:
      return a-1, 1, c, 'B'
    elif a==b==1:
      if s2=='BC':
        return 0, 2, c, 'B'
      else:
        return 2, 0, c, 'A'
    else:
      if a>b:
        return a-1, b+1, c, 'B'
      else:
        return a+1, b-1, c, 'A'
  elif s1=='AC':
    if a==c==0:
      return None, None, None, 'D'
    elif a==0:
      return 1, b, c-1, 'A'
    elif c==0:
      return a-1, b, 1, 'C'
    elif a==c==1:
      if s2=='AB':
        return 2, b, 0, 'A'
      else:
        return 0, b, 2, 'C'
    else:
      if a>c:
        return a-1, b, c+1, 'C'
      else:
        return a+1, b, c-1, 'A'
  else:
    if b==c==0:
      return None, None, None, 'D'
    elif b==0:
      return a, 1, c-1, 'B'
    elif c==0:
      return a, b-1, 1, 'C'
    elif b==c==1:
      if s2=='AB':
        return a, 2, 0, 'B'
      else:
        return a, 0, 2, 'C'
    else:
      if b>c:
        return a, b-1, c+1, 'C'
      else:
        return a, b+1, c-1, 'B'

N, A, B, C=map(int, input().split())
S=[input() for _ in range(N)]
ans=['']*N
for i in range(N-1):
  A, B, C, P=f(S[i], S[i+1], A, B, C)
  if P=='D':
    print('No')
    exit()
  else:
    ans[i]=P
  
if S[-1]=='AB':
  if A==B==0:
    print('No')
    exit()
  else:
    if A<B:
      ans[-1]='A'
    else:
      ans[-1]='B'
elif S[-1]=='BC':
  if B==C==0:
    print('No')
    exit()
  else:
    if B<C:
      ans[-1]='B'
    else:
      ans[-1]='C'
else:
  if A==C==0:
    print('No')
    exit()
  else:
    if A<C:
      ans[-1]='A'
    else:
      ans[-1]='C'
      
print('Yes')
print(*ans, sep='\n')

Measured memory_bytes: 87172
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

bool vis[25][25];
string arr[25];

vector<pair<ll,ll>> moves = {{-1,0},{1,0},{0,-1},{0,1}};

int main()
{
   FAST/**/
   
   ll h,w;
   cin>>h>>w;
   
   rep(h)
        cin>>arr[i];
   
   ll ans = 0;
   
   //cout<<"moves size = "<<moves.size()<<"\n";   
   
   for(ll i=0;i<h;i++)
   {
       for(ll j=0;j<w;j++)
       {
           if(arr[i][j] == '#')
                continue;
           memset(vis,0,sizeof(vis));
           queue<pair<ll,ll>> q;
           q.push(mp(i,j));
           vis[i][j] = 1;
           
           ll dis[h+5][w+5];
           memset(dis,-1,sizeof(dis));
           
           dis[i][j] = 0;
           
           while(q.size()>0)
           {
               auto curr = q.front();
               q.pop();
               
               repi(i1,4)
               {
                   pair<ll,ll> p;
                   p.ff = curr.ff + moves[i1].ff;
                   p.ss = curr.ss + moves[i1].ss;
                   
                   if(p.ff<0 || p.ff>=h || p.ss<0 || p.ss>=w)
                        continue;
                   if(vis[p.ff][p.ss]) 
                        continue;
                   if(arr[p.ff][p.ss] == '#')
                        continue;
                   vis[p.ff][p.ss] = 1;
                   dis[p.ff][p.ss] = dis[curr.ff][curr.ss] + 1;
                   ans = max(ans, dis[p.ff][p.ss]);
                   q.push(p);
               }
           }
       }
   }
   
   cout<<ans;
           
   
   return 0;        
}  
   

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
change = [True] * N
if N == 1:
    print('Yes')
    exit()

for i in range(N-1, 0, -1):
    diff = H[i] - H[i-1]
    if diff >= 0:
        continue
    elif diff == -1:
        H[i-1] -= 1
    else:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14396
sa = str(input())
sb = str(input())
sc = str(input())
s_list = [sa, sb, sc]
member = ['a', 'b', 'c']

stop = False
turn = 0
while not stop:
    if len(s_list[turn]) == 0:
        stop = True
        print(member[turn].upper())
        break
    else:
        next = member.index(s_list[turn][0])
        s_list[turn] = s_list[turn][1:]
        turn = next


Measured memory_bytes: 9052
n = int(input())
h_lst = list(map(int, input().split()))
cnt = 0
res = 0
for i, left in enumerate(h_lst):
  if i <= len(h_lst)-2 and left >= h_lst[i+1]:
    cnt +=1
  else:
    res = max(res, cnt)
    cnt = 0
print(res)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i >= x ; i --) 
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  printf("%d\n" , x)
#define ddebug(x , y)  printf("%d %d\n" , x , y)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 4005 ;
const int maxm = 2e6 + 5 ;
const ll mod = 998244353 ;
int n ;
char s[maxn] ;
int a[maxn] ;
int sum[maxn][3] ;
int main()
{
    r(n) ;
    rst(s + 1) ;
    if(n < 3)  {puts("0") ; return 0 ;}
    mem0(a) , mem0(sum) ;
    rep(i , 1 , n)  
      if(s[i] == 'R')  a[i] = 0 , sum[i][0] ++ ;
      else if(s[i] == 'G')  a[i] = 1 , sum[i][1] ++ ;
      else  a[i] = 2 , sum[i][2] ++ ;
    per(i , n - 1 , 1)
	  rep(j , 0 , 2)  sum[i][j] += sum[i + 1][j] ; 
    ll ans = 0 ;
    rep(i , 1 , n)
      rep(j , i + 1 , n)
      {
      	 if(a[i] == a[j])  continue ;
      	 int k = 3 - a[i] - a[j] ;
      	 ans += sum[j + 1][k] ;
      	 if(j + j - i <= n && a[j + j - i] == k)  ans -- ;
	  }
	wl(ans) , en() ;
	return 0 ;
}

Measured memory_bytes: 3824
while True:
    h, w = map(int, raw_input().split())
    if h == 0 and w== 0: break

    s1 = '#' * w
    if w < 2:
        s2 = s1
    else:
        s2='#' + '.' * (w-2) + '#'
    for j in range(h):
        if j in [0, h-1]: print s1
        else: print s2
    print

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

const int MAXN = 100010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, dep[MAXN];
vector<int> G[MAXN];

bool cmp(const int &a, const int &b) {
	return dep[a] < dep[b];
}

int solve(int u) {
	int res = G[u].size(), i;
	for(i = 0; i < (int)G[u].size(); i++) {
		int v = G[u][i];
		dep[v] = solve(v);
	}
	sort(G[u].begin(), G[u].end(), cmp);
	for(i = 0; i < (int)G[u].size(); i++) {
		int v = G[u][i];
		res = max(res, (int)G[u].size()-i+dep[v]);
	}
	return res;
}

int main() {

	int i;

	n = read();
	for(i = 2; i <= n; i++) {
		int u = read();
		G[u].push_back(i);
	}

	printf("%d\n", solve(1));
	return 0;
}


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


int D = 365;
int M = 26;
vi c(M);
vii s(D, vi(M));
vi t(D);

vi last(M);


void input() {
    cin >> D;
    rep (i, M) cin >> c[i];
    rep (i, D) {
        rep (j, M) {
            cin >> s[i][j];
        }
    }

    rep (i, D) {
        cin >> t[i];
        t[i]--;
    }
}

ll calc_score() {
    ll score = 0;
    rep (i, D) {
        score += s[i][t[i]];
        last[t[i]] = i + 1;
        rep (j, M) {
            score -= c[j] * (i + 1 - last[j]);
        }
        cout << score << endl;
    }
    return score;
}

signed main() {
    fio();

    input();

    calc_score();
}

Measured memory_bytes: 3696
#include<iostream>

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long sub[n] = {0};
    for(int i = 1; i < n; i++){
        long long ai;
        cin >> ai;
        sub[ai-1]++;
    }
    for(int i = 0; i < n; i++){
        cout << sub[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5216
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll A, B, K;
	cin >> A >> B >> K;

	ll count = 0;
	ford(i, 1, max(A, B) + 1) {
		if (A % i == 0 && B % i == 0) {
			++count;
			if (count == K) {
				cout << i << endl;
				break;
			}
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<int64_t, int64_t>> w(n);
    REP(i, n) cin >> w[i].second >> w[i].first;
    int64_t time = 0;
    bool flag = true;
    sort(w.begin(), w.end());
    REP(i, n) {
        time += w[i].second;
        if(w[i].first < time) flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n;
    cin >> n;
    ll ans = 0, mx = 0;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        if(x >= mx)
        {

            ans++;
            mx = x;
        }
    }
    cout << ans;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


template <typename T, const T& F(const T&, const T&), T ZERO>
// template <typename T, T F(T, T), T ZERO>
struct SegmentTree {
    ll n;
    vector<T> v;

    SegmentTree(ll n_){
        n = 1;
        while(n < n_){ n *= 2; }
        v.resize(2 * n - 1);
        fill(v.begin(), v.end(), ZERO);
    }

    // zero-indexed
    void update(ll k, T a, bool replace){
        k += n - 1;
        if(replace){
            v[k] = a;
        }else{
            v[k] = F(a, v[k]);
        }
        while(k > 0){
            k = (k - 1) / 2;
            v[k] = F(v[k * 2 + 1], v[k * 2 + 2]);
        }
    }

    // [a, b), zero-indexed
    T query(ll a, ll b) const {
        return query_internal(a, b, 0, 0, n);
    }

    T get(ll a) const {
        return query(a, a + 1);
    }

    T query_internal(ll a, ll b, ll k, ll l, ll r) const {
        if(r <= a || b <= l){ return ZERO; }
        if(a <= l && r <= b){
            return v[k];
        }else{
            T v1 = query_internal(a, b, k * 2 + 1, l, (l + r) / 2);
            T v2 = query_internal(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(v1, v2);
        }
    }
};


int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xy(n);
    vector<ll> i2y;
    REP(i, n){
        cin >> xy.at(i).first >> xy.at(i).second;
        i2y.push_back(xy.at(i).second);
    }
    sort(ALL(xy));

    sort(ALL(i2y));
    i2y.erase(unique(ALL(i2y)), i2y.end());

    map<ll, ll> y2i;
    REP(i, i2y.size()){ y2i[i2y.at(i)] = i; }

    REP(i, n){
        xy.at(i).second = y2i.at(xy.at(i).second);
    }


    SegmentTree<ll, min, numeric_limits<ll>::max()>
    stp(i2y.size()), stm(i2y.size());
    stp.update(xy.at(0).second, xy.at(0).first + i2y.at(xy.at(0).second), false);
    stm.update(xy.at(0).second, xy.at(0).first - i2y.at(xy.at(0).second), false);

    ll ans = 0;
    for(ll i = 1; i < n; ++i){
        const ll xi = xy.at(i).first;
        const ll iyi = xy.at(i).second;
        const ll xpy = xi + i2y.at(iyi);
        const ll xmy = xi - i2y.at(iyi);
        const ll min_xpy = stp.query(0, iyi + 1);
        if(min_xpy != numeric_limits<ll>::max()){
            ans = max(ans, xpy - min_xpy);
        }
        const ll min_xmy = stm.query(iyi + 1, i2y.size());
        if(min_xmy != numeric_limits<ll>::max()){
            ans = max(ans, xmy - min_xmy);
        }
        stp.update(iyi, xpy, false);
        stm.update(iyi, xmy, false);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 28768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

ll M = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= M;
	if(k%2 == 1){
		ret *= x; ret %= M;
	}
	return ret;
}

ll C[3][1000000];
void C_init(int t,int x,int n){
	rep(i,x){
		if(i < n)C[t][i] = 0;
		else if(i == n)C[t][i] = 1;
		else {
			ll ret = C[t][i-1];
			ret *= i; ret %= M;
			ret *= modpow(i-n,M-2); ret %= M;
			C[t][i] = ret;
		}
	}
}

int main(){
	ll n,m,k;
	cin >> n >> m >> k;
	n --;
	C_init(0,900001,n);
	C_init(1,600001,m);
	C_init(2,600001,k);
	//if(n > 1000 || m > 1000 || k > 1000)return 0;
	
	ll ret = 0;
	ll sum_ = 1;
	for(ll t = m+k ; t >= 0 ; t --){
		if(t < m+k){
			sum_ *= 2;
			if(sum_ >= M)sum_ -= M;
			if(m+k-t >= m+1){
				sum_ -= C[1][m+k-t-1];
				if(sum_ < 0)sum_ += M;
			}
			if(m+k-t >= k+1){
				sum_ -= C[2][m+k-t-1];
				if(sum_ < 0)sum_ += M;
			}
		}
		ll sum = sum_;
		sum %= M;
		sum *= modpow(3,t); sum %= M;
		sum *= C[0][n+m+k-t]; sum %= M;
		ret += sum;
	}
	cout << ret%M << endl;
}


Measured memory_bytes: 16640
#include<iostream>

using namespace std;
int A[1000000],n;

int binarysearch(int key){
    int left = 0;
    int right = n;
    int mid;
    while(left<right){
        mid = (left+right)/2;
        if (key == A[mid]){
            return 1;
        }
        else if (key > A[mid]){
            left = mid+1;
        }
        else {
            right = mid;
        }
    }
    return 0;
}


int main(){
    int i,q,k,sum = 0;
    cin>> n;
    for (i = 0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    for(i=0;i<q;i++){
        cin>>k;
        if(binarysearch(k)) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3436
#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>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll a,b,c,x,count = 0;
cin >> a >> b >> c >> x;

rep(i,a + 1){
    rep(j,b + 1){
        rep(k,c + 1){
            if(500*i+100*j+50*k == x){
                count++;
            } 
        }
    }
}

cout << count << endl;

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

Measured memory_bytes: 256
<?php
list($h,$w,$m)=explode(" ",trim(fgets(STDIN)));
$j=array_fill(1,$h,0);
$k=array_fill(1,$w,0);
$i=0;
while($i<$m){
  list($x,$y)=explode(" ",trim(fgets(STDIN)));
  $b[$x][$y]=1;
  ++$j[$x];
  ++$k[$y];
  ++$i;
}
arsort($j);
arsort($k);
$ans=0;
$num=0;
foreach($j as $key => $val){
  if($val>=$num){
    $num=$val;
    $num2=0;
    foreach($k as $key2 => $val2){
      if($val2>=$num2){
        $num2=$val2;
        if(isset($b[$key][$key2])){
          $ans=max($ans,$num+$num2-1);
        }else{
          echo $num+$num2;
          exit;
        }
      }else{
        break;
      }
    }
  }else{
    break;
  }
}
echo $ans;

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

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

    long long sum = 0, A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i == 0) continue;
        if (A[i] < A[i - 1]) {
            sum += (A[i - 1] - A[i]);
            A[i] = A[i - 1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll a,b; cin>>a>>b;
  if (a>0 && b>0) {
    puts("Positive\n");
    return 0;

  }
  if (a*b <= 0) {
    puts("Zero\n");
    return 0;
  }
  if (a<0 && b<0) {
    if ((b-a)&1) {
      puts("Positive\n");
      return 0;
    } else {
      puts("Negative\n");
      return 0;
    }
  }
 return 0;
}

Measured memory_bytes: 256
point = [0,0]
for i in range(int(input())):
    (t,h) = [x for x in input().split()]
    if t == h:
        point[0] += 1
        point[1] += 1
    else:
        a = [t,h]
        q = sorted(a)
        if t == q[0]:
            point[1] += 3
        else:
            point[0] += 3
print(point[0],point[1])

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

vector<int> E[1001];
int mae;
int used[1001];
int st[1001];
vector<int> V;
int d;
int maesize;
bool dfs(int v) {
	if (used[v] == d) {
		int mituketa = 0;
		for (int i = 0; i < V.size(); i++) {
			if (mituketa == 1) {
				st[V[i]] = d + 1;
				maesize++;
			}
			else if (V[i] == v) {
				if (i == 0 && V.size() == maesize) {
					mituketa = -1;
					break;
				}
				mituketa = 1;
				st[v] = d + 1;
				maesize = 1;
				mae = v;
			}
		}
		if (mituketa == -1) return false;
		return true;
	}
	else {
		V.pb(v);
		used[v] = d;
		for (int ne : E[v]) {
			if (st[ne] == d) {
				if (dfs(ne)) return true;
			}
		}
		V.pop_back();
		used[v] = d - 1;
		return false;
	}
	return false;
}

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


	int N, M;
	cin >> N >> M;

	rep(i, M) {
		int a, b;
		cin >> a >> b;

		E[a].pb(b);
	}

	int aru = 0;
	mae = 1;
	rep1(i, N) used[i] = -10;

	rep1(i, N) {
		if (used[i] == -10) {
			if (dfs(i)) {
				aru = 1;
				V.clear();
				d++;
				break;
			}
			V.clear();
		}
	}

	if (aru) {
		while (true) {
			if (dfs(mae)) {
				V.clear();
				d++;
			}
			else break;
		}
		vector<int> kotae;
		rep1(i, N) {
			if (st[i] == d) {
				kotae.pb(i);
			}
		}
		co(kotae.size());
		rep(i, kotae.size()) co(kotae[i]);

	}
	else co(-1);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long int> vec(N+2, 0);
    for(int n=1; n<=N; n++) {
        vec[n+1] = n+vec[n];
    }
    long long int ans=0;
    for(int k=K; k<=N+1; k++) {
        ans += ((vec[N+1]-vec[N+1-k])-(vec[k]-vec[0])+1)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    

    return 0;
    
}

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

int main () {
    int K, S;
    cin >> K >> S;
    int sum = 0, count = 0;
    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            int Z = S - X - Y;
                if (Z >= 0 && Z <= K) {
                    count++;
                }
                sum = 0;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
/* input - N, a[N]; op - int 
 * frog can go from i to at most i + 2
*/

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

#define L 100000
#define MIN(a,b) ((a) < (b) ? (a) : (b))

int main(void) 
{
    int N, i, j;

    scanf("%d", &N);

    int a[N], dp[L];

    for (i = 0; i < N; i++) {
        scanf("%d", &a[i]);
        dp[i] = INT_MAX;
    }

    dp[0] = 0;


    for (j = 0; j < N; j++) {
        if (j + 1 < N) {
            dp[j+1] = MIN(dp[j+1], dp[j] + abs(a[j] - a[j+1]));
        } 
        if (j + 2 < N) {
            dp[j+2] = MIN(dp[j + 2], dp[j] + abs(a[j] - a[j+2]));
        }
    }

    printf("%d", dp[N-1]);

    return 0;
}

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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
//#define fastIO 
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); }
int arr[2];
int main() {
	fastIO();
	int n; in(n); while (n--) {
		int t; in(t); arr[t % 2]++;
	}
	if(arr[1] % 2 )std::cout << "NO";
	else std::cout << "YES";
}


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

int main() {
    ll n, m, q, a, b;
    cin >> n >> m >> q;
    vector<ll> row(n+1,0);
    vector<vector<ll>> arr(n+1,row);
    for (ll i=0; i<m; i++) {
        cin >> a >> b;
        arr[a][b]++;
    }
    for (ll i=0; i<=n; i++) {
        ll csum = 0;
        for (ll j=0; j<=n; j++) {
            csum+=arr[i][j];
            arr[i][j] = csum;
        }
    }
    for (ll i=0; i<q; i++) {
        ll res = 0;
        cin >> a >> b;
        for (ll j=a; j<=b; j++) {
            res+=arr[j][b];
        }
        cout << res << endl;
    }
    return 0;
}

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

int dat[210],kmi[210],kma[210],had[210],dp[210][210];//dp[??\][???]
int main(){
	int D,N,cnt;
	cin>>D>>N;
	for(int i=0;i<D;i++){
		cin>>dat[i];
	}
	for(int i=0;i<N;i++){
		cin>>kmi[i]>>kma[i]>>had[i];
	}
	for(int i=0;i<=D;i++)
		for(int j=0;j<N;j++)
			dp[i][j]=-1;
	for(int i=0;i<N;i++){
		if(dat[0]>=kmi[i]&&dat[0]<=kma[i]){
			dp[0][i]=0;
		}
	}

	for(int i=0;i<D-1;i++){
		for(int j=0;j<N;j++){
			if(dat[i+1]>=kmi[j]&&dat[i+1]<=kma[j]){
				cnt=-1;
				for(int k=0;k<N;k++){
					if(dp[i][k]!=-1)cnt=max(cnt,abs(had[k]-had[j])+dp[i][k]);
				}
				dp[i+1][j]=cnt;
			}
		}
	}

	cnt=-1;
	for(int i=0;i<N;i++){
		cnt=max(cnt,dp[D-1][i]);
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1332
package main
import (
	"fmt"
)
func main()  {
	var N,K int
	fmt.Scan(&N,&K)
	pena,acc:=0,0
	plob :=map[int]int{}

	for i := 0; i < K; i++ {
		var p int
		var s string
		fmt.Scan(&p,&s)
		a,b:=plob[p]
		if !b {
			if s=="WA" {
				plob[p]=1
			}else{
				plob[p]=0
				acc++
			}
		}else{
			if a>0 &&  s=="WA" {
				plob[p]++;
			}else if a>0 &&  s=="AC" {
				acc++
				pena+=a
				plob[p]=0
			}
		}

	}

	

	fmt.Println(acc,pena)

}



Measured memory_bytes: 8064
l=int(input())
r=l.bit_length()-1
n=r+1
ans=[]
for i in range(n-1):
    ans.append((i+1,i+2,0))
    ans.append((i+1,i+2,2**i))
for i in range(n-1,-1,-1):
    if l-2**i>=2**r:
        ans.append((i+1,n,l-2**i))
        l-=2**i
print(n,len(ans))
for i in ans:
    print(*i,sep=' ')

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

int main(void)
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    double distance = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    printf("%f\n", distance);

    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
 
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
 
const int N = (int) 2e5 + 7;
const int INF = (int) 1e9 + 7;
 
int x, y;
int a[N];
int ans[N];
vector<int> g[N];
multiset<int> ms;
 
void dfs(int s, int p) {
	ms.insert(a[s]);
	multiset<int>::iterator it = ms.lower_bound(a[s]);
	int rem = -1;
	if (++it != ms.end()) {
		rem = *it;
		ms.erase(it);
	}
	ans[s] = ms.size();
 
	for (int i = 0; i < g[s].size(); ++i) {
		if (g[s][i] != p)
			dfs(g[s][i], s);
	}

	ms.erase(a[s]);
	if (rem != -1) {
		ms.insert(rem);
	}
 
}
 
 
int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
 
	int n;
	sf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		sf("%d", &a[i]);
	}
 
	for (int i = 0; i < n - 1; ++i) {
		sf("%d %d", &x, &y);
		g[x].pp(y);
		g[y].pp(x);
	}
 
	dfs(1, 0);
 
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", ans[i]);
	}
 
	return 0;
}


Measured memory_bytes: 28332
//16D8104007J Kanehiro Maho
#include<stdio.h>
int main(void){
	
	int n,q;
    scanf("%d",&n);
    int mid, left, right;
    int S[n];
    int t;
	int count=0;
	int i,j;

	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
		
	for(i=0; i<q; i++){
		scanf("%d",&t);
		left = 0;
		right = n;
		while(left < right){
			mid = (left+right)/2;
			if(t == S[mid]){
				count++;
				break;
			}
			if(t > S[mid]){
				left = mid+1;
			}else if(t < S[mid]){
				right = mid;
			}
		}
	}

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

}



Measured memory_bytes: 2124
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 21474836470;
//static const long long INF = 9223372000000000000;
static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll

struct edge {int to;double cost;};
typedef pair<double,int> P;

vector<edge> G[1145];
double d[1145];
int V; //dはKを始点とした最短距離を記録

void dijkstra(int s){   //dijkstraをしました
    PQ<P,vector<P>,greater<P> > que;
    fill(d,d+V,INF);
    d[s] = 0;
    que.push(P(0.0,s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

double pyth(int a, int b){  //直角三角形の斜辺を求める std::hypotは知らない
    return sqrt(a*a+b*b);
}

signed main(){
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int n;
    cin >> n;
    int a[1145],b[1145],c[1145];
    REP1(i,n) scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
    a[0] = sx, b[0] = sy, c[0] = 0;
    a[n+1] = gx, b[n+1] = gy, c[n+1] = 0;
    V = n + 2;
    REP(i,V){   //全点対間に辺を張る
        FOR(j,i+1,V){
            double dis = max(0.0,pyth(a[i]-a[j],b[i]-b[j]) - double(c[i]+c[j]));
            edge x,y;
            x.cost = y.cost = dis;
            x.to = j;y.to = i;
            G[i].PB(x);
            G[j].PB(y);
        }
    }

    dijkstra(V-1);

    printf("%.15lf\n",d[0]);

    return 0;
}


Measured memory_bytes: 21908
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

#define int long long

const int N = 51;

const int INF = 1e16;

const int inf = INF / 51;

int n , m , k , a[51] , b[51];

void read() {
	scanf("%lld" , &k);
}

int times = 0 , ans = 0;

signed main() {
	read();
	if(k <= 49) {
		puts("50");
		cout<<50 * k<<" ";
		for(int i = 2;i <= 50;i ++) cout<<0<<" ";
		return 0;
	}
	n = 50;
	cout<<50<<endl;
	for(int j = 1;j <= n; j ++) a[j] =n -1 - k;
	for(int i = 1;i <=n;i ++) {
		if(a[i] < 0) {
			int p = -  a[i];
			p /=(n+1);
			if((n+1) * p != -a[i]) {
				p++;
			}
			a[i] += p * (n + 1);
			k -= p;
		}
	}
	int cal =  k / n;
	for(int i = 1;i <=n;i ++) {
		a[i] += cal*(n+1);
	}
	k %= n;
	for(int i = 1;i <=n;i ++) {
		if(!k) break;
		a[i] +=n+1;
		k--;
	}
	for(int i = 1;i <= n ;i ++) cout<<a[i]<<" ";
}

Measured memory_bytes: 256
a = []
ARGF.each { |e|
  a << e.split(' ').map{ |e| e.to_i }
}

spec, *as = a
n, h, w = spec
puts as.reduce(0) { |acc, e|
  a, b = e
  if h <= a && w <= b
    acc + 1
  else
    acc
  end
}



Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,a,b;
  cin>>x>>a>>b;
  if(b-a<=0)cout<<"delicious"<<endl;
  else if(b-a<=x)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;

  return 0;

}


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

//バブルソート

int bubbleSort(int A[], int N){
  int sw=0;
  bool flag=1;
  
  for(int i=0; flag; i++)
    {
      flag=0;
      
      for(int j=N-1; j>=i+1; j--)
	{
	  if(A[j] < A[j-1])
	    {
	      swap(A[j], A[j-1]);
	      flag=1;
	      sw++;
	    }
	}
    }
  return sw;
}

int main(){
  int A[100], N, sw;
  
  cin >> N;

  for(int i=0; i<N; i++)
    cin >> A[i];

  sw = bubbleSort(A, N);
  
  for(int i=0; i<N; i++)
    {
      if(i)
	cout << " ";

      cout << A[i];
    }
  
  cout << endl;
  cout << sw << endl;
  
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<set<int>> E(N);
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[a].insert(b);
    E[b].insert(a);
  }
  bool flg = false;
  for (int w : E[0]){
    if (E[N - 1].count(w)){
      flg = true;
    }
  }
  cout << (flg ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

signed main (){	
	int aa,bb;
	cin >> aa >> bb;
	if (aa==2 || bb==2){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	cout << endl;
	return 0;
}


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

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

int main(){

  while(true){
    int h, w; cin>> h>> w;
    if(h==0 && w==0) break;
    vector<string> a(h);
    rep(i, h) cin>> a[i];
    string best="";
    set<string> dict;
    const int dx[]={-1, -1, -1,  0, 0,  1, 1, 1};
    const int dy[]={-1,  0,  1, -1, 1, -1, 0, 1};
    rep(i, h)rep(j, w){
      rep(k, 8){
        int x=i, y=j;
        string t="";
        do{
          t+=a[x][y];
          if(dict.count(t)){
            if(best.size()<t.size()){
              best=t;
            }else if(best.size()==t.size()){
              if(t<best) best=t;
            }
          }else if(t.size()>=2){
            dict.insert(t);
          }
          x=(x+h+dx[k])%h;
          y=(y+w+dy[k])%w;
        }while(x!=i || y!=j);
      }
    }

    if(best.size()>=2) cout<< best<< endl;
    else cout<< 0<< endl;
  }

  return 0;
}


Measured memory_bytes: 35760
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto Ns = readln.split.to!(int[]);
  
  writeln(Ns[0]+Ns[1]+Ns[2] >= 22 ? "bust" : "win");
}


Measured memory_bytes: 256