akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	set<ll> st;
	for(int i = 0; i < N; ++i) {
		int t; cin >> t;
		st.insert(t);
	}
	YN(st.size()==N);


    return 0;
}


Measured memory_bytes: 9600
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}

void main() {
	auto r1 = readInts();
	r1[2..$] -= 1;
	int n = r1[0];
	int m = r1[1];
	int s = r1[2];
	auto g = r1[3..$];
	while(n) {
		auto d = new int[][](101,101);
		foreach(di; d){
			di.fill(int.max/1000);
		}
		foreach(i; 0..n) {
			d[i][i] = 0;
		}
		foreach(i; 0..m) {
			auto r2 = readInts();
			r2[0..2] -= 1;
			d[r2[0]][r2[1]] = r2[2];
		}
		foreach(k; 0..n) {
			foreach(i; 0..n) {
				foreach(j; 0..n) {
					d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
				}
			}
		}
		int ans = int.max;
		foreach(i; 0..n) {
			ans = min(ans, d[s][i] + d[i][g[0]] + d[i][g[1]]);
		}
		writeln(ans);
		r1 = readInts();
		r1[2..$] -= 1;
		n = r1[0];
		m = r1[1];
		s = r1[2];
		g = r1[3..$];
	}
}

Measured memory_bytes: 2044
#include<stdio.h>

void trace(int A[], int N){
    for(int i = 0; i < N; i++){
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");

}

int selectionSort(int A[], int N){
    int count = 0;

    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            int tmp = A[i];
            A[i]= A[minj];
            A[minj] = tmp;
            count++;
        }
    }
    return count;

}

int main(){
    int A[100];
    int N;

    scanf("%d", &N);
    for(int i = 0; i < N; i++)scanf("%d",&A[i]);

    int count = selectionSort(A,N);
    trace(A, N);

    printf("%d\n", count);

}

Measured memory_bytes: 2728
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    }
    
    public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    }
}

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

#define M 1000000
#define L 14

char H[M][L];

int getChar(char ch){
  if (ch == 'A')return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
}
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
       else if(strlen(H[h]) == 0) return 0;
  }
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if( strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 14280
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

use std::cmp::Reverse;
const INF: usize = std::usize::MAX;

#[fastout]
fn main() {
   input! {
      mut h: usize,
      mut w: usize,
      k: usize,
      s: (usize, usize),
      g: (usize, usize),
      mut c: [Bytes; h],
   }
   for i in 0..h {
      c[i].insert(0, b'@');
      c[i].push(b'@');
   }
   w += 2;
   c.insert(0, vec![b'@'; w]);
   c.push(vec![b'@'; w]);
   h += 2;

   let mut d = vec![vec![INF; w]; h];
   let mut q = std::collections::BinaryHeap::new();
   d[s.0][s.1] = 0;
   q.push((Reverse(0), 0, s));
   q.push((Reverse(0), 1, s));
   while let Some((Reverse(dn), a, pos)) = q.pop() {
      if dn > d[pos.0][pos.1] {
         continue;
      }
      for &(dx, dy) in if a == 0 {
         [(1, 0), (!0, 0)].iter()
      } else {
         [(0, 1), (0, !0)].iter()
      } {
         let (mut x, mut y) = pos;
         for i in 0.. {
            let dn = dn + 1 + i / k;
            x += dx;
            y += dy;
            if c[x][y] == b'@' {
               break;
            }
            if d[x][y] > dn {
               d[x][y] = dn;
               q.push((Reverse(dn), 1 - a, (x, y)));
            }
            if d[x][y] < dn {
               break;
            }
         }
      }
   }

   let ans = d[g.0][g.1];
   if ans == INF {
      println!("-1");
   } else {
      println!("{}", ans);
   }
}


Measured memory_bytes: 48080
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, i;
    cin>>n;
    set <string> s;
    for(i=0; i<n; i++)
    {
        string a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;



    return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL n;
    cin>>n;
    LL a[n];
    for(LL i=0;i<n;i++)
        cin>>a[i];
        LL f=0;
    for(LL i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1]and a[i]-a[i+1]>1)f=1;
         else if(a[i]>a[i+1]) a[i+1]++;
    }
    if(f)cout<<"No";
    else cout<<"Yes";

}


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

int main() {
    int h, w;
    cin >> h >> w;
    string str[27][27];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> str[i][j];
        }
    }

    string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";  

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(str[i][j] == "snuke") {
                cout << al[j] << i + 1 << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

int main()
{
  int a, s, d, f;
  cin >> a >> s >> d >> f;
  if(a<=s){
    cout << a * d << endl;
  }
  else{
    cout << s * d + (a - s) * f << endl;
  }

}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<int> a(m);
    ll sum = 0;
    rep(i,m){
        int t;cin>>t;
        a[i] = t;
        sum += t;
    }
    ll ans = 0;
    if(sum > n) ans = -1;
    else ans = n- sum;
    cout<<ans<<endl;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);

const int MAXN = 3000 + 5;

string s, t, ans;
int dp[MAXN][MAXN], from[MAXN][MAXN];

void get(int x, int y) {
    if (x == 0 || y == 0) {
        return;
    }

    switch (from[x][y])
    {
    case 1:
        ans += s[x - 1];
        get(x - 1, y - 1);
        break;

    case 2:
        get(x - 1, y);
        break;

    case 3:
        get(x, y - 1);
        break;
    
    default:
        break;
    }
}

int main() {
    IOS

    cin >> s >> t;

    int n = s.length(), m = t.length();
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                from[i][j] = 1;
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                    from[i][j] = 2;
                } else {
                    dp[i][j] = dp[i][j - 1];
                    from[i][j] = 3;
                }
                //dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    get(n, m);

    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i];
    }
    cout << '\n';
}

Measured memory_bytes: 74044
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}
//A 3min
//B 25min
string ans;

void solve(void){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i,0,n){
        cin >> s[i];
    }
    /*
   
    rep(i,0,n-1){
        rep(j,0,n-1){
            ll tmpj = 0,tmpjn = 0;
            bool flag = false;

            rep(k,0,l){
                if(s[j+1][k]< s[j][k]){flag = true;break;}
            }

            if(flag){
                string tmp;
                tmp = s[j+1];
                s[j+1] = s[j];
                s[j] = tmp;
            }

        }
        rep(p,0,n) cout << s[p]<<" ";
        cout << endl;
       
    }
    */
   sort(s.begin(),s.end());
    rep(i,0,n){
        ans+=s[i]; 
    }
    cout << ans <<endl;
}


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

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	
	int a,b;
	char str[15];
	
	scanf("%d %d %s" , &a, &b, &str);
	
	for(int i = 0 ; i < a ; i++){
		if(str[i] != '-'){
			continue;
		}
		else{
			printf("No");
			return 0;
		}	
	}
	for(int i = a+1 ; i <= a+b ; i++){
		if(str[i] != '-'){
			continue;
		}
		else{
			printf("No");
			return 0;
		}
		
	}
	if(str[a] == '-'){
		
		printf("Yes");
	}
	else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
using namespace std;
#define V 10
#define INF (1<<30)-1
struct edge{int from,to,cost;};
int main(){
  int d[V];
  int n;
  while(cin>>n){
    if(n==0) break;
    edge es[2*n];
    int a,b,c;
    int ans = INF,ansi;
    for(int i=0;i<2*n;i+=2){
      cin >> a >> b >> c;
      es[i].from = es[i+1].to = a;
      es[i+1].from = es[i].to = b;
      es[i].cost = es[i+1].cost = c;
    }
    for(int j=0;j<V;j++){
      for(int i=0;i<V;i++) d[i] = INF; 
      d[j] = 0;
      while(true){
	bool updata = false;
	for(int i=0;i<2*n;i++){
	  edge e = es[i];
	  if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
	    d[e.to] = d[e.from] + e.cost;
	    updata = true;
	  }
	}
	if(!updata) break;
      }    
      int s = 0;
      for(int i=0;i<V;i++){
	if(d[i]!=INF){
	  s += d[i];
	}
      }
      if(s<ans&&s!=0){ans = s,ansi =j;};
    }
    cout << ansi << ' ' << ans << endl;
  }
  return 0;
}
 

Measured memory_bytes: 1160
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int a[100005];
Int coR[100005];
Int coL[100005];

int main(){
    cin.tie(0);

    Int N; cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++){
        if (i == 0 || i == N-1) coR[i] = coL[i] = 1;
        else coR[i] = coL[i] = 2;
        
        if (i%2) coL[i] *= -1;
        else coR[i] *= -1;
    }
    sort(coR, coR+N);
    sort(coL, coL+N);
    sort(a, a+N);

    Int ans1 = 0;
    Int ans2 = 0;
    for (int i = 0; i < N; i++){
        ans1 += coR[i]*a[i];
        ans2 += coL[i]*a[i];
    }
    cout << max(ans1, ans2) << endl;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	read(n)
	if(n%10==3) cout<<"bon"<<endl;
	else {
		int dig = n%10;
		if(dig==0 || dig==1 || dig==6 || dig==8) cout<<"pon"<<endl;
		else cout<<"hon"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007


int main() {
	ll M, N, s[110000], ans;
	vector<ll> a;
	cin >> M >> N;
	for (int i = 0; i < N; i++)cin >> s[i];
	sort(s, s + N);
	ans = s[N - 1] - s[0];
	for (int i = 0; i < N - 1; i++) {
		a.push_back(abs(s[i] - s[i + 1]));
	}
	sort(ALL(a), greater<ll>());
	for (int i = 0; i < min(M - 1,N - 1); i++) {
		ans -= a[i];
	}
	cout << ans << endl;
}


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) {
        cout << "No" << endl;
        return 0;
    }
    if (4 * a * b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
mini = min(a, b, c)
new_list = [ a - mini, b - mini, c - mini]
new_list2 = sorted(new_list)
ans2 = 0

maxi = max(new_list)
mid = new_list2[1]

if mid %2 == 0:
   ans2 = mid / 2
else:
   ans2 = ((mid - 1) / 2) + 2

print(int(ans2 + maxi - mid))

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


int main(){
  int num;
  string ch;
  cin >> num;
  cin >> ch;

  if (num >=3200){
    cout << ch << endl;
  }else if (num < 3200){
    cout << "red" << endl;
  }
}

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

int main(void){
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else if(s[k-1]=='C'){
    s[k-1]='c';
  }


  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();
    
        boolean result = (S*T >= D);

        if (result) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
    private static boolean ableToMove(int t_old, int x_old, int y_old, int t_new, int x_new, int y_new) {
        int x_distance = (x_old > x_new) ? (x_old - x_new) : (x_new - x_old);
        int y_distance = (y_old > y_new) ? (y_old - y_new) : (y_new - y_old);
        int distance = x_distance + y_distance;

        int lapse = t_new - t_old;
        if (distance > lapse) {
            return false;
        }
        if ((lapse - distance) % 2 != 0) {
            return false;
        }
        return true;
    }
}


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

signed main(){
  int N;
  cin>>N;
  if(N==1)cout<<0<<endl;
  else cout<<1<<endl;
  return 0;
}

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

al = []
for at in a:
    bin_str = bin(at)
    if bin_str.rfind('0')+1 == len(bin_str):
        al.append(bin_str.rfind('0')-bin_str.rfind('1'))
    else:
        al.append(0)

print(sum(al))


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int count = 0;
  cin >> N;
  
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    count += r - l + 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX=210000;
const long long MOD=1000000007;

typedef long long ll;

ll fac[MAX],finv[MAX],inv[MAX];

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

void com_init(){ //初期化
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        //inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        //finv[i]=finv[i-1]*inv[i]%MOD;
        finv[i]=finv[i-1]*mod_pow(i,MOD-2)%MOD;//フェルマーの小定理より
    }
}

ll comb(ll n, ll k){ //nCk
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    int N,K; cin >> N >> K;
    ll a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N);
    com_init();
    ll ans=0;
    for(int i=N-1;i>=1;i--){
        if(i>=K-1){
            ans+=(comb(i,K-1)*a[i])%MOD;
        }
        ans%=MOD;
    }
    for(int i=0;i<N-1;i++){
        if(N-1-i>=K-1){
            ans=(ans+MOD-(comb(N-1-i,K-1)*a[i])%MOD)%MOD;
        }
    }
    cout << ans%MOD << endl;
}


Measured memory_bytes: 4352
import collections

n = int(input())
a = list(map(int, input().split()))

l = [None] * n * 3
for i in range(n):
    l[i] = a[i]
    l[n+i] = a[i]-1
    l[2*n+i] = a[i]+1
    
c = collections.Counter(l)
    
print(c.most_common()[0][1])

Measured memory_bytes: 30900
n = gets.to_i
pys = []
n.times do
  pys << gets.split.map(&:to_i)
end

sorting = pys.sort

i = 0
maxp = pys.max

while i < n
	if maxp == pys[i]
		puts sorting[-2]
	else
		puts maxp
	end
	i += 1
end

Measured memory_bytes: 20712
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    long[] as;
    foreach (_; 0..N) as ~= readln.chomp.to!long;

    long min_p = 1;
    long r;
    foreach (a; as) {
        if (min_p == a) {
            min_p += 1;
            continue;
        }
        auto x = a / min_p;
        if (x == 0) continue;
        if (a%min_p == 0) {
            r += x-1;
            if (min_p == 1) min_p = 2;
        } else {
            r += x;
        }
    }
    writeln(r);
}

Measured memory_bytes: 4092
import java.util.HashSet;
import java.util.Scanner;

public class Main 
{
	static class Edge
	{
		Node n;
		boolean odddis = false;
		
		public Edge(Node n, boolean odd)
		{
			odddis = odd;
			this.n = n;
		}
	}
	
	static class Node
	{
		int id;
		HashSet<Edge> e = new HashSet<>();
		
		public Node(int i)
		{
			id=i;
		}
	}
	
	static void trav(int pos, boolean odd)
	{
		oddnode[pos] = odd;
		Node n = nd[pos];
		vis[pos]=true;
		
		for(Edge e : n.e)
		{
			if(!vis[e.n.id])
			{
				trav(e.n.id, odd^e.odddis);
			}
		}
	}
	
	static boolean[] vis;
	static boolean[] oddnode;
	
	static Node[] nd;
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		nd = new Node[n];
		vis = new boolean[n];
		oddnode = new boolean[n];
		for(int i =0; i<n;i++)
			nd[i] = new Node(i);
		
		for(int i = 0; i < n-1; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			long w = sc.nextLong();
			nd[a].e.add(new Edge(nd[b], w%2==1));
			nd[b].e.add(new Edge(nd[a], w%2==1));
		}
		
		trav(0,false);
		
		for(int i = 0; i < n; i++)
		{
			if(oddnode[i])System.out.println(1);
			else System.out.println(0);
		}
	}

}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows:
 
 
  c
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)


int main()
{
        io;
        //////////////////////////////////
        cs1{
            ll n,x,t;
            cin>>n>>x>>t;
            ll p=n/x;
            ll ans=t*p;
            if(n%x!=0) ans=ans+t;
            cout<< ans nl;
        }
        //////////////////////////////////
       
}

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

typedef pair<int, int> PII;

const int MAX_N = 110;
const int MAX_H = 25;
const int INF = 1e9;

struct edge{
  int to, cost, hour, r;
  edge(int to, int cost, int hour, int r):
    to(to), cost(cost), hour(hour), r(r){}
};

struct State{
  int v, hour, cost;
  State(int v, int hour, int cost):
    v(v), hour(hour), cost(cost){}
};

int N, M, H, K;
vector<edge> G[MAX_N];
vector<PII> V;
int S, T, P;
int money[(1<<8)];
int dp[MAX_H][MAX_N];

void init(){
  for(int i = 0 ; i < MAX_N ; i++) G[i].clear();
  V.clear();
  fill(money, money+(1<<8), INF);
}

int solve(int bit){
  for(int i = 0 ; i < MAX_H ; i++)
    for(int j = 0 ; j < MAX_N ; j++) dp[i][j] = INF;

  queue<State> que;
  que.push(State(S, 0, 0));  
  
  dp[0][S] = 0;
  
  int res = INF;
  
  while(!que.empty()){
    State q = que.front(); que.pop();
    
    if(res < q.cost) continue;
    
    if(q.v == T){
      res = min(res, q.cost);
    }
    
    int v = q.v;
    for(int i = 0 ; i < (int)G[v].size() ; i++){

      int r = G[v][i].r;
      int nexv = G[v][i].to;
      int nexh = q.hour + G[v][i].hour;      
      int nexc;
      
      nexc = q.cost + G[v][i].cost;
      if((bit>>r) & 1) nexc = q.cost;
      
      if(nexh > H) continue;
      
      if(dp[nexh][nexv] > nexc){     
	dp[nexh][nexv] = nexc;
	
	que.push(State(nexv, nexh, nexc));
      }
    }    
  }
  return res;
}

void rec(int bit, int cost){
  if(money[bit] <= cost) return;
  money[bit] = cost;
  for(int i = 0 ; i < (int)V.size() ; i++){
    int t = bit | V[i].first;
    if(t == bit) continue;
    rec(t, cost + V[i].second);
  }
}

int main(){
  while(cin >> N >> M >> H >> K, N|M|H|K){
    init();
    
    int from, to, cost, hour, r;
    for(int i = 0 ; i < M ; i++){
      cin >> from >> to >> cost >> hour >> r;
      from--, to--, r--;
      G[from].push_back(edge(to, cost, hour, r));
      G[to].push_back(edge(from, cost, hour, r));
    }
    
    cin >> S >> T;
    S--, T--;
    cin >> P;
    
    for(int i = 0 ; i < P ; i++){
      int l, d;
      cin >> l >> d;
      int k;
      int bit = 0;
      for(int j = 0 ; j < l ; j++){
	cin >> k;
	k--;
	bit += (1<<k);
      }      
      V.push_back(PII(bit, d));
    }
    
    rec(0, 0);
    
    int ans = INF;
    for(int i = 0 ; i < (1<<K) ; i++){
      ans = min(ans, solve(i) + money[i]);
    }
    
    cout << (ans == INF ? -1 : ans) << endl;
  }
  
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> a(5);
	rep(i, 5) cin >> a[i];
	ll res = 1e16;
	rep(i, 5) res = min(res, a[i]);
	ll ans1 = (n-1) / res;
	if (n == res) ans1 = 0;
	//cout << res << endl;//
	cout << 5 + ans1 << endl;
}

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

using namespace std;

int main()
{
    int n, m;
    string s[128], t[128];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    cin >> m;
    for (int j = 0; j < m; j++) cin >> t[j];

    int coins, max_coins = 0;
    for (int i = 0; i < n; i++) {
        coins = 0;
        for (int j = 0; j < n; j++) {
            if (s[i] == s[j]) coins++;
        }
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) coins--;
        }
        max_coins = max(coins, max_coins);
    }

    cout << max_coins << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n ,total;
  while( true ){
    cin >> total;
    if( total == 0 ){
      break;
    }
    for( int i=0 ; i<9 ; i++ ){
      cin >> n;
      total -= n;
    }
    cout << total << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;

  string s;
  set<string> ms;
  rep(i,n){
    cin >> s;
    ms.insert(s);
  }
  cout << ms.size() << endl;

  return 0;
    

}


Measured memory_bytes: 19292
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
if N == 1:
    print(0)
    sys.exit()
    
a = pow(10,N,MOD)
b = pow(9,N,MOD)
c = pow(8,N,MOD)

ans = ((a-b)*2%MOD - (a-c)%MOD) % MOD

print(ans)

Measured memory_bytes: 61632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int h[n];
    rep(i, n) {
        cin >> h[i];
    }

    vector<int> dp(n+1);

    dp[2] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++) {
        dp[i+1] = min( dp[i] + abs(h[i-1] - h[i]), dp[i-1] + abs(h[i-2] - h[i]) );
    }

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

Measured memory_bytes: 1024
def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)
a,b,c,d = map(int, input().split())
import math
res = b - a + 1
#print(res)
res -= b // c - (a-1) // c
#print("!" + str(math.ceil(b / c) - math.ceil(a / c)))
#print(res)
res -= b // d - (a-1) // d
#print("!" + str(math.ceil(b / d) - math.ceil(a // d)))
#print(res)
res += b // lcm(c, d) - (a-1) // lcm(c,d)
#print("!" + str(math.ceil(b / lcm(c, d)) - math.ceil(a / lcm(c,d))))
print(res)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;cin>>s;
  bool is_possible=true;
  ll pos=s.length();
  while(pos>0) {
    if     (pos-5>=0&&s.substr(pos-5,5)=="dream") pos-=5;
    else if(pos-5>=0&&s.substr(pos-5,5)=="erase") pos-=5;
    else if(pos-7>=0&&s.substr(pos-7,7)=="dreamer") pos-=7;
    else if(pos-6>=0&&s.substr(pos-6,6)=="eraser") pos-=6; 
    else {is_possible=false;break;}
  }
  print(is_possible?"YES":"NO");
  return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
dic = {}
for i in range(m):
  a, b = map(int, input().split())
  if a in dic:
    dic[a].append(b)
  else:
    dic[a] = [b]
  if b in dic:
    dic[b].append(a)
  else:
    dic[b] = [a]

res = []
for elem in dic[1]:
  res += dic[elem]
if n in res:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 48076
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int N, A, B, C, m = INT_MAX;
vector<int> take;

int calc(vector<int> v)
{
    int a = 0, b = 0, c = 0, mp = 0;
    for (int i = 0; i < N; i++)
    {
        if (v[i] == 0)
        {
            if (a > 0)
            {
                mp += 10;
            }
            a += take[i];
        }
        else if (v[i] == 1)
        {
            if (b > 0)
            {
                mp += 10;
            }
            b += take[i];
        }
        else if (v[i] == 2)
        {
            if (c > 0)
            {
                mp += 10;
            }
            c += take[i];
        }
    }
    if(!a || !b || !c) 
    {
    return INT_MAX;
    }
    mp += abs(A - a);
    mp += abs(B - b);
    mp += abs(C - c);
    return mp;
}

int dfs(int d, vector<int> v)
{
    if (d == N)
    {
    return m = min(calc(v), m);
    }
    for (int i = 0; i < 4; i++)
    {
        v[d] = i;
        dfs(d + 1, v);
    }
}

int main()
{
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++)
    {
        int l;
        cin >> l;
        take.push_back(l);
    }
    vector<int> v(N, 0);
    dfs(0, v);
    cout << m << endl;
}


Measured memory_bytes: 256
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main() {

	string s;
	cin >> s;
	
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;

	}
	else if (s == "Rainy" ) {
		cout << "Sunny" << endl;

	}

	
}



Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]


def to_str(n, base):
    convert_string = "0123456789ABCDEF"
    if n < base:
        return convert_string[n]
    else:
        return to_str(n // base, base) + convert_string[n % base]


print(len(to_str(N, K)))


Measured memory_bytes: 2940
n = int(input())
k = int(input())
if n == 1:
  a = int(input())
  print(min(2*abs(k-a),2*a))
else:
  a = list(map(int,input().split()))
  ans = 0
  for i in range(n):
    if abs(a[i] -k)>a[i]:
      ans += 2*a[i]
    else:
      ans += 2*abs(k-a[i])
  print(ans)

Measured memory_bytes: 3064
N = int(input())
G = [[] for n in range(N+1)]
q = [(1,0)]
ans = N*[-1]

for n in range(N-1):
  u,v,w = map(int,input().split())
  G[u]+=[(v,w)]
  G[v]+=[(u,w)]

while q:
  x,y = q.pop()
  ans[x-1] = y%2 
  for g,d in G[x]:
    q+=[(g,y+d)]*(ans[g-1]<0)

print(*ans,sep="\n")

Measured memory_bytes: 44284
N = int(input())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 

Asum = sum(A)

for i in range(N):
    a = A[i]
    b = B[i]
    A[i] = max(a - b, 0)
    B[i] = max(b - a, 0)
    A[i+1] = max(A[i+1]-B[i], 0)

print(Asum - sum(A))


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

int main(void) {
	char A[10], B[10], C[10];

	scanf("%s %s %s", A, B, C);
	
	if ( A[strlen(A) - 1] == B[0] && B[strlen(B) - 1] == C[0] ) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

int main() {

  int N = 0;
  std::cin >> N;

  std::vector<float> nums;

  for (int i = 0; i < N; ++i) {
    float A = 0;
    std::cin >> A;
    nums.push_back(A);
  }

  float inverse = 0;

  for (int i = 0; i < nums.size(); ++i) {
    inverse += (1 / nums[i]);
  } 

  std::cout << (1 / inverse) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  int mini = ceil(accumulate(all(a), 0.0) / (4 * m));
  int cnt  = 0;
  rep (i, n) {
    if (a[i] >= mini) ++cnt;
  }
  cout << (cnt >= m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;
const int n=1e5;
int maxid(int a,int b,int c)
{
    if(a>=b&&a>=c)return 0;
    if(b>=c)return 1;
    return 2;
}
int main(int argc,char ** argv)
{
    int a,b,c,x,y,i,j,k,t;
    long long sum=0;
    cin>>x>>y>>a>>b>>c;
    vector<int> p(a+1),q(b+1),r(c+1);
    for(i=0;i<a;++i)cin>>p[i];p[i]=0;
    for(i=0;i<b;++i)cin>>q[i];q[i]=0;
    for(i=0;i<c;++i)cin>>r[i];r[i]=0;
    sort(p.begin(),p.end(),greater<int>()),sort(q.begin(),q.end(),greater<int>()),sort(r.begin(),r.end(),greater<int>());
    i=j=k=0;
    // while(x){
    //     if(p[i]<r[k]){
    //         sum+=r[k++];
    //     }
    //     else{
    //         sum+=p[i++];
    //     }
    //     --x;
    // }
    // while(y){
    //     if(q[j]<r[k]){
    //         sum+=r[k++];

    //     }
    //     else{
    //         sum+=q[j++];
    //     }
    //     --y;
    // }
    while(i+j+k<x+y){
        t=maxid((i<x?p[i]:0),(j<y?q[j]:0),(k<c?r[k]:0));
        if(t==0){
            sum+=p[i++];
        }
        else if(t==1){
            sum+=q[j++];
        }
        else{
            sum+=r[k++];
        }
    }
    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct DisjointSparseTable {
  using T = int;
  static T op(const T& x, const T& y) { return max(x, y); }

  const int n;
  VV<T> t;
  template<class Itr> DisjointSparseTable(Itr first, Itr last) :
    n(distance(first, last)), t(__lg(n) + 1, V<T>(first, last)) {
    for (int k = 1; k < (int) t.size(); ++k) {
      for (int i0 = 1 << k; i0 < n; i0 += 1 << k + 1) {
        for (int i = i0 + 1; i < min(i0 + (1 << k), n); ++i) {
          t[k][i] = op(t[k][i - 1], t[k][i]);
        }
        for (int i = i0 - 2; i >= i0 - (1 << k); --i) {
          t[k][i] = op(t[k][i], t[k][i + 1]);
        }
      }
    }
  }
  T acc(int l, int r) const {
    assert(l < r);
    if (l == --r) return t[0][l];
    int k = __lg(l ^ r);
    return op(t[k][l], t[k][r]);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> p(n + 2, n + 1);
  for (int i = 1; i <= n; ++i) cin >> p[i];
  DisjointSparseTable dst(begin(p), end(p));

  auto fl = [&](int i, int x) -> int {
    int ng = -1, ok = i - 1;
    while (ok - ng > 1) {
      int mid = ng + ok >> 1;
      (dst.acc(mid + 1, i) <= x ? ok : ng) = mid;
    }
    return ok;
  };
  auto fr = [&](int i, int x) -> int {
    int ok = i + 1, ng = n + 2;
    while (ng - ok > 1) {
      int mid = ok + ng >> 1;
      (dst.acc(i + 1, mid) <= x ? ok : ng) = mid;
    }
    return ok;
  };

  lint res = 0;
  for (int i = 1; i <= n; ++i) {
    lint l = fl(i, p[i]);
    lint r = fr(i, p[i]);
    if (l) {
      lint ll = fl(l, p[i]);
      res += (l - ll) * (r - i) * p[i];
    }
    if (r <= n) {
      lint rr = fr(r, p[i]);
      res += (i - l) * (rr - r) * p[i];
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 7680
fun main(args: Array<String>) {
    abc148c()
}

fun abc148c() {
    val (a, b) = readLine()!!.split(' ').map { it.toLong() }

    val answer = lcm(a, b)

    println(answer)
}

private fun lcm(a: Long, b: Long): Long {
    return a / gcd(a, b) * b
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}


Measured memory_bytes: 36444
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let x: usize = iter.read();
	let a: usize = iter.read();

	let m = if x < a { 0 } else { 10 };

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


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int u=max(x,y);
	int ans=1145141919;
	for(int i=0;i<=u;i++){
		ans=min(ans,(2*c*i+a*max(x-i,0)+b*max(y-i,0)));
	}
	cout<<ans<<endl;
}

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

def solve(sx, sy, tx, ty):
    first = "U"*(ty-sy)+"R"*(tx-sx)
    second = "D"*(ty-sy)+"L"*(tx-sx)
    third = "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"
    forth = "R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
    
    print(first+second+third+forth)
    
if __name__ == '__main__': 
    sx, sy, tx, ty = map(int, input().split())
    
    solve(sx, sy, tx, ty)

Measured memory_bytes: 3064
n = int(input())
s = list(map(int,input().split()))
s.insert(0,0)
s.append(0)
c = 0

for i in range(n+1):
    c = c + abs(s[i] - s[i+1])

for i in range(1, n+1):
    if (s[i] - s[i-1]) * (s[i+1] - s[i]) >= 0:
        print(c)
    else:
        a = min(abs(s[i] - s[i - 1]), abs(s[i + 1] - s[i]))
        print(c - a * 2)

Measured memory_bytes: 14048
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[SZ];
const int M=262144;
int ls[SZ],rs[SZ],ss[SZ];
bool fl[SZ];
pii ps[SZ];
pii mg(pii a,pii b)
{
	return pii(min(a.fi,b.fi),min(a.se,b.se));
}
int qr(int p)
{
	static int s1[SZ],s2[SZ];
	int n1=0,n2=0;
	for(int l=p+M-1,r=n+M+3;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) s1[++n1]=l^1;
		if(r&1) s2[++n2]=r^1;
	}
	while(n2) s1[++n1]=s2[n2--];
	int g;
	for(int i=1;i<=n1;++i)
		if(ss[s1[i]]) {g=s1[i]; break;}
	while(g<M)
	{
		if(ss[g+g]) g=g+g;
		else g=g+g+1;
	}
	return rs[g]-1;
}
void sett(int x)
{
	for(x+=M;x;x>>=1) ss[x]=1;
}
void build()
{
	for(int i=1;i<=M;++i) ls[i+M]=rs[i+M]=i;
	for(int i=1;i<=n;++i)
		if((n-i)&1) ps[i+M]=pii(a[i],1e9);
		else ps[i+M]=pii(1e9,a[i]);
	for(int i=M-1;i>=1;--i)
		ls[i]=ls[i+i],rs[i]=rs[i+i+1],
		ps[i]=mg(ps[i+i],ps[i+i+1]);
}
void pd(int x)
{
	if(fl[x])
	{
		swap(ps[x].fi,ps[x].se);
		if(x<=M) fl[x+x]^=1, fl[x+x+1]^=1;
		fl[x]=0;
	}
}
void upd(int x)
{
	pd(x+x); pd(x+x+1);
	ps[x]=mg(ps[x+x],ps[x+x+1]);
}
pii qry(int x,int l,int r)
{
	if(rs[x]<l||r<ls[x]) return pii(1e9,1e9);
	pd(x);
	if(l<=ls[x]&&rs[x]<=r)
		return ps[x];
	pii t=mg(qry(x+x,l,r),qry(x+x+1,l,r));
	upd(x); return t;
}
void del(int p)
{
	int x=1;
	while(1)
	{
		pd(x);
		if(x>M) break;
		if(p<=rs[x+x]) x=x+x;
		else x=x+x+1;
	}
	ps[x]=pii(1e9,1e9);
	for(x>>=1;x;x>>=1)
		ps[x]=mg(ps[x+x],ps[x+x+1]); 
}
void flip(int x,int l,int r)
{
	if(rs[x]<l||r<ls[x]) return;
	pd(x);
	if(l<=ls[x]&&rs[x]<=r) {fl[x]^=1; return;}
	flip(x+x,l,r); flip(x+x+1,l,r); upd(x);
}
int os[SZ],on=0,rv[SZ];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i),rv[a[i]]=i;
	build(); sett(n+1);
	while(on<n)
	{
		int x=rv[qry(1,1,n).fi],t=qr(x);
		int y=rv[qry(1,x,t).se];
		os[++on]=a[x]; os[++on]=a[y];
		flip(1,x,y);
		del(x); del(y);
		sett(x); sett(y);
	}
	for(int i=1;i<=on;++i) printf("%d ",os[i]);
}
/*
找到一个全局最小的，右边有奇数个的
提出来
找到右边多少个没有padding
找到这部分最小的右边有奇数个的
xor一波删掉 
*/
 

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

int main(){
    int n,x,ways=0;
    int a=1,b,c;
    
    while(1<2){
    cin>>n>>x;
    if(n==0&&x==0){
    break;
    }else{
        while(a<n-1){
            b=a+1;
                while(b<n){
                    c=b+1;
                    while(c<n+1){
                        if(a+b+c==x){
                            ways+=1;
                        }
                        c++;
                    }
                    b++;
                }
            a++;
        }           
     cout<<ways<<endl;
     ways=0;
     a=1;
    }
    }
}


Measured memory_bytes: 3100