akhauriyash/Code-Regression huggingface dataset:
def r2n(i):
    if i == "I":
        return 1
    elif i == "V":
        return 5
    elif i == "X":
        return 10
    elif i == "L":
        return 50
    elif i == "C":
        return 100
    elif i == "D":
        return 500
    elif i == "M":
        return 1000

while(1):
    try:
        n = list(input())
        prev = r2n(n[0])
        tot = r2n(n[0])
        for i in range(len(n)-1):
            now = r2n(n[i+1])
            if now > prev:
                tot = tot - prev*2 + now
                prev = now
            else:
                tot = tot + now
                prev = now
        print(tot)
    except EOFError:
        break
        


Measured memory_bytes: 5560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] imos = new int[N + 2];
		for(int i=0;i<M;i++){
			imos[L[i]]++;
			imos[R[i] + 1]--;
		}
		int[] sum = new int[N + 2];
		for(int i=1;i<=N;i++) sum[i] = imos[i] + sum[i-1];
		int cnt = 0;
		for(int i=1;i<=N+1;i++) if(sum[i] == M) cnt++;
		Console.WriteLine(cnt);
		
		
		
	}
	int N,M;
	int[] L,R;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		L = new int[M];
		R = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			L[i] = d[0];
			R[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17244
fun main(args: Array<String>) {
    var (n, h) = readIntegerList()
    val abArray = Array(n) { readIntegerList() }
    val maxA = abArray.maxBy { it[0] }!![0]
    val sortedByB = abArray.sortedByDescending { it[1] }
    var ans = 0
    var i = 0
    while (h > 0 && i < n && sortedByB[i][1] > maxA) {
        h -= sortedByB[i][1]
        i++
        ans++
    }
    ans += (Math.max(h, 0) + maxA - 1) / maxA
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 82660
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    s = input()
    count = 0

    # See:
    # https://beta.atcoder.jp/contests/abc047/submissions/1007244
    for i in range(len(s) - 1):
        if s[i] != s[i + 1]:
            count += 1

    print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

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

  ll ans = 1, cur = m;
  while (n != 0) {
    if (n & 1) {
      ans *= cur;
      ans %= mod;
    }
    n >>= 1;
    cur *= cur;
    cur %= mod;
  }

  cout << ans << endl;


  
  return 0;
}


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


def solve(N: int, i: int):
    print(N-i+1)


# Generated by 1.1.4 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
    i = int(next(tokens))  # type: int
    solve(N, i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;

namespace ITP1_7_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int r = int.Parse(str[0]);
            int c = int.Parse(str[1]);
            int[,] SpreadSheet = new int[r+1,c+1];
            

            for(int i = 0; i < r; ++i)
            {
                string[] str1 = Console.ReadLine().Split(' ');
                for(int j = 0; j< c; ++j)
                {
                    SpreadSheet[i, j] = int.Parse(str1[j]);
                    SpreadSheet[r, j] += SpreadSheet[i, j];
                    SpreadSheet[i, c] += SpreadSheet[i, j];
                    SpreadSheet[r, c] += SpreadSheet[i, j];
                }
            }

            for(int i = 0; i < r + 1; ++i)
            {
                for(int j = 0; j < c + 1; ++j)
                {
                    Console.Write("{0}", SpreadSheet[i, j]);
                    if (j == c)
                        Console.Write("\n");
                    else
                        Console.Write(" ");
                }
            }
        }
    }
}

Measured memory_bytes: 5848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	int A,B,X;
	cin>>A>>B>>X;
	string ans="NO";
	if(A<=X&&A+B>=X)ans="YES";
	cout<<ans<<endl;
}

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

int main()
{
  ll h, w; cin >> h >> w;
  vector<string> s(w);
  for (int i=0; i<w; i++){
    cin >> s[i];
  }
  vector<vector<int>> a(h, vector<int>(w, 0));
  rep(i, h) rep(j, w) if (s[i][j]=='#') a[i][j] = 1;
  vector<vector<int>> dp(h, vector<int>(w, inf));
  dp[0][0] = a[0][0];
  for (int i=1; i<h; i++) {
    dp[i][0] = dp[i-1][0] + (a[i-1][0]==0&&a[i][0]==1);
  }
  for (int i=1; i<w; i++) {
    dp[0][i] = dp[0][i-1] + (a[0][i-1]==0&&a[0][i]==1);
  }
  for (int i=1; i<h; i++) {
    for (int j=1; j<w; j++) {
      dp[i][j] = min(dp[i-1][j]+(a[i-1][j]==0&&a[i][j]==1), dp[i][j-1]+(a[i][j-1]==0&&a[i][j]==1));
      // dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + a[i][j];
    }
  }
  cout << dp[h-1][w-1] << endl;

  return 0;
}


Measured memory_bytes: 384
import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):   
        c += bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(c)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
	ll n,W;
	cin>>n>>W;
	vector<pair<ll,ll>> w(n+1);
	for(ll i=1;i<n+1;i++){
		ll a,b;
		cin>>a>>b;
		w[i]=make_pair(a,b);
	}
	vector<vector<ll>> dp(W+1,vector<ll>(n+1,0));
	for(ll i=1;i<n+1;i++){
		for(ll j=0;j<W+1;j++){
			if(j-w[i].first+1>0){
				dp[j][i]=max(dp[j-w[i].first][i-1]+w[i].second,dp[j][i-1]);
             // cout<<"1"<<endl;
			}
			else{
				dp[j][i]=dp[j][i-1];
             // cout<<"2"<<endl;
			}
		}
	}
  /*for(ll j=0;j<W+1;j++){
    for(ll i=0;i<n+1;i++){
      cout<<dp[j][i]<<" ";
    }
    cout<<endl;
  }*/
	cout<<dp[W][n]<<endl;
}

Measured memory_bytes: 82304
// Aizu 1193: Chain Disappearance Puzzle
// 2017.9.14 bal4u@uu

#include <stdio.h>

char map[12][6];

int main()
{
	int h, r, c, r2, c2, t, f, ans;

	while (scanf("%d", &h) && h) {
		for (r = 1; r <= h; r++) for (c = 1; c <= 5; c++) scanf("%d", &t), map[r][c] = t;
		ans = 0, f = 1; while (1) {
			for (f = 0, r = 1; r <= h; r++) for (c = 1; c <= 3; c++) {
				if (!map[r][c]) continue;
				for (t = 1, c2 = c+1; c2 <= 5; c2++, t++)
					if (map[r][c2] != map[r][c]) break;
				if (t >= 3) {
					ans += t * map[r][c], f = 1;
					for (c2 = c; t--; c2++) map[r][c2] = 0;
					c = c2-1;
				}
			}
			if (!f) break;
			for (r = h; r >= 1; r--) for (c = 1; c <= 5; c++) if (map[r][c] == 0) {
				for (r2 = r-1; r2 >= 1; r2--) if (map[r2][c]) break;
				for (t = r; t >= 1; t--, r2--)
					if (r2 < 1) map[t][c] = 0; else map[t][c] = map[r2][c];
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1776
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
			
		int x = scan.nextInt();
		int n = scan.nextInt();
		Set<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++)
			set.add(scan.nextInt());
		scan.close();
		
		int min = 101;
		for(int i = 0; i < 101; i++) 
			if(!set.contains(i))
				if(Math.abs(x-i) < Math.abs(x-min)) {
					min = i;
				}else if(Math.abs(x-i) == Math.abs(x-min) && i < min) {
					min = i;
				}
				
		System.out.println(min);
	}

}


Measured memory_bytes: 36036
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main() {
	int A, B, ans;
	cin >> A >> B;
	if (B % A == 0)
		ans = A + B;
	else
		ans = B - A;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                             
#include <cmath>                                                                
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int x;                                                                        
  cin >> x;                                                                     
  int ans = pow(x,3);                                                           
  cout << ans << endl;                                                          
}                                                                               
                           

Measured memory_bytes: 3256
package main

import "fmt"

const wa = "WA"
const ac = "AC"

type probrem struct {
	waCount int
	isClear bool
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	p := make([]int, m, m)
	s := make([]string, m, m)
	for i := range p {
		fmt.Scan(&p[i], &s[i])
	}
	pr := make(map[int]probrem, n)
	for i := range s {
		v, ok := pr[p[i]]
		if s[i] == wa {
			if !ok {
				pr[p[i]] = probrem{1, false}
			} else {
				if !pr[p[i]].isClear {
					pr[p[i]] = probrem{v.waCount + 1, v.isClear}
				}
			}
		} else if s[i] == ac {
			if ok {
				pr[p[i]] = probrem{v.waCount, true}
			} else {
				pr[p[i]] = probrem{0, true}
			}
		}
	}
	a := 0
	w := 0
	for _, v := range pr {
		if v.isClear {
			a++
			w += v.waCount
		}
	}
	fmt.Println(a, w)

}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const ll ARR = 1e5 + 2;
const ll MOD = 1e9+7;
const ll INF = MOD;
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define gof for(long long int i = 0 ; i < n ; i++)
#define for1(i,s,e) for(long long int i = s ; i < e ; ++i)
#define weight first
#define value second
ll power(ll x, ll y)  
{  
    ll res = 1;     
    x = x % MOD; 
    if (x == 0) return 0; 
  
    while (y > 0)  
    {
        if (y & 1)  
            res = (res*x) % MOD;   
        y = y>>1;
        x = (x*x) % MOD;  
    }  
    return res;  
}  

ll gcd(ll a,ll b) { if (a == 0) return b; return gcd(b%a, a);}
ll max(ll a,ll b){if(a>b) return a; else return b;}
ll min(ll a,ll b){if(a<b) return a; else return b;}
ll max(ll a[], ll n){ll ans = 0; for(ll i = 0 ; i < n ; i++) ans = max(ans,a[i]); return ans;}

ll min(ll a[], ll n){ll ans = INF; for(ll i = 0 ; i < n ; i++) ans = min(ans,a[i]); return ans;}  
bool isPrime(ll N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}



void solve(){
    ll n,W;
    cin >> n >> W;
    ll wt[n+1], val[n+1];
    for1(i,0,n) cin >> wt[i] >> val[i];
    ll i, w;
    ll K[n + 1][W + 1];

    for (i = 0; i <= n; i++)
    {
        for (w = 0; w <= W; w++)
        {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(
                    val[i - 1] + K[i - 1][w - wt[i - 1]],
                    K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }

    cout << K[n][W];

    return;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  long long L;
  cin >> N >> M >> L;
  const long long INF = LLONG_MAX / 10;
  long long dist[N][N];
  for (int i = 0; i < N; i++) fill(dist[i], dist[i] + N, INF);
  for (int i = 0; i < N; i++) dist[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int A, B;
    long long C;
    cin >> A >> B >> C;
    A--, B--;
    dist[A][B] = dist[B][A] = C;
  }
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) dist[i][j] = dist[i][j] <= L ? 1 : INF;
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  int Q;
  cin >> Q;
  while (Q--) {
    int s, t;
    cin >> s >> t;
    long long ans = dist[--s][--t] == INF ? -1 : dist[s][t] - 1;
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 4372
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    string S;
    cin >> S;
    if(S=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long int n, k;
    long long int  sum = 0;
    const int m = 1000000007;
    cin >> n >> k;
    for(long long int i = k; i <= n + 1; i++){
        sum += i * (n - i + 1) + 1;
    }
    cout << sum % m << "\n";
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int power[20];
void function2()
{
	power[0]=1;
	int j;
	for(j=1;j<20;j++)
	{
		power[j]=2*power[j-1];
	}
}
int binary_search(int prefix[][20],int index,int start,int end,int first)
{
	if(start>end)
	   return -1;
	else
	{
		int mid=(start+end)/2;
		int here=prefix[mid][index]-prefix[first-1][index];
		if(here<=1)
		{
			int x=mid;
			int y=binary_search(prefix,index,mid+1,end,first);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		{
			return binary_search(prefix,index,start,mid-1,first);
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	function2();
	int n;
	cin>>n;
	int j,arr[n+1];
	for(j=1;j<=n;j++)
	{
		cin>>arr[j];
	}
	int prefix[n+1][20]={0};
	int i;
	for(j=1;j<=n;j++)
	{
		int x=arr[j];
		for(i=19;i>=0;i--)
		{
			if(x>=power[i])
			{
				prefix[j][i]++;
				x-=power[i];
			}
		}
	}
	for(j=1;j<=n;j++)
	{
		for(i=0;i<20;i++)
		{
			prefix[j][i]+=prefix[j-1][i];
		}
	}
	int answer=0;
	for(j=1;j<=n;j++)
	{
		set<int> st;
		for(i=0;i<20;i++)
		{
			int index=binary_search(prefix,i,j,n,j);
			st.insert(index);
		}
		int most=*st.begin();
		answer+=(most-j+1);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 36468
#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<ll,ll>

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size(), m=t.size();
  int ans=INT_MAX;
  for(int i=0; i<=n-m; i++){
    int now=0;
    for(int j=0; j<m; j++){
      if(s[i+j]!=t[j]) now++;
    }
    ans=min(ans,now);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
def lcm(a,b):
  m=max(a,b)
  n=min(a,b)
  kk=0
  for j in range(n,a*b+1,n):
 

    if j%a==0 and j%b==0:
      kk=j
      break
  return kk
a,b=map(int,input().split())
c=lcm(a,b)
print(c)

Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, k;
    cin >> a >> b >> k;
    if (a + b == k)cout << 0 << " " << 0 << endl;
    else if (a >= k) cout << a - k << " " << b << endl;
    else if(a < k) cout << 0 << " " << max(b-(k-a),0LL) << endl;
    return 0;
}


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

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
#define REP(inc, bgn, end) for(int inc=bgn; inc<end; inc++)
typedef long long ll;

int main() {
    string s;cin>>s;
    if(s[s.length()-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) cout << a*b << endl;
  else cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
int main(){
    int n;
    cin>>n;
    long long ans=1;
    for(int i=0;i<n;i++){
        long long a;
        cin>>a;
        ans=lcm(ans,a);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int i, j, k, p, q, r, x, y, u=0, v, n, m,c=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x>>y;
        if(x==y){
            c++;
        }
        else{
            c=0;
        }
        if(c>=3){
            u=1;
        }
    }
    if(u){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 10684
unittest
{
	assert( [ "5", "error", "2" ].parse.expand.solve == "*rr*r" );
	assert( [ "6", "eleven", "5" ].parse.expand.solve == "e*e*e*" );
	assert( [ "9", "education", "7" ].parse.expand.solve == "******i**" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front;
	input.popFront;
	auto k = input.front.to!( long );
	return tuple( n, s, k );
}

auto solve( long n, string s, long k )
{
	auto ans = s.dup;
	foreach( ref c; ans )
	{
		if( s[ k - 1 ] != c ) c = '*';
	}
	return ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define f(i,n)   for(int i=0;i<n;i++)
#define INF 1e9+5
#define LINF 1e18L+5;
#define pb push_back
#define mk make_pair
using namespace std;
/************************BELIAL**********DEVIL*********BELIAL***********DEVIL*************************/
int main()
{
    

    int n;
    cin>>n;

    //vector<int> arr(n);
    vector<int> dp(3,0);  // maintain ans of prev state 


    for(int days=0;days<n;days++)
    {
            vector<int> c(3);// for a,b,c   
             vector<int> new_dp(3,0);
               for(int i=0;i<3;i++)
               	     cin>> c[i];


         for(int i=0;i<3;i++)
         {
 	 			 for(int j=0;j<3;j++)
 	 			 {
 	 			 		if(i!=j)
 	 			 		{ new_dp[j]= max(new_dp[j],dp[i]+ c[j]);  //  ans of cur state

 	 			 		}
	 			 }

         }

     dp= new_dp;




    }

    cout<<max(max(dp[0],dp[1]),dp[2]);



}

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

bool is_line_symmetry(char c) {
    if ((c == 'i')||(c == 'w')) {
        return true;
    } else {
        return false;
    }
}

bool is_pair(char c1, char c2) {
    if ((c1 == '(')&&(c2 == ')')) return true;
    if ((c1 == ')')&&(c2 == '(')) return true;
    if ((is_line_symmetry(c1)&&(is_line_symmetry(c2))&&(c1 == c2))) return true;
    return false;
}

int main() {
    string s;
    int ans = 0;
    cin >> s;

    if (s == "") {
        cout << 0 << endl;
        return 0;
    }

    if (s.size() == 1) {
        if (is_line_symmetry(s[0])) {
            ans = 0;
            cout << ans;
            return 0;
        } else {
            ans = 1;
            cout << ans;
            return 0;
        }
    }

    if (s.size() % 2 == 1) {
        if (!is_line_symmetry(s[s.size()/2])) {
            ans += 1;
        }
    }
    for (int i=s.size()/2-1; -1<i; i--) {
        if (!is_pair(s[i], s[s.size()-i-1])) {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
int main(void)
    {
    int N,A,B,X ;
    scanf("%d%d%d",&N,&A,&B);
    X=A*N;
    if(X<B)
    {
    printf("%d\n",X);
    }
    else
    {
    printf("%d\n",B);
    }
}        

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<long long> a(n), o(61, 0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    long long x = a[i];
    int j = 0;
    while(x != 0){
      o[j] += x % 2;
      x /= 2;
      j++;
    }
  }
  long long ans = 0;
  for(int k = 0; k < 61; k++){
    //cout << k << " : " << o[k] << endl;
    long long x = (((o[k] * (n - o[k])) % 1000000007) * ((long long)pow(2, k) % 1000000007)) % 1000000007;
    ans = (ans + x) % 1000000007;
  }
  cout << ans << endl;
  return;
}

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


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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e9;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main(){
    //freopen("input00.txt","r",stdin);
    ll T = 1;
    //cin>>T;
    while(T--){
         ll n,m;
         string s;
         cin>>s;
         map<char , ll> MAP;
         for(ll i=0;i<s.size();i++)
            MAP[s[i]]++;
        if(MAP.find('B') != MAP.end() and MAP.find('A') != MAP.end())
            cout << "Yes";
        else
            cout << "No";
        
    }
    return 0;
}

Measured memory_bytes: 256
<?php
    // 自分の得意な言語で
    // Let's チャレンジ！！

    $input_line = fgets(STDIN);
    $number = preg_split("/[\s,]+/", $input_line);

    $n = intval($number[0]);
    $m = intval($number[1]);
while ($n != 0) {
    $input_line = fgets(STDIN);
    $amounts = preg_split("/[\s,]+/", $input_line);
    $maxX = 0;
    for ($i = 0; $i < $n - 1; $i++) {
        for ($j = 1 + $i; $j < $n; $j++) {
            $sum = intval($amounts[$i]) + intval($amounts[$j]);
            if ($sum <= $m) {
                if ($maxX < $sum) {
                    $maxX = $sum;
                }
            } 
        } 
    }
    if ($maxX == 0) {
        echo 'NONE' ."\n";
    } else {
        echo $maxX ."\n";
    }
    
    $input_line = fgets(STDIN);
    $number = preg_split("/[\s,]+/", $input_line);

    $n = intval($number[0]);
    $m = intval($number[1]);
}


Measured memory_bytes: 9640
import java.util.*;
public class Main {
    static final long MODVAL = 998244353L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int count[] = new int[N];
        X--;
        Y--;
        for(int i=0; i<N-1; i++) {
            for(int j=i+1; j<N; j++) {
//                System.out.println(String.format("%d:%d", i, j));
                // 直接到達：j-i
                // XからYへ抜ける： |i-x| + 1 + |j-Y|
                // YからXへ抜ける： |i-Y| + 1 + |j-X|
                int p1 = j-i;
                int p2 = Math.abs(i-X) + 1 + Math.abs(j-Y);
                int p3 = Math.abs(i-Y) + 1 + Math.abs(j-X);
                int best = Math.min(Math.min(p1, p2), p3);
                count[best]++;
            }
        }
        for(int t=1; t<N; t++) {
            System.out.println(count[t]);
        }
    }
}


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

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	
	for (int i = a; i <= min(a+k-1, b); i++)
		cout << i << endl;
		
	for (int i = max(b-k+1, min(a+k-1, b)+1); i <= b; i++)
		cout << i << endl;
}

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

int wa(int n){
    if(n < 10) return n;
    int sum = 0;
    while(true){
        sum += n%10;
        n /= 10;
        if(n == 0) break;
    }
    return sum;
}

int main(){

    int n,a,b,sum=0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;i++){
        if(wa(i) >=a && wa(i) <= b){
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int M = 1e9+7;

long long kaijo[2000005];

int mpow(long long a, int n)
{
  if (n % 2) return mpow(a, n - 1) * a % M;
  if (n == 0) return 1;
  return mpow(a * a % M, n / 2);
}

long long cmb(int n, int r)
{
  return kaijo[n] * mpow(kaijo[r], M-2) % M * mpow(kaijo[n-r], M-2) % M;
}

int main()
{
  int r, c, R, C; cin >> r >> c >> R >> C;
  
  kaijo[0] = 1;
  for (int i = 1; i < 2000005; ++i)
    kaijo[i] = kaijo[i-1] * i % M;
  
  int ans = (cmb(R+C+2, C+1)-cmb(R+c+1, c)-cmb(C+r+1, C+1)+cmb(r+c, c)+M*2) % M;
  cout << ans << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/04  Problem: 075_arc_c / Link: https://arc075.contest.atcoder.jp/tasks/arc075_c?lang=en ----- */
/* ------問題------

長さ N の整数列 a= {a1,a2,…,aN} と、整数 K が与えられます。
a の空でない連続する部分列 {al,al+1,…,ar} (1≤l≤r≤N) は N(N+1)⁄2 個存在します。これらのうち、算術平均が K 以上であるものは何個あるでしょうか？

-----問題ここまで----- */
/* -----解説等-----

平衝二分木がほしいときはBITでだいたいできる

sum(a,L,R)/(L-R+1) >= K は要素の個数がからんで面倒だけど、
数列からKを除いたときは新しい数列の部分列の和が0以上になりますかという問題になる
累積和の引き算で任意の区間を出すやつでO(N^2)にできる
次に累積和の左側の区間に自身よりも小さいものを高速に発見したくなる。
平衝二分木かあと思わなくてもこれはBITと座標圧縮でできて、値を昇順のノードに対応させれば検索が高速にできる。

----解説ここまで---- */
template<typename type>
struct BIT { // 1-index
	int N;
	int nn;
	vector<type> data;
	BIT(int n) {
		N = n + 1;
		data = vector<type>(n + 1, 0);
		nn = 1;
		while (nn * 2 <= N)nn *= 2;
	}
	void add(int i, type w) { // a[i] += w
		for (int x = i; x <= N; x += x & -x) {
			data[x] += w;
		}
	}
	type sum(int i) { // iまでの和 [1,i]
		type ret = 0;
		for (int x = i; x > 0; x -= x & -x) {
			ret += data[x];
		}
		return ret;
	}
	// [l, r]
	type sum(int l, int r) {
		if (l > r) return 0;
		return sum(r) - sum(l - 1);
	}
};



LL N, K;

LL ans = 0LL;

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

	cin >> N >> K;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
		a[i] -= K;
	}
	VL sum(N + 1, 0);
	FOR(i, 0, N) {
		sum[i + 1] = sum[i] + a[i];
	}

	VL xs(sum);
	SORT(xs);
	UNIQ(xs);
	BIT<LL> bit(SZ(sum));
	FOR(i, 0, SZ(sum)) {
		int id = lower_bound(ALL(xs), sum[i]) - xs.begin();
		ans += bit.sum(id + 1);
		bit.add(id + 1, 1);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int N;
map<int,int> data;

void solve() {
    data.clear();
    rep(i,N) {
        int a,b,c;
        cin>>a>>b>>c;
        data[b+c]=a;
    }

    auto it = data.end();
    --it;

    cout<<it->sc<<" "<<it->fr<<endl;



}
int main() {
    while(cin>>N) {
        if(!N) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string a;
 	int ans = 0;
 	cin >> a;
 	for(int i = 0; i < 4; i++){
 		if(a[i]=='2') ans++;
 	}
 	cout << ans << endl;
 	return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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()
int main(){
    string st;
    cin>>st;
    string a;
    int cnt=0;
    REP(i,st.length()){
        if(st[i]!='x'){
            a+=st[i];
        }else{
            cnt++;
        }
    }
    bool f=true;
    REP(i,a.length()){
        if(a[i]!=a[a.length()-1-i]){
            f=false;
            break;
        }
    }
    if(!f){
        cout<<-1<<endl;
        return 0;
    }
    int l=0;
    int r=st.length()-1;
    while(l<=r){
        if(st[l]=='x'&&st[r]=='x'){
            if(l!=r)cnt-=2;else cnt--;
            l++;
            r--;
        }else if(st[l]=='x'){
            l++;
        }else if(st[r]=='x'){
            r--;
        }else{
            l++;
            r--;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define INF 1000000000000000007
using namespace std;

int n,a[410],dp[410][410],sum[410];

signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++){cin>>a[i];sum[i]=sum[i-1]+a[i];}
	for(int l=2;l<=n;l++){
		for(int i=1,j=l+i-1;j<=n;i++,j++){
			dp[i][j]=INF;
			for(int k=i;k<j;k++){
				int val=dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1];
				dp[i][j]=min(dp[i][j],val);
			}
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}

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

main(){
	string s;
	cin >> s;
	//int a[s.length()];
	int flag_0=0;
	int flag_1=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='0'){
			flag_0++;
		}if(s[i]=='1'){
			flag_1++;
		}
	}
	if(flag_1>flag_0){
		cout << flag_0*2 <<endl;
	}else{
		cout << flag_1*2 <<endl;
	}
}


Measured memory_bytes: 512
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

H,W=get_i
a=array(H)
H.times do|i|
    a[i]=get_nsp
end
dp=array(W,0,H)
dp[0][0]=1
H.times do|i|
    W.times do|j|
      next if i==0 and j==0
      if a[i][j]=="."
        if i-1<0
            dp[i][j]=dp[i][j-1]
        elsif j-1<0
            dp[i][j]=dp[i-1][j]
        else
            dp[i][j]=dp[i-1][j]+dp[i][j-1]
        end  
      end 
      dp[i][j]%=(10**9+7)
    end
end
puts dp[H-1][W-1]

Measured memory_bytes: 96764
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 233;
int u[maxn],v[maxn],ans[maxn];
int vis[maxn],d[maxn],dfs_clock = 0;
vector<int> g[maxn];
inline int get(int x,int a){
	if(u[x]==a)return v[x];
	return u[x];
}
void dfs1(int x,int fa){
	d[x] = 0;vis[x] = ++dfs_clock;
	for(int i:g[x]){
		int y = get(i,x);
		if(y==fa)continue;
//		cout<<x<<"->"<<y<<endl;
		if(vis[y]){
			if(vis[y]<vis[x])d[x]++;
			continue;
		}
		dfs1(y,x);
		d[x] += d[y]+1;
	}
}
void dfs2(int x,int fa){
	vis[x] = ++dfs_clock;
	 for(int i:g[x]){
		int y = get(i,x);
		if(y==fa)continue;
		if(vis[y]){
			if(vis[y]<vis[x])ans[i] = x;
			continue;
		}
		if(d[y]%2)ans[i] = y;
		else ans[i] = x;
		dfs2(y,x);
	}
}
int main()
{
	int n,m;cin>>n>>m;
	if(m%2){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);
		g[u[i]].push_back(i);
		g[v[i]].push_back(i);
	}
	dfs1(1,0);
	memset(vis,0,sizeof(vis));
	dfs2(1,0);
//	for(int i=1;i<=n;i++)cout<<d[i]<<" ";cout<<endl;
//	for(int i=1;i<=m;i++)cout<<ans[i]<<" ";cout<<endl;
	for(int i=1;i<=m;i++)
		if(ans[i]==u[i])printf("%d %d\n",u[i],v[i]);
		else printf("%d %d\n",v[i],u[i]);
	return 0;
}

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

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    // cumulative sum
    vector<long long int> sa(n+1);
    for(int i=0; i<n; i++){
        sa[i+1] = sa[i] + a[i];
    }

    int ans = 1;
    for(int i=n-1; i>=0; i--){
        if(a[i] <= 2 * sa[i]) ans += 1;
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
<?php
fscanf(STDIN, "%d %d %d %d", $x1, $y1, $x2, $y2);
$dx = $x2 - $x1;
$dy = $y2 - $y1;
$x3 = $x2 - $dy;
$y3 = $y2 + $dx;
$x4 = $x1 - $dy;
$y4 = $y1 + $dx;
echo "$x3 $y3 $x4 $y4";

Measured memory_bytes: 4728
#include <stdio.h>
#include <stdlib.h>

int GCD(int a, int b)
{
    int r;
    while (r = a % b)
    {
        a = b;
        b = r;
    }
    return b;
}
int main(void)
{
    int n, i;
    scanf("%d", &n);
    int a[n + 1];
    for ( i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    int gcd = a[0];
    for (i = 1; i < n; i++)
    {
        if(gcd > GCD(a[i], gcd))
            gcd = GCD(a[i], gcd);
    }
    printf("%d\n", gcd);
    return 0;
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner((os.Stdin))

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

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B, C, D := nextInt(), nextInt(), nextInt(), nextInt()

	fmt.Printf("%d\n", ABC070B(A, B, C, D))
}

// ABC070B ...
func ABC070B(A, B, C, D int) int {
	if B < C || D < A {
		return 0
	}

	if A <= C && D <= B {
		return D - C
	}
	if C <= A && B <= D {
		return B - A
	}

	if A < C {
		return B - C
	}

	return D - A
}


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

#define ll long long

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define fill(a,b) memset(a,b,sizeof(a))

#define f first
#define s second
#define pb push_back

#define inf 1e17
#define ninf -1*1e17
#define mod 1000000007
#define N 500005
#define Ns 5005

string s;
ll n,m,o,x,y,z,d,k,l,r;

ll dp[N];
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--){
	    
	    ll ans=0;
	    cin>>n;
	    dp[0]=1;
	    for(int i=1;i<=n;i++){
	      for(int k=3;k<=i;k++){
	        dp[i]=(dp[i]+dp[i-k])%mod;
	      }
	    }
	    
	   // for(int i=0;i<=n;i++){
	   //     cout<<dp[i]<<" ";
	   // }
	   // cout<<"\n";
	    cout<<dp[n]<<"\n";
	    
	    
	}
	return 0;
}


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

int main() {
  int n; cin>>n;
  ll res=0;
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=n; j++) {
      for (int k=1; k<=n; k++) {
        res+=gcd(i, gcd(j, k));
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3672
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

using namespace std;

int cnt[210000] = {};

int main(){
	
	int N = 185;
	
	for(int i = 0; i < N; i++){
		for(int j = i; j < N; j++){
			for(int k = j; k < N; k++){
				for(int l = k; l < N; l++){
					cnt[i * i + j * j + k * k + l * l]++;
				}
			}
		}
	}
	
	while(true){
		int num;
		cin >> num;
		if(num == 0){
			break;
		}
		cout << cnt[num] << endl;
	}
	
	return 0;
}


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

template <typename T>
T _max(
  T lhs
  , T rhs
)
{
  return (lhs < rhs) ? rhs : lhs;
}

int main()
{
  int M = 3;
  int N;
  cin >> N;
  vector<vector<int>> abc(N + 1);
  for (auto & ABC : abc)
    ABC.resize(M);
  for (int i = 1; i <= N; ++i)
    for (int j = 0; j < M; ++j)
      cin >> abc[i][j];
  vector<vector<int>> happy(N + 1);
  for (auto & h : happy)
    h.resize(3);
  for (int i = 1; i <= N; ++i)
    for (int j = 0; j < M; ++j)
      happy[i][j] = _max(happy[i - 1][(j + 1)%M], happy[i - 1][(j + 2)%M]) + abc[i][j];
  cout << *max_element(happy[N].begin(), happy[N].end());
  return 0;
}


Measured memory_bytes: 11136
//
//  main.cpp
//  tarea
//
//  Created by AdÃ¡n LÃ³pez Alatorre on 3/31/17.
//  Copyright Â© 2017 AdÃ¡n LÃ³pez Alatorre. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string.h>
#include <bitset>
#include <set>
#include <cstdio>
#include <cmath>
#include <vector>
#include <iomanip>
#include <stack>
#include <map>
#include <queue>
#include <climits>
#define se second
#define fi first

using namespace std;

typedef  long long ll;
typedef vector<int> vi;
typedef pair<ll, ll> ii;

const int MOD = 998244353, maxN = 1e4 + 6, maxV = 4e6 + 6;

int n, ar[maxN];

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    
    cin >> n;
    int res = 0;
    for(int i = 0; i < n; i++){
        cin >> ar[i];
        while(ar[i] % 2 == 0){
            ar[i] >>= 1, res++;
        }
    }
    cout << res << '\n';
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char c[2][3];
    scanf("%c%c%c ",&c[0][0],&c[0][1],&c[0][2]);
    scanf("%c%c%c",&c[1][0],&c[1][1],&c[1][2]);
    if(c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0]){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
def main():
    N, K = map(int, input().split())
    A_have = [0]*N
    num = N

    for k in range(0, K):
        d = int(input())
        A = map(int, input().split())
        for a in A:
            if A_have[a-1] == 0:
                A_have[a-1] = 1
                num -= 1
    print(num)
                    
if __name__ == '__main__':
    main()

Measured memory_bytes: 67676
def read_input():
    n = int(input())

    conds = []
    for i in range(n):
        a, b = map(int, input().split())
        conds.append((a, b))

    return n, conds


def submit():
    n, conds = read_input()

    conds.sort(key=lambda x: x[1])

    curr = 0
    for c in conds:
        curr += c[0]

        if curr > c[1]:
            print('No')
            return

    print('Yes')
    return


if __name__ == '__main__':
    submit()


Measured memory_bytes: 73816
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll cumsum[n+1]={};
    rep(i,n)cumsum[i+1]=cumsum[i]+a[i];
    ll res=1LL<<60;
    rep(i,n-1)res=min(res,abs(cumsum[n]-cumsum[i+1]*2));
    cout << res << endl;
    return 0;
}


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

#define INF 1e9
using namespace std;

int main() {

    int N, K; cin >> N >> K;

    //スターグラフでできる最大の数
    int mx = (N-1) * (N-2) / 2;

    //最大より大きい値が入力された場合は存在しない
    if (mx < K) {
        puts("-1");
        return 0;
    }

    vector<pair<int, int>> ans;
    //最初にスターグラフを作る
    for (int i = 0; i < N-1; ++i) {
        //N番目が中心にあるとして
        ans.push_back(pair<int, int>(i+1, N)); //頂点は1から
    }

    //追加したい辺の数
    int add = mx - K;

    vector<pair<int, int>> edge;
    for (int i = 0; i < N-1; ++i) {
        for (int j = 0; j < i; ++j) {
            //辺の候補を全て列挙
            edge.push_back(pair<int, int>(i+1, j+1)); //頂点は1から
        }
    }

    //追加したい辺を追加
    for (int i = 0; i < add; ++i) {
        ans.push_back(edge[i]);
    }

    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}

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

int main()
{
  int n;
  cin >> n;
  int w[n];
  int left=0;
  rep(i,n) {
    cin >> w[i];
    left+= w[i];
  }
  int right=0,mini=INF,gap;
  rep(i,n){
    left-=w[i];
    right+=w[i];
    gap = abs(left-right);
   	mini = min(gap,mini);
  }
  cout << mini << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

int vis[100111],a[100111];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,m,x; cin >> n >> m;
    memset(a,0,sizeof(a));
    memset(vis,0,sizeof(vis));
    for(int i = 0 ; i < m; i++){
		cin >> x;
		vis[x] = 1;
	}
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	if(!vis[1])a[1]=1;
	if(!vis[2])a[2]=1+a[1];
	for(int i = 3; i <= n; i++){
		if(!vis[i])a[i] = a[i-1]+a[i-2];
		a[i]%=1000000007;
	}
	cout << a[n]%1000000007 << endl;
}	


Measured memory_bytes: 1024