akhauriyash/Code-Regression huggingface dataset:
use proconio::{*, marker::Chars};
use std::collections::BTreeMap;

fn main() {
    input!{
        n: usize,
        s: [Chars; n],
    }

    let mut map = BTreeMap::new();
    // let mut map: BTreeMap<&str, i32> = BTreeMap::new();

    map.entry(String::from("AC")).or_insert(0);
    map.entry(String::from("WA")).or_insert(0);
    map.entry(String::from("TLE")).or_insert(0);
    map.entry(String::from("RE")).or_insert(0);

    for i in 0..n {
        let t: String = s[i].iter().collect();
        *map.entry(t).or_insert(0) += 1;
    }

    println!("AC x {}", map[&String::from("AC")]);
    println!("WA x {}", map[&String::from("WA")]);
    println!("TLE x {}", map[&String::from("TLE")]);
    println!("RE x {}", map[&String::from("RE")]);
}


Measured memory_bytes: 7848
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
int main()
{
    fast;
    ll i,j,t;
    vector<ll> a(5);
    for(i = 0; i < 5; i++)
    {
    	cin >> a[i];
    	if(a[i] == 0)
    		break;
    }
    cout<<i + 1<<endl;
    return 0;
}    

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;

class WithIndex<T>
{
    public T Value;
    public int Index;
    public WithIndex(T value, int index)
    {
        this.Value = value;
        this.Index = index;
    }
}

static class Template
{
    public static int LineToInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static string[] LineToStrings()
    {
        return Console.ReadLine().Split();
    }

    public static int[] LineToInts()
    {
        return LineToStrings()
            .Select(s => int.Parse(s))
            .ToArray();
    }


    public static int[,] LinesToIntTable(int lineCount, int columnCount)
    {
        var value = new int[lineCount, columnCount];
        foreach (var y in Enumerable.Range(0, lineCount))
        {
            var ints = LineToInts();
            foreach (var x in Enumerable.Range(0, columnCount))
            {
                value[y, x] = ints[x];
            }
        }
        return value;
    }

    public static IEnumerable<WithIndex<T>> WithIndex<T>(this IEnumerable<T> sequence)
    {
        int index = 0;
        foreach (var item in sequence)
        {
            yield return new WithIndex<T>(item, index);
            index++;
        }
    }
    //i>=1
    static void f(int[] ballCounts, int n, int i, int sumRemainingShouldBe)
    {
        var sumRemain = Enumerable.Range(1, n / i + 1)
            .Select(index => index * i)
            .Where(index => index <= n)
            .Select(index => ballCounts[index - 1])
            .Sum() % 2;
        if (sumRemain == sumRemainingShouldBe)
        {
            //ボール入れなくていい
            ballCounts[i - 1] = 0;
        }
        else
        {
            //ボール入れないとだめ
            ballCounts[i - 1] = 1;
        }
    }

    static void Main(string[] args)
    {
        var n = LineToInt();
        var remainingShouldBe = LineToInts();
        var ballCounts = new int[n];
        for (int temp = n; temp > 0; temp--)
        {
            f(ballCounts, n, temp, remainingShouldBe[temp - 1]);
        }
        var ballExistingBoxCount = ballCounts.Count(c => c > 0);
        Console.WriteLine(ballExistingBoxCount);
        foreach (var i in Enumerable.Range(0, n))
        {
            if (ballCounts[i] == 0) continue;
            Console.Write(i + 1 + " ");
        }
    }
}



Measured memory_bytes: 29420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long x[n+5];
    long long sum=0;
    for(long long i=0;i<n;i++)
    {
        cin>>x[i];
        sum+=(x[i]-1);
    }
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        long[] nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = nk[0];
        long k = nk[1];
        int[][] ab = new int[n][];
        for(int i = 0; i < n; i ++) ab[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(ab, (x,y) => x[0]-y[0]);
        long count = 0;
        long ans = 0;
        for(int i = 0; i < n; i ++) {
            count += ab[i][1];
            if(count >= k) {
                ans = ab[i][0];
                break;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 23996
#include <bits/stdc++.h>
using namespace std;
int64_t a, b, ans = 0;

int main()
{
  string s;
  stack<int64_t> st;
  while (cin >> s)
  {
    switch (s.at(0))
    {
    case '+':
      a = st.top();
      st.pop();
      b = st.top();
      st.pop();
      st.push(a + b);
      break;
    case '-':
      a = st.top();
      st.pop();
      b = st.top();
      st.pop();
      st.push(b - a);
      break;
    case '*':
      a = st.top();
      st.pop();
      b = st.top();
      st.pop();
      st.push(a * b);
      break;
    default:
      a = stoll(s);
      st.push(a);
      break;
    }
  }
  cout << st.top() << endl;
}


Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

N,M=map(int,input().split())
p=list(map(int,input().split()))

uf=UnionFind(N)
for i in range(M):
    x,y=map(int,input().split())
    uf.union(x-1,y-1)

cnt=0
for i in range(N):
    if uf.is_same(i,p[i]-1):
        cnt+=1
print(cnt)


Measured memory_bytes: 91992
import itertools
n,y = map(int,input().split())
for i,j in itertools.product(range(0,n+1),range(0,n+1)):
  c = n-i-j
  sum_y = 10000*i + 5000*j + 1000*c
  if sum_y == y and c>=0:     
    print(i,j,c)
    break
else:
  print(-1,-1,-1)



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

int main(void){
  int h,w;
  while(1){
    cin >> h >> w;
    if(h==0 && w==0) break;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        if(i%2==0){
          if(j%2==0){
            printf("#");
          }else{
            printf(".");
          }
        }else{
          if(j%2==0){
            printf(".");
          }else{
            printf("#");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 3068
/*
ID: barish21
LANG: C++14
TASK: test
*/
 
/****Author: Barish Namazov****/
#include <bits/stdc++.h>
 
using namespace std;
 
/***TEMPLATE***/
#define intt long long
 
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
#define F first
#define S second
#define pb push_back
 
#define IO ios_base::sync_with_stdio(false);cin.tie();
 
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
 
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
 
const intt INF = 2LL * 1000000000;
/***************/
 
/***Additional Functions***/
 
intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
 
intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}
 
intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}
 
intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}
 
/**************************/
 
const intt initt = 0;
 
intt n, q;
intt t[maxx << 2], lazy[maxx << 2];
 
void init () {
    memset (lazy, -1, sizeof (lazy));
}
 
void relax (intt v, intt l, intt r) {
    t[v] += (r - l + 1) * lazy[v];
    if (l != r)
        lazy[v << 1] += lazy[v] + (lazy[v << 1] == -1), lazy[v << 1 | 1] += lazy[v] + (lazy[v << 1 | 1] == -1);
    lazy[v] = -1;
}
 
/*
void build (intt v, intt l, intt r) {
    if (l == r) {
        t[v] += initt;
        return;
    }
    intt mid = (l + r) >> 1;
    build (v << 1, l, mid);
    build (v << 1 | 1, mid + 1, r);
    t[v] = t[v << 1] + t[v << 1 | 1];
}
*/
 
void update (intt v, intt l, intt r, intt i, intt j, intt val) {
    if (lazy[v] != -1)
        relax (v, l, r);
    if (j < l || i > r)
        return;
    if (i <= l && r <= j) {
        lazy[v] += val + (lazy[v] == -1);
        relax (v, l, r);
        return;
    }
    intt mid = (l + r) >> 1;
    update (v << 1, l, mid, i, j, val);
    update (v << 1 | 1, mid + 1, r, i, j, val);
    t[v] = t[v << 1] + t[v << 1 | 1];
}
 
intt query (intt v, intt l, intt r, intt i, intt j) {
    if (j < l || i > r)
        return 0;
    if (lazy[v] != -1)
        relax (v, l, r);
    if (i <= l && r <= j)
        return t[v];
    intt mid = (l + r) >> 1;
    return query (v << 1, l, mid, i, j) +
           query (v << 1 | 1, mid + 1, r, i, j);
}
 
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    init();
    cin >> n >> q;
    //build (1, 1, n);
    while (q --) {
        intt type, i, j, val;
        cin >> type;
        if (type == 0)
            cin >> i >> j >> val, update (1, 1, n, i, j, val);
        else
            cin >> i >> j, cout << query (1, 1, n, i, j) << endl;
    }
    return 0;
}

Measured memory_bytes: 8332
#include <iostream>
using namespace std;
int main()
{
	int a, b, c,ans;
	cin >> a >> b >> c;
	if (a < b && b < c){
		cout << a << " " << b << " " << c << endl; 
	}
	if (a < c && c < b){
		cout << a << " " << c << " " << b << endl; 
	}
	if (b < a && a < c){
		cout << b << " " << a << " " << c << endl;
	}
	if (b < c && c < a){
		cout << b << " " << c << " " << a << endl; 
	}
	if (c < a && a < b){
		cout << c << " " << a << " " << b << endl; 
	}
	if (c < b && b < a){
		cout << c << " " << b << " " << a << endl; 
	}
	if (a == b && b < c){
		cout << a << " " << b << " " << c << endl;
	}
	if (a == b && b > c){
		cout << c << " " << a << " " << b << endl;
	}
	if (a == c && c < b){
		cout << a << " " << c << " " << b << endl;
	}
	if (a == c && c > b){
		cout << b << " " << a << " " << c << endl;
	}
	if (c == b && b < a){
		cout << c << " " << b << " " << a << endl;
	}
	if (c == b && b > a){
		cout << a << " " << c << " " << b << endl;
	}
	cin >> ans;
	return 0;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < (int) n; ++i)
#define ford(i, n) for (int i = ((int) n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector <int> > vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;
typedef vector<cd> vcd;

#define FILE_NAME "a"

const int MAXN = 2e5 + 10;

int n;
int a[MAXN];

bool read() {
	if  (scanf("%d", &n) < 1) {
		return false;
	}
	forn(i, n) {
		scanf("%d", &a[i]);
		--a[i];
	}
	return true;
}

int solve() {
	int ans = 0;
	forn(i, n) {
		ans += a[a[i]] == i;
	}
	return ans / 2;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		printf("%d\n", solve());
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		System.out.println(ans(n,a,b));
		sc.close();
	}
	
	public static long ans(long n, long a, long b) {
		if (a > b) {
			return 0;
		}
		if (n == 1) {
			if (a == b) {
				return 1;
			}
			return 0;
		}
		return (b-a) * (n-2) + 1;
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;
static const int MAX = 100000;

int main() {
    int n, H[MAX];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> H[i];

    bool can = true;
    H[0]--;
    for (int i = 1; i < n; ++i) {
        if (H[i - 1] + 1 <= H[i]) H[i]--;
        if (H[i - 1] > H[i]) {
            can = false;
            break;
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	vector < int >x(N);
	vector < int >y(M);

	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
	}

	int xMax = *max_element(x.begin(), x.end());
	int yMin = *min_element(y.begin(), y.end());

	if (xMax < yMin && X < yMin && yMin <= Y) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	long long int N = 0,counter=0,a=0,b=0,c=0;
	cin >> a>>b>>c;
	if (b - a + c > 0) {
		cout << b - a + c << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long int n,k;
        cin>>n>>k;
        int arr[n];
        for(int i=0;i<n;i++)
            cin>>arr[i];
        long long int sum=0;
        for(int i=0;i<n;i++)
            sum+=arr[i];
        long long int count=0;
        if(sum%(4*k)==0)
            count=sum/(4*k);
        else 
            count=(sum/(4*k))+1;
        int flag=0;
        for(int i=0;i<n;i++)
        {
            if(flag<k)
            {
                if(arr[i]>=count)
                    flag+=1;
            }
            else break;
        }
        if(flag==k)
            cout<<"Yes"<<endl;
        else 
            cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll po = 1;
  FOR(i, 1, N - 1) po *= i;
  vector<long double> X(N), Y(N);
  REP(i, N) cin >> X[i] >> Y[i];
  long double ans = 0;
  REP(i, N) {
    FOR(j, i + 1, N) {
      ans += SQRT(DPOW(X[i] - X[j], 2) + DPOW(Y[i] - Y[j], 2));
    }
  }
  cout << SP(20) << ans * 2 / N << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char srx[100001];
int main()
{
    gets(srx);
    int ans=0;
    for(int i=1;i<strlen(srx);i++)
    if(srx[i]!=srx[i-1])
    ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
    int n,d;
    cin>>n>>d;
    int view;
    view = 1 + d * 2;
    int ans;
    int mod;
    mod = n % view;
    ans = n / view;
    if (mod)
        ans++;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
   int a;
   cin>>a;
   vector<vector<int>> data(a, vector<int>(2));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  long double sum=0;
  int te=a*(a-1)/2;
  int re=1;
  rep(i,a-2){
      re*=(i+1);
  }
  //cout<<re<<endl;
  //cout<<te<<endl;
  rep(i,a){
      rep(j,a){
          if(i!=j){
              sum+=re*(a-1)*sqrt((data.at(i).at(0)-data.at(j).at(0))*(data.at(i).at(0)-data.at(j).at(0))+(data.at(i).at(1)-data.at(j).at(1))*(data.at(i).at(1)-data.at(j).at(1)));
          }
      }
  }
  int count=1;
  rep(i,a){
      count*=(i+1);
  }
  
  cout<<setprecision(10)<<sum/count<<endl;
}





Measured memory_bytes: 256
T = input()
ans=[]
for k in range(1, len(T)+1):
    if T[-k] == "?":
        ans.append("D")
    else:
        ans.append(T[-k])
"""
if T[-1] == '?':
    ans.append('D')
else:
    ans.append(T[-1])
for k in range(2, len(T)+1):
    if T[-k] == '?':
        if T[-k+1] == "P":
            ans.append("D")
        else:
            ans.append("P")
    else:
        ans.append(T[-k])
"""
a = '' 
for k in range(1, len(ans)+1):
    a += ans[-k]
print(a)

Measured memory_bytes: 11136
def dfs(A):
    if len(A) == n:
        tmp = [0 for i in range(m+1)]
        for i, k in enumerate(A):
            if k:
                for j in range(m+1):
                    tmp[j] += a[i][j]
        chk = 0
        for i in range(1, m+1):
            if tmp[i] >= x:
                chk += 1
        if chk == m:
            ans[0] = min(tmp[0], ans[0])
        return

    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()


n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = [10**10]
dfs([])
if ans[0] != 10**10:
    print(ans[0])
else:
    print(-1)


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string s;
    cin >> k >> s;
    if(k >= s.size()){
        cout << s << endl;
    }else{
        for(int i = 0; i < k; i++)cout << s[i];
        cout << "..." << endl;
    }
}

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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int n;
	cin >> n;
	int num = 0;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(num+1 == a) ++num;
	}

	cout << ((num == 0) ? -1 : (n-num));

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
ll pre[1000005]={0};
ll suff[1000005]={0};


int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
ll s;
ll x,y;
cin>>s;
ll g=1000000000;

pll p[3];
p[0].ff=0;
p[0].ss=0;
p[1].ss=0;

if(s<=g)
{
	 x=s;
	 y=s/x;
	 p[1].ff=x;
	 p[2].ss=y;
	 p[2].ff=x-1;
}

else
{	
	

	if(s!=g*g)
	{
	p[0].ff=0;
	p[0].ss=1;
	p[1].ff=g;
	p[1].ss=0;

	ll k=s/g;
	y=k+1;
	x=s%g;
	p[2].ff=x;
	p[2].ss=y;
	}
	
	else
	{	
		p[1].ff=g;
		p[2].ff=g;
		p[2].ss=g;
	}
}


for(ll i=0;i<3;i++)
{
	cout<<p[i].ff<<" "<<p[i].ss<<" ";
}
cout<<"\n";
}

Measured memory_bytes: 3968
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		int n;
		cin >> n;
		set<string> st;
		REP(i, n) {
			string s;
			cin >> s;
			st.insert(s);
		}
		put(st.size());
	}
} // namespace idaten

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


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

int main() {
	
	std::vector<int> v(3);
	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(), v.end());

	std::cout << v[0]+v[1] << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 998244353;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    LL n; cin >> n;

    LL dist[n + 1];
    memset(dist, 0, sizeof(dist));

    for (int i = 1; i <= n; i++){
    	int x; cin >> x;
    	if (i == 1){
    	    if (x != 0){
    	        cout << 0 << endl;
    	        return 0;
    	    }
    	}
    	dist[x]++; 
    }

    if (dist[0] > 1){
    	cout << 0 << endl;
    	return 0;
    }
    for (int i = 1; i <= n; i++){
    	if (dist[i]) continue;
    	for (int j = i + 1; j <= n; j++){
    		if (dist[j]){
    			cout << 0 << endl;
    			return 0;
    		}
    	}
    	break;
    }

    LL ans = 1;
    dist[0] = 1;
    for (int i = 1; i <= n; i++){
    	if (dist[i] == 0) break;
    	ans = (ans * pows(dist[i - 1], dist[i])) % MOD;
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1152
<?php

$line = fgets(STDIN);

$lines = explode(" ", $line);

$lines[0] = trim($lines[0]);
$lines[1] = trim($lines[1]);

if ($lines[0] < $lines[1]){
    echo "a < b";
}elseif ($lines[0] > $lines[1]){
    echo "a > b";
}else{
    echo "a == b";
}
?>

Measured memory_bytes: 15456
#include<bits/stdc++.h>
#include<iomanip>
#define inf 1e18
#define N 100005
#define ll long long int
#define pb push_back
using namespace std;
int main(void){
	int n,i,j;
	cin>>n;
	double p[n],s=0.0;
	for(i=0;i<n;i++)
	cin>>p[i];
	double dp[n+1][n+1];
	//dp[0][0]=0.0;
	for(i=0;i<=n;i++)
	dp[i][0]=0.0;
	dp[0][0]=1.0;
	for(i=0;i<=n;i++){
		for(j=1;j<=n;j++)
		{
			if(i==0)
		dp[i][j]=dp[i][j-1]*(1-p[j-1]);
		else
		dp[i][j]=dp[i-1][j-1]*p[j-1]+dp[i][j-1]*(1-p[j-1]);
		}
	}
	for(i=(n+1)/2;i<=n;i++){
		s+=dp[i][n];
	}
	cout<<setprecision(15)<<s<<endl;
}


Measured memory_bytes: 70528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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;

int N;
vector<int> A;
int main(){
    cin >> N;
    REP(i,N-1){
        int a;
        cin >> a;
        A.push_back(a);
    }
    int buka[N];
    REP(i,N){
        buka[i] = 0;
    }
    REP(i,N-1){
        buka[A[i] - 1]++;
    }
    REP(i,N){
        cout << buka[i] << endl;
    }

}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
typedef long long ll;
int n, m;
int v, p;
int ar[maxn];
bool check(int index){
    int x = ar[index] + m;
    if(ar[index] + m < ar[n - p + 1])return false;
    ll last = 1LL * (v - p + 1) * m;
    for(int i = 1; i <= n - p + 1; i++){
        last -= min(m, max(0, x - ar[i]));
    }
    return last <= 0;
}
int main()
{
    scanf("%d%d%d%d", &n, &m, &v, &p);
    for(int i = 1; i <= n; i++)scanf("%d", ar + i);
    sort(ar + 1, ar + n + 1);
    //for(int i = 1; i <= n; i++)cout << ar[i] << " ";
    //cout << "\n";
    int l = 1, r = n - p + 1;
    while(l < r){
        int mid = l + r >> 1;
        if(check(mid))r = mid;
        else l = mid + 1;
    }
    printf("%d\n", n - l + 1);
    return 0;
}


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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;

typedef long long ll;


//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}
//---------------//

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

    cin >> N;
    ll A[N];
    ll B[N];
    REP(i, 0, N){
        cin >> A[i];
        B[i] = A[i] - (i + 1);
    } 

    sort(B, B + N);
    ll b = B[N/2];
    ll ans = 0;
    REP(i, 0, N){
        ans += abs(b - B[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


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

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


int main(){
  int n;
  string s, t;
  cin >> n;
  cin >> s >> t;

  string str;

  rep(i, n){
    str += s[i];
    str += t[i];
  }

  cout << str << endl;
}

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

using namespace std;

int main(){
  long long int x,y,xa,xb,xc,ans=0;
  int a[100010],b[100010],c[100010];
  
  cin >> x >> y >> xa >> xb >> xc;
  
  for(int i=0;i<xa;i++)
    cin >> a[i];
  for(int i=0;i<xb;i++)
    cin >> b[i];
  for(int i=0;i<xc;i++)
    cin >> c[i];
  
  priority_queue<int> qa;
  priority_queue<int> qb;
  priority_queue<int> qc;
  priority_queue<int> qd;
  
  for(int i=0;i<xa;i++){
    qa.push(a[i]);
  }
  for(int i=0;i<xb;i++){
    qb.push(b[i]);
  }
  for(int i=0;i<xc;i++){
    qc.push(c[i]);
  }
  
  
    for(int i=0;i<x;i++){
      qd.push(qa.top());
      qa.pop();
    }
    for(int i=0;i<y;i++){
      qd.push(qb.top());
      qb.pop();
    }
  for(int i=0;i<xc;i++){
    qd.push(qc.top());
    qc.pop();
  }
  
  for(int i=0;i<x+y;i++){
    ans += qd.top();
    qd.pop();
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
int a;
cin >> a;
vector<int>b(a);
int sum = 0;
rep(i,a){
  cin >> b[i];
  sum += b[i];
}
int mini = sum;
int pre  = 0;
for(int i=0;i<a;++i){
  cin >> b[i];
  pre +=b[i];
  mini = min(mini,abs(pre-(sum-pre)));
}
cout << mini << endl;
return 0;
}

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

int main() {
	char a;
	cin >> a;
	if (a=='a'|| a == 'i' || a == 'u' || a == 'e' || a == 'o'   )
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=1000005,maxm=55;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-6;

int n,x,y;

int a[maxn]={0};

int cal(int st,int en)
{
    int r=en-st;
    if(en<=x||st>=y) return r;
    if(st<=x&&y<=en) return en-y+1+x-st;
    if(x<=st&&en<=y)
    {
        r=min(r,y-x+1-(en-st));
    }
    else if(en<=y)
    {
        r=min(r,x-st+1+y-en);
    }
    else
    {
        r=min(r,en-y+1+st-x);
    }
    return r;
}

int main()
{
	int i,j,k;
	scanf("%d %d %d",&n,&x,&y);
	--x;--y;
	for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            a[cal(i,j)]++;
            //cout<<i<<" "<<j<<" "<<cal(i,j)<<endl;
        }
    }
    for(i=1;i<=n-1;i++) printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 256
n,c,k = [int(i) for i in input().split()]
start = []
end   = []
for i in range(n):
    t = int(input())
    start.append(t)
    end.append(t+k)
    
start.sort()
end.sort()

ind = 0
cnt = 0
while(ind<n):
    time = end[ind]
    for i in range(1,c+1):
        next_ind = ind + i
        if next_ind==n or start[next_ind]>time:
            break
    ind = next_ind
    cnt += 1
print(cnt)

Measured memory_bytes: 11456
n = int(input())

def wa_only_pos(list):
    a = 0
    for i in range(n):
        if list[i] > 0:
            a = a+list[i]
    return a

v_in = input().split()
v = []
for i in range(n):
    v.append(int(v_in[i]))

c_in = input().split()
c = []
for i in range(n):
    c.append(int(c_in[i]))

sub = []
for i in range(n):
    sub.append(v[i]-c[i])

print(wa_only_pos(sub))







Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    int x,y,n,m,h,k,max=-10000000,min=10000000,ans=0,sum=0;
    string s,t;
    cin >> n >> m;
    if(n==3)
        ans+=100000;
    if(n==2)
        ans+=200000;
    if(n==1)
        ans+=300000;
    
    if(m==3)
        ans+=100000;
    if(m==2)
        ans+=200000;
    if(m==1)
        ans+=300000;

    if(n==1&&m==1)
        ans+=400000;
    cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int r;
	cin >> r;
	if(r < 1200){
		cout << "ABC" << endl;
	}
	else if(r >= 1200 && r < 2800){
		cout << "ARC" << endl;
	}
	else cout << "AGC" << endl;
	
	
	
	
	
	
	
	

						
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back

const ll mod = 1000000007;

int main(){
	long long int W, H, x, y;

	cin >> W >> H >> x >> y;

	double maxS = double(W * H) / 2.0;
	
	int flag = ((double)x == (double)W / 2.0 && (double)y == (double)H / 2.0) ? 1: 0;
	cout << maxS << endl << flag << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
 
#define DEBUG(x) cerr << #x << " = " << x << endl
 
template<class T, class U>
T lexical_cast(const U& from) {
    stringstream ss;
    ss << from;
    T to;
    ss >> to;
    return to;
}
 
int toMinute(const string& s) {
    return lexical_cast<int>(s.substr(0,2))*60 + lexical_cast<int>(s.substr(3,2));
}
 
int main() {
    int N, T; cin >> N >> T;
    vector<int> st(N), ar(N);
    vector<string> name(N);
    for(int i = 0; i < N; i++) {
        string stt, stn, art, arn;
        cin >> stt >> stn >> art >> arn;
        if(i != 0) {
            st[i-1] = toMinute(stt);
        }
        if(i != N - 1) {
            ar[i] = toMinute(art);
            name[i] = arn;
        }
    }
    int cnt = 0;
    for(int i = 0; i < N - 1; i++) {
        if(st[i] - ar[i] >= T) {
            cnt++;
        }
    }
    cout << cnt << endl;
    for(int i = 0; i < N - 1; i++) {
        if(st[i] - ar[i] >= T) {
            cout << name[i] << ' ' << (st[i] - ar[i]) << endl;
        }
    }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n;
    double d; cin >> n >> d;
    vector<double> x(n), y(n);
    int ans = 0;
    rep(i, n){
        double x, y;
        cin >> x >> y;
        if(sqrt(x*x + y*y) <= d) ans++;
    }
    pr(ans);

    return 0;}

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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

const int MAX = 1e5+1;

void solve() {
	int n;
	cin >> n;
	int a[MAX];
	int g = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		g = __gcd(g,a[i]);
	}

	cout << g << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N;
  ll ans=1;
  cin >> N;
  bool b[1000];
  memset(b,1,sizeof(b));
  int C[1001]={0};
  b[0] = b[1] = 0;
  for(int i=2; i<32; i++){
    for(int j=2*i; j<=1000; j+=i){
      b[j]=0;
    }
  }
  vector<int> p;
  rep(i, 1000){
    if(b[i]) p.push_back(i);
  }
  for(auto i:p){
    for(int j=1; j<=10; j++){
      C[i] += N/(int)pow(i, j);
    }
    ans *= C[i]+1;
    ans %= MOD;
    
  }
  cout << ans << endl; 
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int n;
ll dp[3];
int main(){
	scanf("%d",&n);
	ll ans=1;
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		int cnt=0,flag=-1;
		rep(i,0,3)if(dp[i]==t){
			cnt++;
			flag=i;
		}
		ans=ans*cnt%MOD;
		dp[flag]++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, K;
  cin >> N >> K;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += min(2 * X[i], 2 * abs(K - X[i]));
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    ll t,n,k,k1,k2,b,a,m,c;
    cin>>t;
    if(t<600)
        n=8;
    else if(t<800)
        n=7;
    else if(t<1000)
      n=6;
    else if(t<1200)
        n=5;
    else if(t<1400)
        n=4;
    else if(t<1600)
        n=3;
    else if(t<1800)
        n=2;
    else
        n=1;
    cout<<n<<endl;
    return 0;
    while(t--){
        ll ans=0,c=0;
        cin>>n;
        //string s;
        //cin>>s;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];

    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

bool check(int x)
{
	return (x <= 9 && x >= 0);
}

void solve()
{
	string str; cin >> str;
	int dp[str.size() + 50][2];
	dp[0][0] = 0; dp[0][1] = 1;
	for(int i=1; i<=str.size(); i++)
	{
		dp[i][0] = dp[i][1] = 999999999;
		int tmp = str[i - 1] - '0';
		for(int j=0; j <= 9; j++)
		{
			if(check(j + 10 - tmp)) dp[i][0] = min(dp[i][0], dp[i - 1][1] + j + (j + 10 - tmp));
			if(check(j - tmp)) 	 	dp[i][0] = min(dp[i][0], dp[i - 1][0] + j + (j - tmp));
			if(check(j + 10 - tmp - 1)) dp[i][1] = min(dp[i][1], dp[i - 1][1] + j + (j + 10 - tmp - 1));
			if(check(j - tmp - 1))		dp[i][1] = min(dp[i][1], dp[i - 1][0] + j + (j - tmp - 1));
		}
//		cout << dp[i][0] << ' ' << dp[i][1] << '\n';
	}
	cout << dp[str.size()][0];
}

Measured memory_bytes: 9116