akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {


    public static void solve() {
        int n = in.nextInt();

        int[] stones = new int[n];

        for(int i = 0; i < n; i += 1) {
            stones[i] = in.nextInt();
        }

        int[] store = new int[n];

        for(int i = 1; i < n; i += 1) {
            store[i] = Integer.MAX_VALUE;

            for(int j = 1; j <= 2; j += 1)
                if(i-j >= 0)
                    store[i] = Math.min(store[i], store[i-j]+Math.abs(stones[i]-stones[i-j]));
        }

        out.println(store[n-1]);
    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

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

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

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

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

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

Measured memory_bytes: 33128
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 2 * 1e5;


template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


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

	long long n, a, b;
	long long ans;
	cin >> n >> a >> b;
	ans = 0;
	if (a == 0 || b == 0) {
		if (a)
			ans = n;
	} else {
		ans = (n / (a + b)) * a;
		n = n % (a + b);
		ans += min(a, n);
	}

	cout << ans << '\n';
}


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

int main() {
  int n;
  cin >> n;
  int a=0;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "Y")
      a=1;
  }
  
  if (a == 1)
    cout << "Four" <<endl;
  else 
    cout << "Three" << endl;
}


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

using namespace  std;

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

	vector<int> data(N,0);
	for (int i = 0; i < N; i++) {
		cin >> data.at(i);
	}
	int counter = 1;
	for (int i = 0; i < N; i++) {
		if (counter == data.at(i))counter++;
	}
	if (counter == 1) {
		cout << -1 << endl;
	}
	else {
		cout << N + 1 - counter << endl;
	}
	return 0;
}

Measured memory_bytes: 4048
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ABC_practice
{
    public class Program
    {

        #region templete

        private static void WL(string s) { WriteLine(s); }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
        /// <summary>
        /// 最小公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }

        static void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
        static void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

        public static void Main(string[] args)
        {
            new Program().Solve();
            ReadLine();
        }

        #endregion

        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var l = new List<long>();
            l.Add(2);
            l.Add(1);

            for (int i = 2; i <= n; i++)
            {
                l.Add(l.ElementAt(i - 1) + l.ElementAt(i - 2));
            }
            WL($"{l.ElementAt(n)}");
        }
    }
}


#region console in

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

#endregion

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

const int MAX_N = 100;

int main(){
    int A[MAX_N];
    int n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];

    for (int k = 0; k < n - 1; k++) cout << A[k] << " ";
    cout << A[n - 1] << "\n";

    for (int i = 1; i < n; 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;

       for (int k = 0; k < n - 1; k++) {
           cout << A[k] << " ";
       }
       cout << A[n - 1] << "\n";
    }
}



Measured memory_bytes: 3092
def main():
    from math import gcd

    K = int(input())

    result = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            t = gcd(a, b)
            for c in range(1, K + 1):
                result += gcd(t, c)
    print(result)


main()


Measured memory_bytes: 9176
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll N;
	std::cin >> N;
	auto p = getPrimeFactor(N);

	ll ans = 0;
	for (auto itr = p.begin(); itr != p.end(); itr++) {
		ll cnt = itr->second;
		ll i = 1;
		while (cnt / i > 0) {
			cnt -= i;
			i++;
			ans++;
		}
	}

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


Measured memory_bytes: 3632
use std::str::FromStr;

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

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let ss : Vec<String> = get_vec();
    let s : String = ss[0].to_string();
    let t : String = ss[1].to_string();
    let u : String = ss[2].to_string();

    let mut ans : String = s.to_uppercase().chars().nth(0).unwrap().to_string();
    ans.push(t.to_uppercase().chars().nth(0).unwrap());
    ans.push(u.to_uppercase().chars().nth(0).unwrap());

    println!("{}", ans);
}


Measured memory_bytes: 4352
import std.stdio; // readln
import std.array; // split
import std.conv; // to

void main(){
	string[] s = split(readln());

	int a = to!int(s[0]);
	int b = to!int(s[1]);
	int c = to!int(s[2]);
	if(a == b) writeln(c);
	else if(a == c) writeln(b);
	else writeln(a);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static String[] numlilst = {"3","5","7"};
	public static void main(String[] args) {
		long ans = dfs(0);
		System.out.println(ans);
		sc.close();
	}
	static long dfs(long s) {
		if (s > N) {
			return 0;
		}
		int ret;
		if (is753(s)) ret = 1; else ret = 0;
		for (String nums : numlilst) {
			String hikisu = Long.toString(s) + nums;
			ret += dfs(Long.parseLong(hikisu));
		}
		return ret;
	}
	static boolean is753(long s) {
		String sStr = Long.toString(s);
		for (String nums : numlilst) {
			if (!sStr.contains(nums)) return false;
		}
		return true;
	}
}

Measured memory_bytes: 39736
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int cnt=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j*100+k*50==x){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<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 ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <int, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1e5 + 123;
int n, a[N], b[N], c[N], d[N];
map <int, int> mc, md;
vi g[N];
int used[N], C;

void dfs(int v) {
	used[v] = 1;
	for (int to : g[v]) {
		if (used[to] == 1) {
			C = 1;
		}
		if (!used[to]) {
			dfs(to);
		}
	}
	used[v] = 2;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		c[i] = a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		d[i] = b[i];
	}
	sort(c + 1, c + n + 1);
	sort(d + 1, d + n + 1);
	int flag = 0;
	for (int i = 1; i <= n; i++) {
		if (c[i] > d[i]) {
			cout << "No";
			return 0;
		}
		if (i < n && d[i] >= c[i + 1]) {
			flag = 1;
		}
	}
	if (flag) {
		cout << "Yes";
	}	else {
		for (int i = 1; i <= n; i++) {
			mc[c[i]] = i;
			md[d[i]] = i;
		}
		for (int i = 1; i <= n; i++) {
			g[md[b[i]]].pb(mc[a[i]]);
		}
		int cycles = 0;
		for (int i = 1; i <= n; i++) {
			if (!used[i]) {
				C = 0;
				dfs(i);
				cycles += C;
			}
		}
		if (cycles > 1) {
			cout << "Yes";
		}	else {
			cout << "No";
		}
	}
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



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

	bool zero = false;
	int cnt = 0;
	for (auto num : A) {
		if (num < 0)cnt++;
		if (num == 0)zero = true;
	}

	for (auto& num : A)num = abs(num);
	ll res = accumulate(A.begin(), A.end(), 0ll);
	if (!zero && cnt % 2 != 0) {
		res -= *min_element(A.begin(), A.end()) * 2;
	}
	cout << res << endl;


	return 0;
}


Measured memory_bytes: 1024
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 int64_t n,x;
 cin>>n>>x;
 vector<int64_t>a(n);
 rep(i,n){
   cin>>a.at(i);
 }
 sort(all(a));
 int64_t cnt=0;
 rep(i,n){
   if(cnt+a.at(i)>x){
    cout<<i<<endl;
    return 0;
   }else{
     cnt+=a.at(i);
   }
 }
 if(cnt==x){
 cout<<n<<endl;
}else{cout<<n-1<<endl;}
}




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


class Program {

	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
		static void Main(string[] args) {
			char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		string res = "";
		//int res = 0;

		string[] strs = Console.ReadLine().Split(cs);

		res = "" + strs[2] + " " + strs[0] + " " + strs[1];
		Console.WriteLine(res);
		return;


	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

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

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

void solve(long long K, long long X) {
  if (500 * K >= X) {
    cout << YES << endl;

  } else {
    cout << NO << endl;
  }
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long X;
  scanf("%lld", &X);
  solve(K, X);
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  cout << ((N == A.size()) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 3984
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> hoge(n);
  long long int all=0;
  for(long long int i=0; i<n; i++){
    cin>>hoge.at(i);
    all+=hoge.at(i);
  }
  sort(hoge.begin(),hoge.end());
  if(all-hoge.at(n-1)>hoge.at(n-1)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]
    if op == '?':
        break
    elif op =='+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)

Measured memory_bytes: 7760
#include<stdio.h>
long long b[100],c[100],d[100],e[100],f[100];
long long gcd(long long a,long long b){
	while(b){
		a%=b;
		long long t=a;
		a=b;
		b=t;
	}
	return a;
}
long long lcm(long long a,long long b){return a*b/gcd(a,b);}
long long dfs(long long a){
	if(a==-1)return 1;
	long long L=dfs(d[a]-1);
	long long R=dfs(e[a]-1);
	long long s=gcd(c[a],b[a]);
	c[a]/=s;
	b[a]/=s;
	//printf("%lld,%lld\n",L*c[a],R*b[a]);
	long long u=lcm(L*b[a],R*c[a]);
	return u/c[a]+u/b[a];
}
int main(){
	long long a;
	while(scanf("%lld",&a),a){
		for(long long i=0;i<a;i++)scanf("%lld%lld%lld%lld",b+i,c+i,d+i,e+i);
		for(long long i=0;i<a;i++)f[i]=-1;
		for(long long i=0;i<a;i++){
			if(d[i]>0)f[d[i]-1]=i;
			if(e[i]>0)f[e[i]-1]=i;
		}
		long long parent=0;
		for(long long i=0;i<a;i++)if(f[i]==-1)parent=i;
		printf("%lld\n",dfs(parent));
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

struct Matrix
{
    int n;
    vector<vector<int>> mat;
    Matrix(int n): n(n)
    {
        mat = vector<vector<int>>(n, vector<int>(n, 0));
    }
    Matrix operator*(const Matrix &m) const
    {
        Matrix res(n);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                for(int k = 0; k < n; k++)
                {
                    res.mat[i][j] += mat[i][k] * m.mat[k][j];
                    res.mat[i][j] %= mod;
                }
        return res;
    }
};

Matrix matexpo(Matrix &b, int p, int n)
{
    Matrix res(n);
    for(int i = 0; i < n; i++)
        res.mat[i][i] = 1;
    while(p)
    {
        if(p & 1)
            res = res * b;
        b = b * b;
        p >>= 1;
    }
    return res;
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    Matrix m(n);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> m.mat[j][i];
    Matrix res = matexpo(m, k, n);
    int ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            ans += res.mat[i][j], ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

int A, B;
int totArea;
int remArea;

int main() {
	scanf("%d %d", &A, &B);
	totArea = A * B;
	remArea = (A + B) - 1;
	int finalAns = totArea - remArea;
	printf("%d\n", finalAns);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

ll i, j, H, W, flag;

int main(){
  ll c = 0, d = 0;
  vector<vector<char>> s(100, vector<char>(100));
  vector<vector<ll>> box(100, vector<ll>(100));
  string S;
  cin >> H >> W;
  rep(i, H){
    cin >> S;
    rep(j, W){
      s[i][j] = S[j];
    }
  }
  
  box[0][0] = 0;
  if(s[0][0] == '#'){
    box[0][0] = 1;
  }
  
  for (int i = 1; i < H; i++){
    if(s[i][0] == '#' && s[i - 1][0] == '.'){
        box[i][0] = box[i - 1][0] + 1;
    } else {
      box[i][0] = box[i - 1][0];
    }
  }
  
  for (int i = 1; i < W; i++){
    if(s[0][i] == '#' && s[0][i - 1] == '.'){
      box[0][i] = box[0][i - 1] + 1;
    } else {
      box[0][i] = box[0][i - 1];
    }
  }
  
  for (i = 1; i < H; i++){
    for (j = 1; j < W; j++){
      if(box[i - 1][j] < box[i][j - 1]){
        box[i][j] = box[i - 1][j];
        flag = 0;
      } else if(box[i - 1][j] > box[i][j - 1]){
        box[i][j] = box[i][j - 1];
        flag = 1;
      } else {
        if(s[i - 1][j] == '#'){
          box[i][j] = box[i - 1][j];
          flag = 0;
        } else {
          box[i][j] = box[i][j - 1];
          flag = 1;
        }
      }
      if(flag == 0 && s[i - 1][j] == '.' && s[i][j] == '#'){
        box[i][j]++;
      }
      if(flag == 1 && s[i][j - 1] == '.' && s[i][j] == '#'){
        box[i][j]++;
      }
    }
  }
  
  cout << box[H - 1][W - 1] << endl;
  
  return 0;
}

Measured memory_bytes: 384
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
if n == 1:
    print(1)
else:
    f = 1
    for i in range(1,n+1):
        f *= i
        f = f%1000000007
    print(f)


Measured memory_bytes: 3060
N = int(input())
names = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
FIRST = ('M', 'A', 'R', 'C', 'H')
for _ in range(N):
  name = input()
  if name[0] in FIRST:
    names[name[0]] += 1
ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += names[FIRST[i]]*names[FIRST[j]]*names[FIRST[k]]
print(ans)


Measured memory_bytes: 3064
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
ans = [[0] * (W + 2) for i in range(H + 2)]
mine = []
for i in range(H):
	for j in range(W):
		if S[i][j] != "#":
			continue
		mine.append((i, j))
		for v in range(3):
			for h in range(3):
				ans[i + v][j + h] += 1

for i, j in mine:
	ans[i + 1][j + 1] = "#"
for l in ans[1: H + 1]:
	print("".join(map(str, l[1: W + 1])))


Measured memory_bytes: 3188
#include<iostream>
#include<string>

std::pair<std::string,int> team[10];

int main()
{
	int n,win,lose,draw,point;
	std::string name;
	bool first=true;
	
	while(1)
	{
		std::cin>>n;
		if(n==0)break;
		
		for(int i=0;i<n;i++)
		{
			std::cin>>name>>win>>lose>>draw;
			point=win*3+draw;
			team[i].first=name;
			team[i].second=point;
		}
		
		for(int i=0;i<n;i++)
		{
			for(int j=i;j>0&&team[j].second>team[j-1].second;j--)
			{
				std::pair<std::string,int> temp;
				temp=team[j];
				team[j]=team[j-1];
				team[j-1]=temp;
			}
		}
		
		if(first){first=false;}
		else{std::cout<<std::endl;}
		for(int i=0;i<n;i++)
		{
			std::cout<<team[i].first<<','<<team[i].second<<std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
bool pr[1000007];
ll fpow(ll x,ll y){x=x%MOD;ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll compatible[n][n];
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	cin>>compatible[i][j];
	
	ll dp[(1LL<<n)];
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(int mask=0;mask<(1LL<<n);mask++)
	{
		ll x=__builtin_popcountll(mask);
		for(int j=0;j<n;j++)
		{
			if(!(mask&(1LL<<j)) && compatible[x][j])
			{
				dp[mask|(1LL<<j)]+=dp[mask];
				dp[mask|(1LL<<j)]%=MOD;
				
			}
		}
	}
	cout<<dp[(1LL<<n)-1];

}

Measured memory_bytes: 16640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
A = np.array(read().split(),np.int64)

A.sort()
x = (A * np.arange(N+1,1,-1) % MOD).sum() % MOD
x *= pow(2, N+N-2, MOD); x %= MOD
print(x)


Measured memory_bytes: 25240
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, k, x, y = [ni() for _ in range(4)]

if n <= k:
        print(n * x)
else:
        print(k * x + (n - k) * y)

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

int R, S, P;

int win(char c) {
  int ret = -1;
  if (c == 'r') ret = P;
  if (c == 's') ret = R;
  if (c == 'p') ret = S;
  return ret;
}

int main() {
  int N, K;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i < K) {
      ans += win(T.at(i));
      continue;
    }
    if (T.at(i) == T.at(i - K)) T.at(i) = ' ';
    else ans += win(T.at(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3736
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
int main()
{
	string s;

	cin >> s;

	if(s.find("9") <= 2){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;

}

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

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

#define INF 1000000000

typedef unsigned long long ull;

using namespace std;

int main() {
    ull X;
    cin >> X;

    ull value = 100;

    for (ull i = 1; i < 100000000; ++i) {
        value = value + value / 100;
        if (X <= value) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    int n, x, min, max;
    long sum;
    int i;
    scanf("%d",&n);
    scanf("%d",&x);
    min = max = sum = x;
    for (i=1;i<n; i++) {
        scanf("%d",&x);
        sum += x;
        if(max<x) max = x;
        if(min>x) min = x;
        
    }
    printf("%d %d %ld\n",min,max,sum);
        return 0;
}

Measured memory_bytes: 600
def resolve():
    N = input()
    S = input()
    x = 0
    max_x = 0
    for i in range(len(S)):
        if S[i] == "I":
            x += 1
            if x > max_x:
                max_x = x
        elif S[i] == "D":
            x -= 1
    print(max_x)

resolve()

Measured memory_bytes: 9048
s = input()
t = input()
ss = [0]
tt = [0]

for i in range(len(s)):
    if s[i]=='B':
        ss.append(ss[-1]+2)
    else:
        ss.append(ss[-1]+1)

for i in range(len(t)):
    if t[i]=='B':
        tt.append(tt[-1]+2)
    else:
        tt.append(tt[-1]+1)

q = int(input())

for i in range(q):
    a,b,c,d = map(int, input().split())
    if (ss[b]-ss[a-1])%3==(tt[d]-tt[c-1])%3:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 53836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

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

  int n;
  cin >> n;
  vector<int> p(n);
  int sum = 0;
  int m = 0;
  rep(i, n) {
    cin >> p[i];
    sum += p[i];
    m = max(m, p[i]);
  }
  cout << sum-m/2<< endl;
}


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

int main()
{
    int n;

    cin >> n;

    int a[n];

    for( int i = 0; i < n; i++ )
        cin >> a[i];

    bool j1 = false, j2 = false, j3 = false;
    for( int i = 0; i < n; i++ )
    {
        j1 = i == 0 ? 0: 1;
        j2 = i * 2 + 1 < n ? 1: 0;
        j3 = i * 2 + 2 < n ? 1: 0;
        
        cout << "node " << i + 1 << ": key = " << a[i] << ", ";
        if(j1)
            cout << "parent key = " << a[(i-1)/2] << ", ";
        if(j2)
            cout << "left key = " << a[i*2+1] << ", ";
        if(j3)
            cout << "right key = " << a[i*2+2] << ", ";
        cout << endl;
    }

    return 0;
}



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vector<pair<ll, ll>> r(n), b(n);
REP(i, n) cin >> r.at(i).second >> r.at(i).first;
REP(i, n) cin >> b.at(i).first >> b.at(i).second;

sort(all(r));
reverse(all(r));
sort(all(b));

ll res = 0;
REP(i, n)
  REP(j,n)
    if(b.at(i).first > r.at(j).second && b.at(i).second > r.at(j).first){
      res++;
      r.at(j).first = MOD;
      r.at(j).second = MOD;
      break;
    }

cout << res << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  cout<<A.at(N-1)-A.at(0)<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
#include<map>
#include<string>
using namespace std;

int N, M, P[100], K;
int memo[100];

int DFS(int idx, const vector<int> e[100]){
	if(memo[idx] != INT_MAX) return memo[idx];
	memo[idx] = P[idx];
	if( !e[idx].empty() ){
		int cost = 0;
		for(int i = 0; i < e[idx].size(); i++){
			cost += DFS(e[idx][i], e);
		}
		memo[idx] = min(memo[idx], cost);
	}
	return memo[idx];
}

int main(){
	while(cin >> N, N){
		vector<int> e[100];
		map<string, int> idx;
		string I, O, Q;
		fill_n(memo, 100, INT_MAX);
	
		for(int i = 0; i < N; i++){
			cin >> I >> P[i];
			idx[I] = i;
		}
		cin >> M;
		for(int i = 0; i < M; i++){
			cin >> O >> K;
			int O_idx = idx[O];
			for(int j = 0; j < K; j++){
				cin >> Q;
				e[O_idx].push_back(idx[Q]);
			}
		}
		cin >> I;
		printf("%d\n", DFS(idx[I], e) );
	}
	return 0;
}

Measured memory_bytes: 1248
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a,b,n;cin>>a>>b>>n;
	n=min(b-1,n);
	cout<<(a*n-((a*n)%b))/b<<endl;

	return 0;
} 

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3640
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"

tmp=a[0]
for i in range(n):
    tmp=math.gcd(tmp,a[i])
if tmp!=1:
    print(nc)
    exit()

a.sort()

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def factorize(N,prime_list):  # prime_listに素数のリストをぶち込め！
    lst = []
    for p in prime_list:
        if p * p > N:
            break
        while N % p == 0:
            N //= p
            lst.append(p)
    if N > 1:
        lst.append(N)
    return lst

plst=primes(1000000)
dic={}
for i in range(n):
    fac=factorize(a[i],plst)
    for j in fac:
        if j in dic:
            print(sc)
            exit()
    for j in fac:
        dic[j]=1
print(pc)

Measured memory_bytes: 200936
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	double hehe=n;
	double num=ceil(hehe/2);
	double ans=num/hehe;
	cout<<fixed<<setprecision(10);
	cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 256
//ex7_3
//TKC001

#include<stdio.h>
#include<stdlib.h>

int main(void){
    //row_memo[i] = 1のときptr[i][]を消さない。col_memo[j] = 1のときptr[][j]を消さない
    int height, width, i, j, *row_memo, *col_memo;
    char **ptr;
    scanf("%d %d", &height, &width);

    //row_memoの動的確保
    row_memo = (int*)calloc(height, sizeof(int));
    if(row_memo == NULL){
        exit(1);
    }
    //col_memoの動的確保
    col_memo = (int*)calloc(width, sizeof(int));
    if(col_memo == NULL){
        exit(1);
    }
    //配列の先頭をheight個確保
    ptr = (char**)calloc(height, sizeof(char*));
    if(ptr == NULL){
        exit(1);
    }

    //大きさwidthの配列をheight個確保
    for(i = 0; i < height; i++){
        ptr[i] = (char*)calloc(width+1, sizeof(char));
        if(ptr[i] == NULL){
            exit(1);
        }
    }

    //入力
    for(i = 0; i < height; i++){
        scanf("%s", ptr[i]);
    }

    //黒があった行と列でrow_memoとcol_memoを1にする。
    for(i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            if(ptr[i][j] == '#'){
                row_memo[i] = 1;
                col_memo[j] = 1;
            }
        }   
    }

    //row_memoとcol_memoが0である行と列は省いて出力
    for(i = 0; i < height; i++){
        if (row_memo[i] == 0){
            continue;
        }
        for(j = 0; j < width; j++){
            if(col_memo[j] == 0){
                continue;
            }
            printf("%c", ptr[i][j]);
        }
        printf("\n");
    }
    
    //メモリを解放
    free(row_memo);
    free(col_memo);
    for ( i = 0; i < height; i++)
    {
        free(ptr[i]);
    }

    free(ptr);
    
    return 0;
}

Measured memory_bytes: 1608
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<int> > t(n, vector<int>(2));
        for(int i=0; i<n; ++i){
            for(int j=0; j<2; ++j){
                int h, m, s;
                char c;
                cin >> h >> c >> m >> c >> s;
                t[i][j] = (h * 60 + m) * 60 + s;
            }
        }
        sort(t.begin(), t.end());

        int ret = 0;
        vector<bool> check(n, false);
        for(int i=0; i<n; ++i){
            if(!check[i])
                ++ ret;
            for(int j=i+1; j<n; ++j){
                if(t[j][0] >= t[i][1] && !check[j]){
                    check[j] = true;
                    break;
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1664
from math import factorial
from collections import defaultdict
def nCr(n,r):
    return int(factorial(n)/(factorial(n-r)*factorial(r)))
N,A,B=map(int,input().split())
V=list(map(int,input().split()))
dict=defaultdict(int)
for i in V:
    dict[i]+=1
V.sort(reverse=True)
v=[]
value=0
tmp=0
for i in range(N):
    if value!=V[i]:
        tmp=1
        value=V[i]
    else:
        tmp+=1
    v.append([V[i],tmp])
ans=0
print(sum(V[:A])/A)
if V[0]==V[A-1]:
    for i in range(A,B+1):
        if V[0]==V[i-1]:
            ans+=nCr(dict[V[0]],i)
    print(ans)

else:
    print(nCr(dict[V[A-1]],v[A-1][1]))


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for(int i = (a); i >=(b); --i)
#define endl '\n'
#define debug(a) cout << a << endl
using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
 
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
 
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;

ll n, m;
ll a[limit1];
ll res = 0, sum = 0, ans = 0, kd, hkd;


void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void ReadIn(){
    cin >> n >> m;
    For(i, 1, m){
        cin >> a[i];
        sum += a[i];
    }
    res = n - sum;
    if(res < 0){
        cout << - 1;
        return;
    }
    cout << res;
}
int main(){
    FastIn();
    ReadIn();
}
    

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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

long long lcm(long long a, long long b){
    return a*b/gcd(a,b);
}

int main(){
    
    int n; cin>>n;
    ll ans = 1;
    REP(i,n){
        ll t; cin>>t;
        ans = lcm(ans,t);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include<sstream>

using namespace std;
#define ll long long
#define mod 1000000007


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

    vector<int> v(n);
    for (int &i : v) {
        cin >> i;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (v[i] != v[j] && v[j] != v[k] && v[i] + v[j] > v[k]) {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3644
import sys
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print('Yes')
else:
  M=1
  for i in range(N-1):
    M=max(M,H[i])
    if H[i]<=H[i+1]:
      pass
    elif H[i]-H[i+1]==1:
      H[i]-=1
      if M-H[i]>1:
        print('No')
        sys.exit()
      else:
        pass
    elif H[i]-H[i+1]>=2:
      print('No')
      sys.exit()
  print('Yes')

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

using namespace std;


int main() {

	int n;
	cin >> n;

	vector<int> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}


	int count = 0;
	for (int i = 1; i < n-1; i++)
	{
		int p1 = p[i - 1];
		int p2 = p[i];
		int p3 = p[i + 1];

		p1 -= p2;
		p3 -= p2;
		p2 -= p2; //必ず0になる


		//一番小さいとき
		if (p1 > 0 && p3 >0 ) {
			continue;
		}

		//一番大きいとき
		if (p1 < 0 && p3 < 0) {
			continue;
		}

		//等しいとき
		if (p1 == p2 && p3 == p2) {
			continue;
		}

		count++;
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll n,a,b;
    in>>n>>a>>b;
    cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using namespace std;

int main(){
	int h,w;cin>>h>>w;
	int c[10][10];for(int i=0;i<100;i++)cin>>c[i/10][i%10];
	int a[h][w];for(int i=0;i<h*w;i++)cin>>a[i/w][i%w];

	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
		}}
	}

	int ans=0;
	for(int i=0;i<w*h;i++)if(a[i/w][i%w]!=-1)ans+=c[a[i/w][i%w]][1];
	cout<<ans<<endl;
}



Measured memory_bytes: 384
# import math
from fractions import gcd

a, b = map(int, input().split())

#最大公約数: greatest common divisor(gcd)
# g = math.gcd(a,b)
g=gcd(a,b)

def prime_decomposition(n):
  i=2
  table = []
  while i*i <= n:
    while n%i==0:
      n//=i
      table.append(i)
    i+=1
  if n>1:
    table.append(n)
  return table
print(len(set(prime_decomposition(g)))+1)

Measured memory_bytes: 5596
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, m;
    cin >> n >> m;
    using P = pair<int, pii>;
    vector<P> v;
    rep(i, m) {
        int p, y;
        cin >> p >> y;
        v.push_back({i, {p, y}});
    }
    sort(all(v), [&](P a, P b) {return a.se.se < b.se.se;});
    map<int, int> mp;
    vector<string> ans(m);
    rep(i, v.size()) {
        string s, t;
        int x = ++mp[v[i].se.fi];
        s = to_string(v[i].se.fi);
        t = to_string(x);
        while(s.size() < 6) s = "0" + s;
        while(t.size() < 6) t = "0" + t;
        ans[v[i].fi] = s+t;
    }
    rep(i, m) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 12788
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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


	int N;
	cin >> N;
	vector<ll>A(N);
	vector<ll>A_(N);
	for (int i = 0; i < N; i++) { cin >> A[i]; A_[i] = A[i]; }
	sort(all(A_));
	map<ll, pair<ll,ll>>mp;
	for (int i = 0; i < N; i++) { mp[A[i]].first = i; mp[A_[i]].second = i; }
	int ans = 0;
	fore(x, mp)ans += (x.second.first % 2 != x.second.second % 2);
	puts(ans/2);


	return 0;
}

Measured memory_bytes: 8064
object Main extends App {
  import scala.io.StdIn._


  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  println(if ((n + 1) / 2 >= k) "YES" else "NO")
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 25412
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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++)
using namespace std;

int main(){
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  int ans = 0;
  rep(i, s.size()){
    if (s[i] != t[i]) ans++;
  }
  cout << ans / 2 << endl;
}


Measured memory_bytes: 3604