akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type XY struct {
	x int
	y int
}

var sc = bufio.NewScanner(os.Stdin)

func next() []int {
	var arr []int
	sc.Scan()
	for _, v := range strings.Fields(sc.Text()) {
		p, _ := strconv.Atoi(v)
		arr = append(arr, p)
	}
	return arr
}

func main() {
	input := next()
	H, W, N := input[0], input[1], input[2]
	dxy := [][]int{{-1, -1}, {-1, 0}, {-1, 1},
		{0, -1}, {0, 0}, {0, 1},
		{1, -1}, {1, 0}, {1, 1}}
	count := make(map[XY]int)
	ans := make([]int, 10)
	ans[0] = (H - 2) * (W - 2)

	for i := 0; i < N; i++ {
		input := next()
		for _, v := range dxy {
			xy := XY{input[0] + v[0], input[1] + v[1]}
			if (2 <= xy.x && xy.x <= H-1) && (2 <= xy.y && xy.y <= W-1) {
				if _, ok := count[xy]; ok {
					count[xy]++
				} else {
					count[xy] = 1
				}
			}
		}
	}

	for _, v := range count {
		ans[0]--
		ans[v]++
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}

Measured memory_bytes: 112768
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << endl;
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  int i = min(a, b);
  int j = max(a, b);
  bool ok = false;
  while (i <= j)
  {
    if (abs(a - i) == abs(b - i))
    {
      ok = true;
      break;
    }
    i++;
  }
  if (ok)
  {
    cout << i << endl;
  }
  else
  {
    cout << "IMPOSSIBLE" << endl;
  }
}
  

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

ll solve() {
    ll N, a, p;
    cin >> N;
    cin >> p;
    ll c = 1;
    ll ans = 0;
    for ( int i = 1; i < N; i++ ) {
        cin >> a;
        if ( a == p ) {
            c++;
        } else {
            ans += c / 2;
            c = 1;
        }
        p = a;
    }
    ans += c / 2;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define ll long long
#define pii pair<int, int>
#define maxn 1005
#define INF 0x3f3f3f3f

#define dbg(n) cout << n << endl
#define mod 1000000007
using namespace std;

inline void read(ll &x){
	ll f = 1; x = 0; char s = getchar();
    while(s > '9' || s < '0'){
		if(s == '-') f = -1;
		s = getchar();
	}
    while(s <= '9' && s >= '0'){
		x = x * 10 + s - '0';
		s = getchar();
	}
    x = x * f;
}

struct E{
	ll f, t, c;
	E(ll f, ll t, ll c) : f(f), t(t), c(c){};
};

ll G1[5000][5000];
vector<E> GG1[5000];

int main(){
	ll n, m, f, t, c;
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			G1[i][j] = INF;
	for(int i = 0; i < m; ++i){
		cin >> f >> t >> c;
		G1[f][t] = c;
		G1[t][f] = c;
		GG1[f].push_back(E(f, t, c));
		GG1[t].push_back(E(t, f, c));
	}
	for(int k = 1; k <= n; ++k)
		for(int j = 1; j <= n; ++j)
			for(int i = 1; i <= n; ++i)
				G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]);
	ll ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j < GG1[i].size(); ++j)
			if(GG1[i][j].c > G1[i][GG1[i][j].t]) ans++;
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 2688
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  ll ans = 0;
  ll maxH = A[0];
  for (int i = 1; i < N; ++i) {
    if (A[i] < maxH) ans += maxH - A[i];
    else maxH = A[i];
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4772
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        x: i64,
        k:i64,
        d:i64
    }

    let a: i64 = x.abs() / d;

    if a >= k {
        println!("{}", x.abs() - k * d);
        return;
    }

    let b = k - a;
    let c = x.abs() - a * d;
    if b % 2 == 1 {
        println!("{}", (c - d).abs());
    } else {
        println!("{}", c);
    }
}


Measured memory_bytes: 2148
// atcoder/ddcc2020-qual/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> a(n);
    cin >> a;
    for (int i = 0; i + 1 < a.size(); ++i) {
      a[i + 1] += a[i];
    }
    lli mn = 1LL << 60;
    for (int i = 0; i < a.size() - 1; ++i) {
      lli x = a.back() - a[i];
      lli y = a.back() - x;
      setmin(mn, abs(x - y));
    }
    cout << mn << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){

  stack<char> s;
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    char c; cin >> c;
    if(s.size() == 0) s.push(c);

    char t = s.top();
    if(t != c) s.push(c);
  }

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 384
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r += sorted(p)[-x:]
r += sorted(q)[-y:]
ans = sum(sorted(r)[-(x + y):])

print(ans)


Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
vector<int> ans(100000, 0);
vector<bool> v(100000,false);
map<int, vector<pair<int, int>>> m;

int N=100000;
vector<int> node(N);
map<int, int> mp;
void init(int n)
{
	for (int i = 0; i < n; i++)
	{
		node[i] = i;
		mp[i]++;
	}
}
int root(int x)
{
	return node[x] == x ? x : node[x] = root(node[x]);
}
bool same(int x, int y)
{
	return root(x) == root(y);
}

void unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y)
	{
		return;
	}
	node[x] = y;
	mp[y] += mp[x];
	mp[x] = 0;
}
int main(){
	int n,m;
	cin >> n >> m;
	init(n);
	set<int> kazoeru;
	REP(i,m){
		int x,y,z;
		cin >> x >> y >> z;
		unite(x,y);
		kazoeru.insert(x);
		kazoeru.insert(y);
	}
	int ans=n-kazoeru.size();
	for(auto& i:mp){
		if(i.second>1){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define int long long int
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define DEBUG false
#pragma GCC optimize "trapv"

using namespace std;
char ch[1100][1100];
int dp[1100][1100];

int32_t main()
{
    nitro;
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        cin>>ch[i][j];
    }
    memset(dp,0,sizeof(dp));
    for(int i=0;i<w;i++){
    if(ch[0][i]!='#')
    dp[0][i]=1;
    else
    break;
    }
    for(int i=0;i<h;i++){
    if(ch[i][0]!='#')
    dp[i][0]=1;
    else
    break;
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(ch[i][j]!='#')
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
            else
            dp[i][j]=0;
        }
    }
    cout<<dp[h-1][w-1]<<'\n';
return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool ans = false;
  if (abs(a - c) <= d) {
    ans = true;
  } else if (abs(a - b) <= d && abs(b - c) <= d) {
    ans = true;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
 * 2672.cc: Rescue a Postal Worker
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_K = 6;
const int KBITS = 1 << MAX_K;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

struct Stat {
  int d, i, sbits, tbits;
  Stat() {}
  Stat(int _d, int _i, int _sbits, int _tbits):
    d(_d), i(_i), sbits(_sbits), tbits(_tbits) {}
  bool operator<(const Stat &s) const { return d > s.d; }
  void print() {
    printf("Stat: i=%d, sbits=%d, tbits=%d: d=%d\n", i, sbits, tbits, d);
  }
};

/* global variables */

vpii nbrs[MAX_N];
int ss[MAX_N], ts[MAX_N];
int dists[MAX_N][KBITS][KBITS];

/* subroutines */

/* main */

int main() {
  int n, m, k, p;
  cin >> n >> m >> k >> p;
  p--;

  for (int i = 0; i < m; i++) {
    int xi, yi, wi;
    cin >> xi >> yi >> wi;
    xi--, yi--;
    nbrs[xi].push_back(pii(yi, wi));
    nbrs[yi].push_back(pii(xi, wi));
  }

  for (int i = 0; i < k; i++) {
    int si, ti;
    cin >> si >> ti;
    si--, ti--;
    ss[si] = ts[ti] = (1 << i);
  }

  int kbits = 1 << k;
  
  for (int i = 0; i < n; i++)
    for (int sbits = 0; sbits < kbits; sbits++)
      for (int tbits = 0; tbits < kbits; tbits++)
	dists[i][sbits][tbits] = INF;
  dists[p][0][0] = 0;

  priority_queue<Stat> q;
  q.push(Stat(0, p, 0, 0));

  while (! q.empty()) {
    Stat u = q.top(); q.pop();
    if (dists[u.i][u.sbits][u.tbits] != u.d) continue;
    //u.print();
    
    if (u.tbits == kbits - 1) break;

    vpii &nbru = nbrs[u.i];
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first, vd = u.d + vit->second;
      int vsbits = u.sbits | ss[vi];
      int vtbits = (vsbits & ts[vi]) ? (u.tbits | ts[vi]) : u.tbits;

      if (dists[vi][vsbits][vtbits] > vd) {
	dists[vi][vsbits][vtbits] = vd;
	q.push(Stat(vd, vi, vsbits, vtbits));
      }
    }
  }

  int mind = INF;
  for (int i = 0; i < n; i++)
    if (mind > dists[i][kbits - 1][kbits - 1])
      mind = dists[i][kbits - 1][kbits - 1];

  if (mind >= INF) cout << "Cannot deliver" << endl;
  else printf("%d\n", mind);

  return 0;
}

Measured memory_bytes: 18148
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	char s;
	scanf(" %d",&a);
	cin>>s;
	scanf(" %d",&b);
	switch(s){
	
	case '+':
		cout <<a+b<<endl;
		break;
	case '-':
	cout<<a-b<<endl;
	break;	

		
	}
	
	
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll max(ll a, ll b, ll c, ll d) {
	return max(a,max(b,max(c,d)));
}
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = max(a*c,a*d,b*c,b*d);
	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s1, s2;
	cin >> s1 >> s2;
	sort(s1.begin(), s1.end());
	sort(s2.rbegin(), s2.rend());
	if (s1 < s2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

/* 最小公倍数 */
ll lcm(ll a, ll b)
{
	ll gcdRes = gcd(a, b);
	return (a * (b / gcdRes));
}


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

	N++;
	vector<vector<ll>> gVal(N, vector<ll>(N));
	REP(i, N) {
		REP(j, N) {
			gVal[i][j] = gcd(i, j);
		}
	}
	
	ll ans = 0;
	REPN(i, 1, N) {
		REPN(j, 1, N) {
			REPN(k, 1, N) {
				ll val = gVal[i][j];
				ans += gVal[val][k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int a=1;
  for(int i=0;i<N;i++){
     if(a<K){
       a*=2; 
     }else{
       a+=K;
     }
  }
  cout << a << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
//最大公約数
ll gcd(ll a, ll b){
  if(b == 0)return a;
  else return gcd(b, a % b);
}



int main(){
    int x;
    cin >> x;
    ll lcm = x * 360 / gcd(360, x);
    cout << lcm / x << endl;
}





Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a > b) swap(a,b);
    if (a < c && c < b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//木の連結成分の個数は頂点数ー辺の数

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    int ans=0;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i<j&&j<k){
                    if(l[i]==l[j]||l[j]==l[k]||l[k]==l[i])continue;
                    if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]) ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = s[k-1] - s[0]
for i in range(1,n-k+1):
    if s[i+k-1] - s[i] < c:
        c = s[i+k-1] - s[i]

print(c)

Measured memory_bytes: 7508
#include <iostream>

using namespace std;

int main()
{
    int a,b,w,q,r;
    cin >> a >> b;
    if(b==0 && a==0){
        cout << 0;}
    else {
    r=a*b;
    w=a+b;
    q=a-b;

     if(w>=q && w>=r)
        cout << w;
     else if(q>=w && q>=r)
        cout << q;
     else if(r>=w && r>=q)
     cout << r;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 300010;

bool is_prime[MAX];

void sieve(){
    rep(i, MAX) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    For(i, 2, MAX){
        if(i%7!=1 && i%7!=6) is_prime[i] = false;
        if(is_prime[i]){
            for(int j=2; i*j<MAX; ++j)if(j%7==1 || j%7==6){
                is_prime[i*j] = false;
            }
        }
    }
}

int main(){
    sieve();
    int n;
    while(scanf("%d", &n) && n!=1){
        printf("%d:", n);
        vector<int> ans;
        for(int i=1; i*i<=n; ++i)if(i%7==1 || i%7==6){
            if(n%i == 0){
                if(is_prime[i]) ans.push_back(i);
                if(i*i!=n && is_prime[n/i]) ans.push_back(n/i);
            }
        }
        sort(ans.begin(), ans.end());
        for(int i: ans) printf(" %d", i);
        printf("\n");
    }
}


Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<vector<int>> S(N,vector<int>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin>>S.at(i).at(j);
    }
  }
  int K=S.at(0).at(0); int L=S.at(0).at(1);
  for(int i=0; i<N; i++){
    if(S.at(i).at(1)<L){
      K=S.at(i).at(0);
    L=S.at(i).at(1);
    }
    else continue;
  }
  cout<<L+K<<endl;
}
    


Measured memory_bytes: 8788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <assert.h>
using namespace std;
#define int long long

signed main() {
	int N;
	cin >> N;
	int res = (int)1 << 60;
	for (int i = 1; i*i <= N; i++) {
		if (N % i == 0) {
			res = min(res, i + (N / i) - 2);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let n: i64 = read();
    let mut an = read_vec();
    an.sort();
    an.push(0);

    let mut tmp_max_size: i64 = an.iter().sum();
    let mut i = n;
    let mut ans = 0;
    while 0 <= i {
        tmp_max_size -= an[i as usize];
        if tmp_max_size * 2 >= an[i as usize] {
            ans += 1;
        } else {
            break;
        }
        i -= 1;
    }

    println!("{:?}", ans);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 8444
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,m = mi()
    a = li()
    s = sum(a)
    print(max(n-s,-1))

main()




Measured memory_bytes: 10736
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
const int mod = 1000000009;

struct SegmentTree {
private:
    int n;
    vll node;

public:
    SegmentTree(vll v) {
        ll sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        REP(i,sz) node[i+n-1] = v[i];
        REPN(i,n-2) node[i] = node[2*i+1]+ node[2*i+2];
    }
    void update(int k, ll x){
        k += n-1;
        node[k] = x;
        while(k){
            k = (k-1)/2;
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    ll getsum(int a, int b, int k=0, int l=0, int r=-1){
        if(r<0) r=n;
        if(r<=a || b<=l) return 0;
        if(a<=l && r<=b) return node[k];
        return getsum(a,b,2*k+1,l,(l+r)/2)+getsum(a,b,2*k+2,(l+r)/2,r) ;
    }
};

int n;
vll a;
ll ret,as,bs,cs,ds;
const ll INF = 1LL<<60;

ll calc(){
    if (as == 0 || bs == 0 || cs == 0 || ds == 0) return INF;
    ll mini = min({as,bs,cs,ds});
    ll maxi = max({as,bs,cs,ds});
    return maxi-mini;
}

int main(){
    I(n);
    a.resize(n);
    REP(i,n) LL(a[i]);
    SegmentTree st = SegmentTree(a);

    ret = INF;
    int absep = 1;
    int cdsep = 3;

    FOR(bcsep,2,n){
        as = st.getsum(0,absep);
        bs = st.getsum(absep,bcsep);
        while(absep+1 < bcsep){
            ll ias = st.getsum(0,absep+1);
            ll ibs = st.getsum(absep+1,bcsep);
            if (abs(as-bs) >= abs(ias-ibs)){
                absep++;
                as = ias;
                bs = ibs;
            } else {
                break;
            }
        }
        
        cs = st.getsum(bcsep,cdsep);
        ds = st.getsum(cdsep,n);
        while(cdsep+1 < n){
            ll ics = st.getsum(bcsep,cdsep+1);
            ll ids = st.getsum(cdsep+1,n);
            if (abs(cs-ds) >= abs(ics-ids)){
                cdsep++;
                cs = ics;
                ds = ids;
            } else {
                break;
            }
        }

        ret = min(ret,calc());
    }
    cout << ret << endl;
}

Measured memory_bytes: 7424
#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 Would
#define you
#define please


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


	int N;
	cin >> N;


	pair<int, int> C[200000];
	int A, B;

	rep(i, N) {
		cin >> A >> B;
		C[i] = make_pair(A, i);
		C[i + N] = make_pair(B, i + N);
	}

	sort(C, C + 2 * N);

	ll kotae = 1e18;
	rep (j, 4) {

		int D[200000] = {};
		rep(i, N) {
			D[C[i].second]++;
		}

		int allA = 1;
		int allB = 1;

		int safe = 0;
		rep(i, N) {
			if (D[i] && D[i + N]) safe = 1;
			if (C[i].second < N) allB = 0;
			else allA = 0;
		}
		if (allA || allB) safe = 1;

		ll kekka = 0;
		if (safe) {
			rep(i, N) kekka += C[i].first;
		}
		if (kekka) kotae = min(kotae, kekka);

		switch (j) {
		case 0:
			swap(C[N - 1], C[N]);
			break;
		case 1:
			swap(C[N - 1], C[N]);
			swap(C[N - 1], C[N + 1]);
			break;
		case 2:
			swap(C[N - 1], C[N + 1]);
			swap(C[N - 2], C[N]);
			break;
		case 3:
			break;
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 2688
H, W, M = map(int, input().split())
hw = set(tuple(map(lambda x: int(x) - 1,input().split())) for _ in range(M))

rows = [0] * H
cols = [0] * W
for h, w in hw:
    rows[h] += 1
    cols[w] += 1

max_rows = max(rows)
max_cols = max(cols)

max_rows_indexes = [i for i in range(H) if rows[i] == max_rows]
max_cols_indexes = [i for i in range(W) if cols[i] == max_cols]

duplicate = True
if M >= len(max_rows_indexes) * len(max_cols_indexes):
    for h in max_rows_indexes:
        for w in max_cols_indexes:
            if (h, w) not in hw:
                duplicate = False
                break
        if not duplicate:
            break
else:
    duplicate = False

if duplicate:
    print(max_rows + max_cols - 1)
else:
    print(max_rows + max_cols)


Measured memory_bytes: 83524
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    
    d = defaultdict(int)
    for i in range(1,N+1):
        bot,top = str(i)[0],str(i)[-1]
        d[bot,top] += 1
    
    ans = 0
    for i in range(1,N+1):
        top,bot = str(i)[0],str(i)[-1]
        ans += d[bot,top]    
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 40428
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する

int main(){
    string S;
    llong m;
    llong h;
    while(1){
        cin >> S;
        cin >> m;
        if(S=="-"){
            break;
        }
        for(int i=0; i<m; i++){
            cin >> h;
            S = S.substr(h, S.size()) + S.substr(0, h);
        }
        cout << S << endl;
    }
    return 0;
}


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

namespace AtTest.AGC_033
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            if (n == 1)
            {
                WriteLine("First");
                return;
            }
            List<int>[] graph = new List<int>[n];
            for (int i = 0; i < n; i++) graph[i] = new List<int>();

            for(int i = 0; i < n-1; i++)
            {
                int[] ab = ReadInts();
                int a = ab[0] - 1;
                int b = ab[1] - 1;

                graph[a].Add(b);
                graph[b].Add(a);
            }
            int u = 0;
            bool[] used = new bool[n];
            for(int i = 0; i < n; i++)
            {
                if (graph[i].Count > 1) continue;

                var minQueue = new Queue<int[]>();
                minQueue.Enqueue(new int[2] { i, 1 });
                while (minQueue.Count > 0)
                {
                    int[] val = minQueue.Dequeue();

                    used[val[0]] = true;
                    u = val[0];
                    for(int j = 0; j < graph[val[0]].Count; j++)
                    {
                        if (used[graph[val[0]][j]]) continue;

                        minQueue.Enqueue(new int[2]
                        { graph[val[0]][j], val[1] + 1 });
                    }
                }
                break;
            }

            int length = 0;
            var queue = new Queue<int[]>();
            queue.Enqueue(new int[2] { u, 1 });
            for (int i = 0; i < n; i++) used[i] = false;
            while (queue.Count > 0)
            {
                int[] val = queue.Dequeue();

                used[val[0]] = true;
                length = Max(length, val[1]);
                u = val[0];
                for (int j = 0; j < graph[val[0]].Count; j++)
                {
                    if (used[graph[val[0]][j]]) continue;

                    queue.Enqueue(new int[2]
                    { graph[val[0]][j], val[1] + 1 });
                }
            }

            if ((length-2) % 3 == 0)
            {
                WriteLine("Second");
            }
            else
            {
                WriteLine("First");
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 54304
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int thp = sc.nextInt();
        int tat = sc.nextInt();
        int ahp = sc.nextInt();
        int aat = sc.nextInt();
        for(int i = 0; i < 100; i++){
        	ahp -= tat;
            if(ahp <= 0){
            	System.out.println("Yes");
                break;
            }
            thp -= aat;
            if(thp <= 0){
            	System.out.println("No");
                break;
            }
            
        }
    }
}

Measured memory_bytes: 35716
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp

#include <iostream>
#include <vector>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <sstream>

using namespace std;

int main() {
	string input = "";
	vector<string> data = {};
	getline(cin, input);
	string parseTmp = "";
	for (auto it = input.begin(); it != input.end(); ++it) {
		if (*it == ' ') {
			data.push_back(parseTmp);
			parseTmp = "";
		} else {
			parseTmp.push_back(*it);
		}
	}
	data.push_back(parseTmp);

	vector<int> stack = {};

	for (auto it = data.begin(); it != data.end(); ++it) {
		string c = *it;
		if (c == "+" || c == "-" || c == "*" || c == "/") {
			int num2 = stack.back();
			stack.pop_back();
			int num1 = stack.back();
			stack.pop_back();
			int num =
				(c == "+" ? num1 + num2 :
				(c == "-" ? num1 - num2 :
				(c == "*" ? num1 * num2 :
				(c == "/" ? num1 / num2 : 0))));
			stack.push_back(num);
		} else {
			stringstream ss(c);
			int operand;
			ss >> operand;
			stack.push_back(operand);
		}

	}

	cout << stack.back() << endl;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n];
	vector< pair<ll,ll> > vc;
	ll fl[100001]={0};
	for(i=0;i<n;i++){
		cin>>ar[i];
		fl[ar[i]]++;
	}

	for(i=0;i<100001;i++){
		if(fl[i]>0){
			vc.ps({i,fl[i]});
		}
	}

	if(vc.size()==1){
		cout<<vc[0].sc;
		return 0;
	}
	else if(vc.size()==2){
		if(abs(vc[0].fs-vc[1].fs)<=1){
			cout<<vc[0].sc+vc[1].sc;
		}
		else cout<<(max(vc[0].sc,vc[1].sc));
		return 0;
	}
	ll mx=0;
	for(i=1;i<vc.size()-1;i++){
		k=vc[i].sc+vc[i-1].sc+vc[i+1].sc;
		if(k>mx){
			mx=k;
		}
	}
	cout<<mx;
	return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    long long dp[n];
   for(int i=0;i<n;i++)
   {
        cin>>arr[i];
   }
   dp[0]=0;
   dp[1]=abs(arr[1]-arr[0]);
   for(int i=2;i<n;i++)
   {
       dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
   }
   cout<<dp[n-1];
   return 0;
}


Measured memory_bytes: 1408
def main():
    h,w=map(int,input().split())
    a=[list(input()) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if a[i][j]==".":
                a[i][j]=99999
    ans=0
    import collections
    from copy import deepcopy
    direction=[[0,1],[0,-1],[1,0],[-1,0]]
    for sh in range(h):
        for sw in range(w):
            if a[sh][sw]==99999:
                field=deepcopy(a)
                field[sh][sw]=0
                next_list=collections.deque([[sh,sw]])
                while next_list:
                    n=next_list.popleft()
                    for dx,dy in direction:
                        ny,nx=n[0]+dy,n[1]+dx
                        if 0<=ny<=h-1 and 0<=nx<=w-1 and field[ny][nx]!="#" and field[ny][nx]==99999:
                            field[ny][nx]=field[n[0]][n[1]]+1
                            if field[ny][nx]>ans:
                                ans=field[ny][nx]
                            next_list.append([ny,nx])
    print(ans)
if __name__ == '__main__':
    main()

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

int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  
  vector<int> b(5);
  for(int i=0;i<5;i++){
    if(a[i]%10==0){
      b[i]=a[i];
    }
    else{
    b[i]=(a[i]/10+1)*10;
    }
  }
  
  vector<int> c(5);
  for(int i=0;i<5;i++){
    if(a[i]%10==0){
      c[i]=10;
    }
    else{
      c[i]=a[i]-a[i]/10*10;
    }
  }
  
  sort(c.begin(),c.end());
  
  int sum=0;
  for(int i=0;i<5;i++){
    sum += b[i];
  }
  
  sum -= 10-c[0];
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	ll n, x; cin >> n >> x;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	for(int i=1;i<n;i++)
	{
		a[i] += a[i - 1];
	}
	if (a[n - 1] < x)cout << n - 1 << endl;
	else if(a[n - 1] == x)cout << n << endl;
	else
	{
		rep(i, n) { if (a[i] > x) { n = i; break; } }
		cout << n << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int P[3], J[2];
    int minp = 2000, minj = 2000;

    for(int i = 0; i < 3; i++){
        cin >> P[i];
        if(P[i] < minp) minp = P[i];
    }

    for(int i = 0; i < 2; i++){
        cin >> J[i];
        if(J[i] < minj) minj = J[i];
    }
    cout << (minp + minj - 50) << endl;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<int, int> P;
static const int INF = 2e9;

struct Edge
{
	int to;
	int cost;
};
vector<Edge> G1[5001];
vector<Edge> G2[5001];
int d[5001];
bool isUsed[5001];

void solve()
{
	int N, K;
	cin >> N >> K;
	vector<int> C(N);
	vector<int> R(N);
	for (int i = 0; i < N; ++i)
	{
		scanf("%d %d", &C[i], &R[i]);
//		cin >> C[i] >> R[i];
	}
	for (int i = 0; i < K; ++i)
	{
		int from, to;
		Edge e1, e2;
		cin >> from >> to;
		--from; --to;
		e1.to = to;
		e1.cost = 1;
		e2.to = from;
		e2.cost = 1;
		G1[from].push_back(e1);
		G1[to].push_back(e2);
	}
	for (int i = 0; i < N; ++i)
	{
		memset(isUsed, 0, sizeof(isUsed));
		queue<P> que;
		que.push(P(i, R[i]));
		isUsed[i] = true;
		while (!que.empty())
		{
			P p = que.front();
			que.pop();
			int v = p.first;
			for (int j = 0; j < G1[v].size(); ++j)
			{
				int to = G1[v][j].to;
				if (!isUsed[to] && p.second >= 1)
				{
					isUsed[to] = true;
					que.push(P(to, p.second - 1));
					Edge e;
					e.to = to;
					e.cost = C[i];
					G2[i].push_back(e);
				}
			}
		}
	}

	for (int i = 0; i < N; ++i)
	{
		d[i] = INF;
	}
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	d[0] = 0;
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.first;
		for (int i = 0; i < G2[v].size(); ++i)
		{
			Edge e = G2[v][i];
			if (d[e.to] > p.second + e.cost)
			{
				d[e.to] = p.second + e.cost;
				pque.push(P(e.to, d[e.to]));
			}
		}
	}
	cout << d[N - 1] << endl;
}

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

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

int main() {
vector<int> vec(5);
for (int i = 0; i < 5; i++) {
    cin >> vec[i];
    }
for (int i = 0; i < 5; i++) {
    if (vec[i] == 0) {
        cout << i + 1 << endl;
        }
    }
}


Measured memory_bytes: 3624
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int n,m;
vector<int>e[maxn];
int ans[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  queue<int>q;
  q.push(1);
  ans[1] = 1;
  while(!q.empty()){
    int x = q.front();
    q.pop();
    for(int i=0;i<e[x].size();i++){
      int v = e[x][i];
      if(ans[v])continue;
      ans[v] = x;
      q.push(v);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=2;i<=n;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 10364
main(c,t){double*p=t,v;for(;t=c&2&&printf("%f\n",v),~scanf("%s%c",&t,&c);)v=t<48?*--p=t&1?t&2?t&4?*p/v:*p+v:*p-v:*p*v:(*++p=atoi(&t));}

Measured memory_bytes: 0
//https://arc093.contest.atcoder.jp/tasks/arc093_c

#include<bits/stdc++.h>
const int N = 2005;
const int mod = 1e9 + 7;
using namespace std;

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

vector <iii> edge;

int po(int k){
    int x = 2, ans = 1;
    while (k){
        if (k&1) ans = 1LL * ans * x % mod;
        x = 1LL * x * x % mod;
        k >>= 1;
    }
    return ans;
}

int n, m;
long long x;

struct {
    int p[N], cnt, n;
    void init(int _n) {n = _n; for (int i = 1; i <= n; i++) p[i] = i; cnt = n;}
    int findset(int i) {return ((p[i] == i) ? i : p[i] = findset(p[i]));}
    bool dsu(int i, int j, bool x){
        i = findset(i); j = findset(j);
        if (i == j) return false;
        if (x) p[i] = j, cnt--;
        return true;
    }
} A, B;

int solve(long long Max){
    B.init(m);
    for (int i = 0; i < m; i++){
        A.init(n);
        long long cost = edge[i].first;
        A.dsu(edge[i].second.first, edge[i].second.second, 1);
        for (int j = 0; j < m; j++) {
            if (A.dsu(edge[j].second.first, edge[j].second.second, 1)) {
                cost += edge[j].first;
            }
        }
        if (cost >= Max) continue;
        A.init(n);
        for (int j = 0; j < m; j++) {
            int x = edge[j].first, k = j;
            while (k < m && edge[k].first == x) {
                if (A.dsu(edge[k].second.first, edge[k].second.second, 0)) B.dsu(i+1, k+1, 1);
                k++;
            }
            while (j < m && edge[j].first == x) A.dsu(edge[j].second.first, edge[j].second.second, 1), j++; j--;
        }
    }
    return po(B.cnt);
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cin >> x;
    for (int i = 1; i <= m; i++) {
        int u, v, c; cin >> u >> v >> c;
        edge.push_back(iii(c, ii(u, v)));
    }
    sort(edge.begin(), edge.end());
    solve(x);
    int ans = solve(x) - solve(x+1);
    if (ans < 0) ans += mod;
    cout << ans;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a-1)==0){
		cout<<"Borys"<<endl;
	}
	else if((b-a-1)%2!=0){
		cout<<"Alice"<<endl;
	}
	
	else if((b-a-1)%2==0){
		cout<<"Borys"<<endl;
	}
	
	
}

Measured memory_bytes: 256