akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   int n,a,b;cin>>n>>a>>b;
   cout<<(a*n>b?b:a*n);
}



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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;
    for (auto c : s)
        cout << (c == ',' ? ' ' : c);
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

monst = []
for i in 1..N+1 do
  monst[i-1] = lines[1][i-1]
end

remain = []
for i in 1..N do
  remain[i-1] = lines[2][i-1]
end

ans = 0
for i in 1..N do
  if monst[i-1] <= remain[i-1] then
    ans += monst[i-1]
    remain[i-1] -= monst[i-1]
  else
    ans += remain[i-1]
    remain[i-1] = 0
  end
  if remain[i-1] > 0 then
    if monst[i] <= remain[i-1] then
      ans += monst[i]
      monst[i] = 0
    else
      ans += remain[i-1]
      monst[i] -= remain[i-1]
    end
  end
end
    
print ans

Measured memory_bytes: 19292
def abc106b_105():
    n = int(input())
    cnt = 0
    for i in range(1, n + 1):
        if i % 2 == 0: continue
        yaku_cnt = 0
        for j in range(1, i + 1):
            if i % j == 0:
                yaku_cnt += 1
        if yaku_cnt == 8:
            cnt += 1

    print(cnt)


abc106b_105()


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

bool uni(string s){
  bool f = true;
  rep(i, sz(s) - 1) if(s[0] != s[i + 1]) f = false;
  return f;
}

main(){
  string s; cin >> s;

  int ans = inf;
  rep(i, 26){
    string t = s;
    char c = char('a' + i);
    int count = 0;
    while(not uni(t)){
      string u;
      rep(i, sz(t) - 1)
	if(t[i] == c or t[i + 1] == c) u += c;
	else u += t[i];
      t = u;
      count++;
    }
    ans = min(ans, count);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]);
        int B = int.Parse(s[1]);
        Console.WriteLine(Math.Max(Math.Max(A + B, A - B), A * B));
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 1e6 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int LN = 22;

long long n, m, u, v, k, t, q, x, d, p, a, b, c, s;


int cnt(int x) {
   int res = 0;
   while (x) {
      res++;
      x /= 10;
   }
   return res % 2;
}
int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n;
   int sol = 0;
   for (int i = 1; i <= n; ++i) {
      sol += cnt(i);
   }
   cout << sol << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,p;
    string s;
    cin>>n>>p>>s;
    if(p==2){
        ll ans=0;
        rep(i,n) if((s[i]-'0')%2==0) ans+=i+1;
        cout<<ans<<"\n";
        return 0;
    }
    if(p==5){
        ll ans=0;
        rep(i,n) if((s[i]-'0')%5==0) ans+=i+1;
        cout<<ans<<"\n";
        return 0;
    }
    ll A[200001]={0},B[200011];
    B[0]=1;
    rep(i,n) B[i+1]=B[i]*10%p;
    rep(i,n) A[n-i-1]=(A[n-i]+(s[n-i-1]-'0')*B[i])%p;
    ll num[200001]={0};
    rep(i,n+1) num[A[i]]++;
    ll ans=0;
    rep(i,p) ans+=num[i]*(num[i]-1)/2;
    cout<<ans<<"\n";
}


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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

int main() {

    int a, b;
    cin >> a >> b;

    if (b >= a)
        puts("unsafe");
    else
        puts("safe");

    return 0;
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];
int l[N], r[N];

int main() {
	megaRandom();
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	vector<int> v;
	for(int i = 1; i <= n; i ++) {
		l[i] = i;
		while(sz(v) > 0 && a[v.back()] > a[i]) {
			l[i] = l[v.back()];
			v.pp();
	 	}
	 	v.pb(i);
	}
	v.clear();
	for(int i = n; i >= 1; i --) {
		r[i] = i;
		while(sz(v) > 0 && a[v.back()] > a[i]) {
			r[i] = r[v.back()];
			v.pp();
	 	}
	 	v.pb(i);
	}
	ll res = 0;
	for(int i = 1; i <= n; i ++) {
		int left = i - l[i] + 1, right = r[i] - i + 1;
		res += 1ll * left * right * a[i];
	}
	printf("%lld", res);
	return 0;  
}


Measured memory_bytes: 10104
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum,B[100001],l[100000],r[100000],Q;
LL ans;
LL no;
bool b,bb[100001];
string s,t;

int main() {
	for (int i = 0; i < 100001; i++) {
		bb[i] = true;
		B[i] = 0;
	}
	bb[1] = false;
	for (int i = 2; i < 100001; i++) {
		for (int j = i+i; j < 100001; j += i) {
			bb[j] = false;
		}
	}
	for (int i = 2; i < 100001; i++) {
		if (bb[i]) {
			if (bb[(i + 1) / 2]) {
				B[i]++;
			}
		}
		B[i] += B[i - 1];
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
	}
	for (int i = 0; i < N; i++) {
		cout << B[r[i]]-B[l[i]-1] << endl;
	}


	return 0;
}



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

void maxHeapify(int *,int,int);
void swap(int *,int,int);

int main(){
  int i,n,*A;
  scanf("%d",&n);
  A = malloc(sizeof(int)*n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  for(i=(n-1)/2;i>=0;i--)maxHeapify(A,i,n);
  for(i=0;i<n-1;i++)printf(" %d",A[i]);
  printf(" %d\n",A[n-1]);
  free(A);
  return 0;
}

void maxHeapify(int *A,int i,int n){
  int l,r,max;
  l = i*2+1;
  r = (i+1)*2;
  if(l < n && A[l]>A[i])max = l;
  else max = i;
  if(r < n && A[r]>A[max])max = r;
  if(max != i){
    swap(A,i,max);
    maxHeapify(A,max,n);
  }
}

void swap(int *A,int i,int j){
  int tmp;
  tmp = A[i];
  A[i] = A[j];
  A[j] = tmp;
}



Measured memory_bytes: 3344
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define pop(v) (v).back(); (v).pop_back()
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    lint x,a,b;
    cin>>x>>a>>b;
    co((x-a)%b);
}

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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> visited(n, 0);
	vector<int> path(n, -1);
	vector<vector<int>> v(n);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	visited[0] = 1;
	queue<int> q;
	q.push(0);
	while(!q.empty()) {
		int cur = q.front();
		q.pop();
		for(auto it = v[cur].begin(); it != v[cur].end(); ++it) {
			if(!visited[*it]) {
				visited[*it] = true;
				path[*it] = cur;
				q.push(*it);
			}
		}
	}
	for(int i = 1; i < path.size(); ++i) {
		if(path[i] == -1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for(int i = 1; i < path.size(); ++i) {
		cout << path[i] + 1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 10168
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
#define N 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    set <ll> st = {1,2,3};
    st.erase(a);
    st.erase(b);
    cout<<*st.begin();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 998244353
#define ll long long
using namespace std;
int n,a,b,q[300005],x[300005],ans;
ll k;
int pow(int c,int p){
	int tot=1;
	while(p){
		if(p&1) tot=1ll*c*tot%mod;
		c=1ll*c*c%mod;
		p>>=1;
	}
	return tot;
}
int C(int A,int B){
	if(A==0) return 1; if(A>B||B-A>n) return 0; if(A==B) return 1;
	return 1ll*q[B]*x[A]%mod*x[B-A]%mod;
}
int main(){
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	q[1]=1;for(int i=2;i<=n;++i) q[i]=1ll*q[i-1]*i%mod;
	x[n]=pow(q[n],mod-2);
	for(int i=n-1;i>=0;--i) x[i]=x[i+1]*1ll*(i+1)%mod;
	if(k==0){puts("1");return 0;}
	for(int i=1;i<=n;++i){
		ll j=k-1ll*i*a;
		if(j%b) continue;
		j/=b;
		ans=(ans+1ll*C(i,n)*C(j,n)%mod)%mod;
	}
	printf("%d",ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
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;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    ll x;
    cin >> x;

    for(ll a = -200; a <= 200; ++a){
       for(ll b = -200; b <= 200; ++b){
           if(a*a*a*a*a - b*b*b*b*b == x){
               cout << a << ' ' << b << '\n';
               return 0;
           }
       }
    } 
    return 0;
}


Measured memory_bytes: 3608
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        h: usize,
        w: usize,
        a: usize,
        b: usize
    }
    let d = 1000000007;
    let mut st = vec![0; h + w + 1];
    st[0] = 1;
    for i in 1..h + w + 1 {
        st[i] = st[i - 1] * i % d;
    }
    let sti: Vec<usize> = st.iter().map(|&x| inv_m(x, d)).collect();
    let mut ans = 0;
    for i in b..w {
        ans = (ans + st[h - a - 1 + i] * sti[h - a - 1] % d * sti[i] % d * st[a - 1 + w - i - 1] % d * sti[a - 1] % d * sti[w - i - 1] % d) % d;
    }
    println!("{}", ans);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


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

int main()
{
    int N; cin >> N;
    long long T[1005], A[1005];
    for (int n = 1; n <= N; n++)
    {
        cin >> T[n] >> A[n];
    }

    for (int i = 1; i <= N - 1; i++)
    {
        long long T_1 = T[i], A_1 = A[i];
        long long T_2 = T[i + 1], A_2 = A[i + 1];

        if (T_1 <= T_2 && A_1 <= A_2) continue;
        else if (T_1 > T_2 && A_1 <= A_2)
        {
            long long x = ((T_1 - 1) / T_2) + 1;
            T_2 *= x;
            A_2 *= x;
        }
        else if (T_1 <= T_2 && A_1 > A_2)
        {
            long long x = ((A_1 - 1) / A_2) + 1;
            T_2 *= x;
            A_2 *= x;
        }
        else // (T_1 > T_2 && A_1 > A_2)
        {
            long long x = max( ((T_1 - 1) / T_2) + 1, ((A_1 - 1) / A_2) + 1 );
            T_2 *= x;
            A_2 *= x;
        }

        T[i + 1] = T_2;
        A[i + 1] = A_2;
    }

    cout << T[N] + A[N] << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N:usize = iter.next().unwrap().parse().unwrap();
    let mut D = HashMap::new();
    for _ in 0..N{
        let k = iter.next().unwrap().chars().collect::<Vec<_>>();
        let v = *(D.get(&k).unwrap_or(&0));
        D.insert(k, v+1);
    }
    let M:usize = iter.next().unwrap().parse().unwrap();
    for _ in 0..M{
        let k = iter.next().unwrap().chars().collect::<Vec<_>>();
        let v = *(D.get(&k).unwrap_or(&0));
        D.insert(k, v-1);
    }

    let mut ans = 0;
    for (_,v) in D{
        ans = max(ans,v);
    }

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

Measured memory_bytes: 4352
from bisect import bisect_left
N=int(input())
y=list(map(int, input().split()))
y.sort()
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bisect_left(y[(j+1):],tmp)
print(ans)

Measured memory_bytes: 74844
#include <stdio.h>
#include <string.h>
int main(){
 	char A[15],B[15],C[15];
 	scanf("%s %s %s",&A,&B,&C);
 	int lenA=strlen(A);
 	int lenB=strlen(B);
 	
 	if(A[lenA-1]==B[0]&&B[lenB-1]==C[0]){
 		printf("YES");
	 }
	 else{
	 	printf("NO");
	 }
 	
	return 0;	
	}

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

typedef long long ll;
typedef pair <int , int> pii;
typedef long double ld;

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int ans = 0;
   string s;
   cin >> s;
   for(int i = 0 ; i < 3 ; i++){
      int cur = 0;
      for(int j = i ; j < 3 ; j++){
         if(s[j] == 'R')
            cur++;
         else
            break;
      }
      ans = max(ans , cur);
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
using namespace std;

#define ll long long
int main(){

int n,k,x,y;
cin>>n>>k>>x>>y;

int total=0;
if(n<=k)
{
    
    total=x*(n);
}else{
    total=k*x;
    total+=y*(n-k);
}
cout<<total;

}


Measured memory_bytes: 3188
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> pre(2 * 1e5 + 1, -1);
    vector<ll> next(N, -1);
    for (ll i = 0; i < N; i++) {
        if (pre[A[i]] != -1) {
            next[pre[A[i]]] = i;
        }
        pre[A[i]] = i;
    }
    for (ll i = 0; i < N; i++) {
        if (next[i] == -1) {
            next[i] = pre[A[i]];
        }
        pre[A[i]] = min(pre[A[i]], i);
    }

    vector<ll> pre_visit(N, -1);
    ll curr = 0;
    while (true) {
        ll pos = curr % N;
        pre_visit[pos] = curr;

        ll cost = (next[pos] > pos ? next[pos] - pos : N + next[pos] - pos) + 1;
        if (curr + cost >= N * K) {
            //ループする前に終わる
            //シミュレート
            vector<ll> ans;
            for (ll i = pos; i < N; i++) {
                cost = (next[i] > i ? next[i] - i : N + next[i] - i) + 1;
                if (i + cost >= N) {
                    ans.push_back(A[i]);
                } else {
                    i = next[i];
                }
            }
            for (ll i = 0; i < ans.size(); i++) {
                cout << ans[i] << " \n"[i == ans.size() - 1];
            }

            return 0;
        }

        //遷移
        curr += cost;

        if (pre_visit[curr % N] != -1) {
            //ループした
            break;
        }
    }

    ll diff = curr - pre_visit[curr % N];

    curr += (N * K - 1 - curr) / diff * diff;

    //currからN * K - 1まで行くシミュレーション
    vector<ll> ans;
    for (; curr < N * K;) {
        ll pos = curr % N;
        ll cost = (next[pos] > pos ? next[pos] - pos : N + next[pos] - pos) + 1;
        if (curr + cost > N * K) {
            ans.push_back(A[pos]);
            curr++;
        } else {
            curr += cost;
        }
    }
    for (ll i = 0; i < ans.size(); i++) {
        cout << ans[i] << " \n"[i == ans.size() - 1];
    }
}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007


ll solve (vector<ll> &s,ll x){
    auto p=lower_bound(s.begin(),s.end(),x);
    ll ans=1e15;
    if(p<s.end()) ans=min(ans,abs(x-*p));
    if(p>s.begin()){
        ans=min(ans,abs(x-*(p-1)));
    }
    return ans;

}

int main(){
    ll i,j;
    ll a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a);
    vector<ll> t(b);
    for(i=0;i<a;i++) cin>>s[i];
    for(i=0;i<b;i++) cin>>t[i];



    for(i=0;i<q;i++){
        ll x;
        cin>>x;
        ll ans=1e15;

        auto p=lower_bound(s.begin(),s.end(),x);
        if(p<s.end()) ans=min(ans,abs(x-*p)+solve(t,*p));
        if(p-s.begin()>0){
            ans=min(ans,abs(x-*(p-1))+solve(t,*(p-1)));
        }

        p=lower_bound(t.begin(),t.end(),x);
        if(p<t.end()) ans=min(ans,abs(x-*p)+solve(s,*p));
        if(p-t.begin()>0){
            ans=min(ans,abs(x-*(p-1))+solve(s,*(p-1)));
        }
        
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  ll N;
  ll A, B;
  cin >> N >> A >> B;
  ll ans = N / (A + B) * A;
  ans += min(N % (A + B), A);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;


int main(){
	ll N; cin >> N;
    vector<ll> A(N);
    vector<ll> B(N,0);
    REP(i,N-1){
      cin >> A[i];
      B[A[i]-1]++;
    }
    REP(i,N){
         cout << B[i] << endl;
    }
    
  	return 0;
}

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

using namespace std;

#define N 2500

vector<pair<int, long long>> gf[N + 1]; // (Input)
long long dist[N + 1];
int reachable[N + 1];
int n; // (Input)
bool seen[N + 1];

/* O(V * E) - Returns true if there is a negative cycle reachable from u. */
bool bellman_ford(int u){
	bool converged = false;

	// Initializing.
	memset(dist, 0x3f, sizeof(dist));
	dist[u] = 0;

	// It takes at most n - 1 iterations to converge if there is no negative cycle reachable from u.
	for (int i = 1; !converged and i <= n; i++){
		converged = true;

		// For every vertex u.
		for (int u = 1; u <= n; u++){
			// For every edge (u, v).
			for (int j = 0; j < (int)gf[u].size(); j++){
				int v = gf[u][j].first;
				int w = gf[u][j].second;

				// Trying to relax this edge.
				if (dist[u] + w < dist[v]){
					dist[v] = dist[u] + w;
					converged = false;
				}
			}
		}
	}

	// Returns true if it didn't converge after n - 1 iterations.
	return !converged;
}

void dfs(vector<vector<pair<int, long long>>> const& g, int u){
	int v, i;

	seen[u] = true;
	reachable[u]++;

	for (i = 0; i < g[u].size(); i++){
		v = g[u][i].first;
	
		if (!seen[v]){
			dfs(g, v);
		}
	}
}

int main(){
	vector<vector<pair<int, long long>>> g, gt;
	int m, u, v, i;
	long long w, p;

	scanf("%d%d%lld", &n, &m, &p);
	g.resize(n + 1);
	gt.resize(n + 1);

	for (i = 1; i <= m; i++){
		scanf("%d%d%lld", &u, &v, &w);
		g[u].push_back({v, -(w - p)});
		gt[v].push_back({u, -(w - p)});
	}

	memset(seen, false, sizeof(seen));
	dfs(g, 1); // Reachable from 1.

	memset(seen, false, sizeof(seen));
	dfs(gt, n); // Can reach n.

	if (reachable[1] != 2 or reachable[n] != 2){
		printf("-1\n");
		return 0;
	}

	for (u = 1; u <= n; u++){
		for (i = 0; i < g[u].size(); i++){
			v = g[u][i].first;
			w = g[u][i].second;

			if (reachable[u] == 2 and reachable[v] == 2){
				gf[u].push_back({v, w});
			}
		}
	}

	if (bellman_ford(1)){
		printf("-1\n");
	}
	else{
		printf("%lld\n", max(0ll, -dist[n]));
	}

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	long X, Y, Z;
	cin >> X >> Y >> Z;

	cout << Z << " " << X << " " << Y << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ans = false;
		for(int i=0; i<n; i++) {
			String c = sc.next();
			if(c.contains("Y")) {
				ans = true; 
				break;
			}
			
		}
		if(ans){
			System.out.println("Four");
		} else {
			System.out.println("Three");
		}
		
		
	}

}


Measured memory_bytes: 35632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  while(getline(cin,s),s!="."){
    stack<char> a;
    bool flag=false;
    for(int i=0;i<s.size();++i){
      if(s[i]=='(' || s[i]=='[') a.push(s[i]);
      else if(s[i]==')')
        if(a.empty() || a.top()!='(') flag=true;
        else a.pop();
      else if(s[i]==']')
        if(a.empty() || a.top()!='[') flag=true;
        else a.pop();
      if(flag) break;
    }
    if(flag || !a.empty()) cout<<"no\n";
    else cout<<"yes\n";
  }
  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vector<map<int,int>> data(m);
    int zeros = 0, mid = 0;
    rep(i,n) {
        int x; cin >> x;
        if (x % m == 0) zeros++;
        else if (m % 2 == 0 && x % m == m / 2) mid++;
        else data[x%m][x]++;
    }
    ll ans = zeros / 2 + mid / 2;
    for (int i = 1; i < (m+1)/2; i++) {
        int pair_l = 0, pair_r = 0, rem_l = 0, rem_r = 0;
        for (int x : vint {i,m-i}) {
            for (P p : data[x]) {
                if (x == i) {
                    pair_l += p.second / 2;
                    rem_l += p.second % 2;
                } else {
                    pair_r += p.second / 2;
                    rem_r += p.second % 2;
                }
            }
        }
        if (rem_l > rem_r) {
            swap(pair_l,pair_r);
            swap(rem_l,rem_r);
        }
        int sub = min(pair_l,(rem_r-rem_l)/2);
        pair_l -= sub;
        rem_l += sub * 2;
        ans += pair_l + pair_r + min(rem_l,rem_r);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12520
import sys
sys.setrecursionlimit(10000)

def place(i, j, w):
    return i*w + j

def get_path(w, h, c):
    path = list()
    for i in range(h):
        for j in range(w):
            # place = i*w + j
            can_go = list()
            if c[i][j] != 0:
                if i != 0 and c[i-1][j] != 0:
                    can_go.append( place(i-1, j, w) )
                
                if i != h-1 and c[i+1][j] != 0:
                    can_go.append( place(i+1, j, w) )

                if j != 0 and c[i][j-1] != 0:
                    can_go.append( place(i, j-1, w) )
                
                if j != w-1 and c[i][j+1] != 0:
                    can_go.append( place(i, j+1, w) )
                
                if i != 0 and j!= 0 and c[i-1][j-1] != 0:
                    can_go.append( place(i-1, j-1, w) )
                
                if i != 0 and j != w-1 and c[i-1][j+1] != 0:
                    can_go.append( place(i-1, j+1, w) )
                
                if i!= h-1 and j != 0 and c[i+1][j-1] != 0:
                    can_go.append( place(i+1, j-1, w) )
                
                if i!= h-1 and j != w-1 and c[i+1][j+1] != 0:
                    can_go.append( place(i+1, j+1, w) )
                
            path.append(can_go)
    
    return path

def dfs(p, path, visit, w, h, c):
    visit[p] = 1 # 来訪時刻の記録

    for nxt in path[p]: #繋がってる点の内
        if visit[nxt] == 0: # 未探索の場合には
            dfs(nxt, path, visit, w, h, c) # 先に進む
    
    return

# def print_path(i, j, path, w, h):
#     arr = path[i*w + j]
#     print("print path start")
#     for x in arr:
#         print(x//w, x%w)
#     print("print path fin")

def solve(w, h, c):
    path = get_path(w, h, c)
    visit = [0]*(w*h)

    # print_path(3, 18, path, w, h)
    ans = 0
    for place in range(w*h):
        i = place // w
        j = place % w
        if c[i][j] != 0 and visit[place] == 0:
            dfs(place, path, visit, w, h, c)
            # print(i, j)
            ans += 1
    
    print(ans)
    return 

w, h = map(int, input().split())
while w != 0 and h != 0:
    c = [list(map(int, input().split())) for _ in range(h)]
    solve(w, h, c)
    w, h = map(int, input().split())


Measured memory_bytes: 8900
L, R = map(int,input().split())
mod = 2019

ans = pow(10,9)+7
for i in range(L,R):
  for j in range(i+1,R+1):
    val = ((i%mod) * (j%mod))%mod
    ans = min(ans, val)
    if ans == 0:
      break
  if ans == 0:
    break

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	string s;
	cin >> s;
	if (s[1] == 'B') {
		cout << "ARC" << endl;
	} else {
		cout << "ABC" << endl;
	}

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    string S;
    cin >> S;
    ll ans = 0;
    ll str = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == 'R'){
            str++;
        }
        else{
            ans = max(str,ans);
            str = 0;
        }
    }
    ans = max(str,ans);
    cout << ans << endl;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**6)

class UnionFind:
    def __init__(self, N):
        self.par = list(range(N))

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        else:
            self.par[rx] = ry

    def same(self, x, y):
        return self.root(x) == self.root(y)

def solve2():
    N, M = [int(_) for _ in raw_input().split()]
    Tree = UnionFind(N)
    for i in range(M):
        Xi, Yi, Zi = [int(_) for _ in raw_input().split()]
        Xi -= 1
        Yi -= 1
        Tree.unite(Xi, Yi)
    UnionSet = set()
    for i in range(N):
        UnionSet.add(Tree.root(i))
    print len(UnionSet)

if __name__ == '__main__':
    solve2()


Measured memory_bytes: 295836
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <array>

using namespace std;

int main()
{
	vector<int> A(9);
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> A.at(i * 3 + j);
		}
	}

	int N;
	cin >> N;
	vector<bool> marks(9);
	for (int i = 0; i < N; i++)
	{
		int b;
		cin >> b;

		for (int i = 0; i < 9; i++)
		{
			if (A.at(i) == b)
			{
				marks.at(i) = true;
			}
		}
	}

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (!marks.at(i * 3 + j))
			{
				break;
			}

			if (j == 2)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (!marks.at(j * 3 + i))
			{
				break;
			}

			if (j == 2)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	if (marks.at(0) && marks.at(4) && marks.at(8) || marks.at(2) && marks.at(4) && marks.at(6))
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			if (a < 10 && b < 10) {
				System.out.println(a * b);
			} else {
				System.out.println(-1);
			}
		}
	}
}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int input_sec = scan.nextInt();
        int output_sec = input_sec % 60;
        int output_minute = input_sec / 60;
        int output_hour = 0;
        if (output_minute != 0 && output_minute >= 60){
            output_hour = output_minute / 60;
            output_minute %= 60;
        }
        System.out.println(output_hour + ":" + output_minute + ":" + output_sec);
    }
}


Measured memory_bytes: 26392
#include<bits/stdc++.h>
using namespace std;
const int N = 5005;
typedef long long ll;
ll p[N],c[N];
void solve(){
ll n,x,mx=INT_MIN; cin>>n>>x;
for(int i=1;i<=n;i++) cin>>p[i];
for(int j=1;j<=n;j++) cin>>c[j];
for(int i=1;i<=n;i++){
        ll curr=i,turns=0,ans=0;
        vector<ll> res;
        while(true){
                curr=p[curr];
                ans+=c[curr];
                res.push_back(ans);
                turns++;
                if(curr==i||turns==x) break;
        }
        //for(int i=0;i<res.size();i++) cout<<res[i]<<" "; cout<<endl;
        if(turns==x) { mx=max(*max_element(res.begin(),res.end()),mx); }
        else {

                //cout<<turns<<" "<<x%turns-1<<" "<<endl;
                if(res[res.size()-1]<0){ mx=max(*max_element(res.begin(),res.end()),mx); }
                else{ mx=max(mx,max((x/turns-1)*(res[res.size()-1])+*max_element(res.begin(),res.end()),((x/turns)*res[res.size()-1])+(x%turns?*max_element(res.begin(),res.begin()+(x%turns)):0)));}
        }
}
cout<<mx<<endl;
}
int main(){
solve();
}



Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define clr(A, x) memset(A, x, sizeof(A))
#define cpy(A, B) memcpy(A, B, sizeof(B))
#define g(s) getline(cin, s) ///ai grija la fin/cin ///
#define FASTIO ios_base::sync_with_stdio(0)
const long long INFLL = 2 * 1e18 + 100;
const int INFINT = 2 * 1e9 + 100;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//ifstream fin("input.txt");
//ofstream fout("output.txt");
void die()
{
    cout << "-1";
    exit(0);
}
const int NMAX = 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;



int main()
{
    FASTIO;
    int n;
    int mmax = 0, mmin = INFINT;
    cin >> n;
    for1(i, n)
    {
        int a;
        cin >> a;
        mmax = max(mmax, a);
        mmin = min(mmin, a);
    }
    cout << mmax - mmin;


    return 0;
}


Measured memory_bytes: 256
N, K, S = map(int, input().split())
A = [0]*N
if S != 1:
    for i in range(K):
        A[i] = S
    for i in range(K,N):
        A[i] = max(S-1,1)
    print(" ".join(map(str,A)))
else:
    for i in range(K):
        A[i] = S
    for i in range(K,N):
        A[i] = max(S+1,1)
    print(" ".join(map(str,A)))

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

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

const long long MOD = (int) 1e9 + 7;

long long binPow(long long a, long long b) {
    if (b == 0)
        return 1;

    long long ans = binPow(a, b / 2);
    ans = ans * ans % MOD;

    if (b % 2)
        ans = ans * a % MOD;

    return ans;
}

int main() {
//    freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    vector<long long> a(n);
    map<int, int> q;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];

        --a[i];

        a[i] = (a[i] % m + m) % m;

        if (i)
            (a[i] += a[i - 1]) %= m;
//        ++q[a[i]];

//        cout << a[i] << " ";
    }

    long long ans = 0;
    long long last = 0;
    int j = -1;
    for (int i = 0; i < n; ++i) {
        while (j + 1 < n && j + 1 < i + m - 1) {
            ++j;
            ++q[a[j]];
        }

        ans += q[last];

//        break;

        last = a[i];
        --q[a[i]];
    }

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


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define pb push_back
#define ll long long

using namespace std;

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

    int h1,m1,h2,m2;
    cin>>h1>>m1>>h2>>m2;

    int k;
    cin>>k;
    if(h2<h1)h2+=24;
    cout<<(h2-h1)*60 + (m2-m1) - k<<"\n";

}


Measured memory_bytes: 3652
import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)
 
        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i
 
    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num
 
    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret
 
sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])
 
for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")

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

int main()
{
  int size;
  cin >> size;
  vector <int> nums(size);
  for (int i = 0; i < size; i++)
  {
    cin >> nums.at(i);
  }
  for (int i = size - 1; i >= 0; i--)
  {
    cout << nums.at(i);
    if (i != 0)
    {
      cout << ' ';
    }
  }
  cout << endl;
}


Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int [] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        int sum = 0;
        for (int i = 1; i < n-1; i++){
            int [] new_a = {a[i-1], a[i], a[i+1]};
            Arrays.sort(new_a);
            if (new_a[1] == a[i]){
                sum++;
            }
        }
        System.out.println(sum);
    }
}

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

int main(){
    int n; cin>>n;
    vector<int> b(n-1);

    for(int i=0; i<n-1; i++) cin>>b[i];

    ll ans = 0;

    ans += b[0];

    ans += b[n-2];

    for(int i=1; i<n-1; i++){
        if(b[i] >= b[i-1])ans += b[i-1];

        if(b[i] < b[i-1])ans += b[i];
    }

    cout<<ans<<endl;

    return 0;
    
}

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

int main() {
  int N,n;
  int c=0;
  cin >> N ;
  vector<int> A(N);
  for(n=0;n<N;n++)
    cin >> A.at(n);
  for(n=0;n<N;n++){
    if(A.at(n)%2==0){
      if(A.at(n)%3!=0&&A.at(n)%5!=0){
        c++;
      }
    }
  } 
  if(c!=0)
     cout << "DENIED" << endl; 
  else
     cout << "APPROVED" << endl;  
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int R = Integer.parseInt(str);
			str = br.readLine();
			int G = Integer.parseInt(str);
			System.out.println(2*G - R);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


Measured memory_bytes: 22868
n=int(input())
ss=[]
for _ in range(n):
    s=input()
    if 'A' in s or 'B' in s:
        ss.append(s)
c = sum(s.count('AB') for s in ss)
a = min(sum(s[0] == 'B' for s in ss), sum(s[-1] == 'A' for s in ss))
if a:
    c += a
    if sum((s[0] == 'B' and s[-1] != 'A') or (s[0] != 'B' and s[-1] == 'A') for s in ss) == 0:
        c -= 1
print(c)

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt();
		if((A==B && B!=C)||(B==C && C!=A)||(C==A && A!=B)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
char a[3];
    cin >> a[0] >> a[1] >> a[2];
    int five = 0;
    int seven = 0;

    for(int i=0;i<3;i++){
        if(a[i] == '5'){
            five++;
        }
        else if(a[i] == '7'){
            seven++;
        }
    }
    if(five==2 && seven == 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll M,D;cin>>M>>D;
	
	// 解法
	ll ans = 0;
	REP(i,M){
		REP(j, D){
			ll d1 = (j+1)%10;
			ll d2 = (j+1)/10;
			ll m = i+1;
			if (m==d1*d2 & d1!=1 & d2!=1){
				// printf("%lld, %lld\n", i+1, j+1);
				ans++;
			}
		}
	}

	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256