akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } 
int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<ll,ll>>A(n);
  rep0(i,n)cin >> A[i].first >> A[i].second;
  sort(A.begin(),A.end());
  ll now = 0;
  ll nowmoney = 0;
  ll j = 0;
  while(1){
    if(m <= now)break;
    now += A[j].second;
    nowmoney += A[j].second * A[j].first;
    if(now > m){
      nowmoney -= (now - m) * A[j].first;
    }
    j++;
  }
  cout << nowmoney << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;

	vll a(n), b(n), c(m), d(m);


	rep(i, n) cin >> a[i] >> b[i];
	rep(i, m) cin >> c[i] >> d[i];


	rep(i,n) {
		ll man = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		int ans = 0;
		rep(j,m) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < man) {
				man = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j;
			}
		}
		cout << ans + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

vin par(100050);
vin deep(100050);
void init(int n);
int root(int x);
void unite(int x,int y);
bool same(int x,int y);

int main(){
    int n,m;cin>>n>>m;
    vin p(n);rep(i,n)cin>>p[i];
    init(n);
    int x,y;
    rep(i,m){
        cin>>x>>y;
        unite(p[x-1],p[y-1]);
    }
    int ans=0;
    rep(i,n){
        if(same(p[i],i+1))ans++;
    }
    cout<<ans<<endl;
}

void init(int n){
    rep(i,n+1){
        par[i]=i;
        deep[i]=0;
    }
}
int root(int x){
    if(par[x]==x)return x;
    else return par[x]=root(par[x]);
}
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(deep[x]<deep[y])par[x]=y;
    else{
        par[y]=x;
        if(deep[x]==deep[y])deep[x]++;
    }
}
bool same(int x,int y){
    return root(x)==root(y);
}

Measured memory_bytes: 1408
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
for i in range(n):
  if i%2:
    b.appendleft(a[i])
  else:
    b.append(a[i])
if n%2:
  print(*reversed(list(b)))
else:
  print(*list(b))

Measured memory_bytes: 32340
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=1<<18;

int main(){
    int h,w,m;
    cin>>h>>w>>m;
    vector<int> y(h,0);
    vector<int> x(w,0);
    vector<P> v;
    int ymax=0;
    int xmax=0;
    while(m>0){
        int i,j;
        cin>>i>>j;
        i--; j--;
        v.push_back(P(i,j));
        y[i]++;
        x[j]++;
        if(ymax<y[i]) ymax=y[i];
        if(xmax<x[j]) xmax=x[j];
        m--;
    }

    vector<int> yitr;
    vector<int> xitr;
    for(int i=0;i<h;i++){
        if(ymax==y[i]) yitr.push_back(i);
    }
    for(int i=0;i<w;i++){
        if(xmax==x[i]) xitr.push_back(i);
    }
    ll num=yitr.size()*xitr.size();
    ll cnt=0;
    for(P p:v){
        int i=p.first;
        int j=p.second;
        if(y[i]==ymax && x[j]==xmax) cnt++;
    }
    int ans=ymax+xmax-1;
    if(cnt<num){
        ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 12360
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	map<char, int>m;
	int n = s.size();
	int ans = n*(n - 1) / 2;
	rep(i, 0, s.size()) {
		m[s[i]]++;

	}
	for (auto &a : m) {
		ans -= a.second*(a.second - 1) / 2;
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


signed main(){
    int a, b;
    std::string op;
    auto plus = [](auto x, auto y){ return x + y;};
    auto minus = [](auto x, auto y){ return x - y;};
    auto mul = [](auto x, auto y){ return x * y;};
    auto div = [](auto x, auto y){ return x / y;};

    while(1){
        std::cin >> a >> op >> b;
        if (op == "?"){
            break;
        }
        if(op=="+"){
            std::cout << plus(a, b) << std::endl;
        }
        if(op=="-"){
            std::cout << minus(a, b) << std::endl;
        }
        if(op=="*"){
            std::cout << mul(a, b) << std::endl;
        }
        if(op=="/"){
            std::cout << div(a, b) << std::endl;
        }
    }


    return 0;
}


Measured memory_bytes: 3136
using System;

class Program
{
    static void Main(string[] args)
    {
        string line = Console.ReadLine();

        if (line.Length == 3)
        {
            string revLine = "";

            for (int i = line.Length - 1; i > -1; i--)
                revLine += line[i].ToString();

            Console.WriteLine(revLine);
        }
        else
        {
            Console.WriteLine(line);
        }
        
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
 
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;

void Insert(int);
Node Search(Node, int);
Node Min(Node);
Node Successor(Node);
void Del(Node);
void Inorder(Node);
void Preorder(Node);

Node root;
 
int main(){
  int n, i, x;
  char command[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", command);
    if ( command[0] == 'i' ){
      scanf("%d", &x);
      Insert(x);
    }
    else if( command[0] == 'f' ) {
      scanf("%d", &x);
      if( Search(root, x) != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if( command[0] == 'd') {
      scanf("%d", &x);
      Del(Search(root, x));
    }
    else if ( command[0] == 'p' ){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}
void Insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x != NIL) {
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}
 
Node Search(Node u, int k) {
  if( u == NIL || k == u->key) return u;
  if(k < u->key) return Search(u->l, k);
  else return Search(u->r, k);
}
 
Node Min(Node u) {
  while(u->l != NIL) {
    u = u->l;
  }
  return u;
}
 
Node Successor(Node u) {
  Node y = NIL;
  if( u->r != NIL ) return Min(u->r);
  y = u->p;
  while(y != NIL && u == y->r) {
    u = y;
    y = y->p;
  }
  return y;
}
 
void Del(Node u) {
  Node y = NIL;
  Node x = NIL;
 
  if( u->l == NIL || u->r == NIL ) y = u;
  else y = Successor(u);
 
  if( y->l != NIL ) x = y->l;
  else x = y->r;
 
  if( x != NIL ) x->p = y->p;
 
  if( y->p == NIL) root = x;
  else if( y == y->p->l ) y->p->l = x;
  else y->p->r = x;
 
  if( y != u ) {
    u->key = y->key;
  }
}
 
 
void Inorder(Node u) {
  if(u->l != NIL)Inorder(u->l);
  printf(" %d", u->key);
  if(u->r != NIL)Inorder(u->r);
}
 
void Preorder(Node u) {
  printf(" %d", u->key);
  if(u->l != NIL)Preorder(u->l);
  if(u->r != NIL)Preorder(u->r);
}
 
 

Measured memory_bytes: 19364
//
// Created by sueta on 18/06/16.
//
#include <bits/stdc++.h>

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

using namespace std;

int main(){
    int A,B;
    cin >> A;
    cin >> B;
    if(abs(A-B) <= 16 - (A + B)){
        cout << "Yay!" ;
    } else {
        cout << ":(" ;
    }
    return 0;
}

Measured memory_bytes: 764
n = gets.to_i
s = gets.chomp.split(//)

count = 0

def slim(n,s)
    $slims = []
    n.times do |n|
        if s[n].to_s != s[n+1].to_s
            $slims.push(s[n])
            n = n - 1
        end
    end
    return $slims
end

puts slim(n,s).length

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

int main() {
	int N;
	cin >> N;
	if(N % 2 == 0) {
		cout << N * (N - 1) / 2 - N / 2 << endl;
		for(int i=1;i<=N;i++) {
			int forbidden = N - (i - 1);
			for(int j=i+1;j<=N;j++) {
				if(j == forbidden) continue;
				cout << i << " " << j << endl;
			}
		}
	} else {
		cout << N * (N - 1) / 2 - (N - 1) / 2 << endl;
		for(int i=1;i<=N;i++) {
			int forbidden = N - i;
			for(int j=i+1;j<=N;j++) {
				if(j == forbidden) continue;
				cout << i << " " << j << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;


// bool win[41][41];
// bool used[41][41];

// bool dfs(int a, int b) {
// 	if(used[a][b]) return win[a][b];
// 	used[a][b] = true;
// 	if(a < 2 && b < 2) return win[a][b] = false;
// 	bool res = false;
// 	for(int i = 1; i * 2 <= a; i++) {
// 		if(!dfs(a - 2*i, b + i)) res = true;
// 	}
// 	for(int i = 1; i * 2 <= b; i++) {
// 		if(!dfs(a+i, b - 2 * i)) res = true;
//  	}
//  	return win[a][b] = res;
// }


int main(){
	// rep(i, 21) {
	// 	rep(j, 21) {
	// 		cout << "xo"[dfs(i, j)];
	// 	}
	// 	cout << endl;
	// }
	ll a, b;
	cin >> a >> b;
	if(abs(a-b) <= 1) cout << "Brown" << endl;
	else cout << "Alice" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

vi ans;
 
int32_t main()
{
    fast;
    int a, b, k; cin >> a >> b >> k;
    int val = min(a, b);
    Rep(i, 1, val) {
        if(a % i == 0 and b % i == 0) ans.pb(i);
    }
    sort(ans.rbegin(), ans.rend());
    cout << ans[k-1];

    
    
    
    return 0;
}

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

char s[11];
int main() {
	int n, q; scanf("%d%d", &n, &q);
	queue<P>que;
	int tim = 0;
	rep(i, n) {
		int t; scanf("%s%d", s, &t);
		que.push(P(s, t));
	}
	while (!que.empty()) {
		P p = que.front(); que.pop();
		if (p.second <= q) {
			tim += p.second;
			printf("%s %d\n", p.first.c_str(), tim);
		}
		else {
			tim += q;
			p.second -= q; que.push(p);
		}
	}
}

Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> vec(n);
    for(int i = 0; i < m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        vec.at(a).push_back(b);
        vec.at(b).push_back(a);
    }
    queue<int> q;
    vector<int> dist(n,INF);
    vector<int> pre(n,-1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();q.pop();
        for(auto u : vec.at(v)){
            if(dist.at(u) != INF) continue;
            dist.at(u) = dist.at(v) + 1;
            pre.at(u) = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    for(int i = 0; i < n;i++){
        if(i == 0) continue;
        cout << ++pre.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 10636
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    cout << "2018" + S.substr(4, 6) << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int q; cin >> q;
  vector<int> ans(q);
  rep(k, q) {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    rep(i, n) rep(j, m) {
      if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
      else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }
    ans[k] = dp[n][m];
  }
  for(auto x : ans) cout << x << endl;
}


Measured memory_bytes: 6860
def main():
    n, m = [int(e) for e in input().split()]
    if n == 1 and m == 0:
        print(0)
        exit()

    if m == 0:
        print(10**(n - 1))
        exit()

    S, C = zip(*[[int(e) for e in input().split()] for i in range(m)])

    ans = 0
    D = {}
    for si, ci in zip(S, C):
        if D.get(si) == ci:
            continue

        if n != 1 and si == 1 and ci == 0:
            print(-1)
            exit()

        if D.get(si) is not None:
            print(-1)
            exit()

        ans += 10**(n - si) * ci
        D[si] = ci

    if len(str(ans)) > n:
        print(-1)
        exit()

    if len(str(ans)) < n:
        ans += 10**(n - 1)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    ans = 0
    for ai, a in enumerate(A):
        if (ai + 1) % 2 == 1 and a % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61772
#include <cstdio>
#include <cstring>
int main(void)
{
  while(1){
    int n;
    scanf("%d",&n);
    if(!n) break;
    int t=1,f=2,r=3;
    int res = 1;
    char str[10];
    int temp;
    for(int i=0;i<n;i++){
      scanf("%s",str);
      if(str[0] == 'N'){
	temp = f;
	f = 7 - t;
	t = temp;
      }else if(str[0] == 'E'){
	temp = t;
	t = 7 - r;
	r = temp;
      }else if(str[0] == 'W'){
	temp = r;
	r = 7 - t;
	t = temp; 
      }else if(str[0] == 'S'){
	temp = t;
	t = 7 - f;
	f = temp;
      }else if(str[0] == 'R'){
	temp = r;
	r = 7 - f;
	f = temp;
      }else{
	temp = f;
	f = 7 - r;
	r = temp;
      }
      res += t;
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1036
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vector<vpll> path, path2; vl D1, D2;
//***********//
int main() {
	cin >> N;
	ll Ga, Sa, Ba, Gb, Sb, Bb;
	cin >> Ga >> Sa >> Ba;
	cin >> Gb >> Sb >> Bb;
	vl dp(N + 1);
	for (i = 0; i <= N; i++) {
		dp[i] = N - i;
	}
	// 容量i使用時の価値最大値
	for (i = 0; i < N; i++) {
		if (i + Ga <= N) dp[i + Ga] = max(dp[i + Ga], dp[i] + Gb-Ga);
		if (i + Sa <= N) dp[i + Sa] = max(dp[i + Sa], dp[i] + Sb-Sa);
		if (i + Ba <= N) dp[i + Ba] = max(dp[i + Ba], dp[i] + Bb-Ba);
	}
	M = N;
	for (i = 0; i <= N; i++) {
		M = max(M, dp[i]);
	}
	vl dp2(M + 1);
	for (i = 0; i <= M; i++) {
		dp2[i] = M - i;
	}
	for (i = 0; i < M; i++) {
		if (i + Gb <= M) dp2[i + Gb] = max(dp2[i + Gb], dp2[i] + Ga-Gb);
		if (i + Sb <= M) dp2[i + Sb] = max(dp2[i + Sb], dp2[i] + Sa-Sb);
		if (i + Bb <= M) dp2[i + Bb] = max(dp2[i + Bb], dp2[i] + Ba-Bb);
	}
	ans = M;
	for (i = 0; i <= M; i++) {
		ans = max(ans, dp2[i]);
	}
	cout << ans;
}

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

int main(){
    int n, t, a, h, i, p;
    double min = 999999999;
    cin >> n >> t >> a;
    for(i=1; i<=n; i++){
        cin >> h;
        if((double)abs(a - t + h*0.006) < min){
            min = (double)abs(a - t + h*0.006);
            p = i;
        }
    }
    cout << p;
    return 0;
}

Measured memory_bytes: 256
def ma():
  n,m=map(int,input().split())
  ans=0
  e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
  f=list(map(int,input().split()))
  for i in range(2**n):
    l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
    if sum([int(len(e[j-1]&l)%2 !=f[j-1]) for j in range(1,m+1)])==0:ans+=1
  print(ans)

if __name__=="__main__":
  ma()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll t, x;
  cin >> t >> x;

  printf("%.16f\n", (double)t/x);
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main{
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		long K=sc.nextLong();
		int[][] to=new int[N][63];
		for (int i=0;i<N;++i) Arrays.fill(to[i], -1);
		for (int i=0;i<N;++i) {
			to[i][0]=sc.nextInt()-1;
		}
		for (int i=0;i+1<63;++i) {
			for (int src=0;src<N;++src) {
				to[src][i+1]=to[to[src][i]][i];
			}
		}
		int cur=0;
		int p=0;
		for (;K>0;K>>=1,p++) {
			if (K%2==1) {
				cur=to[cur][p];
			}
 		}
		System.out.println(cur+1);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}


Measured memory_bytes: 99548
#include <iostream>

using namespace std;

int main() {
  int N, P{}, M{};
  string S;
  cin >> N >> S;
  for (int i = 0; i != N; ++i) {
    if (S[i] == '(') ++P;
    else --P;
    M = min(M, P);
  }
  cout << string(-M,'(') << S << string(P-M,')') << endl;
}


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


int main()
{
    string s;
    cin>>s;
    int ret=760;
    for(int i=0;i<=s.length()-3;i++){
        int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        ret=min(ret,abs(x-753));

    }
    cout<<ret;
    return 0;




}






Measured memory_bytes: 256
//==========================================================================
    #define mod 1e9+7
    #include<decimal/decimal>
    #include <iostream>           //  CCCCC RRRRR  EEEEE  AAA   TTTTT EEEEE DDDD
    #include<algorithm>           //  C     R  R   E     A   A    T   E     D  D
    #include<bits/stdc++.h>       //  C     RRRR   EEEE  AAAAA    T   EEEE  D  D
    #include<cstring>             //  C     R  R   E     A   A    T   E     D  D
    #include<vector>              //  CCCCC R   R  EEEEE A   A    T   EEEEE DDDD
    //==========================================================================
    #include<stack>               //  BBBB   Y   Y
    #include<queue>               //  B   B   Y Y
    #include<deque>               //  BBBB     Y
    #include<cmath>               //  B   B    Y
    #include<numeric>             //  BBBB     Y
    //==========================================================================
    #include<utility>             //   AAA  M   M M   M IIIII TTTTT
    #include<unordered_map>       //  A   A MMMMM MMMMM   I     T
    #include<unordered_set>       //  AAAAA M M M M M M   I     T
    #include<set>                 //  A   A M   M M   M   I     T
    #include<map>                 //  A   A M   M M   M IIIII   T
    #include<list>
    #include<set>
    #include<string>
    //==========================================================================
    //==========================================================================
     
using namespace std;
 
int main() 
 {
      ios_base::sync_with_stdio(false); 
      cin.tie(NULL); 
      int in,x[4]={0};
      cin>>in;
      x[in]=1;
      cin>>in;
      x[in]=1;
      for(int i=1;i<=3;i++)
      {
           if(x[i]==0)
           {
           cout<<i<<endl;
           break;
                
           }
      }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  double res = W * H / 2;
  cout << fixed << setprecision(10) << res << " "
       << (W / 2 == x && H / 2 == y ? 1 : 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define F -1
#define NOF 1

int row[N],c[N],dpos[2*N-1],dneg[2*N-1],T[N][N];

void tofree(){
  int i,j;
  for(i=0;i<N;i++)row[i]=c[i]=F;
  for(i=0;i<2*N-1;i++)dpos[i]=dneg[i]=F;
}

void printBord(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(T[i][j]==1){
	if(row[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  if(i==N){
    printBord();
    return;
  }
  for(j=0;j<N;j++){
    if(c[j]==NOF || dpos[i+j]==NOF || dneg[i-j+N-1]==NOF)continue;
    row[i]=j;
    c[j]=dpos[i+j]=dneg[i-j+N-1]=NOF;
    putQueen(i+1);
    c[j]=dpos[i+j]=dneg[i-j+N-1]=F;
  }
}

int main(){
  int i,j,n,m,v;
  tofree();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      T[i][j]=0;
    }
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&m,&v);
    T[m][v]=1;
  }
  putQueen(0);
  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#define MAX_N 102
using namespace std;
void solve();
void init();
int dfs(int,int,char);
char field[MAX_N][MAX_N];
int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
int W,H;
void print();
int main(){
  while(cin>>H>>W,W){
    init();
    for(int i=1;i<H+1;i++){
      for(int j=1;j<W+1;j++){
	cin>>field[i][j];
      }
    }
    solve();
  }
  return 0;
}
void init(){
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      field[i][j]='.';
    }
  }
}
int dfs(int x,int y,char c){
  if(field[y][x]!=c)return 0;  
  field[y][x]='.';
  for(int i=0;i<4;i++){
    dfs(x+dx[i],y+dy[i],c);
  }
  return 1;
}
void solve(){
  int a=0;
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      if(field[i][j]!='.')a+=dfs(j,i,field[i][j]);
    }
  }
  cout<<a<<endl;
}
void print()
{
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout<<field[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
const int N = 4e5 + 5;
typedef long long ll;
const ll inf=1e15;
#define pb push_back
const int INF=(0x3f3f3f3f);
 
//#define _

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
#ifdef _
  //freopen("text.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  const clock_t begin_time=clock();
#endif  
  
  
  int n;
  cin>>n;
  vector<pair<long long,long long>>vec;
  for(int i = 0; i < n; i++){
    long long x,l;
    cin>>x>>l;
    long long x1,x2;
    x1 = x + l;
    x2 = x - l;
    vec.pb(make_pair(x1,x2));
  }
  
  sort(vec.begin(),vec.end());
  
  int cur = -1000000000;
  
  int answ = 0;
  for (int i = 0; i < n; i++){
    if (cur <= vec[i].second){
      answ++;
      cur = vec[i].first;
    }
  }
  
  cout << answ << '\n';
#ifdef _
  //cout<<"\n\n\n\n\n\n\n\n\n\n\n";
  //cout<<float(clock()-begin_time)/CLOCKS_PER_SEC;
  cout<<fixed<<setprecision(45)<<double(clock()-begin_time)/CLOCKS_PER_SEC;
#endif
}










Measured memory_bytes: 2420
using System;
public class Hello{
    public static void Main(){
        string input = Console.ReadLine();
        for(int x = 0;x < input.Length - 1;x++){
            if(input.Substring(x,2) == "AC"){
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

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

using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    string tmp = s;
    reverse(tmp.begin(),tmp.end());
    if(tmp != s)
        return cout << "No" << endl,0;
    int n = s.size();
    string tt = s.substr(0,(n-1)/2);
    tmp = tt;
    reverse(tmp.begin(),tmp.end());

    if(tmp != tt)
        return cout << "No" << endl,0;

    cout << "Yes" << endl;



}


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

using namespace std;

int main(void){
	int t1, t2, r1, r2;
	cin >> t1 >> t2 >> r1 >> r2;

	if(r1 != -1 && r2 != -1){
		if(r1 > r2) cout << "Alice" << endl;
		else if(r1 < r2) cout << "Bob" << endl;
		else cout << "Draw" << endl;
		return 0;
	}

	if(t1 < t2) cout << "Alice" << endl;
	else if(t1 > t2) cout << "Bob" << endl;
	else cout << "Draw" << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <iostream>

using namespace std;

typedef long long ll;

int MOD = 1;

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 6e3 + 5;

Modint _dp [MAX_N][(int) 9e3 + 5];
const int ZERO = MAX_N;
Modint& dp (int i, int j) {
  return _dp[i][j + ZERO];
}

int main () {
  int n;
  cin >> n >> MOD;
  n *= 3;
 
  dp(0, 0) = Modint(1);
  for (int i = 0; i < n; i++) {
    for (int j = -i; j <= i / 2; j++) {
      dp(i + 1, j - 1) += dp(i, j); // add a singleton
      dp(i + 2, j + 1) += dp(i, j) * Modint(i + 1);
      dp(i + 3, j) += dp(i, j) * Modint((i + 1) * (i + 2));
    }
  }

  Modint ans (0);
  for (int j = -n; j <= 0; j++) {
    ans += dp(n, j);
  }

  cout << ans << endl;
}


Measured memory_bytes: 422784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 1e18;
  rep(i, n) rep(j, n) {
    if(i == j) continue;
    ll x = p[j].first - p[i].first;
    ll y = p[j].second - p[i].second;
    ll cnt = 0;
    rep(a, n) {
      bool ok = false;
      rep(b, n) {
        if(a == b) continue;
        ll xx = p[b].first - p[a].first;
        ll yy = p[b].second - p[a].second;
        if(xx == x && yy == y) ok = true;
      }
      if(ok) cnt++;
    }
    ans = min(ans, n - cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=5e5+5;
const int P=998244353;
int n,m,Ans,fac[N],inv[N],fn[N],fm[N];
int ksm(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1ll*res*x%P;
		x=1ll*x*x%P,k>>=1;
	}return res;
}
void Pre(int Lim){
	fac[0]=1;for(int i=1;i<=Lim;i++)fac[i]=1ll*fac[i-1]*i%P;
	inv[Lim]=ksm(fac[Lim],P-2);for(int i=Lim;i>=1;i--)inv[i-1]=1ll*inv[i]*i%P;
	fn[0]=1;for(int i=1;i<=Lim;i++)fn[i]=1ll*fn[i-1]*(n+1)%P;
	fm[0]=1;for(int i=1;i<=Lim;i++)fm[i]=1ll*fm[i-1]*(m+1)%P;
}
int C(int n,int m){return (n<m||m<0)?0:1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),Pre(5e5);
	for(int i=0;i<=n;i++){
		int t0=1ll*(i&1?P-1:1)*C(n,i)%P*C(m,i)%P;
		int t1=1ll*fac[i]%P*fn[m-i]%P*fm[n-i]%P;
		Ans=(Ans+1ll*t0*t1%P)%P;
	}printf("%d",Ans);
	return 0;
}


Measured memory_bytes: 11556
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

void selectionSort(vector<int> v, int N);

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	selectionSort(v, N);
}

void selectionSort(vector<int> v, int N) {
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;

		for (int j = i; j < N; j++) {
			if (v.at(j) < v.at(minj)) minj = j;
		}

		if (i != minj) {
			int n = v.at(i);
			v.at(i) = v.at(minj);
			v.at(minj) = n;
			cnt++;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << v.at(i);
		if (i == N - 1) {
			cout << endl;
			cout << cnt << endl;
		}
		else {
			cout << ' ';
		}
	}
}


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

template<typename T>
struct Segtree{
	vector<T> node;
	int n{1};
	T unit{};
	Segtree(vector<T> data){
		int sz = data.size();
		while(n<sz) n*=2;
		node.resize(2*n-1,0);
		for(int i=0; i<sz; i++){
			node.at(n-1+i) = data.at(i);
		}
		for(int i=n-2; i>=0; i--){
			node.at(i) = comp( node.at(i*2+1),node.at(i*2+2) );
		}
	} 
	T comp(const T &a, const T &b){
		return a|b;
	}
	void update(int i, T v){
		i += n-1;
		node.at(i) = v;
		while(i){
			i = (i-1)/2;
			node.at(i) = comp( node.at(i*2+1),node.at(i*2+2) );
		}
	}
	T find(int a, int b, int now=0, int l=0, int r=-1){
		if(r<0) r = n;
		if(r <= a || b <= l) return unit;
		if(a <= l && r <= b) return node.at(now);
		T lv = find(a, b, 2*now+1, l, (l+r)/2);
		T rv = find(a, b, 2*now+2, (l+r)/2, r);
		return comp(lv, rv);
	}
};

int main(){
	int n,q;
	string s;
	cin >> n >> s >> q;
	vector<bitset<26>> bit(n);
	for(int i=0; i<n; i++){
		bit.at(i).set(s.at(i)-'a');
	} 
	Segtree<bitset<26>> t(bit);
	for(int i=0; i<q; i++){
		int q0; cin >> q0;
		if(q0==1){
			int iq; 
			char cq;
			cin >> iq >> cq;
			bitset<26> e;
			e.set(cq-'a');
			t.update(--iq, e);
		}
		if(q0==2){
			int lq, rq; cin >> lq >> rq;
			cout << t.find(lq-1, rq).count() << '\n';
		}
		
	}
	cout << flush;
	
}

Measured memory_bytes: 16900
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	var c int
	for i := 1; i < n-1; i++ {
		if (p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1]) {
			c++
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>

using namespace std;

long long pow_ll(int cnt, long long ll){
    long long ans = 1;
    for(int i=0; i<cnt; i++){
        ans *= ll;
    }

    return ans;
}

int main(){
    long long n;
    stack<char> ans;
    cin >> n;
    long long n_new;
    for(int i=1; i<99; i++){
        long long pow_26 = pow_ll(i, 26);
        if(n <= pow_26){
           n--;
           for(int j=0; j<i; j++){
               char ans_c = char((n%26) + 'a');
               ans.push(ans_c);
               n /= 26;
           }
           break;
        }else{
          n -= pow_26;
        }
    }
    int cnt = ans.size();
    for(int i=0; i<cnt; i++){
       cout << ans.top();
       ans.pop();
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 3648
mass = [[0 for p in xrange(14)] for q in xrange(14)]
while True:
	try:
		x,y,size = map(int,raw_input().split(','))
		x += 2 ; y += 2
		if   size == 1:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=0;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=0;mass[x][y-1]+=1;mass[x+1][y-1]+=0;mass[x+2][y-1]+=0
			mass[x-2][y]  +=0;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=0
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=0;mass[x][y+1]+=1;mass[x+1][y+1]+=0;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=0;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
		elif size == 2:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=0;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=1;mass[x][y-1]+=1;mass[x+1][y-1]+=1;mass[x+2][y-1]+=0
			mass[x-2][y]  +=0;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=0
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=1;mass[x][y+1]+=1;mass[x+1][y+1]+=1;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=0;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
		elif size == 3:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=1;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=1;mass[x][y-1]+=1;mass[x+1][y-1]+=1;mass[x+2][y-1]+=0
			mass[x-2][y]  +=1;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=1
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=1;mass[x][y+1]+=1;mass[x+1][y+1]+=1;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=1;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
	except: break
white = 0
max = 0
for p in xrange(2,12):
	for q in xrange(2,12):
		if mass[p][q] == 0: white += 1
		if mass[p][q] > max: max = mass[p][q]
print white
print max

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

using namespace std;

int b[100];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		cin >> b[i];
	}
	int cnt = b[0];
	for (int i = 0; i < n - 2; ++i) {
		cnt += min(b[i], b[i + 1]);
	}
	cnt += b[n - 2];
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
using i64=long long;
using pi=std::pair<int,int>;
const int N=100007;
std::vector<pi>e[N];int n,root,mn,size[N],ef[N],es[N];i64 ans;
int read(){int x;scanf("%d",&x);return x;}
void dfs(int u,int fa)
{
    int mx=0,v;size[u]=1,ef[u]=es[u]=1e9;
    for(pi x:e[u]) if((v=x.first)^fa) dfs(v,u),size[u]+=size[v],mx=std::max(mx,size[v]),es[u]=std::min(es[u],x.second),ans+=2ll*x.second*std::min(size[v],n-size[v]); else ef[u]=x.second;
    mx=std::max(mx,n-size[u]),mx<mn? mn=mx,root=u:0;
}
int main()
{
    mn=n=read();
    for(int i=1,u,v,w;i<n;++i) u=read(),v=read(),w=read(),e[u].push_back({v,w}),e[v].push_back({u,w});
    dfs(1,0),ans-=(mn*2==n? ef[root]:std::min(ef[root],es[root]));
    printf("%lld",ans);
}


Measured memory_bytes: 13568
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define cri const int
#define ll long long
using namespace std;
int dp[502][502],ans;
pair<int,int>f[502];
inline int read(int x=0){ scanf("%d",&x);return x; }
int main(){
	cri n=read(),mod=read();
	for(int i=0;i<n+n;i++){
		if(i>=n) f[i]=make_pair((int)sqrt(4*n*n-i*i)+1,0);
		else f[i]=make_pair((int)(sqrt(n*n-i*i-1e-7))+1,(int)sqrt(4*n*n-i*i)+(i!=0));
	//	cout<<f[i].first<<" "<<f[i].second<<endl;
	}
	sort(f,f+n+n);
	for(int k=0;k<=n;k++){
		int c1=0,c2=0;
		memset(dp,0,sizeof dp);
		dp[0][0]=1;
		for(int i=0;i<n+n;!f[i].second?c1++:c2++,i++)
			for(int j=0;j<=k;j++){
				if(!f[i].second) dp[i+1][j]=(dp[i+1][j]+1ll*dp[i][j]*(f[i].first-j-c1))%mod;
				else{
					if(j<k) dp[i+1][j+1]=(dp[i+1][j+1]+1ll*dp[i][j]*(f[i].first-j-c1))%mod;
					dp[i+1][j]=(dp[i+1][j]+1ll*dp[i][j]*(f[i].second-n-k-(c2-j)))%mod;
				}
			}
		if(k&1) ans=(ans-dp[n+n][k]+mod)%mod;
		else ans=(ans+dp[n+n][k])%mod;
	}
	cout<<ans<<endl;
}

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

int gcd(int a, int b)
{
    if (a%b == 0)
    {
        return b;
    }

    return gcd(b, a%b);
}

int main()
{
    int a, b;

    cin >> a >> b;

    if (a >= b)
    {
        cout << gcd(a, b) << endl;
    }
    else
    {
        cout << gcd(b, a) << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> xs(n);
    for (auto &v : xs) cin >> v;
    vector<ll> ys(m);
    for (auto &v : ys) cin >> v;

    ll ansX = 0;
    for (ll x = 0; x < n - 1; x++)
    {
        ll num = ((x + 1) * (n - 1 - x)) % MOD;
        ansX += (num * (xs[x + 1] - xs[x])) % MOD;
        ansX %= MOD;
    }

    ll ansY = 0;
    for (ll y = 0; y < m - 1; y++)
    {
        ll num = ((y + 1) * (m - 1 - y)) % MOD;
        ansY += (num * (ys[y + 1] - ys[y])) % MOD;
        ansY %= MOD;
    }
    
    cout << (ansX * ansY % MOD) << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = 0;

    for (int i = 1; i <= n; i++) {
      sum += i;
    }
    System.out.println(sum);
  }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    ll N;
    SCLLD(N);

    ll ans1,ans2;
    vector<ll> A;
    VSCLLD(A,N);
    sort(A.begin(),A.end());

    ans1 = 0; ans2 = 0;
    int index = 0;
    if (N % 2 != 0){
        REP(i,N/2){
            ans1 += 2 * A[N-index-1];
            index++;
        }
        REP(j,2){
            ans1 -= A[N-index-1];
            index++;
        }
        REP(k,N - N/2 - 2){
            ans1 -= 2 * A[N-index-1];
            index++;
        }

        index = 0;
        REP(i,N/2){
            ans2 -= 2 * A[index];
            index++;
        }
        REP(j,2){
            ans2 += A[index];
            index++;
        }
        REP(k,N - N/2 - 2){
            ans2 += 2 * A[index];
            index++;
        }
    }else{
        REP(i,N/2 -1 ){
            ans1 -= 2 * A[index];
            index++;
        }
        ans1 -= A[index]; index++;
        ans1 += A[index]; index++;
        REP(j,N/2 - 1){
            ans1 += 2 * A[index];
            index++; 
        }
    }

    PRINTLLD(max(ans1,ans2));
}

Measured memory_bytes: 1400