akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

int bfs(const std::vector<std::string>& maze, int startX, int startY, int W, int H) {
	std::vector<std::vector<int>> count(H + 2);
	for (int i = 0; i < H + 2; i++) {
		count[i].resize(W + 2, -1);
	}
	std::queue<std::pair<int, int>> q;
	q.push({startX, startY});
	count[startX][startY] = 0;
	int max = 0;
	while (!q.empty()) {
		auto p = q.front();
		q.pop();
		auto x = p.first, y = p.second;
		auto c = count[x][y];
		if (maze[x + 1][y] == '.' && count[x + 1][y] == -1) {
			q.push({x + 1, y});
			count[x + 1][y] = c + 1;
		}
		if (maze[x - 1][y] == '.' && count[x - 1][y] == -1) {
			q.push({x - 1, y});
			count[x - 1][y] = c + 1;
		}
		if (maze[x][y + 1] == '.' && count[x][y + 1] == -1) {
			q.push({x, y + 1});
			count[x][y + 1] = c + 1;
		}
		if (maze[x][y - 1] == '.' && count[x][y - 1] == -1) {
			q.push({x, y - 1});
			count[x][y - 1] = c + 1;
		}
		max = std::max(c, max);
	}
	return max;
}

int main() {
	int H, W;
	std::cin >> H >> W;
	std::vector<std::string> maze(H + 2);
	for (int i = 0; i <= W + 1; i++) {
		maze[0] += "#";
		maze[H + 1] += "#";
	}
	for (int i = 1; i <= H; i++) {
		std::string s;
		std::cin >> s;
		maze[i] = "#" + s + "#";
	}
	int max = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (maze[i][j] == '.') {
				max = std::max(bfs(maze, i, j, W, H), max);
			}
		}
	}
	std::cout << max << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };

int main() {
	int n, x;
	std::cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		std::cout << "No" << std::endl;
	}
	else {
		if (n == 2) {
			std::cout << "Yes" << std::endl;
			std::cout << 1 << std::endl;
			std::cout << 2 << std::endl;
			std::cout << 3 << std::endl;
		}
		else {
			std::cout << "Yes" << std::endl;
			bool used[200010];
			for (int i = 0;i < 2 * n;i++)used[i] = true;
			if (x != 2) {
				used[x] = used[x - 1] = used[x - 2] = used[x + 1] = false;
			}
			else {
				used[x] = used[x - 1] = used[x + 2] = used[x + 1] = false;
			}
			int count = 1;
			for (int i = 0;i < n - 2;) {
				if (!used[count]) {
					count++;
				}
				else {
					std::cout << count << std::endl;
					count++;
					i++;
				}
			}
			if (x != 2) {
				std::cout << x - 1 << std::endl;
				std::cout << x << std::endl;
				std::cout << x + 1 << std::endl;
				std::cout << x - 2 << std::endl;
			}
			else {
				std::cout << x + 1 << std::endl;
				std::cout << x << std::endl;
				std::cout << x - 1 << std::endl;
				std::cout << x + 2 << std::endl;
			}
			for (int i = n + 2;i < 2 * n-1;) {
				if (!used[count]) {
					count++;
				}
				else {
					std::cout << count << std::endl;
					count++;
					i++;
				}
			}
		}
	}
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename T>
class SegmentTree {
    const T unit;
    const function<T(const T&, const T&)> op;
    vector<T> container;

public:
    template <typename Op>
    SegmentTree(int size, const T& identity, const Op& operation)
        : unit(identity)
        , op(operation)
        , container(msb1(size * 2 - 1))
    {
        fill(container.begin(), container.end(), unit);
    }

    void update(size_t i, const T& v)
    {
        size_t n = container.size() / 2;
        size_t j = n + i;
        container[j] = v;
        j /= 2;
        while (j != 0) {
            container[j] = op(container[j * 2], container[j * 2 + 1]);
            j /= 2;
        }
    }

    T find(size_t s, size_t t)
    {
        if (s >= t) {
            return unit;
        }
        return find_inner(s, t, 0, container.size() / 2, 1);
    }

private:
    T find_inner(size_t s, size_t t, size_t lb, size_t ub, size_t node)
    {
        if (s == lb && t == ub) {
            return container[node];
        }

        T result = unit;
        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            result = op(result, find_inner(s, min(mid, t), lb, mid, node * 2));
        }
        if (mid < t) {
            result = op(result, find_inner(max(s, mid), t, mid, ub, node * 2 + 1));
        }

        return result;
    }
    int msb1(int x)
    {
        x |= x >> 1;
        x |= x >> 2;
        x |= x >> 4;
        x |= x >> 8;
        x |= x >> 16;

        return x + 1;
    }
};

template <typename T>
void compress(vector<T>& v)
{
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
}

int main()
{
    int n, q;
    cin >> n >> q;

    SegmentTree<int32_t> seg(n, numeric_limits<int32_t>::max(), [](const int32_t& lh, const int32_t& rh) {
        return min(lh, rh);
    });

    rep(i, q)
    {
        int com;
        int32_t x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            seg.update(x, y);
        } else {
            cout << seg.find(x, y + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3880
N = gets.to_i
A = []
B = []
x = []
for i in 0..N-1

    x[i] = []

    A[i],B[i] = gets.split.map(&:to_i)

    x[i][0] = A[i]+B[i]
    x[i][1] = i 

end

x.sort!{|a,b| a[0] <=> b[0]}
a = 0
b = 0

for i in 0..N-1

    if i % 2 == 0

        a += A[x[N-1-i][1]]

    else

        b += B[x[N-1-i][1]]

    end

end

puts a-b



Measured memory_bytes: 12044
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<int> pre(1001*1001, -1);
bool flag = true;
//-------------------------------------------------------------------
int MAX_V = 1001*1001;
vvi G = vv(MAX_V, 0, 0, int);
vvi rG = vv(MAX_V, 0, 0, int);
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);
vector<int> vs;

void add_edge(int from, int to){ G[from].push_back(to), rG[to].push_back(from);}
void dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rG[v].size();i++) {
    if(!used[rG[v][i]]) {
      rdfs(rG[v][i], k);
      flag = false;
    }
  }
}
int scc(int V){
  for(int i=0;i<MAX_V;i++) used[i] = false;
  vs.clear();
  for(int i=0;i<=V;i++) if(!used[i]) dfs(i);
  for(int i=0;i<MAX_V;i++) used[i] = false;
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--) if(!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
std::vector<int> mpath(1001*1001, -1);

int f(int now){
  if(mpath[now]!=-1) return mpath[now];
  int d = 0;
  for(int i=0;i<G[now].size();i++) d = max(d, f(G[now][i]));
  d++;
  mpath[now] = d;
  return d;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  vvi A = vv(N+1, N, 0, int);
  vector<int> nyu(1001*1001, 1);
  for(int i=1;i<=N;i++) for(int j=1;j<=N-1;j++) std::cin >> A[i][j];
  for(int i=1;i<=N;i++) {
    for(int j=1;j<=N-2;j++) {
      add_edge(min(i,A[i][j])*1001+max(i,A[i][j]), min(i,A[i][j+1])*1001+max(i,A[i][j+1]));
      nyu[min(i,A[i][j+1])*1001+max(i,A[i][j+1])] = 0;
    }
  }
  scc(1001*1001);
  if(!flag){
    std::cout << -1 << '\n';
    return 0;
  }
  int ans = 0;
  for(int i=0;i<1001*1001;i++) if(nyu[i]==1) ans = max(f(i), ans);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 104180
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    vector<int> a(4, 0);
    for (int i = 0; i < 3; i++) {
        int b, c;
        cin >> b >> c;
        b--; c--;
        a[b]++;
        a[c]++;
    }
    for (int i = 0; i < 4; i++) {
        if (a[i] >= 3 || a[i] == 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


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

int main(){
    int N,D;
    int x=0;
    int m=0,n=1;

    cin >> N >> D;
    m=N;
    
    while(n!=0){
    n=floor(m/(2*D+1));
    m=m-(2*D+1);
    x++;
    }
    if(m==-(2*D+1)){
        x--;
    }
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  int N,K,Q;
  int tmp;
  int P[1000000] = {0};
  scanf("%d %d %d",&N,&K,&Q);
  for(int i=0; i<Q; i++){
    scanf("%d",&tmp);
    P[tmp]++;
  }
  for(int i=1; i<=N; i++){
    if(K-Q+P[i]>0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<int>adj[100005];
vector<int>depth(100005,0),val(100005,0);
vector<int>indeg(100005,0);
vector<bool>vis(100005,false);
int ans=0;
///val-> kendisinden sonraki en uzun yol
///depth->kendisinden önceki en uzun yol
int dfs(int x,int d){
      vis[x]=true;
      depth[x]=d;
      for(int i=0;i<adj[x].size();i++){
            int y=adj[x][i];
            if(vis[y])continue;
            dfs(y,d+1);
      }
      for(int i=0;i<adj[x].size();i++){
            int y=adj[x][i];
            val[x]=max(val[x],val[y]+1);
      }
      ans=max(ans,val[x]+depth[x]);
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,m;
      cin>>n>>m;
      for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            adj[x].pb(y);
            indeg[y]++;
      }
      for(int i=1;i<=n;i++){
            if(vis[i]||indeg[i])continue;
            dfs(i,0);
      }
      cout<<ans;
}


Measured memory_bytes: 15872
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> H(N+1, 0);
    for(int i = 1; i<= N; i++)  cin >> H[i];
    for(int i = 1; i<= N; i++){
        cout << "node " << i << ": ";
        cout << "key = " << H[i] << ", ";
        if(i / 2 > 0) cout << "parent key = " << H[i / 2] << ", ";
        if(2 * i <= N) cout << "left key = " << H[i * 2] << ", ";
        if(2 * i + 1 <= N) cout << "right key = " << H[i * 2 + 1] << ", ";
        cout << endl;
    }
}


Measured memory_bytes: 3096
from scipy.sparse import *
from itertools import *
 
n,m,r = [int(x) for x in input().split()]
R = [int(i)-1 for i in input().split()]
route_list = [[10**8]*n for i in range(n)]
ans = 10**9
for j in range(m):
  a,b,c = map(int,input().split())
  route_list[a-1][b-1] = c
  route_list[b-1][a-1] = c
 
Co = csgraph.floyd_warshall(csr_matrix(route_list))
 
for v in permutations(R):
  temp = 0
  for i in range(1,r):
    temp += Co[v[i-1]][v[i]]
  ans = min(ans,temp)
print(int(ans))

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	ll n;
	cin >> n;

	ll res = 0;
	for (ll a = 1; a <= n; ++a)
	{
		for (ll b = 1; a*b < n; ++b)
		{
			res++;
		}
	}
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    int a = 0;
    int b = 1;
    cin >> N >> M;
    int s[M], c[M];
    for (int i = 0; i < M; i++){
        int n = 1;
        cin >> s[i] >> c[i];
        for (int k = 0; k < N - s[i]; k++)  n *= 10; 
        a += n * c[i];
        for (int j = 0; j < i; j++){
            if (s[i] == s[j] && c[i] != c[j]){
                cout << -1;
                goto Exit;
            }
            else if (s[i] == s[j]){
                a -= n * c[i];      break;
            }
        }
    }
    for (int j = 0; j < M; j++){    
        if (N > 1){
            if (s[j] == 1 && c[j] == 0){
                cout << -1;
                goto Exit;
            }
        }
    }
    for (int i = 0; i < N - 1; i++) b *= 10;
    if (M == 0){    
        if (N == 1){
            cout << 0;  goto Exit;
        }
        else{
            cout << b;  goto Exit;
        }
    }
    else{
        if (b == 1){
            if (a >= 0 && a < 10)           cout << a;
            else                            cout << -1;
        }
        else if (a >= b && a < b * 10)      cout << a;
        else if (a < b){
            a += b;                         cout << a;
        }                     
        else                                cout << -1;
    }
    Exit: ;
}

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

int main() {
  int X,A,B,C,R,c;
  int cnt = 0;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  for(int i = 0; A >= i; i++){
    for(int j = 0; B >= j; j++){
      R = X - (500 * i + 100 * j);
      if(R % 50 == 0){
        c = R / 50;
        if(0 <= c && c <= C){
          cnt++;
        }
      }
    }
  }

  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define  div "%lld"
#define  pdiv "%lld\n"
using namespace std;
///check n=1;
///check corner case;
map<ll,ll>check,str;

int main()
{
    FIO;
     double n,i,j,cc=0;
     cin>>n;
     j=n/3.0;
     printf("%.12f\n",j*j*j);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, R: int):
    if N >= 10:
        print(R)
    else:
        print(R + 100*(10 - N))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(N, R)

if __name__ == '__main__':
    main()


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

int main()
{
	while(true){
		int n,m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int a[1000];
		for(int i=0; i<n; i++){
			cin >> a[i];
		}

		int sum = -1;

		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				int p = a[i]+a[j];

				if(p<=m && p>sum){
					sum = p;
				}
			}
		}

		if(sum!=-1){
			cout << sum << endl;
		}
		else{
			cout << "NONE" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=2e3+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head
int main(void){
    int n,x,y;
    cin>>n>>x>>y;
    VI ans(n);
    rep(i,1,n){
        rep(j,i+1,n+1){
            ++ans[min(j-i,abs(x-i)+1+abs(y-j))];
        }
    }
    rep(i,1,n)cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
    long long int n;
    int k, answer = 1;

    scanf("%lld %d", &n, &k);

    while (n >= k)
    {
        n = n/k;
        answer ++;
    }
    

    printf("%d", answer);

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string S;
    cin >> S;

    ll N = S.size();
    S = '0' + S;
    S = S + '0';

    //cout << S << endl;
    vector<ll> X(N+1);
    REP(i, N+1) X[i] = (S[i]-'0') ^ (S[i+1]-'0');


    ll res = N;
    //cout << X << endl;
    REP(i, N+1){
    	if(X[i]==1){
    		res = min(res, max((ll)i, N-i));
    	}
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> mp;

    for(ll i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    ll count = 0;

    for(auto e:mp)
    {
        if(e.first > e.second)count += e.second;
        else if(e.first < e.second)count += e.second - e.first;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6272
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<int,P> PP;
int W,H,p[20][2],m=1,C[105][105],mv[5]={0,-1,0,1,0},G[2],T[20][9];
char M[105][105];

void dbg()
{
	for(int i=0;i<H;i++,puts(""))
		for(int j=0;j<W;j++)
			printf("%d ",C[i][j]);
}

int bfs(int sy,int sx,int gy,int gx)
{
	int c[105][105]={0};
	memset(c,0x7f,sizeof(c));
	priority_queue<PP,vector<PP>,greater<PP> >Q;
	Q.push(make_pair(0,make_pair(sy,sx)));
	for(;!Q.empty();)
	{
		PP tmp=Q.top();Q.pop();
		if(tmp.second.first==gy&&tmp.second.second==gx)
			return tmp.first;
		if(tmp.first>c[tmp.second.first][tmp.second.second])
			continue;
		for(int i=0;i<4;i++)
		{
			int ny=tmp.second.first+mv[i];
			int nx=tmp.second.second+mv[i+1];
			if(M[ny][nx]=='#'||ny<0||ny>=H||nx<0||nx>=W)continue;
			if(tmp.first+C[tmp.second.first][tmp.second.second]<c[ny][nx])
			{
				c[ny][nx]=tmp.first+C[tmp.second.first][tmp.second.second];
				Q.push(make_pair(tmp.first+C[tmp.second.first][tmp.second.second],make_pair(ny,nx)));
			}
		}
	}
}

int main()
{
	scanf("%d%d\n",&W,&H);
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			C[i][j]=1;
	for(int i=0;i<H;i++)gets(M[i]);
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		{
			if(M[i][j]=='S')
				p[0][0]=i,p[0][1]=j,M[i][j]='.';
			else if(M[i][j]=='G')
				G[0]=i,G[1]=j,M[i][j]='.';
			else if(M[i][j]=='M')
			{
				p[m][0]=i,p[m][1]=j,M[i][j]='.';
				m++;
			}
			else if(M[i][j]=='#')
			{
				for(int h=max(0,i-2);h<min(H,i+3);h++)
					for(int w=max(0,j-2);w<min(W,j+3);w++)
						C[h][w]=max(4-max(abs(i-h),abs(j-w)),C[h][w]);
			}
		}
	p[m][0]=G[0];
	p[m][1]=G[1];
	for(int i=0;i<=m;i++)
		for(int j=0;j<=m;j++)
		{
			if(i==j)continue;
			T[i][j]=bfs(p[i][0],p[i][1],p[j][0],p[j][1]);
		}
	int route[100],res=1000000000;
	if(m==1)
	{
		res=T[0][1];
	}
	else
	{
		for(int i=0;i<=m;i++)
			route[i]=i;
		do
		{
			int tmp=0;
			for(int i=0;i<m;i++)
				tmp+=T[route[i]][route[i+1]];
			res=min(res,tmp);
		}while(next_permutation(route+1,route+m));
	}
	printf("%d\n",res);
	//dbg();
}

Measured memory_bytes: 1300
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




template <class T> void printVector(std::vector<T> u){
  const int k = u.size();
  for(int i = 0; i < k - 1;i++) cout << u.at(i) << ' ';
  cout << u.at(k - 1) << BR;
}


int main(void){
  int h, w, n, idx = 0; cin >> h >> w >> n;
  Vint A(n);
  REP(i, n) cin >> A.at(i);
  Wint data(h, Vint(w));
  REP(i, h * w){
    int p = i / w, q = i % w;
    int index = (p % 2 == 0) ? q : w - 1 - q;
    data[p][index] = idx + 1;
    A.at(idx)--;
    if(A.at(idx) == 0) idx++;
  }
  vREP(ele, data) printVector(ele);
  return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m, &x, &y)
	xs := make([]int, n+1)
	ys := make([]int, m+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}
	xs[n] = x
	for i := 0; i < m; i++ {
		fmt.Scan(&ys[i])
	}
	ys[m] = y

	sort.Ints(xs)
	sort.Ints(ys)
	if xs[n] < ys[0] {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


Measured memory_bytes: 512
N, M = map(int, input().split())
to = [[] for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

ans = 0
v = [0] * N

def DFS(n):
    global ans
    v[n] = 1
    #print(v)
    if sum(v) == N:
        ans += 1
    for i in to[n]:
        if v[i] == 0:
            DFS(i)
    v[n] = 0

DFS(0)
print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long  n , m;
        cin >> n >> m;
        long ans = 0; 
        ans = m * 1900 + (n - m) * 100;
        while(m > 0){
            ans *= 2;
            m -= 1;
        }
        cout << ans << endl;
        
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <bitset>

using namespace std;

typedef long long ll;

ll N, qN;

int main() {
    cin >> N;
    for(ll i = 1; i <= 3500; i++) {
        for(ll j = 1; j <= 3500; j++) {
            ll a = N * i * j;
            ll b = 4 * i * j - N * (i + j);
            if(b && a % b == 0 && a / b > 0) {
                cout << i << " " << j << " " << a / b << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    char A[1][102]={};
    char B[1][102]={};
    char C[1][102]={};
    int la=0,lb=0,lc=0;
    int turn=0;
    int a=0,b=0,c=0;
    char temp;
    scanf("%s",A[0]);
    scanf("%s",B[0]);
    scanf("%s",C[0]);
    la=strlen(A[0])-1;
    lb=strlen(B[0])-1;
    lc=strlen(C[0])-1;
    while(1){
        if(turn==0){
            temp= A[0][a];
            if(a>la){
                printf("A\n");
                break;
            }
            if(A[0][a]=='a'){
                turn=0;
            }
            else if(A[0][a]=='b'){
                turn=1;
            }
            else turn=2;
            a++;
        }
        if(turn==1){
            if(b>lb){
                printf("B\n");
                break;
            }
            if(B[0][b]=='a'){
                turn=0;
            }
            else if(B[0][b]=='b'){
                turn=1;
            }
            else turn=2;
            b++;
        }
        
        if(turn==2){
            temp= C[0][c];
                if(c>lc){
                    printf("C\n");
                    break;
                }
                if(C[0][c]=='a'){
                    turn=0;
                }
                else if(C[0][c]=='b'){
                    turn=1;
                }
                else turn=2;
                c++;
            
            }
        }
        return 0;
    }

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

const int MN = 550;
int N;
using B = bitset<MN>;
int g[MN][MN];


B used[MN][MN];

int L, R, D, U;
void dfs_up(int a, int b, int id) {
    if (!(L <= a && a <= R && D <= b && b <= U)) return;
    if (g[a][b] == 0 || used[a][b][id]) return;
    used[a][b][id] = true;
    dfs_up(a-1, b, id); dfs_up(a, b-1, id);
}

void dfs_dw(int a, int b, int id) {
    if (!(L <= a && a <= R && D <= b && b <= U)) return;
    if (g[a][b] == 0 || used[a][b][id]) return;
    used[a][b][id] = true;
    dfs_dw(a+1, b, id); dfs_dw(a, b+1, id);
}

ll ans = 0;

void solve(int l, int r, int d, int u) {
    if (r < l || u < d) return;
    if (l == r && d == u) return;
    L = l; R = r; D = d; U = u;
    for (int x = l; x <= r; x++) {
        for (int y = d; y <= u; y++) {
            used[x][y] = B();
        }
    }
    if (r-l > u-d) {
        int m = (l+r)/2;
        for (int y = d; y <= u; y++) {
            dfs_up(m, y, y);
        }
        for (int y = u; y >= d; y--) {
            dfs_dw(m+1, y, y);
        }
        unordered_map<B, int> mp1, mp2;
        for (int x = l; x <= r; x++) {
            for (int y = d; y <= u; y++) {
                if (x <= m) mp1[used[x][y]] += g[x][y];
                else mp2[used[x][y]] += g[x][y];
            }
        }
        for (auto &p1: mp1) {
            for (auto &p2: mp2) {
                if ((p1.first & p2.first).count()) ans += ll(p1.second) * p2.second;
            }
        }
        solve(l, m, d, u);
        solve(m+1, r, d, u);
    } else {
        int m = (d+u)/2;

        for (int x = l; x <= r; x++) {
            dfs_up(x, m, x);
        }
        for (int x = r; x >= l; x--) {
            dfs_dw(x, m+1, x);
        }
        unordered_map<B, int> mp1, mp2;
        for (int x = l; x <= r; x++) {
            for (int y = d; y <= u; y++) {
                if (y <= m) mp1[used[x][y]] += g[x][y];
                else mp2[used[x][y]] += g[x][y];
            }
        }
        for (auto &p1: mp1) {
            for (auto &p2: mp2) {
                if ((p1.first & p2.first).count()) ans += ll(p1.second) * p2.second;
            }
        }
        solve(l, r, d, m);
        solve(l, r, m+1, u);
    }
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(20) << fixed;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= N; j++) {
            int d = 0;
            if (isdigit(s[j-1])) d = s[j-1] - '0';
            g[i][j] = d;
            //ans -= d*d;
        }
    }
    solve(1, N, 1, N);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 1005;
const ll inf = 1e18;
int n, m;
ll x[N], y[N], z[N];

ll dp[N][N][2][2][2];

ll go(int i, int rem, int one, int two, int three) {
	if(i == n){
		if(rem == 0) return 0;	
		else return -inf;
	} 
	ll &ret = dp[i][rem][one][two][three];
	if(ret != -1) return ret;
	ret = -inf;
	ll rx = x[i], ry = y[i], rz = z[i];
	if(one) rx = -x[i];
	if(two) ry = -y[i];
	if(three) rz = -z[i];
	if(rem) ret = max(ret, rx + ry + rz + go(i + 1, rem - 1, one, two, three));
	ret = max(ret, go(i + 1, rem, one, two, three));
	return ret;
}


int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = -inf;
	for(int mask = 0; mask < (1 << 3); mask++) {
		ans = max(ans, go(0, m, (mask & 1), ((mask >> 1) & 1), ((mask >> 2) & 1)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 63488
import math

a, b, h, m = map(float, input().split())

a_angle = math.pi * 2 * (h / 12 + m / (60 * 12))
b_angle = math.pi * 2 * (m / 60)

ans = math.sqrt(pow(a,2) + pow(b,2) - (2 * a * b * math.cos(abs(a_angle - b_angle))))

print(ans)

Measured memory_bytes: 9392
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
 	}
	return res;
}


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

	int N;
	cin >> N;

	cout << N * N * N << endl;




ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, L) = read_int_tuple();
    let sum = L*N + N*(N-1)/2;
    let eat = if L+N-1 < 0 {
        L+N-1
    } else if L > 0 {
        L
    } else {
        0
    };
    println!("{}", sum-eat);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    if(S == "Sunny")cout << "Cloudy" << endl;
    else if(S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}



Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	ll a,b;
	cin>>a>>b;
	ll lc = a*b/__gcd(a,b);
	string as,bs;
	cin>>as>>bs;
	if(a<b) {
		swap(a,b);
		swap(as,bs);
	}
	vi ap(a),bp(b);
	REP(i,0,a-1) {
		ap[i]=i*(lc/a)+1;
	}
	REP(i,0,b-1) {
		bp[i]=i*(lc/b)+1;
	}
	REP(i,0,a-1) {
		auto atb = find(bp.begin(),bp.end(),ap[i])-bp.begin();
		if (atb!=b) {
			if(as[i]!=bs[atb]) {
				cout<<-1;
				return;
			}
		}
	}
	cout<<lc;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main(){
    string s;
    cin >> s;
    int n1 = 0,n2 = s.size()-1;
    while(n1 < n2){
        if(s.at(n1) != s.at(n2)){
            cout << "No" << endl;
            return 0;
        } 
        n1++;
        n2--;
    }
    n1 = 0;
    n2 = (s.size()-1) / 2 - 1;
    while(n1 < n2){
        if(s.at(n1) != s.at(n2)){
            cout << "No" << endl;
            return 0;
        } 
        n1++;
        n2--;
    }
    n1 = (s.size()+3) / 2 - 1;
    n2 = s.size()-1;
    while(n1 < n2){
        if(s.at(n1) != s.at(n2)){
            cout << "No" << endl;
            return 0;
        } 
        n1++;
        n2--;
    }
    cout << "Yes" << endl;
    return 0;
} 

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

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  vector<int> W(w+1,0), H(h+1,0);

  for(int i=0; i<n; i++){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1){
      for(int j=0; j<x; j++)W[j]=1;
    }else if(a==2){
      for(int j=w; j>x; j--)W[j]=1;
    }else if(a==3){
      for(int j=0; j<y; j++)H[j]=1;
    }else if(a==4){
      for(int j=h; j>y; j--)H[j]=1;
    }
  }
  int wid=count(W.begin(),W.end(),0)-1, hig=count(H.begin(),H.end(),0)-1;
  cout<<max(0,wid)*max(0,hig)<<endl;
}


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

int N,check,a[1200] = {0};
int num[1002],pro[1002],fat[1002],car[1002],cal[1002] = {0};
int proto,fatto,carto,calto;
int main()
{
    while(cin >> N, N)
    {
        for(int i = 0; i < N; i++)
        {
            cin >> num[i] >> pro[i] >> fat[i] >> car[i];
            cal[i] = pro[i] * 4 + fat[i] * 9 + car[i] * 4;
        }
        cin >> proto >> fatto >> carto >> calto;
        for(int i = 0; i < N; i++)
        {
            if(pro[i] <= proto && fat[i] <= fatto && car[i] <= carto && cal[i] <= calto)
            {
                cout << num[i] <<endl;
            }
            else check++;
        }
        if(check == N)cout << "NA" << endl;
        //else for(int i = 0; i < check; i++)cout << "a" << a[i] << endl;
        a[1200] = {0};
        check = 0;
    }
    return 0;
}

Measured memory_bytes: 3080
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans = v[0];
    for i in 0..n {
        ans = gcd(ans, v[i]);
    }
    println!("{}", ans);
}

fn gcd(a:usize, b:usize) -> usize {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}


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

typedef unsigned long long ULL;

const int MAXN = 2.5e5 + 10;
const ULL P = 233ULL, iP = 7204522363551799129ULL;

int n;
ULL hsh1[MAXN], hsh2[MAXN];
char s[MAXN];
std::map <ULL, int> mp;

int main() {
	scanf("%d %s", &n, s + 1), hsh2[0] = 1;
	for (int i = 1; i <= n; ++i) {
		hsh1[i] = hsh1[i - 1], hsh2[i] = hsh2[i - 1];
		if (s[i] == '+') hsh1[i] += hsh2[i];
		else if (s[i] == '-') hsh1[i] -= hsh2[i];
		else if (s[i] == '<') hsh2[i] *= iP;
		else hsh2[i] *= P;
		++mp[hsh1[i]];
	}
	ULL ans = 0;
	for (int i = 1; i <= n; ++i) ans += mp[hsh1[n] * hsh2[i - 1] + hsh1[i - 1]], --mp[hsh1[i]];
	printf("%llu\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;


void solve()
{
	ll n,k,ans=0;
	cin>>n>>k;
	ll y=log2(1e9)/log2(k);
	for(int i=y;i>=0;i--)
	{
		ll x=pow(k,i);
		//cout<<x<<endl;
		if(x<=n)
		{
			ans=i;
			break;
		}
	}
	ans++;
	cout<<ans<<endl;
	return;
}
int main()
{
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

ans = []

#abピザの数を決め打ちする
for ab in range(max(x,y) + 1):
    ans.append(a * max((x - ab),0) + b * max((y - ab),0) + 2 * c * ab)

print(min(ans))

Measured memory_bytes: 7096
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;
int INF = (int)(1e9+7);
ll modu = (ll)(1e9+7);

vector <vector <int> > v(25,vector<int>(25));
vector < vector <ll> > dp(25,vector <ll>(2100000,-1));

ll funcion(int i, int n, int pos)
{
	//DBG(i); DBG(pos); RAYA;
	if(dp[i][pos]!=-1) return dp[i][pos];
	if(i==n) return 1LL;
	dp[i][pos]=0;
	forn(j,n)
	{
		if(v[i][j]==1 && ((1<<j)&pos)!=0)
		{
			dp[i][pos]+=funcion(i+1,n,((1<<j)^pos));
			dp[i][pos]%=modu;
		}
	}
	return dp[i][pos];
}


 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("T3.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	forn(i,n)
	{
		forn(j,n) cin >> v[i][j];
	}
	int start = (1<<n)-1;
	cout << funcion(0,n,start) << "\n";
	
    return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int> v(m * 2);
    rep(i, m * 2)
    {
        cin >> v[i];
    }
    reps(i, n)
    {
        cout << count(all(v), i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 53;
LL v[MAXN];
LL a, b;
map<LL, LL> cnt;

LL ncr[MAXN][MAXN];
void pre() {
  ncr[1][0] = 1; ncr[1][1] = 1;
  for(LL i = 2; i < MAXN; i++) {
    ncr[i][0] = 1;
    for(LL r = 1; r <= i; r++) {
      ncr[i][r] = ncr[i-1][r] + ncr[i-1][r-1];
    }
  }
}

LL num[MAXN], den[MAXN];

int main() {
  ios_base::sync_with_stdio(false);
  LL n;
  cin >> n >> a >> b;
  assert(a > 0 && a <= b && b <= n);
  for(int i = 1; i <= n; i++) {
    cin >> v[i];
    cnt[v[i]]++;
  }
  pre();
  sort(v + 1, v + n + 1);
  double maxim = 0;
  int idx = 0;
  for(int s = a; s <= b; s++) {
    LL total = 0;
    for(int i = n, cnt = 0; i > 0 && cnt < s; cnt++, i--) {
      total += v[i];
    }
    if(total/(double)s > maxim) {
      maxim = max(maxim, total/(double)s);
      idx = s;
    }
    num[s] = total; den[s] = s;
    LL g = gcd(total, (LL)s);
    num[s] /= g, den[s] /= g;
  }
  cout << setprecision(9) << fixed << maxim << '\n';
  LL res = 0;
  for(int s = a; s <= b; s++) {
    LL total = 0;
    map<LL, LL> taken;
    LL last;
    for(int i = n, cnt = 0; i > 0 && cnt < s; cnt++, i--) {
      total += v[i];
      taken[v[i]]++;
      last = v[i];
    }
    double temp = total/(double)s;
    if(num[s] == num[idx] && den[s] == den[idx]) {
      res += ncr[cnt[last]][taken[last]];
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256