akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)

using namespace std;


int main(){
    int n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;
    cin >> s;
    int temp=0;
    string ans = "Yes";

    if(c<d){
        for(int i = b+1;i<d;i++){
            if(s[i] == '#' && s[i+1] == '#') {
                ans = "No";
                // break;
            }
        }
        for(int j = a+1;j<c;j++){
            if(s[j] == '#' && s[j+1] == '#') {
                ans = "No";
                // break;
            }
        }
    }
    else{
        for(int i = b-1;i<d;i++){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                temp = 1;
            }
        }
        for(int i = b+1;i<d;i++){
            if(s[i] == '#' && s[i+1] == '#') {
                ans = "No";
                // break;
            }
        }
        for(int j = a+1;j<c;j++){
            if(s[j] == '#' && s[j+1] == '#') {
                ans = "No";
                // break;
            }
        }
        
        if(temp != 1) ans ="No";

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

ll dp[10010];

//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll h, n; cin >> h >> n;
    vector<pair<ll, ll> > ab(n);
    rep(i, n) {
        ll a, b; cin  >> a >> b;
        ab[i] = make_pair(b, a);
    }
    
    sort(ALL(ab));
    fill(dp, dp+10010, INTINF);
    dp[0] = 0LL;
    rep2(i, 1, 10010){
        rep(j, n){
            ll a = ab[j].second;
            ll b = ab[j].first;
            if(i - a >= 0LL){
                dp[i] = min(dp[i], dp[i-a] + b);
            }
            else{
                dp[i] = min(dp[i], ab[j].first);
            }
        }
    }
    

    cout << dp[h] << endl;
    
    
    return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
    if (h[i] >= k)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> in(h);
  for (int i = 0; i < h; i++) cin >> in[i];
  int ans = 1 << 30;
  for (int mask = 0; mask < (1 << (h - 1)); mask++) {
    vector<vector<int>> v;
    v.push_back({0});
    for (int i = 0; i < h - 1; i++) {
      if (mask & (1 << i)) v.push_back({i + 1});
      else v.back().push_back(i + 1);
    }
    int cur = __builtin_popcount(mask);
    int n = (int) v.size();
    vector<int> cnt(n);
    for (int i = 0; i < w; i++) {
      vector<int> cc(n);
      for (int j = 0; j < n; j++) {
        for (int& x : v[j]) cc[j] += in[x][i] - '0';
      }
      bool split = false, invalid = false;
      for (int j = 0; j < n; j++) {
        if (cc[j] > k) invalid = true;
        if (cc[j] + cnt[j] > k) split = true;
      }
      if (invalid) {
        cur = 1 << 30;
        break;
      } else if (split) {
        for (int j = 0; j < n; j++) cnt[j] = cc[j];
        cur++;
      } else {
        for (int j = 0; j < n; j++) cnt[j] += cc[j];
      }
    }
    ans = min(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int mod = 1000000007;

int main(){
  int N, K;
  std::cin >> N >> K;
  long long int dp[51][51][2604] = {};
  dp[0][0][0] = 1;
  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= i; j++){
      for(int k = 2*j; k <= K; k++){
        dp[i][j][k] = ((2*j+1)*dp[i-1][j][k-2*j] + (j+1)*(j+1)*dp[i-1][j+1][k-2*j] + ((j>0) ? dp[i-1][j-1][k-2*j] : 0)) % mod;
      }
    }
  }

  std::cout << dp[N][0][K] << std::endl;

  return 0;
}



Measured memory_bytes: 53120
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef map<string,int> si;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}


int atcoder() {
    double a,b,c,d,e,f;
    set<double> water,sugar;
    cin >> a >> b >> c >> d >> e >> f;
    double ans = 0;
    double ansx=0,ansy=0;
    
    for(int i=0; 100*a*i<=f; ++i){
        for(int j=0; 100*(a*i+b*j)<=f ;++j){
            if(100*(a*i+b*j)!=0) water.insert(100*(a*i+b*j));
        }
    }
    for(int i=0; c*i<=f; ++i){
        for(int j=0; c*i+d*j<=f ;++j){
            sugar.insert(c*i+d*j);
        }
    }
    
    for(auto x : water){
        for(auto y : sugar){
            if(x+y<=f && 100*y/x<=e && 100*y/x>=ans){
                ans = 100*y/x;
                ansx = x;
                ansy = y;
            }
        }
    }

    cout << (int)(ansx+ansy) << " " << (int)ansy << ENT;
    return 0;
}

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


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct node{
        int data;
        struct node *next;
        struct node *prev;
}llist;
llist *head = NULL;
llist *last = NULL;
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
main()
{
        int n, key;
        char command[12];
        llist *p;
        scanf("%d", &n);
        while(n--){
                scanf("%*c%s", command);
                if(!strcmp(command, "insert")){
                        scanf(" %d", &key);
                        insert(key);
                }else if(!strcmp(command, "delete")){
                        scanf(" %d", &key);
                        delete(key);
                }else if(!strcmp(command, "deleteFirst")){
                        deleteFirst();
                }else if(!strcmp(command, "deleteLast")){
                        deleteLast();
                }
        }
        if(head != NULL){
                printf("%d", head -> data);
                p = head -> next;
                while(p != NULL){
                        printf(" %d", p -> data);
                        p = p -> next;
                }
                putchar('\n');
        }
}
void insert(int data)
{
        llist *p;
        if((p = (llist*)malloc(sizeof(llist))) == NULL){
                fprintf(stderr, "Memory cannot allocate\n");
                exit(0);
        }
        p -> data = data;
        p -> prev = NULL;
        p -> next = head;
        head = p;
        if(last == NULL){
                last = p;
        }else{
                        p -> next -> prev = p;
                }
}
void delete(int data)
{
        llist *p = head;
        while(p != NULL){
                if(p -> data == data){
                        if(p != head){
                                p -> prev -> next = p -> next;
                        }else{
                                head = p -> next;
                        }
                        if(p != last){
                                p -> next -> prev = p -> prev;
                        }else{
                                last = p -> prev;
                        }
                        free(p);
                        return;
                }
                p = p -> next;
        }
}
void deleteFirst(void)
{
        llist *p = head;
        if(last == NULL){
                        return;
        }
        if(head -> next == NULL){
                        last = NULL;
        }else{
                        head -> next -> prev = NULL;
        }
                head = head -> next;
                free(p);
        return;
}
void deleteLast(void)
{
        llist *p = last;
    if(head == NULL){
        return;
    }
    if(last -> prev == NULL){
        head = NULL;
    }else{
        last -> prev -> next = NULL;
    }
    last = last -> prev;
    free(p);
    return;
}

Measured memory_bytes: 32988
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    VI l, r;
    REP(i,n){
        if (s[i] == 'o'){
            if (l.empty() || i > l.back() + c) l.push_back(i);
        }
    }
    FORR(i,n-1,0){
        if (s[i] == 'o'){
            if (r.empty() || i < r.back() - c) r.push_back(i);
        }
    }
    reverse(ALL(r));
    if (l.size() > k){
        cout << endl;
        return 0;
    }
    VI ans;
    REP(i,k){
        // int next = l[i] + 1;
        // while (next < n && s[i] == 'x') next++;
        // if (next == n) continue;
        // if (i == k - 1 || next + c < r[i + 1]) ans.push_back(l[i]);
        if (l[i] == r[i]) ans.push_back(l[i]);
    }
    for (int x : ans) cout << x + 1 << endl;
    return 0;
}


Measured memory_bytes: 4216
S=int(input())
S_=list(map(str,str(S))) #['1', 'p', '2', 'p', '5']
l=len(str(S))-1 #2
l_=len(S_)-1 #4
n=list(range(1,l_,2)) #[1, 3]

ans_2=[]
ans_3=[]
for i in range(2**l):
    listA=[]
    listB=[None]*(l+1) 
    for j in range(l):
        if ((i>>j)&1):
            listB[j]='+'
    ans_1=[]
    for o,p in zip(S_,listB):
        ans_1.append(o)
        ans_1.append(p)
    ans_2=[f for f in ans_1 if not f==None]
    ans_2=''.join(ans_2)
    ans_2=ans_2.split('+')
    ans_3.append(sum(list(map(int,ans_2))))
print(sum(ans_3))

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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    ll n;
    cin >> n;

    if(n % 2 != 0) cout << 0 << endl;
    else {
        ll ans = 0;
        ll den = 10;
        while(n >= den) {
            ans += n / den;
            den *= 5;
        }
        cout << ans << endl;
    }
}

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

int main() {
  string s;
  int q;
  cin >> s >> q;
  int cnt = 0;
  string a, b;
  rep(i,q) {
    int t;
    cin >> t;
    if(t == 1) {
      swap(a,b);
      cnt++;
      continue;
    }
    int f;
    char c;
    cin >> f >> c;
    if(f == 1) {
      a += c;
    }else{
      b += c;
    }
  }
  reverse(a.begin(), a.end());
  if(cnt % 2 == 1) reverse(s.begin(), s.end());
  string ans = a + s + b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4216
import java.util.Scanner;

// C - Takahashi's Information
// https://atcoder.jp/contests/abc088/tasks/abc088_c
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            c[i][0] = Integer.parseInt(scanner.next());
            c[i][1] = Integer.parseInt(scanner.next());
            c[i][2] = Integer.parseInt(scanner.next());
        }

        scanner.close();

        for (int i = 0; i < c.length; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < c[i].length; j++) {
                int num = c[i][j];
                if (min > num) {
                    min = num;
                }
            }

            // 全てにminを引く
            for (int j = 0; j < c[i].length; j++) {
                c[i][j] -= min;
            }
        }

        // 各列の値が同一であれば正しい、そうでなければ誤り
        for (int i = 0; i < c.length; i++) {
            if (c[0][i] != c[1][i] || c[1][i] != c[2][i]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23764
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <chrono>
#include <numeric>

using namespace std;
using namespace std::chrono;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 
    
int main() {
    fast
    lo n;
    cin >> n;
    printf("%f\n", n * 3.1415926 * 2);
    return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

int main()
{
	int N;
	int F[110][15]={};
	int P[110][15]={};
	int c;
	lint tmp,ans=-9e18;
	
	cin >> N;
	for(int i=0;i<N;i++)
		for(int j=0;j<10;j++)
			cin >> F[i][j];
	for(int i=0;i<N;i++)
		for(int j=0;j<11;j++)
			cin >> P[i][j];
	
	for(int i=1;i<(1<<10);i++)
	{
		tmp=0;
		for(int j=0;j<N;j++)
		{
			c=0;
			for(int k=0;k<10;k++)
				if(F[j][k]==1 && (i>>k)&1==1)c++;
			tmp+=P[j][c];
		}
		ans=max(ans,tmp);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())

    A = list(map(int, input().split()))

    # first positive
    sign = 1
    S = 0
    cost = 0
    for a in A:
        S += a
        if S * sign > 0:
            pass
        else:
            cost += abs(S) + 1
            S = sign
        sign *= -1
    p = cost

    # first negative
    sign = -1
    S = 0
    cost = 0
    for a in A:
        S += a
        if S * sign > 0:
            pass
        else:
            cost += abs(S) + 1
            S = sign
        sign *= -1
    q = cost

    print(min(p,q))


if __name__ == "__main__":
    main()


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  ll ans = 0;

  for(ll a = 1;a<=n-1;a++){
    for(ll b = 1;b<=n/a;b++){
      if(n-a*b==0) continue;
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


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

int ans[100];
int cor;

int main(){
	int T,N;
	int s,t,sum;
	while( cin >> T >> N )
	{
		sum = 0;
		for(int i = 0;i < N;i++){
			cin >> s >> t;
			sum += t-s;
		}
		if( sum < T )
			ans[cor] = T-sum;
		cor++;
	}
	for(int i = 0;i < cor;i++){
		if( ans[i] )
			cout << ans[i] << endl;
		else
			cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	int a=(int)(sqrt(n));
	cout<<a*a;
	re 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}
int main() {
	// your code goes here
 cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll p=2019;
    
    string s;
    cin >> s;
    n=s.length();
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        a[i] = (ll)(s[i] - '0');
    }
    reverse(a.begin(),a.end());
    vector<int> sum(n + 1, 0);
    for(ll i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i] * pow_mod(10, i, p) % p;
        sum[i + 1] %= p;
    }
    map<ll, ll> mp;
    for(ll i = 0; i < n + 1; i++) {
        // cout << sum[i] << " ";
        mp[sum[i]]++;
    }
    // cout << endl;
    ll ans = 0;
    
    for(const auto &p : mp) {
        ans += (p.second - 1) * p.second / 2;
    }
    cout << ans << endl;
     
     
	return 0;
}

Measured memory_bytes: 5820
# C
from collections import deque

def Connected(g, nodenum):
    visited = [False]*nodenum
    que = deque([])
    posi = 0
    que.append(posi)
    while que:
        visit = que.pop()
        visited[visit] = True
        for goto in g[visit]:
            if visited[goto]:
                continue
            que.append(goto)
    if all(visited):
        return True
    else:
        return False

n, m = map(int, input().split())
g = [[] for _ in range(n)]
edge_log = []
for _ in range(m):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    edge_log.append((a-1, b-1))

ans = 0
for edge in edge_log:
    g[edge[0]].remove(edge[1])
    g[edge[1]].remove(edge[0])
    if not Connected(g, nodenum=n):
        ans += 1
    g[edge[0]].append(edge[1])
    g[edge[1]].append(edge[0])
print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int n,k,x,ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		ans+=2*min(x,k-x);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long sum = 0;
    for (long i=1;i<=n;i++){
      sum += get(i,n);
    }
    System.out.println(sum);
  }

  public static long get(long a, long b){
    long g = (long) b/a;
    long c = (long) (g+1)*g*a/2;
    return c;
  }
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=800+5,inf=1e9,fx[4]={-1,0,1,0},fy[4]={0,-1,0,1};
char s[N][N];
int g[N][N];
pair<int,int>q[N*N];int tail;

int main()
{
	//freopen("1.in","r",stdin);
	int n,m,k;
	cin>>n>>m>>k;
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,n)
	rep(j,1,m)
	if(s[i][j]!='#')g[i][j]=inf;
	rep(i,1,n)
	rep(j,1,m)
	if(s[i][j]=='S')
	{
		tail=1;
		q[1]=make_pair(i,j);
		g[i][j]=0;
	}
	int ans=inf;
	rep(head,1,tail)
	{
		int x=q[head].first,y=q[head].second;
		ans=min(ans,min(min(min(x-1,y-1),n-x),m-y));
		if(g[x][y]==k)continue;
		rep(i,0,3)
		{
			int tx=x+fx[i],ty=y+fy[i];
			if(g[tx][ty]==inf)
			{
				g[tx][ty]=g[x][y]+1;
				q[++tail]=make_pair(tx,ty);
			}
		}
	}
	cout<<(ans+k-1)/k+1;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl t(n);
  rep(i, n) cin >> t[i];
  ll lcm = 1;
  rep(i, n) lcm = lcm / __gcd(lcm, t[i]) * t[i];
  cout << lcm << endl;
}

Measured memory_bytes: 256
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second


int main(int argc, const char * argv[]) {
  
  int n;
  int m;
  
  cin >> n;
  cin >> m;
  
  cout << ( n - 1 ) * ( m - 1 ) << endl;
  
  return 0;
}


Measured memory_bytes: 3572
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,x;cin>>n>>x;
  vector<bool>used(2*n-1,false);
  vl ans(2*n-1);
  if(n==2){
    if(x==2){
      cout<<"Yes"<<endl;
      cout<<1<<endl;
      cout<<2<<endl;
      cout<<3<<endl;
    }
    else cout<<"No"<<endl;
  }
  
  else {
    if(x==1||x==2*n-1){
      cout<<"No"<<endl;
      return 0;
    }
    if(x==2){
      ans[n-1]=x;
      ans[n-2]=x+1;
      ans[n]=x-1;
      ans[n+1]=x+2;
      used[x-1]=true;
      used[x+1-1]=true;
      used[x-1-1]=true;
      used[x+2-1]=true;
    }
    else{
      ans[n-1]=x;
      ans[n-2]=x-1;
      ans[n]=x+1;
      ans[n+1]=x-2;
      used[x-1]=true;
      used[x-1-1]=true;
      used[x+1-1]=true;
      used[x-2-1]=true;
    }
    ll j=0;
    rep(i,2*n-1){
      if(ans[i]!=0)continue;
      while(used[j]){
        j++;
      }
      ans[i]=j+1;
      used[j]=true;
    }
    cout<<"Yes"<<endl;
    rep(i,2*n-1){
      cout<<ans[i]<<endl;
    }
  }
}
      
      
  
  

Measured memory_bytes: 3200
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int n, m, a, b, c, k, l, p, q, t;

	string s;
	cin >> s;

	string u = "CODEFESTIVAL2016";

	auto ans = 0;

	rep(i, u.size()) {
		if (u[i] != s[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 764
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

D = i()
c = I()
for i in range(D):
    s = l()
    print(s.index(max(s))+1)

Measured memory_bytes: 72956
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    vector<ll> yakusuu=divisor(n);
    ans=LINF;
    rep(i,Size(yakusuu)){
        ans=min(yakusuu[i]+n/yakusuu[i]-2,ans);
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll val_a[200010] = {}, val_b[200010] = {}, val_c[200010] = {}, val_d[200010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    ll ans = INF;
    ll sum[200010] = {};
    rep(i,0,N){
        sum[i+1] = sum[i] + A[i];
    }
    ll fi = 0;
    rep(i,0,N){
        if(i == 0 || i >= N-2) continue;
        while(fi+1 < i){
            ll lv = sum[fi+1];
            ll rv = sum[i+1] - sum[fi+1];
            // print(lv);
            // print(rv);
            // print(abs(lv -rv));
            // print("/");
            ll lv_next = sum[fi+2];
            ll rv_next = sum[i+1] - sum[fi+2];
            // print(lv_next);
            // print(rv_next);
            // print(abs(lv_next - rv_next));
            // print("--");
            if(abs(lv-rv) > abs(lv_next - rv_next)){
                fi++;
            }else{
                break;
            }
        }
        val_a[i] = sum[fi+1];
        val_b[i] = sum[i+1] - sum[fi+1];
        // 1 2 3: 4 5| 6 7:8 9
    }
    fi = N-2;
    for(int i = N-1; i >= 0; i--){
        if(i == 0 || i >= N-2) continue;
        while(fi - 1 > i){
            // cout << "i = " << i << endl;
            // cout << "fi = " << fi << endl;
            ll lv = sum[fi+1] - sum[i+1];
            ll rv = sum[N] - sum[fi+1];
            // print(lv);
            // print(rv);
            // print(abs(lv -rv));
            // print("/");
            ll lv_next = sum[fi] - sum[i+1];
            ll rv_next = sum[N] - sum[fi];
            // print(lv_next);
            // print(rv_next);
            // print(abs(lv_next - rv_next));
            // print("--");
            if(abs(lv -rv) > abs(lv_next - rv_next)){
                fi--;
            }else{
                break;
            }
        }
        val_c[i] = sum[fi+1] - sum[i+1];
        val_d[i] = sum[N] - sum[fi+1];
    }
    rep(i,1,N-2){
        ll max_val = max(max(val_a[i],val_b[i]), max(val_c[i],val_d[i]));
        ll min_val = min(min(val_a[i],val_b[i]), min(val_c[i],val_d[i]));
        ans = min(ans, max_val-min_val);

    }
    // printa(val_a,N);
    // printa(val_b,N);
    // print("");
    // printa(val_c,N);
    // printa(val_d,N);
    print(ans);
    // i = 4
    // 1 2 3: 4 5| 6 7:8 9


}


Measured memory_bytes: 9600
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include "set"
#include "map"
#include "unordered_map"
#include <string>
#include <iomanip>
#include <numeric>
#include "cmath"

using namespace std;
#define double long double
#define int long long
#define all(a) a.begin(), a.end()


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


    int k; cin>>k; 
    
    string s;
    while(k--){
        s+="ACL";
    }
    
    cout<<s<<'\n';

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, A, B;

void solve(){
	cout << min(A, B);
	int m = 0;
	if(A + B > N){
		m = (A + B) - N;
	}
	cout << " " << m << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> A >> B;
		solve();
	return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

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

    int n;
    cin >> n;
    vi pos(n);
    for(int i = 0, num; i < n; ++i)
    {
        cin >> num;
        --num;
        pos[num] = i;
    }

    ll ans = 0;

    multiset<int> ms;
    ms.insert(-1);
    ms.insert(-1);
    ms.insert(n);
    ms.insert(n);

    for(int i = n-1; ~i; --i)
    {
        ms.insert(pos[i]);
        auto it = ms.find(pos[i]);
        ++it;
        int s1 = *it;
        ++it;
        int s2 = *it;
        //s2 je vece ili jednako od s1
        it = ms.find(pos[i]);
        --it;
        int p2 = *it;
        --it;
        int p1 = *it;
        //p1 je manje ili jednako od p2

        /*
        for(auto e : ms)
            cout << e << " ";
        cout << endl;
        */

        //cout << p1 << " " << p2 << " " << s1 << " " << s2 << endl;
        
        ll izraz = ((s2-s1)*(pos[i]-p2) + (p2-p1) * (s1-pos[i]));
        //cout << izraz << endl;
        //cout << "---------" << endl;

        ans += 1LL * (i+1) * izraz;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 8236
#include<iostream>
using namespace std;
int gcd(int x, int y)
{
	if (x%y == 0)
		return y;
	if (x < y)
	{
		int t = x;
		x = y;
		y = t;
	}
	gcd(y, x%y);
}
int main()
{
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  int ans=1;
  int num = 0;

    for(int i=0;i<N;i++){

      num+=a.at(i)-1;}

  cout<<num<<endl;
}


Measured memory_bytes: 768
N, x = map(int, input().split())
a = list(map(int, input().split()))

result = 0
b = max(a[0] - x, 0)
result += b
a[0] -= b
for i in range(1, N):
    b = max(a[i - 1] + a[i] - x, 0)
    result += b
    a[i] -= b
print(result)

Measured memory_bytes: 14052
n = int(input())
*A, = map(int, input().split())

C = {a:0 for a in A}

for a in A:
    C[a] += 1

maxA = max(A)

D = {a:0 for a in A}

for a in A:
    t = 2
    while a*t <= maxA:
        D[a*t] = 1
        t = t+1

counter = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        counter += 1
        
print(counter)

Measured memory_bytes: 104200
S = input()

if len(S) % 2 != 0:
    print('No')
    exit()

for i in range(len(S)):
    if i % 2 ==0:
        if S[i] != 'h':
            print('No')
            exit()
    else:
        if S[i] != 'i':
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 38384
#include<iostream>
#include<math.h>
 using namespace std ;
 int main()
{
short int a,b,c,d;

cin>>a;
cin>>b;
cin>>c;
cin>>d;
if((abs(c-a))<=d) cout<< "Yes";
else
 if((abs(c-b)<=d)&& ( abs(b-a)<=d) ) cout<< "Yes";
else
cout<< "No";




}

Measured memory_bytes: 3620
import sys

class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents=[-1 for _ in range(n)]
    
    def find(self,n):
        x=self.parents[n]
        if x<0:
            return n
        else:
            self.parents[n]=self.find(self.parents[n])
            return self.parents[n]
    
    def union(self,n,m):
        x=self.find(n)
        y=self.find(m)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x

sys.setrecursionlimit(10**9)    
n,m=map(int,input().split())
uf=UnionFind(n)

for _ in range(m):
    a,b=map(lambda x: int(x)-1, input().split())
    uf.union(a,b) 

ans=0

for p in uf.parents:
    ans=min(ans,p)

print(abs(ans))

Measured memory_bytes: 14492
#include <cstdio>
using namespace std;
int main()
{
	int n=700,i;
	char c[3];
	scanf("%s",c);
	for(i=0;i<3;i++)
	{
		if(c[i]=='o')
		{
			n+=100;
		}
	}
	printf("%d",n);
} 

Measured memory_bytes: 128
#include <iostream>
using std::cin ;
using std::cout;

int main(){
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  int N,K,Q; cin>>N>>K>>Q;
  int num = Q-K;
  int member[1000005];
  for (int i=0;i<Q;++i){
    int tmp; cin>>tmp;
    ++member[tmp-1];
  }
  for(int i=0;i<N;++i){
    if((member[i])>num){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,a[21],n,b[21],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>x,ans+=x;
	for(int i=1;i<n;i++)cin>>b[i];
	for(int i=2;i<=n;i++){
		if(a[i]==a[i-1]+1)ans+=b[a[i-1]];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ui NMAX = 5000;
static ui N;
static string S;

struct Z_algorithm {
  vector<ul> Z;

  Z_algorithm(const string& str) {
    ul n = str.size();
    Z.resize(n, 0);
    ul c = 0;
    FORi(i, 1, n) {
      if (Z[i - c] + i < Z[c] + c) {
        Z[i] = Z[i - c];
      } else {
        ul j = 0;
        if (i < c + Z[c]) {
          j = c + Z[c] - i;
        }
        while (i + j < n && str[i + j] == str[j]) {
          j++;
        }
        Z[i] = j;
        c = i;
      }
    }
  }
};

void solve(void) {
  ul res = 0;
  FOR0(i, N) {
    Z_algorithm z(S.substr(i));
    FOR0(j, N - i) {
      ul k = z.Z[j];
      if (k > j) {
        k = j;
      }
      res = max(k, res);
    }
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  cin >> S;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

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

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  multiset<ll> s;

  for (ll i = 0; i < n; ++i) {
    ll now = a[i];
    auto itr = s.lower_bound(now);
    if (itr != s.begin()) s.erase(--itr);
    s.insert(now);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>;


using namespace std;



int main() {
    string s, p;
    cin >> s;
    cin >> p;

    s = s + s;
    if (s.find(p)<=200 && s.find(p)>=0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3180
N = int(input())
h_list = list(input().split())
h_list = [int(h) for h in h_list]

max_h = max(h_list)
answer = 0

while max_h > 0:
	for i in range(N):
		if max_h == h_list[i]:
			l = i
			for j in range(i, N):
				if max_h != h_list[j]:
					r = j-1
					break
				if j == N-1:
					r = j
			for k in range(l, r+1):
				h_list[k] = h_list[k] - 1
			answer += 1

	max_h = max(h_list)

print(answer)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int n;
int a[100005];
vi up;
int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  REP(i,1,n){
    if(a[i]>a[i-1])up.pb(true);
    if(a[i]<a[i-1])up.pb(false);
  }
  //rep(i,up.size())cout<<i<<": "<<up[i]<<endl;
  ll ans=1;
  REP(i,1,up.size())if(up[i]!=up[i-1]){ans++;i++;}
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1276
#include <cstdio>

int main()
{
	int n,p=1; scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		int x; scanf("%d",&x);
		if(x==p) p++;
	}
	if(p==1) printf("-1");
	else printf("%d",n-p+1);
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    vector<Vi> cell(H, Vi(W));
    vector<Pii> bombs;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '#') {
                bombs.emplace_back(i, j);
            }
        }
    }

    constexpr Pii step[] = {
        {1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};

    for (const auto& p : bombs) {
        int x, y;
        tie(x, y) = p;
        cell[x][y] = -I_INF;
        for (int i = 0; i < 8; i++) {
            int nx, ny;
            nx = x + step[i].first;
            ny = y + step[i].second;
            if (nx >= 0 && nx < H && ny >= 0 && ny < W) {
                ++cell[nx][ny];
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (cell[i][j] < 0) {
                cout << '#';
            }
            else {
                cout << cell[i][j];
            }
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
#define DEBUG 0
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2019/9/1 21:07:26
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

int main()
{
  ll N;
  cin >> N;
  cout << N * (N - 1) / 2 << endl;
}

Measured memory_bytes: 256
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (a, b, h, m) = readInts()

    val md = 2 * PI * m / 60.toDouble()
    val hd = 2 * PI * (h * 60 + m) / (12 * 60).toDouble()

    var d = abs(hd - md)
    // a2=b2+c2−2bccosA

    val bb = b * b
    val aa = a * a
    val ab = a * b * 2 * cos(d)
    println(sqrt(bb + aa - ab))
}


Measured memory_bytes: 36520
#include<stdio.h>

int main(void){
    int M,  Answer, Sum = 0;
    double N;
    scanf("%lf %d",&N, &M);
    int A[M];
    for(int i = 0; i < M; i++){
        scanf("%d",&A[i]);
        Sum += A[i];
    }
    Answer = N-Sum;
    if(Answer < 0){
        printf("-1");
    }
    else{
        printf("%d\n",Answer);
    }
    return 0;
}

Measured memory_bytes: 1772