akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char argv[]){
	int num;
	
	scanf("%d", &num);

	int buf, i, max, min;

	scanf("%d", &min);	
	for(i = 1, max = INT_MIN; i < num; i++){
		scanf("%d", &buf);
		if(max < buf - min)
			max = buf - min;
		if(buf < min)
			min = buf;
	}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 596
// include
#include <iostream>

// using namespace 
using namespace std;

// typedef
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> PII;

// macro
#define REP(index, num) for (auto index = 0; index < num; index++)
#define FOR(index, num) for (auto index = 1; index <= num; index++)

#define MAX_HEIGHT 60
#define MAX_WIDTH 60
#define INF (int)1e9

// global
int N;
int A, B;
int totalSum = 0;

int FindSumOfDigits(int num);

int main()
{
  cin >> N;
  cin >> A >> B;

  FOR(nId, N)
  {
    int sumOfDigits = FindSumOfDigits(nId);
    if (A <= sumOfDigits && sumOfDigits <= B)
      totalSum += nId;
  }

  cout << totalSum << endl;

}

int FindSumOfDigits(int num)
{
  int sum = 0;
  while (num)
  {
    sum += num % 10;  // 一番小さい桁を足す
    num = num / 10; // 桁を減らす。
  }
  return sum;
}

Measured memory_bytes: 764
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}
 
#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"
 
// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;
 
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;
 
int main()
{
	FAST_IO;
 
 	ll n, d, cnt = 0;
 	cin >> n >> d;
 	for(int i=0;i<n;i++)
 	{
 		ll x, y;
 		cin >> x >> y;
 		if(x * x + y * y <= d * d) cnt += 1;
 	}
 	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "-1" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<P> A(N);
    rep(i,N) cin>>A[i].first,A[i].second=i;
    SORT(A);
    ll ans=0;
    rep(i,N) if(i%2!=A[i].second%2) ++ans;
    cout<< ans/2 <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

typedef long long ll;

ll N;
vector<ll> P;

bool check() {
  for (ll i = 0; i < N; ++i) {
    if (P[i] != i) return false;
  }
  return true;
}
int main() {
  cin >> N;
  P.resize(N);
  for (ll i = 0; i < N; ++i) {
    cin >> P[i];
    --P[i];
  }
  for (ll i = 0; i < N; ++i) {
    if (P[i] != i) {
      ll j = P[i];
      swap(P[i], P[j]);
      break;
    }
  }
  cout << (check() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Monad

chekans::Float -> Bool
chekans x = x - y  == 0.0
    where 
        y = fromIntegral $ truncate x

powm::Float->Float->Float
powm y z = (y-z) * (y-z)

dis::[[Float]] -> [Float]
dis xxs = [sqrt $ sum $ zipWith (powm) xs ys| xs<-xxs,ys<-xxs]

main:: IO ()
main = do
    [n,d] <- map read . words <$> getLine
    xs <- map (map read . words) <$> replicateM n getLine
    let dist = dis xs
    let ans = length $ filter (chekans) dist
    print (div (ans-n) 2)

Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    int a,b;cin>>a>>b;
    string ret = a+b==15?"+":"*";
    if(a+b!=15&&a*b!=15)ret="x";
    cout<<ret<<endl;
	return 0;
}



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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,m;
    ll ans=0;
    cin>>n>>m;
    vector<ll> x(n),y(n),z(n),v(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>x[i]>>y[i]>>z[i];
    }
    
    for(int bitcnt = 0; bitcnt < (1<<3); bitcnt++)
    {
        for(int i = 0; i < n; i++)
        {
            ll val=0;
            if((bitcnt & 1)==1) val+=x[i];
            else val -=x[i];

            if(((bitcnt>>1) & 1)==1) val+=y[i];
            else val -=y[i];

            if(((bitcnt>>2) & 1)==1) val+=z[i];
            else val -=z[i];

            v[i]=val;
        }
        sort(all(v));
        reverse(all(v));
        ll tmp=0;
        
        for(int i = 0; i < m; i++)
        {
            tmp+=v[i];
        }
        ans=max(ans,tmp);
    }
    
    cout<<ans<<endl;

    return 0;
}

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;
using P = pair<int,int>;

int main() {
	int n, p[100001], pos[100001];
	cin >> n;
	rep(i, n) cin >> p[i + 1];
	for(int i = 1; i <= n; i++) {
		pos[p[i]] = i;
	}
	set<ll> s{0, n+1};
	ll ans = 0;
	for(int i = n; i >= 1; i--) {
		int ps = pos[i];
		s.insert(ps);
		if (i == n) continue;
		auto it11 = s.find(ps), it21 = it11;
		if (it11 != s.begin()) it11--;
		auto it12 = it11;
		if (it12 != s.begin()) it12--;
		it21++;
		if (it21 == s.end()) it21--;
		auto it22 = it21;
		it22++;
		if (it22 == s.end()) it22--;
		ans += i * (*it11 - *it12) * (*it21 - ps);
		ans += i * (ps - *it11) * (*it22 - *it21);
	}
	cout << ans << endl;
}


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

int main()
{
		int N = 0;
		char S[100000] = {};
		int slime_count = 0;

		cin >> N;

		for (int i = 0; i < N; i++) {
			cin >> S[i];
		}

		S[N] = '#';
		char Now_slime;
		for (int i = 0; S[i] != '#'; i++) {
			if (S[i] != S[i + 1]) {
				slime_count++;
			}
		}
		

		cout << slime_count << endl;
		return 0;
	
}

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

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    int all = accumulate(T.begin(), T.end(), 0);
    int M;
    cin >> M;
    rep(i, M) {
        int P, X;
        cin >> P >> X;
        cout << all - T[P - 1] + X << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import random

D = int(input())
C = list(map(int, input().split()))  # (26,)
S = [list(map(int, input().split())) for _ in range(D)]  # (365, 26)


class Scorer:

    def __init__(self, c, s):
        self.n_cty = len(c)
        self.c = c  # (26,)
        self.s = s  # (365, 26)
        self.elapsed_time = [0] * self.n_cty

        self.score = 0

    def step(self, d, cty):
        elapsed_time = self.elapsed_time[:]

        for cty_ in range(self.n_cty):
            if cty_ == cty:
                elapsed_time[cty_] = 0
            else:
                elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in range(len(elapsed_time)):
            cur_score -= self.c[cty_] * elapsed_time[cty_]

        score = self.score + cur_score
        return score

    def update(self, d, cty):
        elapsed_time = self.elapsed_time[:]

        for cty_ in range(self.n_cty):
            if cty_ == cty:
                elapsed_time[cty_] = 0
            else:
                elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in range(len(elapsed_time)):
            cur_score -= self.c[cty_] * elapsed_time[cty_]

        score = self.score + cur_score

        # update
        self.elapsed_time = elapsed_time
        self.score = score

        return score


# greedy
T = []
scorer = Scorer(C, S)
for d in range(D):
    best_cty = -1
    best_score = -float('inf')
    for cty in range(26):
        cur_score = scorer.step(d, cty)
        if best_score < cur_score:
            best_cty = cty
            best_score = cur_score
    scorer.update(d, best_cty)
    T.append(best_cty)

N_REPLACE = 1
N_ITER = 100
EPS = 0.001
ATT = 1.00

best_score = scorer.score
for _ in range(N_ITER):
    scorer = Scorer(C, S)

    T_ = T[:]

    # replace N elements
    for i in range(N_REPLACE):
        T_[random.randint(0, D - 1)] = random.randint(0, 25)

    for d in range(D):
        cty = T_[d]
        scorer.update(d, cty)

    if best_score < scorer.score:
        best_score = scorer.score
        T = T_[:]
    elif random.random() < EPS:
        best_score = scorer.score
        T = T_[:]

    EPS *= ATT

for t in T:
    print(t + 1)



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

using namespace std;

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

int main(){
  int x,y; cin >> x >> y;

  bool a=(y%2==0);
  bool b=(x*4>=y);
  bool c=(x*2<=y);

  if(a && b && c){
    puts("Yes");
  }else{
    puts("No");
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i, n) for(auto i = 0*(n); i < (n); ++i)

bool data[10];

int main(){
  int K, N;
  cin >> K >> N;
  rep(i, N) {
    int a;
    cin >> a;
    data[a] = 1;
  }

  for(int i = K; ; ++i) {
    int x = i;
    bool f = false;
    while(x > 0) {
      if(data[x%10]) { f = true; break; }
      x /= 10;
    }
    if(!f) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <regex>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(n);
  long long nowx = 0, nowy = 0, nowt = 0;
  rep(i, n) {
    int in(t, x, y);
    int diff = t - nowt,
        dx = abs(nowx - x),
        dy = abs(nowy - y),
        d = dx + dy,
        result = diff - d;
    if(not (result >= 0 and not (result & 1))) {
      out("No") return 0;
    }
    nowt = t;
    nowx = x;
    nowy = y;
  }

  out("Yes");
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
t="D"
for i in range(0,n):
  if k==1 and i==0:
    if s[k-1]=="A":
      t="a"
    if s[k-1]=="B":
      t="b"
    if s[k-1]=="C":
      t="c"
    moji = t
    continue
  elif i==k-1:
    if s[k-1]=="A":
      t="a"
    if s[k-1]=="B":
      t="b"
    if s[k-1]=="C":
      t="c"
    moji += t
  elif i==0:
    moji=s[0]
    continue
  else:
    moji += s[i]
  
print(moji)

Measured memory_bytes: 3064
A = []

for _ in range(3):
  tmp = map(int, input().split())
  A += tmp

N = int(input())

b = []

for _ in range(N):
  b.append(int(input()))

Bingo=[]
  
for bb in b:
  if bb not in A:
    continue;
  Bingo.append(A.index(bb)+1)

if ((1 in Bingo) and (2 in Bingo) and (3 in Bingo)) or\
((4 in Bingo) and (5 in Bingo) and (6 in Bingo)) or\
((7 in Bingo) and (8 in Bingo) and (9 in Bingo)) or\
((1 in Bingo) and (4 in Bingo) and (7 in Bingo)) or\
((2 in Bingo) and (5 in Bingo) and (8 in Bingo)) or\
((3 in Bingo) and (6 in Bingo) and (9 in Bingo)) or\
((1 in Bingo) and (5 in Bingo) and (9 in Bingo)) or\
((3 in Bingo) and (5 in Bingo) and (7 in Bingo)):
  print("Yes")
else:
  print("No")

      

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)

int main()
{
        fast;
        int k;
        string s;
        cin>>k;
        cin>>s;
        if(s.length()<=k)
                cout<<s<<endl;
        else
        {
                cout<<s.substr(0,k)+"..."<<endl;
        }
}

Measured memory_bytes: 3632
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ld, ld> P;
typedef vector<ld> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll a;
    ld b;
    cin>>a>>b;
    cout<<(ll)(a*b+0.001)<<endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print(vvl &ans){
    cout << "Yes" << "\n";
    ll k = ans.size();
    cout << k << endl;
    rep(i,k) {
        cout << ans[i].size() << " ";
        for(auto j : ans[i])cout << j << " ";
        cout << "\n";
    }
}

int main(){
    ll n; cin >> n;
    vvl ans;
    
    if(n == 1) {
        ans = {{1}, {1}};
        print(ans);

        return 0;
    }
    ll rt = sqrt(n * 2);
    if(rt * (rt + 1) != n * 2){
        cout << "No" << endl;
        return 0;
    }

    ans = {{1,2}, {2,3}, {3,1}};
    ll cnt = 3;
    while(cnt < n){
        ll ps = cnt + 1;
        vector<ll> add;
        rep(i,ans.size()) {
            ans[i].emplace_back(ps);
            add.emplace_back(ps);
            ps++;
        }
        ans.emplace_back(add);
        cnt = ps-1;
    }

    print(ans);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n";
typedef long long ll;
typedef unsigned long long ull;   
const int N = 2*1e5+10;

ll x;
ll n,k;
int arr[N];
string s,t;

int main()
{
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    cin>>n;
    cin>>s>>t;
    string ans ="";
    for(int i=0;i<n;i++)
    {
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans<<endl;
    

    return 0;
}

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

#define ll long long
int a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		cout<<"Possible";
	else
		cout<<"Impossible";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<iostream>
using namespace std;

struct point{
	double x,y;
};

double tri(point p,point q){
	return (p.x*q.y-p.y*q.x);
}

int main(){
	point *p;
	double ans;
	int i,j=1,n;
	while(cin>>n){
		if(n==0) break;
		p=new point[n+1];
		for(i=0;i<n;i++) cin>>p[i].x>>p[i].y;
		p[n]=p[0];
		ans=0;
		for(i=0;i<n;i++) ans+=tri(p[i],p[i+1]);
		printf("%d %.1f\n",j++,fabs(ans/2));
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (1<=a<=100 && 1<=b<=100 && 1<=c<=100) {
    if (a+b==c || b+c==a || a+c==b){
      printf("Yes");
    } else{
      printf("No");
    }
  } else {
    printf("Invalid!");
  }
  return 0;
}

Measured memory_bytes: 1696
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    j = max(0, i - 1)
    k = min(n - 1, i + 1)
    b = a[j:k+1]
    b.sort()
    ans += b[1] == a[i]

print(ans)


Measured memory_bytes: 38384
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

s=input().strip()

yes=0
for i in range(7):
    if s[:i]+s[-7+i:]=="keyence":
        yes=1
    #print(i,s[:i]+s[-7+i:])
if s[:7]=="keyence":    # this case is not considered in the loop
    yes=1

print("YES" if yes else "NO")


Measured memory_bytes: 3064
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "abc165_c.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, q;
  cin >> n >> m >> q;
  m++;
  vi a(q), b(q), c(q), d(q);
  REP(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  int ans = 0;
  FOR(i0, 1, m) {
    FOR(i1, i0, m) {
      FOR(i2, i1, m) {
        FOR(i3, i2, m) {
          FOR(i4, i3, m) {
            FOR(i5, i4, m) {
              FOR(i6, i5, m) {
                FOR(i7, i6, m) {
                  FOR(i8, i7, m) {
                    FOR(i9, i8, m) {
                      int val[10] = {i0, i1, i2, i3, i4, i5, i6, i7, i8, i9};
                      vi now(n);
                      REP(i, n) { now[i] = val[i]; }
                      int tmp = 0;
                      REP(i, q) {
                        if (now[b[i]] - now[a[i]] == c[i])
                          tmp += d[i];
                      }
                      chmax(ans, tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	if(s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0]) cout << "YES";
	else cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    char s[64];
    int n = 0,i,l;
    scanf("%s",s);
    l = strlen(s);
    for(i = 0;i <= l - 2;i++){
        if(s[i] != s[i + 1]){
            n++;
        }
    }
    if(s[0] == s[l - 1] && s[l - 1] == 'o'){
        n++;
    }
    n--;
    if(n % 2){
        printf("x\n");
    }
    else{
        printf("o\n");
    }
    return 0;
}

Measured memory_bytes: 524
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
string s;
set<string>se;
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin.tie(NULL);
    cout.tie(NULL);
    int cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(se.count(s)==0){
            cnt++;
            se.insert(s);
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 19244
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin>>N>>K;
    K++;
    bitset<40> bs(K);
    bitset<40> bs_a[101010];
    rep(i,0,N){
        cin>>a[i];
        bs_a[i] = bitset<40>(a[i]);
    }
    ll num[40][2];
    rep(i,0,40){
        rep(j,0,2){
            ll count=0;
            rep(k,0,N){
                if(bs_a[k][i]==j){
                    count++;
                }
            }
            num[i][j]=count*pow(2,i);
        }
    }
    ll tmp1=0;
    ans = 0;
    urep(i,39,0){
        if(bs[i]==1){
            ll tmp2 = tmp1;
            tmp2+=num[i][1];
            rep(j,0,i){
                tmp2+=max(num[j][0],num[j][1]);
            }
            ans = max(ans,tmp2);
        }
        tmp1 += num[i][!bs[i]];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>

int main(){
  int a, b, k;
  std::cin >> a >> b >> k;
  
  int cnt = 0;
  int i;

  for(i = 100; i != 1; --i){
    if (a % i == 0 && b % i == 0)
      cnt++;
    if(cnt == k)
      break;
  }
  
  std::cout << i << std::endl;

  int x;
  std::cin >> x;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
ll read()
{
    char s;
    ll k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
} 
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
int a,b,px,py; 
int n,m;
char c[110][110];
int main()
{
	a=read();b=read();
	for (int i=1;i<=100;i+=2)
		for (int j=1;j<=100;j+=2)
		{
			c[i][j]='#';
			b--;
			if (b==0) 
			{
				px=i;py=j;
				break;
			}
		}
	a--;
	if (py!=1&&px==1) a--;
	if (a<0)
	{
		for (int i=1;i<=2;i++)
		for (int j=py;j<=100;j++)
		c[i][j]='#';
	}
	px++;c[px][py]='#';
	px++;c[px][py]='#';
	for (int i=1;i<=100;i++) c[px][i]='#';
	for (int i=1;i<=px;i++)
		for (int j=1;j<=100;j++)
		{
			if (c[i][j]!='#')
			{
				c[i][j]='.';
			}
		}
//	cout<<a<<" ";
	
	for (int i=100;i>=1;i-=2)
		for (int j=1;j<=100;j+=2)
		{
			if (a<=0) break;
			c[i][j]='.';
			a--;
			if (a==0) 
			{
				break;
			}
		}
	for (int i=px;i<=100;i++)
		for (int j=1;j<=100;j++)
		{
			if (c[i][j]!='.')
			{
				c[i][j]='#';
			}
		}
	printf("100 100\n");
	for (int i=1;i<=100;i++,printf("\n"))
		for (int j=1;j<=100;j++)
		{
			printf("%c",c[i][j]);
		}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int fx(int x){
  if (x < 10) return x;
  else return fx(x/10)+x%10;  
}

int main() 
{
    int N;
    cin >> N;
    int S;
 
    S = fx(N);
  
    if (N%S==0) cout << "Yes "  << endl; 
    else cout << "No "  << endl;
  return 0;
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringx(o)if type(o) == 'table' then local keys = {}for k in pairs(o) do table.insert(keys, k) end table.sort(keys)local inside = {}for i=1,#keys do local k = keys[i]local v = o[k]if type(k) == 'string' then k = string.format('%q', k)end table.insert(inside, '['..k..'] = ' .. tostringx(v))end return '{' .. table.concat(inside, ', ') .. '}'else if type(o) == 'string' then o = string.format('%q', o)end return tostring(o)end end
----
local N, K = read.nn()
local A = read.N(N)
table.sort(A)
local amin = A[1]
local tbl = {}
local rev = {['😞']='🏆', ['🏆']='😞'}
for i=0,amin-1 do
    tbl[i] = '😞'
end
for i=0,K-1 do
    if tbl[i] == '😞' then
        for _,a in ipairs(A) do
            tbl[i+a] = '🏆'
        end
    else
        for _,a in ipairs(A) do
            if tbl[i+a] == nil then
                tbl[i+a] = '😞'
            end
        end
    end
end
--print(tostringx(tbl))
if tbl[K]=='🏆' then
    print('First')
elseif tbl[K]=='😞' then
    print('Second')
else
    error()
end

Measured memory_bytes: 4580
require 'date'

while line = gets
  y1, m1, d1, y2, m2, d2 = line.chomp.split.map(&:to_i)
  break if y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0
  date1, date2 = Date.new(y1, m1, d1), Date.new(y2, m2, d2)
  puts (date2 - date1).to_i
end

Measured memory_bytes: 8880
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskC solver = new TaskC();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskC {    
    final String[] list = { "dreamereraser", "dreamererase", "dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase" };
    String s;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      s = in.next();
      int ptr = 0, n = s.length();
      while (ptr < n) {
        int oldptr = ptr;
        for (String i : list)
          if (ptr + i.length() <= n && s.substring(ptr, ptr + i.length()).equals(i)) {
            ptr += i.length();
            break;
          }
        if (ptr == oldptr)
          break;
      }
      out.println(ptr == n ? "YES" : "NO");
    }
    
    int i(long x) {
      return (int) x;
    }
    
    <T> void heapSort(T[] a, int s, int e) {
      Queue<T> queue = new PriorityQueue<>();
      for (int i = s; i <= e; ++i)
        queue.add(a[i]);
      for (int i = s; i <= e; ++i)
        a[i] = queue.poll();
    }    
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

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

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

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  ll count = n * (n-1) / 2;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}

int main(void) {
	double n; cin >> n;
	for (int i=0;i<100;i++) {
		if ((int)(n * 100) % 108 == 0) {
			cout << (int)(n*100/108) << endl;
			return 0;
		}	
		n += 0.01;
	}
	cout << ":(" << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> c;
    c.resize(9);
    rep(i, n)
    {
        if (a[i] <= 399)
            c[0] = 1;
        else if (a[i] <= 799)
            c[1] = 1;
        else if (a[i] <= 1199)
            c[2] = 1;
        else if (a[i] <= 1599)
            c[3] = 1;
        else if (a[i] <= 1999)
            c[4] = 1;
        else if (a[i] <= 2399)
            c[5] = 1;
        else if (a[i] <= 2799)
            c[6] = 1;
        else if (a[i] <= 3199)
            c[7] = 1;
        else
            c[8]++;
    }
    int min = 0;
    rep(i, 8)
    {
        if (c[i] == 1)
            min++;
    }
    if (min == 0)
        cout << 1 << " " << c[8] << endl;
    else
        cout << min << " " << min + c[8] << endl;
    return 0;
}


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


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int pre = 0;
		String in = sc.next();
		StringBuffer sb = new StringBuffer(in);
		boolean end = false;
		while(!end) {
			end = true;
			for(int i = pre; i < sb.length()-1; i++) {
				if(i + 3 < sb.length() && sb.charAt(i) == 'S' && sb.charAt(i + 1) == 'S' && sb.charAt(i + 2) == 'T' && sb.charAt(i + 3) == 'T') {
					sb = sb.delete(i, i + 4);
					pre = Math.max(i - 1,0);
					end = false;
					break;
				}
				if(sb.charAt(i) == 'S' && sb.charAt(i + 1) == 'T') {
					sb = sb.delete(i, i + 2);
					pre = Math.max(i - 1,0);
					end = false;
					break;
				}
			}
		}
		System.out.println(sb.toString().length());
	}
}

Measured memory_bytes: 15208
n,m = map(int, input().split())
a = list(map(int, input().split()))
summ = 0
ans = 0
for i in range(n):
    summ += a[i]
summ = summ / (4*m)

for i in range(n):
    if a[i] >= summ:
        ans += 1

if ans >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
mod = 10**9 + 7

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

a = 0
b = 0

for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            a += 1
        elif A[i] < A[j]:
            b += 1

ans = a*K*(K+1)//2 + b*(K-1)*K//2
ans %= mod
print(ans)

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

int main() {
    int64_t X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int64_t> p(A), q(B), r(C);
    for (int64_t& P : p) {
        cin >> P;
    }
    for (int64_t& Q : q) {
        cin >> Q;
    }
    for (int64_t& R : r) {
        cin >> R;
    }

    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq_red, pq_green;
    for (int64_t P : p) {
        if (pq_red.size() < X) {
            pq_red.push(P);
        } else {
            int64_t top = pq_red.top();
            pq_red.pop();
            pq_red.push(max(top, P));
        }
    }
    for (int64_t Q : q) {
        if (pq_green.size() < Y) {
            pq_green.push(Q);
        } else {
            int64_t top = pq_green.top();
            pq_green.pop();
            pq_green.push(max(top, Q));
        }
    }

    sort(r.begin(), r.end());
    for (int64_t R : r) {
        int64_t red_min = pq_red.top();
        int64_t green_min = pq_green.top();
        auto& pq_change = (red_min <= green_min ? pq_red : pq_green);

        int64_t curr_min = pq_change.top();
        pq_change.pop();
        pq_change.push(max(curr_min, R));
    }

    int64_t ans = 0;
    while (!pq_red.empty()) {
        ans += pq_red.top();
        pq_red.pop();
    }
    while (!pq_green.empty()) {
        ans += pq_green.top();
        pq_green.pop();
    }
    cout << ans << endl;
}

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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
using namespace std;
int mod = 1'000'000'000 + 7;

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

string S;
int l;

ll solve(int x = 0) {
    if (x >= l) return 0;
    ll res = stoll(S.substr(x));
    for (int i = x + 1; i < l; i++) {
        res += stoll(S.substr(x, i - x)) * pow(2, l - i - 1);
        res += solve(i);
    }
    return res;
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    cin >> S;
    l = S.length();
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> mo(N);
  for(int i=0;i<N;i++){
    cin>>mo.at(i);
  }
  for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    if(mo.at(i)==mo.at(j)&&mo.at(i)!=0&&i!=j){
      mo.at(j)=0;
    }
  }
  }
  int sum=0;
  for(int i=0;i<N;i++){
    if(mo.at(i)!=0){
      sum++;
    }
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

l=0
r=1
t=a[0]
ans=0

while l<n:
  if r==n:
    ans+=r-l
    l+=1
    continue
  if t+a[r]==t^a[r]:
    t+=a[r]
    r+=1
  else:
    ans+=r-l
    t-=a[l]
    l+=1
print(ans)


Measured memory_bytes: 24424
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    std::vector<ll> v(n);
    map<ll,ll> m;
    for(auto &x:v) {
    	cin>>x;
    	m[x]++;
    }
    ll ans = 0;
    for(auto x:m) {
    	ans += (x.se*x.se) - x.se;
    }
    ans /= 2;
    for(auto x:v) {
    	cout<<ans-(m[x]-1)<<endl;;
    }
    return 0;
}


Measured memory_bytes: 11136
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

ans = 0

for i, pe in enumerate(permutations(range(1, N + 1))):
    if P == pe:
        ans += i
    if Q == pe:
        ans -= i

print(abs(ans))


Measured memory_bytes: 3064
numbers = input()
numbers = numbers.split(" ")

W = int(numbers[0])
H = int(numbers[1])
x = int(numbers[2])
y = int(numbers[3])
r = int(numbers[4])

if (r <= x <= W - r) and (r <= y <= H - r):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7628
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long llint;

int a, b, c, d, n;

int main() {
	scanf("%d%d%d%d", &a, &b, &c, &d);
	scanf("%d", &n);
	a *= 4;
	b *= 2;
	int t = n & 1;
	llint sol = t * min(a, min(b, c));
	n -= t;
	a *= 2;
	b *= 2;
	c *= 2;
	sol += (llint)n/2 * min(min(a, b), min(c, d));
	printf("%lld\n", sol);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,c,j,ans=1111;
  cin>>n>>t;
  for(int i=0;i<n;i++){
    cin>>c>>j;
    if(j<=t) ans=min(ans,c);
  }
  if(ans==1111) cout<<"TLE"<<endl;
  else cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;

  FOR(i, 1, 4) {
    if(i != a && i != b) {
      cout << i << endl;
    }
  }
}


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

string S;
size_t cur;

int digit(){
	int n=S[cur++]-'0';
	return n;
}

int number(){
	int n=digit();
	while(isdigit(S[cur]))
		n=n*10+digit();
	return n;
}


int expression(){
	vector<int> list;
	int ans=0;
	while(S[cur]!=']'){
		if(S[cur]=='[')
			cur++,list.push_back(expression());
		else if(isdigit(S[cur]))
			list.push_back(number());
		else if(cur==S.size())
			return list[0];
	}
	if(S[cur]==']'){
		cur++;
		sort(list.begin(),list.end());
		if(list.size()==1){
			ans+=(list[0]/2+1);
		}else{
			int n=(list.size()/2+1);
			for(int i=0;i<n;i++)
				ans+=list[i];
		}
	}
	return ans;
}
int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> S;
		cur=0;
		int ans=expression();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
from math import factorial
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def nCr(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def nPr(n,r):
    if not (0 <= r <= n):
        return 0
    return nCr(n, r) * g1[r] % mod


N,M=map(int,input().split())
ans=nPr(M,N)**2%mod
for i in range(1,N+1):
    p=nPr(M-i,N-i)**2%mod
    p=p*nPr(N,i)%mod
    p=p*nCr(M,i)%mod
    ans-=((-1) ** ((i % 2) ^ 1))*p
    ans%=mod
print(ans%mod)

Measured memory_bytes: 213196