akhauriyash/Code-Regression huggingface dataset:
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define  MN                           INT_MIN
#define  MX                           INT_MAX
#define int long long
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int n,m;
	cin >> n >> m;
	int a[n];
	priority_queue<int> q;
	for(int i=  0;i<n;i++){
		cin >> a[i];
		q.push(a[i]);
	}
	while(m >  0){
		int need = q.top();
		q.pop();
		m--;
		q.push(need / 2);
	}
	int ans = 0;
	while(!q.empty()){
		ans+= q.top();
		q.pop();
	}
	cout << ans << endl;
}

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

int main()
{
	std::vector<int> x(5);

	for (int i = 0; i < x.size(); i++)
	{
		std::cin >> x[i];
	}

	int answer = 0;
	for (int i = 0; i < x.size(); i++)
	{
		if (x[i] == 0)
		{
			answer = i + 1;
			break;
		}
	}
	std::cout << answer;

	return 0;
}


Measured memory_bytes: 3604
'use strict'

function main(input) {
  input = input.split(" ").map(v => parseInt(v, 10));
  const A = input[0];
  const B = input[1];
  if (B % A === 0)
    return A + B;
  else
    return B - A;
}

const fs = require("fs");
const msg = main(fs.readFileSync("/dev/stdin", "utf8"));
console.log(msg);


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

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

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

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

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

int main()
{
  int n; cin >> n;
  vector<ll> x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  ll sum_h = accumulate(ALL(h), 0ll);
  for(int cx = 0; cx <= 100; ++cx) {
    for(int cy = 0; cy <= 100; ++cy) {
      bool def = false;
      ll H;
      rep(i, n) if(h[i] > 0) {
        def = true;
        H = h[i]+abs(x[i]-cx)+abs(y[i]-cy);
        break;
      }
      if(def) {
        bool ok = true;
        rep(i, n) {
          if(h[i] != max(0ll, H-abs(x[i]-cx)-abs(y[i]-cy))) ok = false;
        }
        if(ok) {
          cout << cx << " " << cy << " " << H << endl;
          return 0;
        }
      }
      else {
        for(H=1; H <= 100; ++H) {
          bool ok = true;
          rep(i, n) {
            if(h[i] != max(0ll, H-abs(x[i]-cx)-abs(y[i]-cy))) ok = false;
          }
          if(ok) {
            cout << cx << " " << cy << " " << H << endl;
            return 0;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> x(N);
	map<pair<int,int>,int> r;
	vector<int> A(N, 99);
	for (int i = 0; i < M; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		x[a].push_back(b);
		x[b].push_back(a);
		r[{a, b}] = (c % 2);
	}
	queue<int> a;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] != 99||x[i].size()==0)continue;
		A[i] = 0; ans++;
		a.push(i);
		while (a.size() > 0) {
			int y = a.front();
			a.pop();
			for (int j = 0; j < x[y].size(); j++) {
				if (A[x[y][j]] == 99)a.push(x[y][j]);
				A[x[y][j]] = A[y] ^ r[{i, x[y][j]}];
			}
		}
	}
	for (int i = 0; i < N; i++)if (A[i] == 99)ans++;
	cout << ans << endl;
	
}




Measured memory_bytes: 19448
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}

int main()
{
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    vector<ll> C(N+1);
    vector<ll> B(N);
    ll loop=0;
    ll time=0;
    C.at(1)=1;
    rep(i,N){
        if(i==0)B.at(i)=1;
        else{
            B.at(i)=A.at(B.at(i-1)-1);
            if(C.at(B.at(i))==0)C.at(B.at(i))=i+1;
            else {
                loop=i+1-C.at(B.at(i));
                time=C.at(B.at(i));
                break;
            }
        }
    }
    if(K<=time)cout<<B.at(K)<<endl;
    else{
        K=(K-time)%loop+time;
        cout<<B.at(K)<<endl;
    }
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

signed main() {
    ll H,W,N;
    cin>>H>>W>>N;
    vector<ll> a(N), v;
    ll out[H][W];

    rep(i,0,N) {
        cin>>a[i];
        rep(j,0,a[i]){
            v.push_back(i+1);
        }
    }

    ll p=0;
    rep(y,0,H){
        if (y%2==0){
            for (ll x=0; x<W; x++){
                out[y][x] = v[p++];
            }
        }else{
            for (ll x=W-1; x>=0; x--){
                out[y][x] = v[p++];
            }
        }
    }
    rep(y,0,H){
        rep(x,0,W){
            cout<<out[y][x];
            if (x!=W-1)
                cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
import sys
import queue

H,W = map(int,input().split())
white = 0
maze = [['#']*(W+2)]
for y in range(H):
	li = list(input())
	white += li.count('.')
	maze.append(['#'] + li + ['#'])
maze.append(['#']*(W+2))



def check(x,y,n):
	if x == W and y == H:
		print (white - n - 1)
		sys.exit()
	elif maze[y][x] == '.':
		maze[y][x] = n
		q.put([x-1,y,n+1])
		q.put([x+1,y,n+1])
		q.put([x,y-1,n+1])
		q.put([x,y+1,n+1])
	else:
		return

q = queue.Queue()
q.put([1,1,0])
while not q.empty():
	x,y,n = q.get()
	check(x,y,n)

print(-1)


Measured memory_bytes: 3952
// 解答不能.
// codelegend氏.
// https://atcoder.jp/contests/abc144/submissions/8163936
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 600;
vector<int> adj[N];
double dp[N], dpr[N], prob[N];

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u - 1].push_back(v - 1);
    }
    dp[n - 1] = 0;
    for(int u = n - 2; u >= 0; u--){
        double curr = 0;
        int sz = adj[u].size();
        for(int v: adj[u]) curr += dp[v];
        dp[u] = 1 + curr / sz;
        dpr[u] = dp[u];
        if(sz > 1) for(int v: adj[u]) dpr[u] = min(dpr[u], 1 + (curr - dp[v]) / (sz - 1));
    }
    prob[0] = 1;
    for(int u = 0; u < n - 1; u++){
        double pj = prob[u] / adj[u].size();
        for(int v: adj[u]) prob[v] += pj;
    }
    double ans = dp[0];
    for(int u = 0; u < n - 1; u++) ans = min(ans, dp[0] - prob[u] * (dp[u] - dpr[u]));
    printf("%.10lf", ans);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int h, w; cin >> h >> w;
	char arr[h][w];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> arr[i][j];

	int dp[h][w];

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (arr[i][j] == '#')
				dp[i][j] = 0;

			else if (i == 0 && j == 0)
				dp[i][j] = 1;

			else if (i == 0)
				dp[i][j] = dp[i][j - 1];

			else if (j == 0)
				dp[i][j] = dp[i - 1][j];

			else
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
		}
	}

	cout << dp[h - 1][w - 1] << endl;

	return 0;
}

Measured memory_bytes: 12412
#include <iostream>
#include <map>
#define MOD 1000000000+7
using namespace std;

map<int, int> prime_factor(int n){
    map<int,int> prime_factor;
    for(int j=1;j<=n;j++){
        int x=j;
        for(int i=2;i*i<=x;i++){
            if(x==1) break;

            while(x%i==0){
                x /= i;
                prime_factor[i] ++;
            }
        }
        if(x>1) prime_factor[x] ++;
    }
    return prime_factor;
}

int main(void){
    int n;
    cin>>n;
    long long ans=1;
    for(auto kv: prime_factor(n)){
        ans *= (kv.second+1);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int mtr[2001][2001];
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		 mtr[i][j]=abs(i-j);
	}
	mtr[x][y]=1;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(i==j)
			 continue;
			else if(i<j)
			{
				mtr[i][j]=min(mtr[i][j],mtr[i][x]+mtr[j][y]+1);
			}
			else
			{
				mtr[i][j]=min(mtr[i][j],mtr[i][y]+mtr[j][x]+1);
			}
		}
	}
	int memo[2001];
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
	    {
	    	memo[mtr[i][j]]++;
		}
	}
	for(int i=1; i<=n-1; i++)
	{
		cout<<memo[i]/2<<"\n";
	}
	return 0;
}

Measured memory_bytes: 19272
#include <stdio.h>

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

Measured memory_bytes: 596
n,a,b=map(int,input().split())

v=b-(a+1)

if v%2==0:
    if a==1 or b==n:
        #ans=int((v+1)/2)+1
        ans=(v-1)//2+1+1
    else:
        dif=min(n-b,a-1)
        #ans1=dif+int((v+2*dif)/2)+1
        ans1=dif+1+v//2
        if (n-b)<(a-1):
            ans2=n-a
        else:
            ans2=b-1
        #ans=min(ans1,ans2)
        ans=ans1
else:
    ans=(v+1)//2
print(ans)


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

const long long mod = 1e9 + 7;

long long calcFact(long long n) {
  long long ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= mod;
  }
  return ans;
}

int main(void) {
  int N, M;
  cin >> N >> M;
  long long ans = 0;
  if (abs(N - M) == 1) {
    ans = (calcFact(N) * calcFact(M)) % mod;
  } else if (abs(N - M) == 0) {
    ans = (2 * (calcFact(N) * calcFact(M)) % mod) % mod;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N;
    vector<int> in(N);
    for (auto& i : in)
        cin >> i;

    sort(in.begin(), in.end());
    cout << in[in.size()-1] - in[0] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int month = s.nextInt();
		int day = s.nextInt();
		s.close();
		int d1 = 0;
		int day10 = day / 10;
		int sum = 0;

		for (int i = 2; i <= month; i++) {
			//月ごとに処理する
			for (int j = 2; j <= day10; j++) {
				d1 = i / j;
				if ((j * 10 +d1) <= day 
						&& i % j ==0 
						&& d1>1
						&& 10 > d1 ) {
					sum++;
				}
			}
		}
		System.out.println(sum);

	}

}


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

int gcd(int a, int b) {
  while(a%b != 0) {
    int t = a % b;
    a = b;
    b = t;
  }
  return b;
}

int main() {
  int K;
  cin >> K;
  LL sum = 0;
  REP(a, K) {
    REP(b, K) {
      int g = gcd(a+1, b+1);
      REP(c, K) {
        sum += gcd(g, c+1);
      }
    }
  }
  cout << sum << endl;
} 

Measured memory_bytes: 3636
import sys
sdin = sys.stdin.readline


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

for k in range(29):
    # 下k桁目までバケットソートする
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    # 下k桁を取り出す
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    # 尺取法(意味不明)
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3] - itr[2]))
    
    # 1の個数が奇数ならその桁のxorが1になる
    if count & 1:
        ans += base
    
    
print(ans)

Measured memory_bytes: 143932
/////////////////////////////////////////////////////////////////////////////////
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'               `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//  
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$'                   `$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//$$$'`$$$$$$$$$$$$$'`$$$$$$!                       !$$$$$$'`$$$$$$$$$$$$$'`$$$//
//$$$$  $$$$$$$$$$$  $$$$$$$                         $$$$$$$  $$$$$$$$$$$  $$$$//
//$$$$. `$' \' \$`  $$$$$$$!       $$        $$      !$$$$$$$  '$/ `/ `$' .$$$$//
//$$$$$. !\  i  i .$$$$$$$$       $$$$      $$$$      $$$$$$$$. i  i  /! .$$$$$//
//$$$$$$   `--`--.$$$$$$$$$        $$        $$       $$$$$$$$$.--'--'   $$$$$$//
//$$$$$$L        `$$$$$^^$$                           $$^^$$$$$'        J$$$$$$//
//$$$$$$$.   .'   ""~   $$$    $.                 .$  $$$   ~""   `.   .$$$$$$$//
//$$$$$$$$.  ;      .e$$$$$!    $$.             .$$  !$$$$$e,      ;  .$$$$$$$$//
//$$$$$$$$$   `.$$$$$$$$$$$$     $$$.         .$$$   $$$$$$$$$$$$.'   $$$$$$$$$//
//$$$$$$$$    .$$$$$$$$$$$$$!     $$`$$$$$$$$'$$    !$$$$$$$$$$$$$.    $$$$$$$$//
//$$$$$$$     $$$$$$$$$$$$$$$$.    $    $$    $   .$$$$$$$$$$$$$$$$     $$$$$$$//
//                                 $    $$    $								   //
//                                 $.   $$   .$								   //
//                                `$        $'								   //
//                                 `$$$$$$$$'								   //
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////

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

// Type-Define 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef std::vector<char> vc;
typedef std::vector< vector<int> > vii;
typedef std::pair<int, int> pii;

// Hash-Define
#define int long long
#define MOD 1000000007
#define debugStart cerr << "\n[DEBUG START]\n"
#define debugStop cerr << "\n[DEBUG STOP]\n"
#define KHATAM cout << std::endl;
#define set_zero(x) memset(x, 0, sizeof(x));
#define ForPrint(x) std::for_each( begin(x), end(x), []( auto const& el ){ std::cout << el << " ";  } )

//Functions 
template<typename T> auto gcd ( T a, T b ) -> int  { return (b==0)?a:gcd(b,a%b); }

const int inf = 1e9 + 5;

signed
main() {

    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = 1; 
    //cin >> T;
    for ( int testcase = 1; testcase <= T; ++testcase ) {
        int N;
        std::cin >> N;
        std::vector<int> arr(3);
        std::vector<int> copy(3);
        for ( int i = 0; i < N; ++i ) {
            
            std::cin >> arr[0] >> arr[1] >> arr[2];
            if( i >= 1 ) {
                arr[0] += max(copy[1], copy[2]);
                arr[1] += max(copy[0], copy[2]);
                arr[2] += max(copy[1], copy[0]);
            }
            copy = arr;
        }
        std::cout << max( {arr[0], arr[1], arr[2]} ) ;
        KHATAM;
    }
    return 0;
}


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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef pair<lli, P> PP;

struct edge {
    lli to;
    lli cost;
};

vector<edge> G[100001];
bool used[100001];

lli prim() {
    lli total = 0;
    priority_queue< P, vector<P>, greater<P> > xque;

    // 事前に最初の node の辺のみ入れておく
    used[1] = true;
    lli cur_v = 1;
    REP(i, 0, (lli)G[cur_v].size()) {
        edge e = G[cur_v][i];
        if (!used[e.to])
            xque.push(P(e.cost, e.to));
    }

    // O(ElogV) なのか・・・？
    while (true) {
        // 次に使われる辺を選ぶ
        edge next = {LLONG_MAX, LLONG_MAX};
        while (!xque.empty()) {
            P p = xque.top();
            xque.pop();
            if (!used[p.second]) {
                next.cost = p.first;
                next.to = p.second;
                total += next.cost;
                used[next.to] = true;
                break;
            }
        }
        if (next.cost == LLONG_MAX)
            break;

        // next が使われた辺なので、新たに next.to から張られる辺を登録
        cur_v = next.to;
        REP(i, 0, (lli)G[cur_v].size()) {
            edge e = G[cur_v][i];
            if (!used[e.to])
                xque.push(P(e.cost, e.to));
        }
    }

    return total;
}


int main() {
    lli n;
    cin >> n;
    // v_xi[i]: i 番目のpair。first が x 座標で、second が何個目か
    vector<PP> v_x;
    vector<PP> v_y;
    REP(i, 0, n) {
        lli x;
        lli y;
        cin >> x >> y;
        v_x.push_back(PP(x, P(y, i+1)));
        v_y.push_back(PP(y, P(x, i+1)));
    }
    sort(v_x.begin(), v_x.end());
    sort(v_y.begin(), v_y.end());

    REP(i, 0, n-1) {
        lli x_diff, y_diff;
        // x 軸方向で辺登録
        x_diff = v_x[i+1].first - v_x[i].first;
        y_diff = abs(v_x[i+1].second.first - v_x[i].second.first);
        edge e1_x = {v_x[i+1].second.second, min(x_diff, y_diff)};
        edge e2_x = {v_x[i].second.second, min(x_diff, y_diff)};
        G[v_x[i].second.second].push_back(e1_x);
        G[v_x[i+1].second.second].push_back(e2_x);

        // y 軸方向で辺登録
        y_diff = v_y[i+1].first - v_y[i].first;
        x_diff = abs(v_y[i+1].second.first - v_y[i].second.first);
        edge e1_y = {v_y[i+1].second.second, min(x_diff, y_diff)};
        edge e2_y = {v_y[i].second.second, min(x_diff, y_diff)};
        G[v_y[i].second.second].push_back(e1_y);
        G[v_y[i+1].second.second].push_back(e2_y);
    }

    lli ans = prim();
    cout << ans << endl;


}


Measured memory_bytes: 20132
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;


void solve(std::string s){
    int n = s.length();
    s.push_back('.');
    V<ll> A;
    loop (n, i) {
        if (s[i] == 'A') {
            A.push_back(0);
            continue;
        }
        if (s[i] == 'B' && s[i + 1] == 'C') {
            A.push_back(1);
            i++;
            continue;
        }
        A.push_back(-1);
    }
    int m = A.size();
    V<ll> B = A;
    loop (m - 1, i) {
        if (B[m - 2 - i] != -1 && B[m - 1 - i] != -1) {
            B[m - 2 - i] += B[m - 1 - i];
        }
    }
    ll ans = 0;
    loop (m, i) {
        if (A[i] == 0) {
            ans += B[i];
        }
    }
    cout << ans << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}



Measured memory_bytes: 3956
# ITP1_7_A
while True:
    m, f, r = (int(x) for x in input().split())
    if m == f == r == -1:
        break
    x = m + f
    if m == -1 or f == -1:
        print('F')
        continue
    if x >= 80:
        print('A')
    elif x < 80 and x >= 65:
        print('B')
    elif x < 65 and x >= 50:
        print('C')
    elif x < 50 and x >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


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

int sum(int a[],int left,int right){
  int ans=0;
  for(int i=left;i<=right;i++){
    ans+=a[i];
  }
  return ans;
}

int max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int main(){
  int n;
  cin>>n;
  int a[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    count=max(count,sum(a[0],0,i)+sum(a[1],i,n-1));
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

m = A - B
n = B - A

if (K % 2 == 0):
    if m > 10**18:
        print('Unfair')
    print(m)
else:
    if (n > 10**18):
        print('Unfair')
    print(n)


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

void solve(int n){
    D eps = n * 1e-5;
    D x = n / 2.0;
    while(!(abs(x*x*x - n) < eps)){
        pf("-- %f\n", x);
        x = x - (x*x*x - n) / (3*x*x);
    }
    printf("%f\n", x);
}

int main(){
    int n;
    while(cin >> n, n > 0){
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int Nt = N, f = 0;
  while (Nt) {
    f += Nt % 10;
    Nt /= 10;
  }
  if (N % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

//閉路やばそう
//閉路の総和がPより大きいとヤバそう
//小さい場合は閉路を回る必要がないが

//閉路判定以外やるだけでは？

struct edge {
	int to; ll cost;
};
vector<edge> G[2500];
vector<int> rG[2500];
ll score[2500];

bool cangoal[2500];
bool canstart[2500];
void solve() {
	int n, m; cin >> n >> m; ll p; cin >> p;
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c; a--; b--;
		G[a].push_back({ b,c });
		rG[b].push_back(a);
	}
	fill(score, score + n, -INF);
	score[0] = 0;

	//頂点0から行けてかつN-1に到達するやつを列挙
	queue<int> q; q.push(n - 1); cangoal[n - 1] = true;
	while (!q.empty()) {
		int id = q.front(); q.pop();
		rep(j, rG[id].size()) {
			int to = rG[id][j];
			if (cangoal[to])continue;
			cangoal[to] = true; q.push(to);
		}
	}
	//rep(i, n)cout << i << " " << cangoal[i] << endl;
	q.push(0); canstart[0] = true;
	while (!q.empty()) {
		int id = q.front(); q.pop();
		rep(j, G[id].size()) {
			int to = G[id][j].to;
			if (canstart[to])continue;
			canstart[to] = true; q.push(to);
		}
	}
	rep(i, n) {
		if (!canstart[i])cangoal[i] = false;
	}

	//とりあえず5000回更新
	rep(aa, 2500) {
		rep(i, n) {
			if (!cangoal[i])continue;
			rep(j, G[i].size()) {
				int to = G[i][j].to;
				if (!cangoal[to])continue;
				ll ns = score[i] + G[i][j].cost - p;
				//cout << i << " " << to << " " << ns << endl;
				if (score[to] < ns) {
					score[to] = ns;
				}
			}
		}
	}

	//まだ更新されるなら無限に回ってる
	rep(i, n) {
		if (!cangoal[i])continue;
		rep(j, G[i].size()) {
			int to = G[i][j].to;
			if (!cangoal[to])continue;
			ll ns = score[i] + G[i][j].cost - p;
			if (score[to] < ns) {
				//cout << i << " " << to << endl;
				cout << -1 << endl; return;
				score[to] = ns;
			}
		}
	}
	if (score[n - 1] < 0)score[n - 1] = 0;
	cout << score[n - 1] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,u,v;
vi g[125252];
bool used[125252];

bool dfs(int a,int b,int turn){
  if(turn==n/2)return true;
  REP(i,g[a].size()){
    int toa = g[a][i];
    if(used[toa])continue;
    REP(j,g[b].size()){
      int tob = g[b][j];
      if(used[tob])continue;
      if(toa==tob)continue;
      used[toa] = true;
      used[tob] = true;
      if( dfs(g[a][i],g[b][j],turn+1) )return true;
      used[toa] = false;
      used[tob] = false;
    }
  }
  return false;
}

bool solve(){
  // ??????
  if(n%2==1)return false;
  REP(i,n)if(g[i].size()>=4)return false;
  int tricount = 0;
  REP(i,n)if(g[i].size()==3)++tricount;
  if(tricount>=3)return false;
  // dfs
  REP(i,n)used[i]=false;
  used[u]=true;
  used[v]=true;
  return dfs(u,v,1);
}

int main(){
  scanf("%d%d%d",&n,&u,&v);
  --u; --v;
  REP(i,n-1){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if(solve())puts("Yes");
  else puts("No");
  return 0;
}

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

vector<int> G[200000];
int N, K;

int dfs(int v, int par, int& ans) {
    int h = 0;
    for (int to : G[v]) {
        if (to == v or to == par) continue;
        h = max(h, dfs(to, v, ans) + 1);
    }
    if (par != 0 and h >= K - 1) {
        h = -1;
        ans++;
    }
    return h;
}

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

    int ans = 0;

    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;

        if (i == 0 and a[i] != 0) {
            a[i] = 0;
            ans++;
        }

        G[i].push_back(a[i]);
        G[a[i]].push_back(i);
    }

    for (int v = 0; v < N; v++) {
        cerr << "[" << v << "] ";
        for (int to : G[v]) {
            cerr << to << ", ";
        }
        cerr << endl;
    }

    dfs(0, 0, ans);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14720
#include<stdio.h>

int main(){

  int num,A[100],i,j,k=0,tmp,flag;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }

  
  for(i=0;i<num;i++){
  flag=1;
  
  while(flag){
    flag=0;
    for(j=num-1;j>=i+1;j--){

      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
        k++; 

      }

    }	
  }
  }
  
  for(i=0;i<num-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",k);

return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;

namespace atcoder_bc173
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            Dictionary<string, int> statusDict = new Dictionary<string, int>();
            string[] statusList = { "AC", "WA", "TLE", "RE" };

            foreach(var it in statusList)
            {
                statusDict[it] = 0;
            }
            for (int i=0;i<N;i++)
            {
                var msg = Console.ReadLine();
                statusDict[msg] += 1;
            }
            foreach(var it in statusList)
            {
                Console.WriteLine("{0} x {1}", it, statusDict[it]);
            }

        }
    }
}


Measured memory_bytes: 31008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	pair<int, int> p[n];
	rep(i,n) {
		int a; cin >> a;
		p[i] = {a, i};
	}
	sort(p, p+n);
	rep(i,n){
		cout << p[i].second + 1 << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 1536
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  10:00-
//A 10:05 AC
//B 10:15 AC
int solve(void){
	int d,w,ya,xa,yb,xb,i,j,ans=0;cin>>d>>w;
	if(d==0){return 0;}
	int ta[20][20];
	for(i=0;i<d;i++){
		for(j=0;j<w;j++){
			cin>>ta[i][j];
		}
	}
	for(ya=0;ya<d;ya++){
		for(xa=0;xa<w;xa++){
			for(yb=ya+2;yb<d;yb++){
				for(xb=xa+2;xb<w;xb++){
					int soto=mod;
					for(i=ya;i<=yb;i++){mineq(soto,ta[i][xa]);mineq(soto,ta[i][xb]);}
					for(j=xa;j<=xb;j++){mineq(soto,ta[ya][j]);mineq(soto,ta[yb][j]);}
					int gen=0;
					for(i=ya+1;i<=yb-1;i++){
						for(j=xa+1;j<=xb-1;j++){
							if(ta[i][j]>=soto){gen=-mod;break;}
							gen+=soto-ta[i][j];
						}
					}
					maxeq(ans,gen);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 1;
}
int main(void){
	while(solve()){}
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> v(100001);
	rep(i,n) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	priority_queue<pii> p;
	ll ans = 0;
	for (int i = 1; i<= m; i++) {
		for (int x: v[i]) {
			p.push(pii(x, i));
		}
		if (p.empty()) continue;
		ans += p.top().first;
		p.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 8584
let n, p = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let o = Array.fold_left (fun o a -> if a mod 2 = 1 then o + 1 else o) 0 a_s
let e = n - o
let _ = Printf.printf "%d\n" @@
    if o = 0 then if p = 1 then 0 else int_of_float @@ 2. ** float e
    else int_of_float @@ 2. ** float (n - 1)

Measured memory_bytes: 384
a=0
b=0
c=0
d=0
N=int(input())
for i in range(N):
  S=input()
  if S=="AC":
    a+=1
  elif S=="WA":
    b+=1
  elif S=="TLE":
    c+=1
  elif S=="RE":
    d+=1
print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d))

Measured memory_bytes: 9208
N = int(input())
s_dict = {}
ans = 0
for i in range(N):
  string = list(input())
  string.sort(reverse=False)
  if tuple(string) in s_dict:
    s_dict[tuple(string)] += 1
  else:
    s_dict[tuple(string)] = 1

for i in s_dict.values():
  if i != 1:
    ans += sum([i for i in range(1,i)])

print(ans)


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

int gcd(int x, int y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    return gcd(x%y,y);
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n;cin>>n;
    cout<<(n-1)/2<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}



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



int main(void)
{
	int i,n,m,x = 0;
	char W[10], end[] = "END_OF_TEXT", T[1000];

	scanf("%s", W);
	n = strlen(W);

	for(i = 0; i < n; i++)
	{
		W[i] = tolower(W[i]);
	}

	while(1)
	{
		scanf("%s", T);
		if (strcmp(T,end) == 0)
		{
			break;
		}

		m = strlen(T);

		for(i = 0; i < m; i++)
		{
			T[i] = tolower(T[i]);
		}
		if (strcmp(T,W) == 0)
		{
			x++;
		}
	}

	printf("%d\n", x);

	return 0;
}

Measured memory_bytes: 552
def divisors(N):
    divs = set([1, N])
    i = 2
    while i ** 2 <= N:
        if N % i == 0:
            divs.add(i)
            divs.add(N//i)
        i += 1
    return list(divs)


def is_ok(N, K):
    if K <= 1:
        return False
    while N % K == 0:
        N //= K
    return N % K == 1


def main():
    N = int(input())
    ans = 0
    for cand in divisors(N):
        if is_ok(N, cand):
            ans += 1
    for cand in divisors(N-1):
        if is_ok(N, cand):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    cout.precision(20); cout << fixed;
    int n, k;
    cin >> n >> k;
    vector<int> a(n), dp(k + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (i - a[j] >= 0 && dp[i - a[j]] == 0) {
                dp[i] = 1;
                break;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second");
}


Measured memory_bytes: 640
N = int(input())
numbers = [list(map(int, input().split()))]

numbers = numbers[0]

count = 0


for i in range(N-2):
    aaa = []
    number_a = int(numbers[i])
    aaa.append(number_a)
    number_b = int(numbers[i+1])
    aaa.append(number_b)
    number_c = int(numbers[i+2])
    aaa.append(number_c)
    if number_b == sorted(aaa)[-2]:
        count += 1
    else:
        continue

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(!(a%2 && b%2 && c%2)){
		cout << 0 << endl;
		return 0;
	}
	int ans = max(a,max(b,c));
	if(ans==a){
		cout << b*c << endl;
	}else{
		ans = b*c/ans;
		cout << ans*a << endl;
	}
}


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


int main(void){
    char a[200001], b[200001];
    scanf("%s", a);
    scanf("%s", b);
    int ans = 0;
    int n = strlen(a);
    for(int i = 0; a[i]; i++){
        if(a[i] != b[i]){
            ans++;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2120
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []
y = 0
for x in range(1, 1001):
    y += x
    l.append(y/x)
m = []
for i in p:
    m.append(l[i-1])
s = [0]
z = 0
for i in m:
    z += i
    s.append(z)
ans = 0
for i in range(n-k+1):
    ans = max(ans, s[i+k] - s[i])
print(ans)

Measured memory_bytes: 78984
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const ll MOD = 1e9 + 7;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<int> Y(N * M, -1), X(N * M, -1);
    ll res = 1;
    for (int i = 0; i < N; i++) {
      int n;
      cin >> n;
      --n;
      if (Y[n] == -1) {
        Y[n] = i;
      } else {
        res = 0;
      }
    }
    for (int i = 0; i < M; i++) {
      int n;
      cin >> n;
      --n;
      if (X[n] == -1) {
        X[n] = i;
      } else {
        res = 0;
      }
    }
    ll ys = 0, xs = 0;
    for (int k = N * M - 1, c = 0; k >= 0; k--, c++) {
      int y = Y[k];
      int x = X[k];
      if (y != -1 && x != -1) {
        ++ys;
        ++xs;
        continue;
      }
      if (y != -1) {
        ++ys;
        res = res * xs % MOD;
        continue;
      }
      if (x != -1) {
        ++xs;
        res = res * ys % MOD;
        continue;
      }
      ll rem = ys * xs - c;
      res = res * rem % MOD;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int x, n;
  cin >> x >> n;
  unordered_map<int, bool> mp;
  int t;
  REP(i, n) {
    cin >> t;
    mp[t] = true;
  }

  if(mp[x] == false) {
    cout << x << endl;
    return 0;
  }

  int i = 1;
  while(true) {
    if(mp[x - i] == false) {
      cout << x - i << endl;
      return 0;
    }
    else if(mp[x + i] == false) {
      cout << x + i << endl;
      return 0;
    }
    i += 1;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 100;

int n;
int l[N];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    
    for (int i = 0; i < n; i++)
        cin >> l[i];
    
    sort(l, l + n);
    int ans = 0;
    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i + 1; j < n - 1; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (l[i] == l[j] || l[j] == l[k])
                    continue;
                if (l[i] + l[j] > l[k] )
                    ans++;
            }
        }
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3664
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <math.h>
#include <complex.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

complex ARG60 = cos(M_PI/3)+sin(M_PI/3)*I;

void pprint(complex c) {
	printf("%lf %lf\n", creal(c), cimag(c));
}

void koch_curve_r(int n, complex p, complex q) {
	if (n == 0) {
		pprint(p);
		return;
	}
	complex pq = q - p;
	complex s = (pq/3);
	complex t = 2 * s;
	complex u = s * ARG60;
	koch_curve_r(n - 1, p, p+s);
	koch_curve_r(n - 1, p+s, p+s+u);
	koch_curve_r(n - 1, p+s+u, p+t);
	koch_curve_r(n - 1, p+t, q);
}

void koch_curve(int n) {
	complex s = 0+0*I;
	complex e = 100+0*I;
	koch_curve_r(n, s, e);
	pprint(e);
}

int main(int argc, char **argv)
{
	int n;
	scanf("%d", &n);
	koch_curve(n);
	return 0;
}

Measured memory_bytes: 636