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

using namespace std;

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

    int sum = abs(a[0]);
    for (int i = 1; i < n + 1; ++i) {
        sum += abs(a[i] - a[i - 1]);
    }

    cout << sum - abs(a[0]) - abs(a[0] - a[1]) + abs(a[1]) << endl;
    for (int i = 1; i < n; ++i) {
        cout << sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1]) << endl;
    }

}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll n;cin>>n;
    string s,t;cin>>s>>t;
    vector<char> ans;
    rep(i,n){
        cout<<s[i];
        cout<<t[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
ans = 0
flag = [-1 for i in range(n+1)]
A = list(map(int,input().split()))
for i in range(n):
    flag[i+1] = A[i]
for i in range(1,n+1):
    if flag[flag[i]] == i:
        ans += 1
print(ans//2)

Measured memory_bytes: 14832
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n, l;
	cin >> n >> l;
	vector<string> s(n);

	REP(i, n) cin >> s[i];

	sort(ALL(s));

	for (auto x : s){
		cout << x;
	}

	cout << endl;
}


Measured memory_bytes: 256
import numpy as np

i = list(map(int, input().split()))

a = i[0]
b = i[1]
h = i[2]
m = i[3]

theta = (abs(30 * h - 5.5 * m) % 360) * (np.pi / 180)

print(np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(theta)))

Measured memory_bytes: 27180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/


signed main(){
	ll a,b;
	cin >> a >> b;
	
	if(a % (b*2+1) == 0) cout << a / (b*2+1) << endl;
	else cout << a / (b*2+1) + 1 << endl;
	return 0;
}


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

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

using namespace std;

typedef pair<int, int> P;

int n, k;
map<int, int> c;
vector<P> v;

int main(){
    cin >> n >> k;
    rep(i, n){
        int a;
        cin >> a;
        ++c[a];
    }
    for(auto o: c){
        v.push_back(P(o.second, o.first));
    }
    sort(v.begin(), v.end());
    int ans = 0;
    rep(i, (int)v.size() - k){
        ans += v[i].first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11768
//
//  main.cpp
//  atcoder001
//
//  Created by 芦原智隆 on 2018/02/01.
//  Copyright © 2018年 芦原智隆. All rights reserved.
//

#include <iostream>
using namespace std;

int main (){
    
    //持っている金額
    int total_money;
    cin >> total_money ;
    
    //ケーキの金額
    int cake_price;
    cin >> cake_price;
    
    //ドーナッツの金額
    int donuts_price;
    cin >> donuts_price;
    
    cout << (total_money - cake_price) % donuts_price << "\n";
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;

int32_t main(){
INIT
string s; cin>>s;
if(s[s.length()-1]=='s'){s+="es";}
else{s+="s";} cout<<s;


return 0;
}





Measured memory_bytes: 3636
# n, k: 数値　s: 文字列　が与えられる
# k文字目を入れ替えよ

n, k = map(int, input().split())
s = input()

# dic = {"A":"a", "B":"b", "C":"c"}

# キーとなる文字　文字列のインデックスは0から
# s[k-1]


# 小文字にする表現がある 下記なら1発
print(s[:k-1] + s[k-1].lower() + s[k:])

# [開始インデックス:終了インデックス] 数値は　より大　と　未満
# print(s[:k-1] + dic.get(s[k-1]) + s[k-1:])

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

int main()
{
    int n;
    unsigned long long buffer[101];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> buffer[i];
    }
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (buffer[i] == buffer[j])
                continue;
            for (int k = j + 1; k < n; k++)
            {
                if (buffer[i] == buffer[k] || buffer[k] == buffer[j])
                    continue;
                if (buffer[i] + buffer[j] > buffer[k] && buffer[i] + buffer[k] > buffer[j] && buffer[k] + buffer[j] > buffer[i])
                {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>

int main()
{
    int64_t n;
    std::cin >> n;

    for (int64_t a = std::floor(std::sqrt(n)); a >= 1; --a)
    {
        if (n % a == 0)
        {
            const int64_t b = n / a;
            std::cout << static_cast<int>(std::floor(std::log10(b) + 1)) << std::endl;
            break;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    vi a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    cout<<a[0]*a[1]/2<<endl;
}

Measured memory_bytes: 3596
N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[10**9 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)

Measured memory_bytes: 173832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <fstream>
#include <bitset>
#include <map>
#include <queue>
#include <complex>
#include <assert.h>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <stack>
#include <numeric>

typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair

using namespace std;

const int N = 55;
vector<int> g[N];
int n, m;
int nv = 0, a = 0, b = 0;
bool vis[N];

void dfs(int x){
	vis[x] = true;
	nv++;
	for(int chi : g[x]){
		if((chi == a && x == b) || (chi == b && x == a) ) continue;
		if(!vis[chi]) dfs(chi);
	}
}


int main(){
	cin >> n >> m;
	vector<pair<int, int> > ed;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		ed.pb({a, b});
		g[a].pb(b);
		g[b].pb(a);
	}
	
	int ct = 0;
	for(const pair<int, int> &e : ed){
		a = e.first, b = e.second, nv = 0;
		memset(vis, false, sizeof(vis));
		dfs(1);
		if(nv != n) ct++;
	}
	cout << ct << endl;
	
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll k;
    cin>>k;
    ll ans=0;
    rep (i,1,1000000)
    {
        ll val=7*power(10,i-1,k);
        ans+=val;
        ans%=k;
        if (ans==0)
        {
            cout<<i<<"\n";
            return 0;
        }
    }
    cout<<"-1\n";
}
 

Measured memory_bytes: 3612
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
template <typename T>
using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using ld = long double;
using namespace std;
const int MOD = 1000000007;

template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }
// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

ll Manhattan_dist(ll x1, ll y1, ll x2, ll y2){
	return abs(x1-x2) + abs(y1-y2);
}
void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
ll gcd(const ll a, const ll b){
	return (b==0) ? a : gcd(b,a%b);
}
// $\min\{s\in\mathbb{N}:p^s|n\}$
ll hmt_p_divide_n(ll p, ll n){
	ll s = 0;
	while(n%p == 0){
		n /= p;
		s++;
	}
	return s;
}

int main(){
	int N;
	cin >> N;
	vi a = getv<int>(N);
	int ans = 0;
	for(auto x:a)
		ans += hmt_p_divide_n(2,x);
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
const ll MOD = 1e9 + 7;
const int MAX = 200001;

// combination
ll fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll comb(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// pow

ll a_pow[MAX], b_pow[MAX], ab_pow[MAX];

void pow_init(ll a, ll b) {
  a_pow[0] = 1;
  b_pow[0] = 1;
  ab_pow[0] = 1;
  for (int i = 1; i < MAX; i++) {
    a_pow[i] = (a_pow[i - 1] * a % MOD);
    b_pow[i] = (b_pow[i - 1] * b % MOD);
    ab_pow[i] = (ab_pow[i - 1] * (a + b) % MOD);
  }
}

// modinv

ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}

// solve
int N, A, B, C;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B >> C;
  comb_init();
  pow_init(A, B);

  ll ans = 0;
  for (ll M = N; M <= 2 * N - 1; M++) {
    ll v = comb(M - 1, N - 1) * ((a_pow[N] * b_pow[M - N] % MOD) + (a_pow[M - N] * b_pow[N] % MOD));
    v %= MOD;
    v *= M * 100;
    v %= MOD;
    v *= modinv((ab_pow[M] * (100 - C)));
    v %= MOD;
    ans += v;
    ans %= MOD;
  }

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

Measured memory_bytes: 9600
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

dp = [False] * (K + 1)  # Firstの勝ちの時にTrue
# dp[0] = False
for k in range(1, K + 1):
    for a in A:
        if a <= k and not dp[k - a]:
            dp[k] = True
            break

print('First' if dp[-1] else 'Second')

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      final int MAX = 123456<<1 + 1;
      boolean[] isPrime = new boolean[MAX];
      int[] primes = new int[MAX];
  
      Arrays.fill(isPrime,true);
      isPrime[0] = isPrime[1] = false;
  
      for ( int i=2, p=0; i < MAX; i++ ) {
        if (isPrime[i]) {
          p++;
          for (int j = i<<1; j < MAX; j += i) {
            isPrime[j] = false;
          }
        }
        primes[i] = p;
      }

      StringBuilder buf = new StringBuilder();
      while(true) {
        int n = Integer.parseInt(in.readLine());

        if(n == 0) break;

        int ans = primes[n<<1] - primes[n];
        buf.append(ans).append("\n");
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 27572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin >> n >> d;
  int x[n][d],r=0;
  double s;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> x[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      s=0;
      for(int k=0;k<d;k++){
        s+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      if(fmod(sqrt(s),1)==0)r++;
    }
  }
  cout << r;
}


Measured memory_bytes: 256
#include <cstdio>
#define N 100006
using namespace std;
int x,y,x1,y1,x2,y2,k,s,ans,f[N];
int main()
{
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	x=x1,y=y1;
	while(x1<x2)x1++,printf("R");
	while(y1<y2)y1++,printf("U");
	while(x1>x)x1--,printf("L");
	while(y1>y)y1--,printf("D");
	printf("D");
	while(x1<x2)x1++,printf("R");
	printf("R");printf("U");
	while(y1<y2)y1++,printf("U");
	printf("L");
	printf("U");
	while(x1>x)x1--,printf("L");
	printf("L");printf("D");
	while(y1>y)y1--,printf("D");
	printf("R");
}

Measured memory_bytes: 128
a,b,x=map(int,input().split())
import math
ab=a*b
s=x/a
h=(ab-s)*2/a
if ab/2<=s:
    print(math.degrees(math.atan2(h,a)))
else:
    w=s*2/b
    print(math.degrees(math.atan2(b,w)))



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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	string S, T;
	cin >>N >>S >>T;
	for (int i=0; i<N; i++)
		cout <<S.at(i) <<T.at(i);
	cout <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <math.h>
#define ll long long;

using namespace std;

class dice {
public:
	int a[7];
	int state[7];
	void move(char s);
};

void dice::move(char s) {
	int t[7];//??????????????´???
	for (int i = 1; i <= 6; i++) {
		t[i] = state[i];
	}
	if (s == 'N') {
		state[1] = t[2];
		state[2] = t[6];
		state[6] = t[5];
		state[5] = t[1];
	}
	else if (s == 'S') {
		state[1] = t[5];
		state[5] = t[6];
		state[6] = t[2];
		state[2] = t[1];
	}
	else if (s == 'W') {
		state[1] = t[3];
		state[3] = t[6];
		state[6] = t[4];
		state[4] = t[1];
	}
	else {
		state[1] = t[4];
		state[4] = t[6];
		state[6] = t[3];
		state[3] = t[1];
	}
}


int main() {
	
	dice dice{
	};
	string s;

	for (int i = 1; i <= 6; i++) {
		cin >> dice.a[i];
		dice.state[i] = dice.a[i];
	}

	cin >> s;
	int size = s.size();
	for (int i = 0; i < size; i++) {
		dice.move(s[0]);
		s.erase(s.begin());
	}
	
	cout << dice.state[1] << endl;
	
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 1000000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

bool np[maxn+5];
vi pfac[maxn+5];
int cnt[maxn+5];

int main()
{
    rep(i,2,maxn) 
    {
        if(np[i]==0)
        {
            for(int j=i;j<=maxn;j+=i) np[j]=1,pfac[j].pb(i);
        }
    }

    int n; scanf("%d",&n);
    rep(i,1,n)
    {
        int x; scanf("%d",&x);
        for(auto p: pfac[x]) cnt[p]++;
    }
    bool f1=1,f2=1;
    rep(i,1,maxn) 
    {
        if(cnt[i]>1) f1=0;
        if(cnt[i]==n) f2=0;
    }
    if(f1) puts("pairwise coprime");
    else if(f2) puts("setwise coprime");
    else puts("not coprime");
    return 0;
}


Measured memory_bytes: 63944
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    
    string key;
    cin >> key;
    for(int i=0;i<3;i++){
      if(key[i]==key[i+1]){
        cout << "Bad";
        return 0;
      }
    }
  	cout << "Good";
    return 0;
        
    
    return 0;
}

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int dx[4] = {0,0,-1,1};
const int dy[4] = {1,-1,0,0};

int main()
{
    ll m,n; cin >> n >> m;
    vector< vector<ll> > g(n);
    vector<ll> dist(n,-1);
    for( int i = 0; i < m; ++i )
    {
        ll a,b; cin >> a >> b;
        a--; b--;
        g[b].push_back(a); g[a].push_back(b);
    }

    queue<ll> que;
    dist[0] = 0;
    que.push(0);
    bool flag = false;
    while(!que.empty())
    {
        ll v = que.front();
        que.pop();
        for( int i = 0; i < g[v].size(); ++i )
        {
            int nv = g[v][i];
            if( dist[nv] != -1 )
            {
                continue;
            }
            dist[nv] = v+1;
            que.push(nv);
            flag = true;
        }
    }
    if( flag == false )
    {
        cout << "No" << endl;
    }
    else if( flag == true )
    {
        cout << "Yes" << endl;
        for( int i = 1; i < dist.size(); ++i )
        {
            if( dist[i] == -1 )
            {
                continue;
            }
            cout << dist[i] << endl;
        }

    }
    return 0;
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


#define INF 1e+9
#define MAX_V 2100

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

  int N, X, Y;
  cin >> N >> X >> Y;

  V = N;

  X--;
  Y--;

  for(int i = 0; i < N-1; i++){

    edge e1 = {i, 1};
    edge e2 = {i+1, 1};
    G[i].push_back(e2);
    G[i+1].push_back(e1);
    
  }

  edge e1 = {Y, 1};
  edge e2 = {X, 1};
  G[X].push_back(e1);
  G[Y].push_back(e2);

  vector<int> ans(N-1);

  rep(i, N-1){
    ans[i] = 0;
  }

  for(int i = 0; i < N; i++){
    dijkstra(i);
    
    for(int j = i+1; j < N; j++){

      ans[d[j]-1]++;

    }

  }

  rep(i, N-1){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
    final static long MOD = 1000000007;

    public static void main(String args[]) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int n = fs.nextInt();
        int [] h= fs.nextIntArray(n);

        int [] dp = new int[n];

        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            dp[i] = i == 1 ? Math.abs(h[i-1] - h[i]) : Math.min(Math.abs(h[i] - h[i-1]) + dp[i-1] , Math.abs(h[i] - h[i-2]) + dp[i-2]);
        }

        //System.out.println(Arrays.toString(dp));
        System.out.println(dp[n-1]);

        out.flush();
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                //                br = new BufferedReader(new FileReader("file2.txt"));

                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

}




Measured memory_bytes: 31572
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;

  cin >> a >> b >> c;

  if(a == 1 && b == 1 && c == 0 || a == 0 && b == 0 && c == 1){
    cout << "Open" << endl;
  }else{
    cout << "Close" << endl;
  }
  return 0;
}




Measured memory_bytes: 3128
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

const double pi=4*atan(1.0);

int main() {
	int N,M;
	cin>>N>>M;
	vector<int> BallNum(N,1);
	vector<bool> IsRedIn(N,false);
	IsRedIn[0]=true;

	for(int i=0;i<M;++i){
		int x,y;
		cin>>x>>y;

		--x;
		--y;

		if(IsRedIn[x]){
			if(BallNum[x]==1){
				IsRedIn[x]=false;
			}
			IsRedIn[y]=true;
		}
		--BallNum[x];
		++BallNum[y];
	}

	int ans=0;
	for(const auto val:IsRedIn){
		if(val)++ans;
	}
	cout<<ans<<endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 640
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long 
const int maxn = 2e5+10;
ll a[maxn],b[maxn];
signed main(){
	int n,m,k;
	cin >> n >> m >> k;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		a[i] += a[i-1];
	}
	for(int i = 1;i <= m;i++){
		cin >> b[i];
		b[i] += b[i-1];
	}
	ll ans = 0;
	for(int i = 1;i <= n;i++)if(a[i] <= k){
		int res = k - a[i];
		if(res <= 0){
			if(res == 0)ans = max(ans,i);
			continue;
		}
		int idx = lower_bound(b+1,b+m+1,res) - b;
		while(b[idx] > res and idx)idx--;
		if(idx > m)idx = m;
		ans = max((ll)i+idx,ans);
	}
	for(int i = 1;i <= m;i++)if(b[i] <= k){
		int res = k - b[i];
		if(res <= 0){
			if(res == 0)ans = max(ans,i);
			continue;
		}
		int idx = lower_bound(a+1,a+n+1,res) - a;
		while(a[idx] > res and idx)idx--;
		if(idx > n)idx = n;
		ans = max((ll)i+idx,ans);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6756
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll k,x;
    cin>>k>>x;
    if(500*k>=x) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N; cin >> N;
	vector<long long>A(N + 1), B(N);
	for (int i = 0;i < N + 1;i++) {
		cin >> A[i];
	}
	for (int i = 0;i < N;i++) {
		cin >> B[i];
	}
	long long ans = 0;
	for (int i = 0;i < N;i++) {
		if (A[i] <= B[i]) {
			ans += A[i];
			B[i] -= A[i];
			if (A[i + 1] <= B[i]) {
				ans += A[i+1];
				A[i + 1] = 0;
			}
			else {
				ans += B[i];
				A[i + 1] -= B[i];
			}
		}
		else {
			ans += B[i];
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  ll n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  
  map<char, ll> rsp;
  rsp['r'] = p;
  rsp['s'] = r;
  rsp['p'] = s;
  
  queue<ll> que;
  for(ll i=0; i<k; i++){
    ll j=i;
    while(j+k < n){
      if(t[j] == t[j+k]){
        que.push(j);
      }
      j += k;
    }
  }
  
  ll sum = 0;
  for(ll i=0; i<n; i++){
  	sum += rsp[t[i]];
  }
  
  ll red = 0;
  while(!que.empty()){
  	ll here = que.front();
    que.pop();
    ll next = que.front();
    if(here + k == next){
      que.pop();
    }
    red += rsp[t[here]];
  }
  
  ll ans = sum - red;
  cout << ans << endl;
}


Measured memory_bytes: 1152
n = int(input())
li = list(map(int, input().split()))
co_li = [0]*8
any_col = 0
for s in li:
    if s < 400:
        co_li[0] += 1
    elif 400 <= s < 800:
        co_li[1] += 1
    elif 800 <= s < 1200:
        co_li[2] += 1
    elif 1200 <= s < 1600:
        co_li[3] += 1
    elif 1600 <= s < 2000:
        co_li[4] += 1
    elif 2000 <= s < 2400:
        co_li[5] += 1
    elif 2400 <= s < 2800:
        co_li[6] += 1
    elif 2800 <= s < 3200:
        co_li[7] += 1
    elif 3200 <= s:
        any_col += 1
color_kind = sum(x>0 for x in co_li)
is_all_any_color = sum(co_li) == 0
min_sum = color_kind + (1 if is_all_any_color is True else 0)
max_sum = color_kind + any_col
print(min_sum,max_sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;





int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<P> g[MAX];
  ll i, j;
  
  for(i=0; i<M; i++) {
    ll p, y;
    cin >> p >> y;
    p--;
    g[p].push_back({y, i});
  }
  
  for(i=0; i<N; i++)
    sort(g[i].begin(), g[i].end());
  
  P ci[MAX];
  for(i=0; i<N; i++) {
    for(j=0; j<g[i].size(); j++) {
      P p=g[i][j];
      
      ci[p.second]={i, j};
    }
  }
  
  for(i=0; i<M; i++) {
    printf("%06lld%06lld\n", ci[i].first+1, ci[i].second+1);
  }
  
  
}




Measured memory_bytes: 8576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, k;
vector<i64> v;
i64 lsum[51], rsum[51];
int main() {
  cin >> n >> k;
  read_n(v, n);
/*
  for (i64 i = 1; i <= n; ++i) {
    lsum[i] = lsum[i - 1] + v[i - 1];
  }
  for (i64 i = 1; i <= n; ++i) {
    rsum[i] = rsum[i - 1] + v[n - i];
  }
*/
  i64 ans = 0;
  for (i64 l = 0; l <= n; ++l) {
    for (i64 r = 0; r <= n - l; ++r) {
      if (l + r > k) break;
      vector<i64> u;
      for (i64 i = 0; i < l; ++i) u.push_back(v[i]);
      for (i64 i = 0; i < r; ++i) u.push_back(v[n - i - 1]);
      sort(begin(u), end(u));
      i64 sum = 0;
      for (i64 x : u) sum += x;
      for (i64 i = 0; i < k - l - r && i < u.size(); ++i) {
        if (u[i] < 0) sum -= u[i];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

	int b[3];
	int i;
	for ( i = 0; i < 3; i++){
		scanf("%d", &b[i]);
	}

	if (b[2] == 1)
		printf("Open\n");
	else if (b[0] == 1){
		if (b[1] == 1)
			printf("Open\n");
		else
			printf("Close\n");
	}
	else
		printf("Close\n");
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

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

    vector<int> A2(N+2,0);
    rep(i,N) A2[i+1] = A[i];
    A2[N+1] = 0;

    ll total = 0;
    rep(i,N+1){
        total += abs(A2[i] - A2[i+1]);
    }
    
    ll ans;
    rep(i,N){
        ans = total - abs(A2[i]-A2[i+1]) - abs(A2[i+1]-A2[i+2]) + abs(A2[i]-A2[i+2]);
        cout << ans << endl;
    }    
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
int main(){

    
    string X,Y;
    cin >> X >> Y;
    
    if(X > Y) {
        cout << '>' << endl;
    }else if(X < Y) {
        cout << '<' << endl;
    }else{
        cout << '=' << endl;
    }

    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
typedef long long int lli;
using namespace std;

int n,w;
lli value[105],weight[105];

lli dp[105][100000+5];

void knapsack(){
	for(int i = 0;i<=n;i++)
		dp[i][0] = 0;
	for(int i =0;i<=w;i++)
		dp[0][i] = 0;

	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=w;j++){
			dp[i][j] = (weight[i] <=j) ? max(dp[i-1][j-weight[i]] +value[i],dp[i-1][j]) : dp[i-1][j];
		}
	}
}
int main(){
	cin>>n>>w;

	for(int i = 1;i<=n;i++)
		cin>>weight[i]>>value[i];

	knapsack();
	cout<<dp[n][w]<<endl;
	
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
set<ll> s;
void build(){
    queue<ll> q;
    q.push(1LL);
    q.push(2LL);
    q.push(3LL);
    q.push(4LL);
    q.push(5LL);
    q.push(6LL);
    q.push(7LL);
    q.push(8LL);
    q.push(9LL);

    while(sz(q)){
        //cout << q.front() << " coleli\n";
        ll a = q.front();
        s.insert(a);
        q.pop();
        if(sz(s) <= 100000)
        for(int i = 0; i <= 9; i++){
            if(abs(a % 10 - i) <= 1 && a * 10 + i <= 3234566667){
                ll nw = a * 10 + i;
                s.insert(nw);
                q.push(nw);
            }
        }
    }
}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    int k;
    cin >> k;
    build();
    int cnt = 1;
    fori(i,s){
        if(cnt == k){
            cout << *i << '\n';
            break;
        }
        cnt++;
    }
    return 0;   
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int gcd(int a, int b) { // a > b
  int c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

int main() {
  int N;
  cin >> N;
  int A[N];
  rep(i,N) {
    cin >> A[i];
  }
  int ans = A[0];
  srep(i,1,N) {
    ans = gcd(ans,A[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion

bool is_p(string s){
    return equal(s.begin(), s.begin() + s.length() / 2, s.rbegin());
}

int32_t main() {
    make(string, s);
    int n = s.length();
    auto t1 = s.substr(0, n / 2);
    auto t2 = s.substr(n / 2 + 1);
    cout << (is_p(s) && is_p(t1) && is_p(t2) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	ll A,B;
	ll price;
	vector<int> given;

	cin >> A >> B;

	for(price=1;price<=5000000;price++){
		//cout << price*80/100 << " " << price*100/100 << endl;
		if(price*80/1000==A && price*100/1000==B){
			cout << price << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;

	return 0;
}



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s; cin >> s;
  int res = 0;
  for(int i = 0; i < sz(s) - i - 1; i++){
    if(s[i] != s[sz(s) - i - 1])++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256