akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        //ABC_C();
        //return;
        string s = Console.ReadLine();
        string ans = "";
        if (s[0] != 'A')
        {
            Console.WriteLine("WA");
            return;
        }
        else
        {
            int count = 0;
            for (int i = 2; i < s.Length - 1; i++)
            {
                if (s[i] == 'C') count++;
            }
            if (count == 1)
            {
                bool flag = true;
                for (int i = 0; i < s.Length; i++)
                {
                    if (!char.IsLower(s[i]) && s[i] != 'A' && s[i] != 'C') flag = false;
                }
                Console.WriteLine((flag ? "AC" : "WA"));
                return;
            }
            else
            {
                Console.WriteLine("WA");
                return;
            }
        }


    }

    public static void ABC_C()
    {
        int[] DG = SpIntRead(' ');
        int D = DG[0];
        int G = DG[1];
        int[,] p = new int[100, 2];
        int[] box;
        for (int i = 0; i < D; i++)
        {
            box = SpIntRead(' ');
            p[i, 0] = box[0];
            p[i, 1] = box[1];
        }
        int ans = solve(D, G, p);
    }

    public static int solve(int D, int G, int[,] p)
    {
        for (int i = 0; i < D; i++)
        {

        }
        return 0;
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }

}


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

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  ll ans;
  if(a==0 && x!=1)ans=b/x - (a-1)/x+1;
  else ans=b/x - (a-1)/x;
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int H,W,X;
int d[100][100][4][11][11];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ad[4]={1,0,3,2},bd[4]={3,2,1,0};
int inf=100;
string s[100];
deque<int> qx,qy,qd,qa,qb;
bool is(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&s[x][y]!='#';
}
void pushf(int x,int y,int z,int a,int b,int c){
	if(d[x][y][z][a][b]<=c) return;
	qx.push_front(x);
	qy.push_front(y);
	qd.push_front(z);
	qa.push_front(a);
	qb.push_front(b);
	d[x][y][z][a][b]=c;
}
void pushb(int x,int y,int z,int a,int b,int c){
	if(d[x][y][z][a][b]<=c) return;
	qx.push_back(x);
	qy.push_back(y);
	qd.push_back(z);
	qa.push_back(a);
	qb.push_back(b);
	d[x][y][z][a][b]=c;
}
int main(){
	cin>>H>>W>>X;
	rep(i,H) rep(j,W) rep(k,4) rep(a,X+1) rep(b,X+1) d[i][j][k][a][b]=inf;
	rep(i,H) cin>>s[i];
	int sx,sy;
	rep(i,H) rep(j,W) if(s[i][j]=='S') sx=i,sy=j;
	pushb(sx,sy,0,X,X,0);
	while(!qx.empty()){
		int x=qx.front(),y=qy.front(),di=qd.front(),a=qa.front(),b=qb.front();
		qx.pop_front(),qy.pop_front(),qd.pop_front(),qa.pop_front(),qb.pop_front();
		if(x==sx&&y==sy&&di==2) continue;
		int c=d[x][y][di][a][b];
		if(s[x][y]=='G'){
			cout<<c<<endl;
			return 0;
		}
		int nx=x+dx[di],ny=y+dy[di];
		if(is(nx,ny)) pushf(nx,ny,di,a,b,c);
		if(!(x==sx&&y==sy) && a>0) pushb(x,y,ad[di],a-1,b,c+1);
		if(!(x==sx&&y==sy) && b>0) pushb(x,y,bd[di],a,b-1,c+1);
	}
	puts("-1");
}

Measured memory_bytes: 19488
a,b,c,d=map(int,input().split())
if a>=d:
    print(d*1)
else:
    if a+b>=d:
        print(a*1)
    else:
        if a+b+c>=d:
            print(a*1+(d-a-b)*(-1))
        else:
            print(a*1+(d-a-b)*(-1))


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

ll GCD(ll a,ll b){
  if(b==0) return a;
  else return GCD(b,a%b);}
ll LCM(ll a, ll b){ return a/GCD(a,b)*b;}
ll F(ll x, ll c, ll d){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/LCM(c,d);
    return res;
}

int main(){
     ll a, b;
     int c, d;
     cin >> a>>b >> c >>d;
     
     ll ans = F(b,c,d)-F(a-1,c,d);
     cout << ans << endl;
}  


Measured memory_bytes: 256
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [ss] <- getInts
  ; let (mm,s) = divMod ss 60
  ; let (h,m) = divMod mm 60
  ; putStrLn (intercalate ":" (map show [h, m, s]))
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

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

using namespace std;

string s, t, r;
int n;
bool a;

int main() {

    cin >> n >> s >> t;

    for (int i = 0; i < s.size(); ++i){
        if (s[i] == t[r.size()]) {r += s[i];}
        else {
            r = "";
            if (s[i] == t[r.size()]) {r += s[i];}
        }
}
    cout << n + n - r.size();

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

int find(int a[], int x)
{
    while (a[x] != x)
    {
        a[x] = a[a[x]];
        x = a[x];
    }
    return x;
}

void unite(int a[], int x, int y)
{
    x = find(a, x);
    y = find(a, y);
    if (x != y)
    {
        a[x] = y;
    }
}

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, q, x, y;
    cin >> n >> m;
    int p[n];
    for (int i = 0; i < n; i++)
        p[i] = i;

    for (int i = 0; i < m; i++)
    {
        cin >> x >> y;
        unite(p, x, y);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> x >> y;
        cout << ((find(p, x) == find(p, y)) ? "yes" : "no") << endl;
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3500
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 100
void push(int);
int pop(void);
int top=0,S[SIZE];
int main(){
  int s,t,a,p;
  char x[SIZE];
  while((p=scanf("%s",x))!=EOF) {
    
if(x[0]=='+')  {
  s=pop();
  t=pop();
  push(s+t);
 }
     else if(x[0]=='-'){
       s=pop();
       t=pop();
       push(t-s);
     }
     else if(x[0]=='*'){
       s=pop();
       t=pop();
       push(s*t);
     }
     else push(atoi(x));
 
  }
  a=pop();
  printf("%d\n",a);

 return 0;
}

void push(int x){
  if(top==SIZE){
    printf("Stack is overflow\n");
    exit(2);
  }
   top++;
  S[top]=x;
 
  
}

int pop(void){
  if(top==0){
    printf("Stack is Empty\n");
    exit(2);
  }
  top--;
  return S[top+1];
}



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

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    num_gcd = {}
    for k in range(K, 0, -1):
        num_select = K // k
        num_gcd_k = pow(num_select, N, MOD)
        for multiple in range(2, num_select+1):
            num_gcd_k -= num_gcd[k * multiple]
        num_gcd[k] = num_gcd_k

    result = 0
    for k in range(1, K+1):
        result += (k * num_gcd[k]) % MOD
    print(result % MOD)
    return


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

if __name__ == '__main__':
    main()


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  for(int i = 0; i < N-2; i++){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
    	count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i=0;i<N;i++){
      int num;
      cin >> num;
      A.push_back(num);
    }
    cout<<A[0];
    for (int i=1;i<N;i++){
      cout<<" "<<A[i];
    }
    cout<<endl;
    for (int i=1;i<=N-1;i++){
      int v = A[i];
      int j = i - 1;
      while(j>=0 && A[j]>v){
        A[j+1] = A[j];
        j--;
      }
      A[j+1] = v;
      cout<<A[0];
      for(int k=1;k<N;k++){
          cout<<" "<< A[k] ;
      }
      cout<<endl;
    }
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll ans=0;
int main(){
    while(true){
        ll a;cin >> a;
        if(!a)break;
        vl v(86400,0);
        rep(i,a){
            string s,g;cin >> s >>g;
            ll l=0,r=0;
            l+=(s[0]-'0')*10*3600+(s[1]-'0')*3600;
            l+=(s[3]-'0')*10*60+(s[4]-'0')*60;
            l+=(s[6]-'0')*10+(s[7]-'0')*1;
            r+=(g[0]-'0')*10*3600+(g[1]-'0')*3600;
            r+=(g[3]-'0')*10*60+(g[4]-'0')*60;
            r+=(g[6]-'0')*10+(g[7]-'0')*1;
            v[l]++;
            if(r<86400)v[r]--;
        }
        vl imos(86401,0);
        rep(i,86400)imos[i+1]+=imos[i]+v[i];
        ll ans=0;
        rep(i,86401)chmax(ans,imos[i]);
        cout <<ans <<endl;
    }
}


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

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (H, W) = read_tuple::<usize>();
    let mut s = Vec::new();
    for i in 0..H {
        s.push(read::<String>().chars().collect::<Vec<char>>());
    }
    let direction = [(0, 1), (0, -1), (1, 0), (-1, 0)];
    for i in 0..H {
        for j in 0..W {
            if s[i][j] == '.' {
                continue;
            }
            let mut flag = true;
            for &(di, dj) in direction.iter() {
                let ni = i as i32 + di;
                let nj = j as i32 + dj;
                if ni >= 0 && ni < H as i32 &&
                    nj >= 0 && nj < W as i32 &&
                    s[ni as usize][nj as usize] == '#' {

                    flag = false;
                    break;
                }
            }
            if flag {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
s = input()

if s[0] != 'A':
    print('WA')
    exit()
cnt = 0

if s[1].isupper():
    print('WA')
    exit()

for i in range(2, len(s)):
    if s[i] == 'C':
        cnt = cnt + 1

if cnt != 1:
    print('WA')
    exit()
index = 0
for i in range(2, len(s) - 1):
    if s[i] == 'C':
        index = i
        break
# print(index)

test = s[2:index] + s[index + 1:len(s)]
# print(test)

if test.islower():
    print('AC')
else:
    print('WA')
exit()

if index != 2 and index + 1 != len(s) - 1:
    if s[2:index].islower() and s[index + 1:len(s) - 1].islower():
        print('AC')
    else:
        print('WA')

elif index == 2:
    if s[index + 1:len(s) - 1].islower():
        print('AC')
    else:
        print('WA')
else:
    if s[2:index].islower():
        print('AC')
    else:
        print('WA')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
string s[n]={};
for(ll i=0; i<n; i++){
cin>>s[i];}
ll a[30]={};
ll b[30]={};
for(ll i=0; i<30; i++){
b[i]=100;}
for(ll i=0; i<n; i++){
ll q=s[i].size();
while(q>=1){
ll w=s[i].at(q-1)-'a'+1;
a[w]++;
q--;}
for(ll k=0; k<30; k++){
b[k]=min(a[k],b[k]);}
for(ll k=0; k<30; k++){
a[k]=0;}}
for(ll k=0; k<30; k++){
if(b[k]==100){
b[k]=0;}}
for(ll i=0; i<30; i++){
if(b[i]==0) continue;
else{
while(b[i]>0){
char h='a'+(int)i-1;
cout<<h;
b[i]--;}}}}


Measured memory_bytes: 3624
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    cs := make([]int, n-1)
    ss := make([]int, n-1)
    fs := make([]int, n-1)
    for i := 0; i < n-1; i++ {
        var c, s, f int
        fmt.Scan(&c, &s, &f)
        cs[i] = c
        ss[i] = s
        fs[i] = f
    }

    //fmt.Println(cs, ss, fs)

    for i := 0; i < n; i++ {
        if i == n-1 {
            fmt.Println(0)
            continue
        }

        var t int
        for j := i; j < n-1; j++ {
            s := ss[j]
            f := fs[j]
            c := cs[j]
            if s > t {
                t = s
            }
            if t%f != 0 {
                t = int(t/f)*f + f
            }
            t += c
        }

        fmt.Println(t)
    }

}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int b,r,g,c,s,t,co=100;
    int i,j,k;
    while(scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t))
    {
        if(t==0)break;
        co+=b*65;
        co+=b*15;
        t-=b+b*5;
        co-=b*3;
        co+=r*39;
        co+=r*15;
        t-=r+r*3;
        co-=r*3;
        co+=g*7;
        t-=g;
        co-=g*3;
        co+=c*2;
        t-=c;
        co-=c*3;
        t-=s;
        co-= t*3;
        printf("%d\n",co);
        co=100;
    }
    return 0;
}

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

string s;
int n,now=0;
bool ch;

int main(){
  int i;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    if(s=="A")now++;
    else if(s=="Un")now--;
    if(now<0)ch=1;
  }
  if(now!=0)ch=1;
  if(ch)cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  char C;
  cin >> C;
  int x = C - 'a';
  char ans = 'a' + (x + 1);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

#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>

vector<vector<int>> comb(int n,int r){

}

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<char>> v(n,vector<char>(m));
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>v[i][j];
    ll ans=0;
    for(int r=0;r<pow(2,n);r++){
        for(int c=0;c<pow(2,m);c++){
            vector<vector<char>> d(v);
            for(int i=0;i<n;i++){
                if(r&(1<<i)){
                    for(int col=0;col<m;col++)d[i][col]='.';
                }
            }
            for(int j=0;j<m;j++){
                if(c&(1<<j)){
                    for(int row=0;row<n;row++)d[row][j]='.';
                }
            }
            int cnt=0;
            for(int row=0;row<n;row++){
                for(int col=0;col<m;col++){
                    if(d[row][col]=='#')++cnt;
                }
            }
            ans+=(cnt==k);
        }
    }
    cout<<ans<<"\n";
}

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll a) { cout << a * (1 + a + a * a) << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll a;
  scanf("%lld", &a);
  solve(a);
  return 0;
}


Measured memory_bytes: 3716
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

typedef long long ll;

const ll M=1000000007;
const int MX=200005;
ll a[MX],b[MX];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    for(int i=n-1;i>=0;i--){
        b[i]=a[i]+b[i+1];
        if(b[i]>=M) b[i]-=M;
    }
    ll s=0;
    for(int i=0;i<n-1;i++){
        s+=(a[i]*b[i+1])%M;
        if(s>=M) s-=M;
    }
    printf("%lld\n",s);
    return 0;
}

Measured memory_bytes: 6884
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int res=0;
  rep(i,s.length()-1){
    if(s[i]!=s[i+1])res++;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D) {
  ll t = ceil((double)C / B);
  ll a = ceil((double)A / D);
  if (t <= a) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 3264
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

arr=limii()

if len(set(arr))==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 64364
def main():
    s = input().strip()
    N = len(s)
    check = [False] * N
    ans = N
    for i in range(N):
        if not check[i]:
            now = s[i]
            check[i] = True
            max_ = N-1-i
            count = 0
            for j in range(i+1):
                if s[j] != now:
                    count += 1
                else:
                    check[j] = True
                    max_ = max(max_, count)
                    count = 0
            ans = min(ans, max_)
    print(ans)

if __name__ == "__main__":
    main()

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

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, q; cin >> n >> q;
	queue<string> name;
	queue<int> time;

	int timer = 0;
	REP(i, n) {
		string a; int b;
		cin >> a >> b;

		name.push(a);
		time.push(b);
	}

	while (!time.empty()) {
		if (time.front() <= q) {
			timer += time.front();
			cout << name.front() << " " << timer << "\n";
			name.pop(); time.pop();
		} else {
			name.push(name.front()); name.pop();
			time.push(time.front() - q); time.pop();
			timer += q;
		}
	}
	return 0;
}

Measured memory_bytes: 5664
n = int(input())
w = list(map(int, input().split()))
s = 0
diff = []

for i in range(n):
    s = s + w[i]

for t in range(1,n):
    s1 = 0
    s2 = 0
    # print("---------------")
    # print("t: "+str(t))

    for u in range(t):
        s1 = s1 + w[u]

    s2 = s - s1
    diff.append(abs(s2 - s1))
    # print("s1: "+str(s1))
    # print("s2: "+str(s2))
print(min(diff))



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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

int main(){
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;

}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    umap<ll, ll > mp;

    cin >> n;

    ll a;
    REP(i, n-1){
        cin >> a;
        mp[a]++;
    }

    REP(i, n){
        cout << mp[i+1] << endl;
    }

    return 0;
}

Measured memory_bytes: 11464
from collections import deque
n,d,a = map(int,input().split())
c,cc = 0,0
deq = deque()
dl = [tuple(map(int,input().split())) for i in range(n)]
dl.sort()
for i in dl:
  x,h = i
  while deq:
    if deq[0][0] < x-2*d:
      cc -= deq.popleft()[1]
    else:
      break
  h -= a*cc
  if h > 0:
    c += (h-1)//a + 1
    cc += (h-1)//a + 1
    deq.append((x,(h-1)//a + 1))
print(c)

Measured memory_bytes: 81496
#include "bits/stdc++.h"
using namespace std;

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

    int n;cin>>n;
    ll t=1,a=1;
    for(int i=0;i<n;i++){
        ll ttmp,atmp;cin>>ttmp>>atmp;
        ll ma=max((t-1)/ttmp+1,(a-1)/atmp+1);
        t=ttmp*ma;a=atmp*ma;
    }
    cout<<t+a<<endl;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  const int m = 100000000;
  vector<bool> is_prime(m + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i * i <= m; i++) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j <= m; j += i) {
      is_prime[j] = false;
    }
  }
  int x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (is_prime[x]) ++ans;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 14896
from math import floor, ceil

N = float(input())

f1 = ceil(N / 1.08)
f2 = floor(N / 1.08)
# print(N, f1, f2)

if ceil(N / 1.08) == floor(N / 1.08):
    print(int(N / 1.08))
elif int(f1 * 1.08) == N:
    print(f1)
else:
    print(":(")


Measured memory_bytes: 38512
#include <iostream>

using namespace std;

int main(){
	char n[100];
    cin>>n;
  	if( n[0] >= 'A' && n[0] <= 'Z' )
      cout<<"A";
	if( n[0] >= 'a' && n[0] <= 'z')
      cout<<"a";
	return 0; 
}

Measured memory_bytes: 3620
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:
        ans[b - 1] = 0
    elif h[a - 1] < h[b - 1]:
        ans[a - 1] = 0
    else:
        ans[a - 1] = 0
        ans[b - 1] = 0
print(sum(ans))


Measured memory_bytes: 20024
#include<bits/stdc++.h>
using namespace std;
int n,m;
int ace[100010];int ancestor(int x){return x-ace[x]?ace[x]=ancestor(ace[x]):x;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)ace[i] = i;
	for(int i=0; i<m; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		ace[ancestor(x)]=ancestor(y);
	}
	int sz1=0,sz2=0;
	for(int i=1; i<=n; i++){
		if(ancestor(i) == ancestor(1))sz1++;
		if(ancestor(i) == ancestor(2))sz2++;
	}
	int sz = min(sz1,sz2);
	cout << sz * (sz-1LL) / 2 + (n - sz) * (n - sz-1LL)/2 - m <<endl;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    cout << max(a * b, max(a + b, a - b)) << endl;

    return 0;
}

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

int main()
{
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    if(K >= N/2)
    {
        cout << N-1 << endl;
        return 0;
    }
    vector<ll> v;
    ll cnt = 1;
    char c = S[0];
    for(int i = 1; i < N; i++)
    {
        if(c == S[i]) cnt++;
        else
        {
            v.push_back(cnt);
            c = S[i];
            cnt = 1;
        }
        if(i == N-1) v.push_back(cnt);
    }
    // calc
    ll ans = 0;
    for(int i = 0; i < v.size(); i++)
    {
        ans += v[i]-1;
    }
    if(K <= v.size()-2) ans += 2 * K;
    else ans += 2LL * max(0LL, ((ll)v.size()-2LL));
    ll t2 = max(0LL, (ll)v.size() - 2LL);
    ll t = max(0LL, min(2LL, K-t2));
    ans += t;
    ans = min((ll)(N-1), ans);
    cout << ans << endl;
    return 0;
}

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

namespace AOJ_DSL_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nq = ReadInt();
            int n = nq[0];
            int q = nq[1];

            UnionFind unionFind = new UnionFind(n);

            for (int i = 0; i < q; i++)
            {
                var input = ReadInt();
                if (input[0] == 0) unionFind.Unite(input[1], input[2]);
                else
                {
                    if (unionFind.Same(input[1], input[2])) Console.WriteLine(1);
                    else Console.WriteLine(0);
                }
            }



            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }

    class UnionFind
    {
        int[] par;
        int[] rank;

        public UnionFind(int n)
        {
            init(n);
        }

        void init(int n)
        {
            par = new int[n];
            rank = new int[n];

            for (int i = 0; i < n; i++)
            {
                par[i] = i;
                rank[i] = 0;
            }
        }

        public int Find(int x)
        {
            if (par[x] == x)
            {
                return x;
            }
            else
            {
                return par[x] = Find(par[x]);
            }
        }

        public void Unite(int x, int y)
        {
            x = Find(x);
            y = Find(y);
            if (x == y) return;

            if (rank[x] < rank[y])
            {
                par[x] = y;
            }
            else
            {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;
            }

        }
        public bool Same(int x, int y)
        {
            return Find(x) == Find(y);
        }
    }
}



Measured memory_bytes: 24580
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H;
	cin >> W;
	vector<string> C_out;
	for (int i = 0; i < H; i++)
	{
		string C_line;
		cin >> C_line;
		C_out.push_back(C_line);
		C_out.push_back(C_line);
	}

	for (int i = 0; i < C_out.size(); i++)
	{
		cout << C_out[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
using namespace std;
int s[100001],n;
/*bool bin(int v)
{
	int left=0,right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(s[mid]==v){
			return true;
		}
		else if(s[mid]<v){
			 left=mid+1;
		}
		else{
			right=mid;
		}
	}
	return false;
}*/
int main(int argc, char *argv[]) {
	int t,q,i,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&t);
		if(*lower_bound(s,s+n,t)==t) sum++;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
 
int main( void )
{
    int h,w,i,j;
    
	while(1){
    	scanf("%d %d", &h, &w);
		
		if((h == 0) && (w == 0)) break;
		
		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++){
				((j == 0) || (j == (w-1)) ||
				 (i == 0) || (i == (h-1))) ? printf("#") : printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
    
    return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
 int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
    if(x+r<=W&&y+r<=H&&x-r>=0&&y-r>=0){
   printf("Yes\n");
  }  else{
   printf("No\n");
  }
  return 0;
 }

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9

int main(){
 
 int n,k;
 cin >> n >> k;
    int *a = new int[n+1];
    for(int i=1;i<=n;i++) cin >> a[i];

  int *dp = new int[n+1];
  dp[0] = dp[1] = 0;  // dp[1] = 0 bcoz same to same cost = 0
  int minval = INT_MAX;

    for(int i=2;i<=n;i++){
        minval = INT_MAX;
        for(int j=1;j<=k;j++){
            int op1 = (i-j) > 0 ? (abs(a[i] - a[i-j]) + dp[i-j]) : inf;
            minval = min(minval,op1);
        }
       dp[i] = minval; 
    }
 cout << dp[n] << endl;

  return 0;  
}

Measured memory_bytes: 4384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX(p,q) (p>q)?p:q
#define MIN(p,q) (p<q)?p:q

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

int main(void)
{
  int l;
  scanf("%d",&l);
  int yy,mm;
  yy = l/100;
  mm = l%100;
  if(yy>12||yy==0)
  {
    if(mm>12||mm==0)
    {
      printf("NA");
    }
    else
    {
      printf("YYMM");
    }
  }
  else
  {
    if(mm>12||mm==0)
    {
      printf("MMYY");
    }
    else
    {
      printf("AMBIGUOUS");
    }
  }

  return 0;
}


Measured memory_bytes: 128
S=input()
A=[]
B=[]
a=0
b=0
for i in range(len(S)):
    if i%2==0:
        A.append("1")
        B.append("0")
    else:
        A.append("0")
        B.append("1")
for i in range(len(S)):
    if A[i]!=S[i]:
        a+=1
    if B[i]!=S[i]:
        b+=1
print(min(a,b))

Measured memory_bytes: 10656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	int sum=0;
	vector<int>arr(n);
	for(int i=0; i<n; i++){
	 cin>>arr[i];
	 sum+=arr[i];
    }
	sort(arr.rbegin(),arr.rend());
	int cnt=0;
	for(int i=0; i<m; i++)
	{
		if(arr[i]>=ceil(sum/(4.0*m)))
		{
			cnt++;
		}
	}
	if(cnt<m)
	 cout<<"No";
	else
	 cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	sec := nextInt()

	hour := calcHour(sec)
	sec = sec - hour*3600

	min := calcMin(sec)
	sec = sec - min*60
	fmt.Fprintf(out, "%d:%d:%d\n", hour, min, sec)
}

func calcHour(time int) int {
	hour := time / 3600
	return hour
}

func calcMin(time int) int {
	min := time / 60
	return min
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1180
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int ans = a[0];
		for(int i=0;i<n;i++) {
			ans = (int)gcd(ans, a[i]);
		}
		System.out.println(ans);
	}

	static long gcd(long x, long y) {
		return y == 0? x: gcd(y, x%y);
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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


Measured memory_bytes: 35668
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<a+b<<endl;}else{
            cout<<b-a<<endl;
    }

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;


void ABC103D()
{
	int N, M;
	cin >> N >> M;
	vector<int> dist(N + 1, N + 1);
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		dist[a] = min(dist[a], b);
	}

	int cut = 0;
	int maxDist = N + 1;
	for (int i = 1; i < N; ++i)
	{
		maxDist = min(maxDist, dist[i]);
		if (maxDist == i + 1)
		{
			++cut;
			maxDist = N + 1;
		}
	}
	cout << cut << endl;
}

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

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,n;
	cin>>x>>n;
	int a[n];
	int ans=202;
	int ans2=0;
	bool born=true;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==0){
		cout<<x<<endl;
		return 0;
	}
	for(int i=x;i<234;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==a[j])
			break;
			else if(i!=a[j] && j==n-1){
				ans=min(ans,i);
				born=false;
				break;
			}
		}
		if(born==false)
		break;
	}
	born=true;
	for(int i=x-1;i>0;i--)
	{
		for(int j=0;j<n;j++)
		{
			if(i==a[j])
			break;
			else if(i!=a[j] && j==n-1){
				ans2=max(ans2,i);
				born=false;
				break;
			}
		}
		if(born==false)
		break;
	}
	if(ans-x>=x-ans2)
	cout<<ans2<<endl;
	else
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
/*s1190073  Rina Sato
  File name: prog11a.c
  This is a program that outputs adjacency matrix of a graph.
*/

#include <stdio.h>

typedef struct Input{
  int u;
  int k;
  int v[1000];
}input;

int main(void){
  int n,i,j,A[100][100];
  input Adj[100];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&Adj[i].u);
    scanf("%d",&Adj[i].k);

    if(Adj[i].k != 0){
      for(j = 0 ; j < Adj[i].k ; j++){
	scanf("%d",&Adj[i].v[j]);
      }
    }
    
  }

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      A[i][j] = 0;
    }
  }

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < Adj[i].k ; j++){
      A[Adj[i].u-1][Adj[i].v[j]-1] = 1;
    } 
  }
  
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      printf("%d",A[i][j]);
      if(j < n-1){
	printf(" ");
      }
    }
    printf("\n");
  }
 
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;

    A*=100; B*=100;

    double Max=-1;
    int ans_water,ans_sugar;

    for(int i=0;A*i<=F;i++){
        for(int j=0;A*i+B*j<=F;j++){
            if(i==0 and j==0) continue;

            for(int k=0;A*i+B*j+C*k<=F;k++){
                for(int l=0;A*i+B*j+C*k+D*l<=F;l++){
                    double m_water=A*i+B*j;
                    double m_sugar=C*k+D*l;
                    if(m_sugar>E*(m_water)/100) continue;

                    double concentration=(m_sugar)/(m_sugar+m_water)*100;
                    if(concentration>Max){
                        Max=concentration;
                        ans_water=m_water;
                        ans_sugar=m_sugar;
                    }
                }
            }
         
        }
    }
    cout<<ans_water+ans_sugar<<' '<<ans_sugar<<endl;
 
}


Measured memory_bytes: 256