akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
using Graph = vector< vector<int> >;
using ll = long long int;

const int INF = 1 << 29;
int dist_st;

vector<int> calc_dist(const Graph &G, int s, int t) {
    int N = G.size();
    vector<int> dist(N, INF);
    dist[s] = 0;
    
    queue<int> que;
    que.emplace(s);
    while(que.size()) {
        int cur = que.front(); que.pop();
        for(auto to : G[cur]) {
            if(dist[to] > dist[cur] + 1) {
                dist[to] = dist[cur] + 1;
                que.emplace(to);
            }
        }
    }

    dist_st = dist[t];
    vector<int> min_dist(N+1);
    for(int i=0; i<N; i++) if(dist[i] <= N) min_dist[ dist[i] ]++;
    return min_dist;
}

int main() {
    int N, M, s, t; cin >> N >> M >> s >> t; s--; t--;
    Graph G(N);
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v; u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    vector<int> ds = calc_dist(G, s, t), dt = calc_dist(G, t, s);
    
    ll ans = 0;
    for(int i=0; i<=N; i++) {
        int target = dist_st - 2 - i;
        if(target < 0) continue;
        ans += 1LL * ds[i] * dt[target];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10600
#include <stdio.h>

int main()
{
        // 入力用変数
        int N, D;

        // 出力用変数
        int out;

        // 入力
        scanf("%d %d", &N, &D);

        // 計算
        out = N / ((D * 2) + 1);
        if ((N %  ((D * 2) + 1)) != 0) {
                out++;
        }

        // 出力
        printf("%d\n", out);

        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int N,L;
int ice[100010];
int dp[100010];

int solve(int pos){
  if(dp[pos] != -1) return dp[pos];
  int ret = 0;
  if(pos > 0 && ice[pos-1] > ice[pos]) ret = max(ret,solve(pos-1));
  if(pos < N - 1 && ice[pos+1] > ice[pos]) ret = max(ret,solve(pos+1));
  return dp[pos] = ret + (L - ice[pos]);
}

int main(){
  cin >> N >> L;
  for(int i=0;i<N;i++){
    cin >> ice[i];
  }
  int ret = 0;
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<N;i++){
    ret = max(ret,solve(i));
  }
  cout << ret << endl;
}
    

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

using namespace std;

const int MAX = 101;
vector<int> V[MAX];
vector<int> Leak;
int N;


void solve(){
  sort(Leak.begin(),Leak.end());
  int ans = 0;
  for(int i = 1; i <= N; i++){
    bool flg = true;
    sort(V[i].begin(),V[i].end());
    for(int j = 0; j < Leak.size(); j++)
      if(!binary_search(V[i].begin(),V[i].end(),Leak[j])){
	flg = false;
	break;
      }
    if(flg && !ans) ans = i;
    else if(flg) ans = -1;
  }
  if(ans == 0) ans = -1;
  cout << ans << endl;
}

void init(){
  for(int i = 0; i < MAX; i++)
    V[i].clear();
  Leak.clear();
}
int main(){
  while(cin >> N && N){
    init();
    int in;
    for(int i = 1; i <= N; i++){
      int num;
      cin >> num;
      for(int j = 0; j < num; j++){
	cin >> in;
	V[i].push_back(in);
      }
    }
    cin >> in;
    while(in--){
      int a;
      cin >> a;
      Leak.push_back(a);
    }
    solve();
  }
  return 0;
}

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

using namespace std;

void solve()
{
	int H, W;
	cin >> H >> W;
	vector< vector<char> > field((H), vector<char>(W));
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> field[i][j];
		}
	}
	for (int i = 0; i < H; ++i)
	{
		bool isCloudExist = false;
		int count = -1;
		for (int j = 0; j < W; ++j)
		{
			if (field[i][j] == 'c')
			{
				cout << 0;
				count = 0;
				isCloudExist = true;
			}
			else if (field[i][j] == '.')
			{
				if (isCloudExist)
				{
					cout << count;
				}
				else
				{
					cout << -1;
				}
			}
			if (isCloudExist)
			{
				++count;
			}
			if (j != W - 1)
			{
				cout << " ";
			}
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 1228
package main

import "fmt"

type op struct {
	rev, front bool
	c          byte
}

func rev(s string) string {
	r := make([]byte, len(s))
	i, j := len(s)-1, 0
	for i >= 0 {
		r[j] = s[i]
		j++
		i--
	}
	return string(r)
}

func main() {
	var S string
	fmt.Scan(&S)
	var Q int
	fmt.Scan(&Q)
	ops := make([]op, Q)
	for i := 0; i < Q; i++ {
		var q int
		fmt.Scan(&q)
		if q == 1 {
			ops[i].rev = true
		} else {
			var f int
			fmt.Scanf("%d %c", &f, &ops[i].c)
			if f == 1 {
				ops[i].front = true
			}
		}
	}
	sum := make([]int, Q+1)
	for i := Q - 1; i >= 1; i-- {
		if ops[i].rev {
			sum[i-1] = sum[i] + 1
		} else {
			sum[i-1] = sum[i]
		}
	}
	// fmt.Println("S", S, "Q", Q, "ops", ops, "sum", sum)
	if sum[0]%2 == 1 {
		S = rev(S)
	}
	//F := make([]byte, 4*int(1e5)+10)
	//B := make([]byte, 4*int(1e5)+10)
	F := make([]byte, 2*Q+5)
	B := make([]byte, 2*Q+5)
	j, k := len(F)/2, len(B)/2
	for i := 0; i < Q; i++ {
		if !ops[i].rev { // 反転ではない(文字列追加)
			if ops[i].front {
				if sum[i]%2 == 1 {
					B[j] = ops[i].c
					j++
				} else {
					F[k] = ops[i].c
					k--
				}
			} else {
				if sum[i]%2 == 1 {
					F[k] = ops[i].c
					k--
				} else {
					B[j] = ops[i].c
					j++
				}
			}
		}
	}
	var FF []byte
	var BB []byte
	for i := 0; i < len(F); i++ {
		if F[i] > 0 {
			FF = append(FF, F[i])
		}
	}
	for i := 0; i < len(B); i++ {
		if B[i] > 0 {
			BB = append(BB, B[i])
		}
	}
	fmt.Println(string(FF) + S + string(BB))
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
  	if (n + a > b + c) cout << "Left";
  	else if (n + a < b + c) cout << "Right";
  	else cout << "Balanced";
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    B = ZZ()
    if A == B:
        print('Yes')
        return
    sa, sb = sum(A), sum(B)
    if sa >= sb:
        print('No')
        return

    numDo = sb - sa
    x = y = 0
    for a, b in zip(A, B):
        if a > b: x += (a - b)
        elif a < b: y += (b-a+1)//2
    print('Yes' if x <= numDo and y <= numDo else 'No')

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int n;
  while(cin>>n,n){
    int a[101][101];
    bool u1[101][101]={};
    bool u2[101][101]={};
    REP(y,n)REP(x,n)cin>>a[y][x];
    REP(y,n){
      int tmp = a[y][0];
      REP(x,n)tmp = min(tmp,a[y][x]);
      REP(x,n)if(tmp==a[y][x])u1[y][x] = true;
    }
    REP(x,n){
      int tmp = a[0][x];
      REP(y,n)tmp = max(tmp,a[y][x]);
      REP(y,n)if(tmp==a[y][x])u2[y][x] = true;
    }
    int ans = 0;
    REP(y,n)REP(x,n)if(u1[y][x]&&u2[y][x])ans = a[y][x];
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#define EPS 1e-5
#include<cmath>
using namespace std;
typedef long long LL;
typedef long double LD;
LL A[200002];
LL N;
LD f(LD x)
{
	LD total = 0;
	for(int i = 1; i <= N; i++)
		total += fabs(A[i]-x);
	return total;
}
LL my_abs(LL n)
{
	return n < 0 ? -n : n;
}
LL f(LL x)
{
	LL total = 0;
	for(int i = 1; i <= N; i++)
		total += my_abs(A[i]-x);
	return total;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	for(int i = 1; i <= N; i++)
	{
		cin >> A[i];
		A[i] -= i;
	}

	LD L = -10000000000;
	LD R = 10000000000;
	while(fabs(R-L) > EPS)
	{
		LD M1 = L + (R-L)/3;
		LD M2 = R - (R-L)/3;
		if(f(M1) > f(M2))
			L = M1;
		else
			R = M2;
	}
	LL ace = floor(L);
	LL best = 10000000000000000;
	for(LL n = ace-2; n <= ace+2; n++)
		best = min(best,f(n));
	cout<<best<<endl;
	cout<<flush;
	return 0;
}
/*

*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	string S;
	cin>>S;
	
	vector<int> cnt(3,0);
	for(int i=0;i<S.size();i++){
		cnt[S[i]-'a']++;
	}
	
	string x = "abc";
	
	do{
		vector<int> C = cnt;
		for(int i=0;i<S.size();i++){
			int c = x[i%3] - 'a';
			C[c]--;
		}
		if(C[0]==0&&C[1]==0&&C[2]==0){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	while(next_permutation(x.begin(),x.end()));
	
	cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;

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

    ll ans = 1;
    while(H > 0){
        H /= 2;
        ans *= 2;
    }
    ans--;
    cout << ans << endl;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	string s;
	int l = 0;
	cin >> a >> b;
	for(int i=a; i<=b; i++){
		s = to_string(i);
		if(s[0]==s[4] && s[1]==s[3]) l++;
	}
	cout << l << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  int N; cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  vector<int> dp(200010);
  dp[N] = a[N-1];
  for(int i = N-1; i >= 1; i--){
    int sum = 0;
    int t = 2;
    while(i * t <= N){
      sum += dp[i * t];
      t++;
    }
    if(sum % 2 == 0){
      dp[i] = a[i-1];
    }
    else dp[i] = 1 - a[i-1];
  }
  vector<int> ans;
  repr(i,1,N+1){
    if(dp[i] == 1) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) cout << ans[i] << endl;
  
}
   

Measured memory_bytes: 3192
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for adx in range(a+1):
    for bdx in range(b+1):
        for cdx in range(c+1):
            if(adx * 500 + bdx * 100 + cdx * 50 == x):
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
using namespace std;
int l,r,ans=2e9;
int main(){
	scanf("%d%d",&l,&r);
	if(r-l+1>=2019)cout<<"0"<<endl;
	else{
		r=r%2019;
		l=l%2019;
		if(r<l)cout<<"0"<<endl;
		else{
			for(int i=l;i<=r;i++)
				for(int j=i+1;j<=r;j++)
					ans=min(ans,i*j%2019);
			cout<<ans<<endl;
		}
	}
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , x;

int main()
{
    _FastIO;
    int ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        while(x % 2 == 0){
            x /= 2;
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

auto solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    int res = 0;
    for(int i=0; i<n; i++) {
        while(a[i] > 0 && a[i] % 2 == 0) {
            res++;
            a[i] /= 2;
        }
    }

    cout << res << endl;
}


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


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    if(c <= b && a <= c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	string s ; cin >> s;
	int cnt = 0;
	rep(i, 3)
	{
		if (s[i] == 'o')
			cnt++;
	}

	cout << 100*cnt + 700 << endl;
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll L, R;
    cin >> L >> R;

    if(R - L >= 2019) {
        out(0);
        re0;
    }

    ll ans = 2019;
    exrep(i, L, R-1) {
        exrep(j, i+1, R) {
            chmin(ans, (i*j)%2019);
        }
    }
    
    out(ans);
    re0;
}

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


int main(){
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		int s=0;
		for(int j=0;j<m;j++){
			int a;
			cin>>a;
			s+=a;
		}
		ans=max(ans,s);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 100010
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long

int n;
int ara[SZ];

int main()  {
//    freopen("in.txt", "r", stdin);
    cin >> n;
    FOR(i, 0, n - 1)   {
        cin >> ara[i];
    }
    int gcd = ara[0];
    FOR(i, 1, n)   {
        gcd = __gcd(gcd, ara[i]);
    }
    cout << gcd << "\n";
    return 0;
}
/**
*/


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

using namespace std;

int main(){
    int n; cin >> n;
    int ans = 0;

    for(int i = 1; i <= n; i++){
        int cnt = 0;
        if(i % 2 != 0){
            for(int j = 1; j <= i; j++){
                if(i % j == 0){
                    cnt++;
                }
            }
        }
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
}

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

vector<P>E[100000];
int d[100000];
P G[200000];
int s[100000], t[100000], l[100000], r[100000];
vector<int>x[200000];

int par[100000];
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x != y)par[x] = y;
}
int main() {
	int n, m, k, q; scanf("%d%d%d%d", &n, &m, &k, &q);
	rep(i, m) {
		int a, b, l; scanf("%d%d%d", &a, &b, &l); a--; b--;
		E[a].push_back(P(l, b)); E[b].push_back(P(l, a));
		G[i] = P(a, b);
	}
	memset(d, 0x3f, sizeof(d));
	priority_queue<P, vector<P>, greater<P>>que;
	rep(i, k) {
		int f; scanf("%d", &f); f--;
		d[f] = 0; que.push(P(0, f));
	}
	while (!que.empty()) {
		P p = que.top(); que.pop();
		if (d[p.second] != p.first)continue;
		for (P u : E[p.second]) {
			if (d[u.second] > p.first + u.first) {
				d[u.second] = p.first + u.first;
				que.push(P(d[u.second], u.second));
			}
		}
	}
	sort(G, G + m, [](P a, P b) {
		return min(d[a.first], d[a.second]) > min(d[b.first], d[b.second]);
	});
	rep(i, q) {
		scanf("%d%d", &s[i], &t[i]); s[i]--; t[i]--;
		r[i] = m - 1;
	}
	rep(k, 18) {
		rep(i, m)x[i].clear();
		rep(i, n)par[i] = i;
		rep(i, q)x[(l[i] + r[i]) / 2].push_back(i);
		rep(i, m) {
			unite(G[i].first, G[i].second);
			for (int j : x[i]) {
				if (find(s[j]) == find(t[j]))r[j] = i;
				else l[j] = i + 1;
			}
		}
	}
	rep(i, q)printf("%d\n", min(d[G[l[i]].first], d[G[l[i]].second]));
}

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

int a[4];

int main()
{
	for(int i=1;i<=3;i++) cin>>a[i];
	sort(a+1,a+4);
	if(a[1]+a[2]==a[3]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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


int main() {

    int n,k; cin >> n >> k;
    int r,s,p; cin >> r >> s >> p;
    ll ans = 0;
    string t; cin >> t;
    vector<ll>h(100001,-1);
    int ppos = 100000,spos = 100000,rpos = 100000;

    rep(i,t.length()){
        if(i < k){
            if(t[i] == 'p'){
                ans += s;
                h[i] = 0;
            }else if(t[i] == 's'){
                ans += r;
                h[i] = 1;
            }else if(t[i] == 'r'){
                ans += p;
                h[i] = 2;
            }
        }else{
            if(t[i] == 'p' && h[i-k] != 0){
                h[i] = 0;
                ans += s;
            }else if(t[i] == 's' && h[i-k] != 1){
                h[i] = 1;
                ans += r;
            }else if(t[i] == 'r' && h[i-k] != 2){
                h[i] = 2;
                ans += p;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
int main(void){
    string str;
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(i==3) cout<<"8";
        else cout<<str[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int a, b, c;
  cin>>a>>b>>c;

  cout << (b-a == c-b ? "YES" : "NO") << LF;

  return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<int[]> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int[] c = new int[26];
            for (int j = 0; j < s.length(); j++) {
                c[s.charAt(j) - 'a'] += 1;
            }
            list.add(c);
        }
        int[] s1 = list.get(0);
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < list.size(); i++) {
            int[] s = list.get(i);
            for (int j = 0; j < s.length; j++) {
                s1[j] = Math.min(s1[j], s[j]);
            }
        }
        for (int i = 0; i < s1.length; i++) {
            int num = s1[i];
            for (int j = 0; j < num; j++) {
                sb.append(Character.toChars(i + 'a'));
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 22996
#include <stdio.h> 
 
 int main(void){ 
     int a, b, d, r; 
     double f; 
     scanf("%d %d", &a, &b); 
     d=a/b; 
     r=a%b; 
     f=(double)a/(double)b; 
      printf("%d %d %f\n", d, r, f); 
     return 0; 
 } 



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

int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


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

using namespace std;

const int N = 2e5 + 5;

struct point {
    int x, y, id;
} a[N];

bool cmp1(const point& a, const point& b) {
    if (a.x != b.x) {
        return a.x < b.x;
    }
    return a.y < b.y;
}

bool cmp2(const point& a, const point& b) {
    if (a.y != b.y) {
        return a.y < b.y;
    }
    return a.x < b.x;
}

int n;
bool visited[N];
vector<pair<long long, int> > g[N];

long long prim(int x) {
    priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > pq;
    long long ans = 0;
    pq.push({0, x});
    while(!pq.empty()) {
        pair<long long, int> p = pq.top();
        pq.pop();
        x = p.second;
        if (visited[x]) {
        	continue;
		}
        ans += p.first;
        visited[x] = true;
        for(int i = 0; i < g[x].size(); i++) {
            int y = g[x][i].second;
            if (!visited[y]) {
            	pq.push(g[x][i]);
            }
        }
    }
    return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
		a[i].id = i + 1;
	}
	sort(a, a + n, cmp1);
	for (int i = 1; i < n; i++) {
		g[a[i].id].push_back({abs(a[i].x - a[i - 1].x), a[i - 1].id});
		g[a[i - 1].id].push_back({abs(a[i].x - a[i - 1].x), a[i].id});
	}
	sort(a, a + n, cmp2);
	for (int i = 1; i < n; i++) {
		g[a[i].id].push_back({abs(a[i].y - a[i - 1].y), a[i - 1].id});
		g[a[i - 1].id].push_back({abs(a[i].y - a[i - 1].y), a[i].id});
	}
	cout << prim(1) << '\n';
	return 0;
}


Measured memory_bytes: 17524
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
const int Max=1e5+8;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
ll n,m,f,l;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}

int mem[209][209][209],k;
        string st,st2;

void init()
{
    memset(mem,-1,sizeof mem);
}
/////////////////////////////////////////////////////////////////////
int solve (int i=0,int t=0,int j=n )
{

}

int main()
{

    int T=1;
///T=D();
    while(T-->0)
    {
       cin>>st;
       n=st.size();
       int ans=0;
       for(int i =0;i<n;i++)
        ans+=(st[i]-'0');
       (ans%9)?cout<<"No":cout<<"Yes";



    }

}


Measured memory_bytes: 3732
while 1:
  n,m=map(int,raw_input().split())
  if n==0&m==0:break
  G=range(1,n+1)
  while n>1:
    if m%n==0:G=G[:n-1]
    else:G=G[m%n:]+G[:(m-1)%n]
    n-=1
  print G[0]

Measured memory_bytes: 4236
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll k;
    cin >> k;
    ll l=9*k;
    if(l%7==0)l/=7;
    ll j = 10;
    REP(i,1000000){
        if((j-1)%l==0){
            cout << i+1 << endl;
            return 0;
        }
        j=j*10%l;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}


fn main() {
    let n: usize = input();
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vector: Vec<String> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let s: Vec<char> = vector[0].chars().collect();
    let t: Vec<char> = vector[1].chars().collect();
    for i in 0..n {
        print!("{}", s[i]);
        print!("{}", t[i]);
    }    
    println!();
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    P p[200005];
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }
    sort(p, p + n);
    P l = p[0], h = p[0];
    int ans = 0;
    for(int i = 1; i < n; i++){
        ans = max(ans, max(abs(p[i].first - l.first) + abs(p[i].second - l.second), 
                           abs(p[i].first - h.first) + abs(p[i].second - h.second)));
        if(p[i].first + p[i].second < l.first + l.second) l = p[i];
        if(p[i].second - p[i].first > h.second - h.first) h = p[i];
    }
    cout << ans << endl;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    double a, b, c, r;
    cin >> a >> b >> c;

    if (a * a * b / 2 <= c)
    {
        r = atan(2 * (a * a * b - c) / (a * a * a));
    }
    else
    {
        r = M_PI / 2 - atan(2 * c / (a * b * b));
    }

    double ans = r * 180 / M_PI;
    cout << Fixed(10) << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	int cnt = 1, c = 0;
	while(cnt < b)
	{
		cnt += a - 1;
		c++; 
	}
	cout << c << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define TC cin>>t;while(t--)
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;

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

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<sum<<nl;
}

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

int n;

void f(string s, int i) {
  if(s.size() == n) {
    cout << s << endl;
    return;
  }
  for(int j = 1; j <= i + 1; j++) {
    string ns = s + (char)('a' + j - 1);
    f(ns, max(i, j));
  }
}

int main() {
  cin >> n;
  f("a", 1);
}

Measured memory_bytes: 1536
n = int(input())
a = list(map(int, input().split()))

minus_counter = 0
for i in range(n):
    if a[i] < 0:
        minus_counter += 1
        a[i] = -a[i]

if minus_counter % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2 * min(a))

Measured memory_bytes: 19936
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
    int l,i,flg1,flg2,cnt1,cnt2;
	char s[11];
    cin>>s;
	flg1=0;
	flg2=0;
	cnt1=0;
	cnt2=0;
	l=strlen(s);
	if(s[0]=='A') flg1=1;
	for(i=0;i<l;i++){
		if(s[i]>='a' && s[i]<='z') cnt1=cnt1+1;
	}
	for(i=2;i<l-1;i++){
		if(s[i]=='C'){
			flg2=1;
			cnt2=cnt2+1;
		}
	}
	if(s[1]=='C') flg2=0;
	if(s[l]=='C') flg2=0;
	if(cnt1!=l-2) flg2=0;
	if(cnt2>1) flg2=0;
	if(flg1==1 && flg2==1) cout<<"AC"<<endl;
	else cout<<"WA"<<endl;

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n), b(n);
    ll asum=0, bsum=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        asum+=a[i];
    }
    for(int i=0; i<n; i++){
        cin>>b[i];
        bsum+=b[i];
    }

    if(asum>bsum){
        cout << "No" << endl;
    }
    else{
        ll agap=0, bgap=0;
        for(int i=0; i<n; i++){
            if(a[i]<b[i]){
                agap+=(b[i]-a[i]+1)/2;
            }
            else if(a[i]>b[i]){
                bgap+=a[i]-b[i];
            }
        }

        if(agap<=bsum-asum && bgap<=bsum-asum){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,n,sum=0,x,i=1;
	cin>>a>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		sum=sum+x;
	}
	if(sum>a)
	cout<<-1<<endl;
	else
	cout<<a-sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
//submitted by: Het Shah

#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5;
int n,m;
int p[N];

int main(){
   
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        p[a]++;
        p[b]++;
    }  

    int ok=1;
    for (int i=1;i<=n;i++){
        if(p[i]%2)
            ok=0;
    }

    if(ok)
        cout<<"YES";
    else cout<<"NO";
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    string s;cin>>s;
    ll n=s.size();
    ll ans=0;
    ll na=0,nb=0;
    for(int i=0;i<n;){
        if(s[i]=='A'){
            na++;
            i++;
        }
        else if(i+1<n&&s[i]=='B'&&s[i+1]=='C'){
            ans+=na;
            i+=2;
        }
        else{
            na=0;
            i++;
        }
            
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

void conv(int n, int a[10])
{
	for(int i=0;i<10;i++)
	{
		a[i]=n%2;
		n=n/2;
	}
}

int main(void)
{
	int n,s;
	while(cin>>n>>s)
	{
		if(n==0&&s==0)
		{
			break;
		}
		int x,y,z[10],ans;
		ans=0;
		for(int i=0;i<1024;i++)
		{
			x=y=0;
			conv(i,z);
			for(int j=0;j<10;j++)
			{
				if(z[j]==1)
				{
					x++;
					y+=j;
				}
			}
			if(x==n&&y==s)
			{
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;

int a[maxn],n,c,k;

int main()
{
	scanf("%d %d %d",&n,&c,&k);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int ans = 1;
	int ed = a[1] + k,cnt = 1;
	for(int i = 2;i <= n;i++)
	{
		if(a[i] > ed || cnt == c) {ans++;ed = a[i]+k;cnt = 0;}
		cnt++;
		//printf("i = %d cnt = %d ans = %d\n",i,cnt,ans);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#define INF 1e9
using namespace std;

int main() {
	int N, tempsum = 0;
	cin >> N;
	int w[N];
	int cache[N] = {};
	int ans = INF;
	for (int i  = 0; i < N; ++i) {
		cin >> w[i];
		tempsum+=w[i];
		cache[i] = tempsum;
	}
	for (int i = 0; i < N; ++i) {
		tempsum = min(abs(2*cache[i]-cache[N-1]),tempsum);
	}
	cout << tempsum << endl;
	return 0;
}

Measured memory_bytes: 256
def myAnswer(N:int,M:int,X:list) -> int:
   if (M == 1): return 0
   if(N == 1): return max(X) - min(X)
   X.sort()
   sub = []
   pre = X[0]
   for n in range(1,M):
      sub.append(X[n] - pre)
      pre = X[n]
   sub.sort(reverse =True)
   return sum(sub[N-1:])

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   X = list(map(int,input().split()))
   print(myAnswer(N,M,X[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 13968
#include <stdio.h>
#include <stdlib.h>
int row(int x[3][3])
{
    int a,b,c;
    for(int i=0;i<2;i++)
    {
        a=x[i][0]-x[i+1][0];
        b=x[i][1]-x[i+1][1];
        c=x[i][2]-x[i+1][2];
        while(!(a==b&&b==c))
        return 0;
    }
    return 1;
}
int line(int x[3][3])
{
    int a,b,c;
    for(int i=0;i<2;i++)
    {
        a=x[0][i]-x[0][i+1];
        b=x[1][i]-x[1][i+1];
        c=x[2][i]-x[2][i+1];
        while(!(a==b&&b==c))
        return 0;
    }
    return 1;
}

int main()
{
    int c[3][3];
    for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    scanf("%d",&c[i][j]);
    if(row(c)&&line((c)))
    printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

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

	for _, v := range b {
		for i, w := range a {
			if v == w {
				ans[i] = true
			}
		}
	}

	if bingo(ans) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func bingo(a []bool) bool {
	w := 3
	for x := 0; x < w; x++ {
		if a[x*w+0] && a[x*w+1] && a[x*w+2] {
			return true
		}
		if a[x+w*0] && a[x+w*1] && a[x+w*2] {
			return true
		}
	}
	if a[0] && a[1*w+1] && a[2*w+2] {
		return true
	}
	if a[2] && a[1*w+1] && a[2*w+0] {
		return true
	}
	return false
}


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

int main()
{
    string S,T,U;
    int A,B;

    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(U==S)
    {
        A--;
        cout<<A<<" "<<B<<endl;
        return 0;
    }
    else
    {
        B--;
        cout<<A<<" "<<B<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
N,M = map(int, input().split())
drink = [list(map(int,input().split())) for _ in range(N)]
cost = 0
drink.sort()

for i in range(N):
    if M > 0:
        if M-drink[i][1]>0:
            cost += drink[i][0]*drink[i][1]
            M -= drink[i][1]
        else:
            cost += drink[i][0]*M
            M = 0
print(cost)

Measured memory_bytes: 27756
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer flush()

	H := readInt()
	W := readInt()
	Ch := readInt() - 1
	Cw := readInt() - 1
	Dh := readInt() - 1
	Dw := readInt() - 1
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	t := make([][]int, H)
	for i := 0; i < H; i++ {
		t[i] = make([]int, W)
		for j := 0; j < W; j++ {
			if S[i][j] == '#' {
				t[i][j] = -1
			} else {
				t[i][j] = math.MaxInt64
			}
		}
	}

	warpCount := 0
	t[Ch][Cw] = warpCount
	q := make([][2]int, 0, 1024)
	q = append(q, [2]int{Ch, Cw})

	warpq := make([][2]int, 0, 1024)
	for len(q) != 0 {
		for len(q) != 0 {
			warpq = append(warpq, q[0])
			h, w := q[0][0], q[0][1]
			q = q[1:]
			if h-1 >= 0 && t[h-1][w] > warpCount {
				q = append(q, [2]int{h - 1, w})
				t[h-1][w] = t[h][w]
			}
			if h+1 < H && t[h+1][w] > warpCount {
				q = append(q, [2]int{h + 1, w})
				t[h+1][w] = t[h][w]
			}
			if w-1 >= 0 && t[h][w-1] > warpCount {
				q = append(q, [2]int{h, w - 1})
				t[h][w-1] = t[h][w]
			}
			if w+1 < W && t[h][w+1] > warpCount {
				q = append(q, [2]int{h, w + 1})
				t[h][w+1] = t[h][w]
			}
		}

		if t[Dh][Dw] != math.MaxInt64 {
			break
		}

		warpCount++
		for i := 0; i < len(warpq); i++ {
			h, w := warpq[i][0], warpq[i][1]
			for i := max(0, h-2); i <= min(H-1, h+2); i++ {
				for j := max(0, w-2); j <= min(W-1, w+2); j++ {
					if t[i][j] <= warpCount {
						continue
					}
					t[i][j] = warpCount
					q = append(q, [2]int{i, j})
				}
			}
		}
		warpq = warpq[:0]
	}

	if t[Dh][Dw] == math.MaxInt64 {
		println(-1)
	} else {
		println(t[Dh][Dw])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
int main() {
  int mx[3][3];
  for (int i = 0; i < 3; ++i) {
   	 for (int j = 0; j < 3; ++j) {
    	cin >> mx[i][j];	 
   	}
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
     int b;
     cin >> b;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) { 
      	if (mx[i][j] == b) mx[i][j] = 0;
      }
    }
  }
  if (mx[0][0]+mx[0][1]+mx[0][2] == 0
        || mx[0][0]+mx[1][0]+mx[2][0] == 0
        || mx[0][2]+mx[1][2]+mx[2][2] == 0
        || mx[2][0]+mx[2][1]+mx[2][2] == 0
        || mx[1][0]+mx[1][1]+mx[1][2] == 0
        || mx[0][1]+mx[1][1]+mx[2][1] == 0
        || mx[0][0]+mx[1][1]+mx[2][2] == 0
        || mx[0][2]+mx[1][1]+mx[2][0] == 0) {
            cout << "Yes";
  }
    else cout << "No";
 return 0;  
}

Measured memory_bytes: 256
package main


import (
	"fmt"
	"io"
	"math"
	"os"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(stdin io.Reader, stdout io.Writer) {
	var a, b int
	fmt.Fscanf(stdin, "%d%d", &a, &b)
	ans := int(math.Max(float64(a*b), math.Max(float64(a+b), float64(a-b))))
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main(){
	int n,q;
	cin >> n >> q;
	dsu d(n+1);
	for(int i = 0; i < q; i++){
		int t,a,b; cin >> t >> a >> b;
		if(t==0){
			d.merge(a,b);
		}else{
			cout << d.same(a,b) << "\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
int a[15][15];
int n,d;
int main()
{
    //init();
    //freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&d);
    for(int i=0;i<n;++i)
        for(int j=0;j<d;++j)
        scanf("%d",&a[i][j]);
    int ans=0,tmp=0;
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            tmp=0;
            for(int k=0;k<d;++k)
            {
                tmp+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            if((int)sqrt(tmp)*(int)sqrt(tmp)==tmp)ans++;
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;
    ll fac[N],facinv[N];ll C(int n,int m){return n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}

    int n,a[N];
    bool solve()
    {
        int c0=0,c1=0;fo(i,1,n) if(a[i]&1) c1++; else c0++;
        if(c0&1) return 1;
        assert(c1);
        if(c1==1) fo(i,1,n) if(a[i]&1) {
            if(a[i]==1) return 0;//debug
            a[i]--;
            int d=0;fo(j,1,n) d=gcd(d,a[j]);fo(j,1,n) a[j]/=d;
            return solve()^1;
        }
        return 0;
    }
	void main()
	{
        fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
        facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;

        n=qread();fo(i,1,n) a[i]=qread();puts(solve()?"First":"Second");
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 18176
#B
n,m = [int(i) for i in input().split()]
xs = []
ys = []
for _ in range(m):
    x,y = [int(i) for i in input().split()]
    xs.append(x)
    ys.append(y)
    
counts = [1] * n
possible = [1] + [0]*(n-1)

for i in range(m):
    x = xs[i]
    y = ys[i]
    
    counts[x-1] -= 1
    counts[y-1] += 1
    
    if possible[x-1]==1:
        possible[y-1] = 1
    
    if counts[x-1]==0:
        possible[x-1] = 0
        
cnt = 0
for v in possible:
    if v==1:
        cnt += 1

print(cnt)   

Measured memory_bytes: 13308
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cctype>
#include<cstring>
#include<list>
#include<map>
#include<sstream>
#include<set>
#include<string>
#include<vector>
typedef long long ll;
using namespace std;
#define MN 300005
#define MM 600005
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define RF(i,a,b) for(int i=a;i>=(b);--i)
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define int long long
signed main()
{
   int T;
   while(cin>>T){
       if(T%10==7){
           cout<<"Yes"<<endl;
           continue;
       }
       if(T/100==7)
       {
           cout<<"Yes"<<endl;
           continue;
       }
       if(T/10%10==7)
       {
           cout<<"Yes"<<endl;
           continue;
       }
       cout<<"No"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<set>
#include<vector>
#include<list>
using namespace std;

const int N = 10000;
const int INFTY = (1 << 29);
int n, e;
int timer, prenum[N], parent[N], lowest[N];
vector<int> G[N];

bool visited[N];
list<int> out;

void dfs( int current, int prev) {
   prenum[current] = lowest[current] = timer++;
  
   visited[current] = true;
   int next;
   for( int i = 0; i < G[current].size(); i++ ) {
      next = G[current][i];

   	  if(!visited[ next ]) {
   	  	parent[next] = current;
//
   	  	dfs(  next, current );

   	  	lowest[current] = min(lowest[current], lowest[next] );
   	  } else if( next != prev ) {
   	  	lowest[current] = min(lowest[current], prenum[next] );
   	  }

   }

  
}

void art_points() {
	for( int i = 0; i < n; i++ ) visited[i] = false;
	timer = 1; 
    //计算lowest
   dfs( 0, -1 );   //0 == root

   set<int> ap;
   int np = 0;
   for( int i = 1; i < n; i++ ) {
   		int p = parent[i];
   		if( p == 0 ) np++;
   		else if ( prenum[p] <= lowest[i]) ap.insert(p);
   }
   if( np >1 ) ap.insert(0);
   for( set<int>::iterator it = ap.begin(); it != ap.end( ); it++ )
   	cout<< *it << endl;

}
int main() {
	
	int u, v;
	cin>> n >> e;
   
	for ( int i = 0; i < e; i++ ) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	
	}
    
   art_points();

   return 0;
}


Measured memory_bytes: 4800