akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int t;
  cin >> t;
  for(int i = 0; i < t; i++) {
    int n;
    cin >> n;
    int max = 0;
    int min = 0;
    int bfrH = 0;
    for(int j = 0; j < n; j++) {
      int h;
      cin >> h;
      int newValue = h - bfrH;
      if(j != 0 && newValue > max) max = newValue;
      if(j != 0 && newValue < min) min = newValue;
      bfrH = h;
    }
    cout << max << ' ' << -min << endl;
  }
  return 0;
}

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

template<uint64_t m = 1000000007>
class ModInt {
public:
    ModInt(const uint64_t x): x(x) { }

    ModInt operator + (ModInt y) const {
        return (x + y.x) % m;
    }

    ModInt operator * (ModInt y) const {
        return (x * y.x) % m;
    }

    void operator += (ModInt y) {
        x = (x + y.x) % m;
    }

    void operator *= (ModInt y) {
        x = (x * y.x) % m;
    }

    uint64_t data() const {
        return x;
    }

private:
    uint64_t x;
};

void shift(const ModInt<13> n, std::vector<ModInt<> > &next, const std::vector<ModInt<> > &frequency) {
    for(int i = 0; i < 13; ++i) {
        next[(n + i).data()] += frequency[i];
    }
}

int main() {
    std::string s;
    std::cin >> s;

    auto frequency = std::vector<ModInt<> >(13, 0);
    frequency[0] = 1;

    ModInt<13> pow10 = 1;

    for(auto i = s.rbegin(); i != s.rend(); ++i) {
        const char c = *i;
        auto freq = std::vector<ModInt<> >(13, 0);

        if(c == '?') {
            for(int i = 0; i <= 9; ++ i) {
                const ModInt<13> r = pow10 * i;

                shift(r, freq, frequency);
            }
        } else {
            const int x = c - '0';
            const ModInt<13> r = pow10 * x;

            shift(r, freq, frequency);
        }

        frequency = std::move(freq);

        pow10 *= 10;
    }

    std::cout << frequency[5].data() << std::endl;

    return 0;
}


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

using namespace std;

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

    string s; cin >> s;
    s[0] == 'S' ? cout << "Cloudy" : s[0] == 'C' ? cout << "Rainy" : cout << "Sunny";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int H, W;
	bool can = true;
	char C[55][55];
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> C[i][j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (C[i][j] == '#'&&C[i][j - 1] != '#'&&C[i - 1][j] != '#'
				&&C[i][j + 1] != '#'&&C[i + 1][j] != '#') {
				can = false;
			}
		}
	}
	if (can)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
C=[1]
s=set([1])
for i in range(N):
  if A[C[i]-1] in s:
    l=C.index(A[C[i]-1])+1
    break
  else:
    C.append(A[C[i]-1])
    s.add(A[C[i]-1])
if K+1<=l:
  print(C[K])
else:
  print(C[l-1+(K+1-l)%(len(C)-l+1)])

Measured memory_bytes: 50940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 0; i < N; i++) {
            int tmp = scan.nextInt() % 4;
            if (tmp == 0) {
                a++;
            } else if (tmp == 2) {
                b++;
            } else {
                c++;
            }
        }
        if (c <= a) {
            System.out.println("Yes");
            return;
        }
        c -= a;
        if (c == 1 && b == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 50620
#include <algorithm>
#include <stdio.h>
using namespace std;

static const int MAX_SIZE = 1001;

int main(){
    int n,ans = 0,area[MAX_SIZE][MAX_SIZE] = {};
    scanf("%d",&n);
    for(int i = 0;i < n;++i){
        int ax,ay,bx,by;
        scanf("%d %d %d %d",&ax,&ay,&bx,&by);
        area[ax][ay]++;
        area[ax][by]--;
        area[bx][ay]--;
        area[bx][by]++;
    }
    
    for(int i = 0;i < MAX_SIZE;++i){
        for(int j = 0;j < MAX_SIZE;++j){
            if(i){
                area[i][j] += area[i - 1][j];
            }
            if(j){
                area[i][j] += area[i][j - 1];
            }
            if(i && j){
                area[i][j] -= area[i - 1][j - 1];
            }
            ans = max(ans,area[i][j]);
        }
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 6668
#include<cstdio>
int a[100005], b[100005];

int main(){
    //printf("%d\n",1<<30);
    int n,k;
    scanf("%d%d",&n,&k);
    //maxbit: 2^29 -> 1<<29
    for(int i = 1; i <= n; i++) scanf("%d%d",&a[i],&b[i]);
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        int left = a[i]&(~k);
        if(left==0) ans += (long long)b[i];
    }
    //first diff pos
    int allOne = (1<<30)-1;
    for(int i = 29; i >= 0; i--){
        if(((1<<i)&k)==0) continue;
        int upper = allOne^((1<<(i+1))-1);
        int bad = ~(k&upper);
        long long cur = 0;
        for(int j = 1; j <= n; j++){
            if(a[j]&(1<<i)) continue;
            int left = a[j]&upper;
            if((left&bad)==0) cur += (long long)b[j];
        }
        if(cur>ans) ans = cur;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
  vector<int> A(3);
  repeat(i,3) cin >>A[i];
  
  sort(A.begin(),A.end());
  
  int ans = A[1]-A[0] + A[2]-A[1];
  cout <<ans<< endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
ss = [[0] * w for _ in range(h)]
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            for k in range(max(0, i - 1), min(h, i + 2)):
                for l in range(max(0, j - 1), min(w, j + 2)):
                    ss[k][l] += 1
for i in range(h):
    ans = ""
    for j in range(w):
        if s[i][j] == "#":
            ans += s[i][j]
        else:
            ans += str(ss[i][j])
    print(ans)


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

#define  PI 3.14159265358979

int main( void ) {
   double r;
    cin >> r;

   double s, l;
    s = r * r * PI;
    l = r * 2.0 * PI;
    printf( "%.8f %.8f\n", s, l );

    return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    char S;
    cin >> S;
    if (S == 'Y') {
      flag = true;
      break;
    }
  }
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}

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

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



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

int main(){
  ll n;
  cin>>n;
  vector<ll> B(n-1);
  for(ll i=0;i<n-1;i++){
   	cin>>B[i]; 
  }
  vector<ll> A(n);
  for(ll i=n-2;i>=0;i--){
   	if(i == n-2){
     A[i] = B[n-2];
      A[i+1] = B[n-2];
    }
    else{
     	if(B[i] < A[i+1]){
        	A[i+1] = B[i];
          	A[i] = B[i];
        }
      	else{
        	A[i] = B[i];
        }
    }
  }
  ll ans = 0;
  for(ll i=0;i<n;i++){
   ans += A[i]; 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr + std::cmp::Ord>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let mut v: Vec<T> = buf
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect();
    v.sort();
    v
}

fn main() {
    let n: usize = read()[0];
    let a: Vec<usize> = read();
    let b: Vec<usize> = read();
    let c: Vec<usize> = read();

    let mut v1 = vec![0_usize; n];
    for i in 0..n {
        let mut cnt = if i == 0 { 0 } else { v1[i - 1] };
        while cnt < n && b[i] > a[cnt] {
            cnt += 1;
        }
        v1[i] = cnt
    }

    let mut v2 = vec![0_usize; n];
    for i in (0..n).rev() {
        let mut cnt = if i == n - 1 { 0 } else { v2[i + 1] };
        while cnt < n && b[i] < c[n - cnt - 1] {
            cnt += 1;
        }
        v2[i] = cnt
    }

    let ans: usize = (0..n).fold(0, |sum, i| sum + v1[i] * v2[i]);
    println!("{}", ans);
}


Measured memory_bytes: 13560
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int inv(int a, long long MOD) {
  return a == 1 ? 1 : (long long)(MOD - MOD / a) * inv(MOD % a, MOD) % MOD;
}

long mod = 1000000007;
int main() {
  long long N, M, K;
  cin >> N >> M >> K;

  long long k_2 = 1;
  for (int i = 1; i <= K - 2; i++) {
    k_2 *= i;
    k_2 %= mod;
  }

  int k_2_inv = inv(k_2, mod);

  long long nm_2_k_2 = k_2_inv;
  long long nm_2 = N * M - 2;

  for (int i = 0; i < K - 2; i++) {
    nm_2_k_2 *= nm_2 - i;
    nm_2_k_2 %= mod;
  }

  // cout << nm_2_k_2 << endl;
  long long ans = 0;
  for (int d = 0; d < N; d++) {
    ans += d * (N - d) * M * M;
  }

  for (int d = 0; d < M; d++) {
    ans += d * (M - d) * N * N;
  }

  ans %= mod;
  ans *= nm_2_k_2;
  ans %= mod;
  ans += mod;
  ans %= mod;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];
    int ans=0;
    REP(i,N){
        if(p[i]==i+1){
            ans++;
            i++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.nextLine();
		LOOP: for (int i = 0; i < n; i++){
			String s = sc.nextLine();
			for (int a = 3; true; a++){
				for (int b = 0; b < 26; b++) {
					if (a % 2 == 0 || a % 13 == 0) continue;
					StringBuffer BF = new StringBuffer(s);
					for (int j = 0; j < BF.length(); j++){
						if (Character.isLowerCase(BF.charAt(j)))
							BF.setCharAt(j, affineCipher(a, b, BF.charAt(j)));
					}
					if (BF.indexOf("that") != -1 || BF.indexOf("this") != -1) {
						System.out.println(BF.toString());
						continue LOOP;
					}
				}
			}
		}
	}
	private static char affineCipher(int a, int b, char y){
		int n = y - 'a';
		int f = (a * y + b) % 26;
		return (char) (f + 'a');
	}
}

Measured memory_bytes: 21140
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		
		init(n);
		for (int i=0;i<q;i++) {
			if(in.nextInt()==0) {
				// update
				update(in.nextInt(), in.nextInt());
			} else {
				// find
				System.out.println(find(in.nextInt(), in.nextInt()));
			}
		}
	}
	
	static int[] nodes;
	static int size; // up to 2^n

	static void init(int n) { // n:data size
		size=1;
		while (size<n) size*=2;
		nodes = new int[size*2-1];
		for (int i=0;i<nodes.length;i++) {
			nodes[i] = Integer.MAX_VALUE;
		}
	}
	
	static void update(int target, int value) {
		int up = size-1 + target;
		nodes[up] = value;
		if (up==0) return;
		up = (up-1)/2;
		while (true) {
			nodes[up] = Math.min(nodes[up*2+1], nodes[up*2+2]);
			if (up==0) break;
			up = (up-1)/2;
		}
	}
	
	static int find(int s, int t) { // find min in s<=i<=t
		return _find(s, t, 0, 0, size-1);
	}
	static int _find(int s, int t, int node, int node_s, int node_t) {
		if (t<node_s||s>node_t) return Integer.MAX_VALUE;
		if (s<=node_s&&node_t<=t) return nodes[node];
		int cl = _find(s, t, node*2+1, node_s, (node_s+node_t)/2);
		int rl = _find(s, t, node*2+2, (node_s+node_t)/2+1, node_t);
		return Math.min(cl, rl);
	}
}

Measured memory_bytes: 105712
n = int(input())
a = list(map(int, input().split()))
b = set(range(1, 10001)) - set(a)
ans = 0
for i in range(1, n):
    if a[i] == a[i - 1]:
        a[i] = list(b)[i]
        ans += 1
print(ans)

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	string s;
	cin>>s;
	int a=0;
	for(auto i:s){
		a+=i-'0';
		a%=9;
	}
	if(a)cout<<"No";
	else cout<<"Yes";
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   if(a==0){
       cout<<"1"<<endl;
       }
       else if(b==0){
       cout<<"2"<<endl;}
       else if(c==0){
       cout<<"3"<<endl;}
       else if(
           d==0){
       cout<<"4"<<endl;}
       else if(e==0){
       cout<<"5"<<endl;}
       return 0;
       
       
       
       }

Measured memory_bytes: 3552
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

const ll N=2e5+5;

ll sp[N];

void sieve(){
  for(int i=2;i<N;i++)sp[i]=i;

    for(int i=2;i*i<N;i++){
      if(sp[i]==i){
      for(int j=i*i;j<N;j+=i){
        sp[j]=i;
      }
    }
}

}
/*
//ll fac[N],inv[N];

ll p=1e9+7;

void fill(){
  fac[0]=inv[0]=1;

  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%p;
  }
}

*/

vl cr(ll x){
  vl d;
  while(x){
    d.pb(x%10);
    x/=10;
  }
  return d;
}

void mul(vl& a , ll n){
ll carry=0;
  for(auto& x:a){
carry+=x*n;
x=carry%10;
carry/=10;
  }
  while(carry){
    a.pb(carry%10);
    carry/=10;
  }
}

ll a[26];
int main()
{ 

  IOS;

string s,t;
cin>>s>>t;

ll cnt=0;

for(int i=0;i<s.size();i++){
  if(s[i]!=t[i])cnt++;
}

cout<<cnt<<endl;


return 0;
 
}



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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool ans = false;
    for (int i=1; i<=B; i++) {
        if (i*A % B == C) {
            ans = true;
        }
    }
    if (ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <deque>
using namespace std;
typedef pair<int,int>P;
const int INF=23333333;
int f[1100][1100],dis[1100][1100],h,w,x1,Y1,x2,y2;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
char c[1100][1100];
void bfs(void)
{
    deque<P>q;
    dis[x1][Y1]=0;
    P start(x1,Y1);
    q.push_front(start);
    while(q.size())
    {
        P t=q.front();
        q.pop_front();
        if(f[t.first][t.second])continue;
        f[t.first][t.second]=1;
        int x,y,d=dis[t.first][t.second];
        for(int i=0;i<4;i++)
        {
            x=t.first+dx[i],y=t.second+dy[i];
            if(x<0||x>=h||y<0||y>=w||c[x][y]=='#'||dis[x][y]<=d)continue;
            dis[x][y]=d;
            q.push_front(P(x,y));
        }
        for(int i=t.first-2;i<=t.first+2;i++)
        {
            if(i<0||i>=h)continue;
            for(int j=t.second-2;j<=t.second+2;j++)
            {
                if(j<0||j>=w||c[i][j]=='#'||dis[i][j]<=d+1)continue;
                dis[i][j]=d+1;
                q.push_back(P(i,j));
            }
        }
    }
}
int main(void)
{
    scanf("%d %d %d %d %d %d",&h,&w,&x1,&Y1,&x2,&y2);
    x1--;Y1--;x2--;y2--;
    for(int i=0;i<h;i++)scanf("%s",c[i]);
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)dis[i][j]=INF;
    }
    bfs();
    printf("%d\n",dis[x2][y2]==INF?-1:dis[x2][y2]);
    return 0;
}


Measured memory_bytes: 12848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    int n;
    cin >> n;
    ve<int> a(n),b(n+1);
    rep(i,n){
        cin >> a[i];
        b[a[i]] = (int)i;
    }
    ll ans = 0;
    set<int> s;
    s.insert(b[n]);
    s.insert(b[n-1]);
    ans += (ll)(n-1) * (1+*s.begin()) * (n-*next(s.begin()));
    s.insert(-1);
    s.insert(n);
    for (int i = n-2; i>0; i--) {
        int x = b[i];
        auto it = s.lower_bound(x);
        int y,z,w;
        y = *it;
        z = *prev(it);
        if(it != prev(s.end())){
            w = *next(it);
            ans += (ll)i * (x-z) * (w - y);
        }
        auto it2 = prev(it);
        if(it2 != s.begin()){
            ans += (ll)i * (z - *prev(it2)) * (y - x);
        }
        s.insert(x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
#define endl "\n" 
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set 
#define mod 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))
#define int long long

int dp[100005];

int helper(int *arr, int n, int i, int cost) {
    if(i == n-1) 
    {
        return 0;
    }
    if(dp[i] != -1) return dp[i]; 
    int ans = imax;
    if(i+1 < n)
        ans = min(ans, abs(arr[i+1] - arr[i]) + helper(arr, n, i+1, cost));
    if(i+2 < n)
        ans = min(ans, abs(arr[i + 2] - arr[i]) + helper(arr, n, i + 2, cost));
    return dp[i] = ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp, -1, sizeof(dp));
    int n; cin >> n;
    int arr[n]; 
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    cout << helper(arr, n, 0, 0);
    return 0;
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
const int maxn = 300100;
int n;
int p[maxn];
inline void solve(int l,int r) {
	int min0 = 0,min1 = 0;
	for(int i = l;i <= r;i += 2) {
		int & min = p[i] < i ? min0 : min1;
		if(p[i] > min) min = p[i]; 
		else return ;
	}
	std::sort(p + l,p + r + 1);
}
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for(int i = 1;i <= n;++i) std::cin >> p[i];
	for(int i = 1, j;i <= n;++i) if(p[i] != i) {
		for(j = i + 1;j + 1 <= n && p[j] == j;j += 2);
		if(i <= j - 2) solve(i, j - 1), i = j - 1;
	}
	std::cout << (std::is_sorted(p + 1,p + n + 1) ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

using integer = unsigned long long;

int main(void) {
  integer a, b, x;
  std::cin >> a >> b >> x;

  integer min = ((a + x - 1) / x) * x;
  integer max = (b / x) * x;

  if (min > max) {
    std::cout << 0 << std::endl;
    return 0;
  }

  integer num = (max - min) / x + 1;

  std::cout << num << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, i, a[210];
	cin >> n;
	n *= 2;
	for (i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	int b = 0, c = 0;
	for (i = 0; i < n; i += 2) {
		b += a[i];
	}
	for (i = 1; i < n - 1; i += 2) {
		c += a[i];
	}
	c += a[0];
	cout << max(b, c) << endl;
	return 0;
}

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

int main() {
	string S,C;
  	cin >> S >> C;
  int Ans = 0;
  for(int i = 0; i < 3; i++){
  	if(S.at(i) == C.at(i)){
    Ans++;
    }
  }
  
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d<=a)
        cout<<d<<endl;
    else if(d<=(a+b))
        cout<<a<<endl;
    else if(d<=(a+b+c))
        cout<<a-(d-a-b)<<endl;
    return 0;
}

Measured memory_bytes: 3652
a,b,c = map(int,input().split())
count = 0
while 1:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(count)
        break
    if a == b and b == c:
        print(-1)
        break
    
    a_a = b / 2 + c / 2
    b_a = a / 2 + c / 2
    c_a = a / 2 + b / 2
    a = a_a
    b = b_a
    c = c_a
    count = count + 1
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int>> G;
int main() {
	cin >> N >> M;
	G.resize(N);
	for (int i = 0; i < M; ++ i) {
		int x, y;
		cin >> x >> y;
		-- x; -- y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	vector<bool> visited(N);
	deque<int> a;
	a.push_back(0); visited[0] = true;
	a.push_back(G[0][0]); visited[G[0][0]] = true;
	for (;;) {
		int x = a.back();
		for (auto y : G[x]) if (!visited[y]) {
			a.push_back(y); visited[y] = true;
			goto next1;
		}
		break;
		next1:;
	}
	for (;;) {
		int x = a.front();
		for (auto y : G[x]) if (!visited[y]) {
			a.push_front(y); visited[y] = true;
			goto next2;
		}
		break;
		next2:;
	}

	cout << a.size() << endl;
	for (auto x : a) cout << x+1 << " ";
	cout << endl;
}


Measured memory_bytes: 6656
#include <stdio.h>

int main (void){
  int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
  if((a + b ==c)||(b+c==a)||(c+a==b)){
    printf("Yes\n");}
  else{
    printf("No\n");}

  return 0;
}


Measured memory_bytes: 128
/*input
7
5 0 7 8 3 3 2
*/
#include "bits/stdc++.h"
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n;
	long long sum = 0, ans = 0;
	for(int i=1;i<=n;++i){
		cin >> a[i];
		sum += a[i];
	}
	for(int i=1;i<=n;++i){
		ans += a[i] * (sum - a[i]);
	}
	assert(ans%2==0);
	cout << ans/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans=0;
  ll f=0;
  for(ll i=0;i<n-1;i++) {
    if(a[i]==a[i+1]) {
      if(ans==0) {
        ans=a[i];
      }
      else {
        ans*=a[i];
        f=1;
      }
      i++;
    }
    if(f) break;
  }
  if(f) cout << ans << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
    int n ;
    cin >> n ;
    ll ans = 0 ;
    vector < int > a(n),hash(n+1);
    for( int i = 0 ; i < n ; i++) cin >> a[i] , hash[a[i]]++;
    for( int i = 0 ; i <=n ; i++){
        ll x = hash[i] ;
        ans += (x*(x-1))/2;
    }
    for( int i = 0 ; i < n ; i++){
        ll x = hash[a[i]];
        ll d = (x*(x-1))/2;
        d = -d ;
        x--;
        d += (x*(x-1))/2 ;
        cout << ans + d << "\n";
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


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

int main(){
  int d, n;
  cin >> d >> n;
  int p = 1;
  for(int i = 0; i <= d; i++){
  	p *= 100;
  }
  if(n == 100){
  	n++;
  }
  cout << p*n/100 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A, B, C, D; cin >> A >> B >> C >> D; 
	int tak = (A + D - 1) / D; 
	int aok = (B + C - 1) / B; 
	if(tak >= aok) cout << "Yes" << endl; 
	else cout << "No" << endl; 
}

Measured memory_bytes: 3632
#include <stdio.h>
#define N 1000
#define INF 1<<21
 
int n,M[N][N];
int d[N];
int Q[2*N],head=0,tail=0;
 
void enq(int);
int deq(void);
void bfs(int);
 
 
int main(){
    int i,j,u,k,v;
 
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++)M[i][j] = 0;
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d %d",&u, &k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            M[u][v] = 1;
        }
    }
    bfs(1);
    for(i=1;i<=n;i++){
        if(d[i] == INF)d[i] = -1;
        printf("%d %d\n",i,d[i]);
    }
    return 0;
 
}
 
void enq(int x){
    Q[tail++] = x;
}
 
int deq(){
    return Q[head++];
}
 
void bfs(int s){
    int i,u,v;
    enq(s);
    for(i=1;i<=n;i++)d[i] = INF;
        d[s] = 0;
    while(head != tail){
        u = deq();
        for(v = 1;v <= n;v++){
            if(M[u][v] == 0)continue;
            if(d[v] != INF)continue;
            d[v] = d[u] + 1;
            enq(v);
        }
    }
}

Measured memory_bytes: 992
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *A,*B,i,n,k,max=-1;
  scanf("%d",&n);
  A=malloc(sizeof(int)*(n+2));
  B=malloc(sizeof(int)*(n+2));
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>max)max=A[i];
   
  }
  int *C=malloc(sizeof(int)*(max+2));
  
  for(i=0;i<=max;i++)C[i]=0;
  for(i=0;i<n;i++)C[A[i]]++;
  int j=0;
  i=0;
  while(1){
    if(j==max+1)break;
      if(C[j]==0){
      j++;
      continue;
    }
    B[i]=j;
    C[j]--;
     i++;
  }
  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!=n-1)printf(" ");
    else printf("\n");
  }
  return 0;
}



Measured memory_bytes: 17396
//ABC333
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B; cin >> A >> B;
    if(A * B % 2 == 1){
        cout << "Yes" << endl;
    }
    else if(A * B % 2 == 0){
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/****************************
*  Developer : joshi08
*  Date  :  14-06-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a,lli b) {lli i,p=1; for(i=0;i<b;i++){p*=a;} return p;}

using namespace std;

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

	lli x,n,i,k,m;
	cin>>x>>n;
	vector<lli> p,a;
	map<lli,lli> g;
	
	
	for(i=0;i<n;i++)
	{
		cin>>k;
		m = x-k;
		if(m<0)
			m *= (-1);
		p.push_back(m);
		a.push_back(k);
		g.insert(pair<lli,lli>(k,i));
	}
	//k = n-1;
	m=0;
	
	
	for(i=0;i<=n+1;i++)
	{
		if(g.find(x-i)==g.end())
		{
			cout<<x-i;
			break;
		}
		
		if(g.find(x+i)==g.end())
		{
			cout<<x+i;
			break;
		}
	}
	
	
	/*if(!p.empty())
	{
		sort(p.begin(),p.end());
		
		if(p[0]==0)
		{
			for(i=1;i<n;i++)
			{
				if(p[i]>m+1)
				{
					k = m+1;
					break;
				}
				else
				if(p[i]<=m)
				{
					continue;
				}
				else
				if(p[i]==m+1)
				{
					m++;
				}
			}
			
			if(i==n)
			{
				cout<<x+m+1;
			}
			else
			{
				cout<<x+k;
			}
		}
		else
		{
			cout<<x;
		}
	}
	else
	{
		cout<<x;
	}*/
	
	
	
	

    return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

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

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

    ll _gcd = A[0];
    for(ll k = 1; k < N; k++)
    {   
        _gcd = gcd(_gcd, A[k]);
    }
    
    cout << _gcd << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
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()
{
    ll N;
    cin >> N;
    cout << (8 - (N-400)/200) << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll N, M; cin >> N >> M;

    if (M/2 >= N) {
        ll res = N; M -= N*2;
        cout << res+M/4 << "\n";
    } else {
        cout << M/2 << "\n";
    }

}


Measured memory_bytes: 256
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
//typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int N = 1e3+1;
ll n,m,k,q;


int Dec(ll x){
    int ret=0;
    while(x){
        x/=10;
        ret++;
    }
    return ret;
}

bool valid(int x){
    int min_dec = INT_MAX;
    for(ll i=1;i*i<=n;i++){
        if(n%i == 0){
            min_dec = min(Dec(n/i),min_dec);
        }
    }
    return min_dec<=x;
}

int main(){

    cin>>n;

    int mid,lo,hi;
    lo = 1;
    hi = Dec(n)+1;
    while(lo<hi){
        mid = (lo+hi)/2;
        if(valid(mid)) hi=mid;
        else lo = mid+1;
    }

    cout<<lo<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

int main(){
	ll n,m,a[100010];
	ll ans=0;
	cin >> n >> m;
	FOR(i,n){
		cin >> a[i];
	}
	ll sum=0;
	map<ll,ll> v;
	v[0]=1;
	FOR(i,n){
		sum+=a[i];
		v[sum%m]++;
	}

	for(auto itr=v.begin();itr!=v.end();itr++){
		ans+=(itr->second)*(itr->second-1)/2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll x,y;
    cin >> x >> y;
    ll ans = 1;
    while(x<y){
        x*=2;
        if(x<=y)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int N; 
	cin >> N; 
	vector<pair<int, long long int>> V[100010] = {}; 
	for(int i = 0; i < N-1; i++){
		int a, b;
		long long int c; 
		cin >> a >> b >> c; 
		V[a].push_back(pair<int, long long int> (b, c)); 
		V[b].push_back(pair<int, long long int> (a, c)); 
	}
	int Q, K; 
	cin >> Q >> K; 
	long long int D[100010] = {};
	for(int i = 1; i <= N; i++){
		D[i] = 1e15;
	}
  	D[K] = 0; 
	queue<int> que;
	que.push(K); 
	while(que.size()){
		int p = que.front(); que.pop(); 
		for(int i = 0; i < V[p].size(); i++){
			int n = (V[p].at(i)).first;  
			if(D[n] == 1e15){
				que.push(n); 
				D[n] = D[p] + (V[p].at(i)).second; 
			}
		}
	}
	for(int q = 0; q < Q; q++){
		int x, y; 
		cin >> x >> y; 
		cout << D[x] + D[y] << endl;
	}
}

Measured memory_bytes: 9984
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [0] * N
for i in range(N):
  A[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
  y = C
  for j in range(M):
    y += A[i][j]*B[j]
  if y > 0:
    ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
const int N = (int)1e5+5;
const int inf = (int)1e17+7;
void solve(){
	int n;
	cin >> n;
	vector<int>G[n+1];
	REP(i,2,n+1){
		int x;
		cin >> x;
		G[x].pb(i);
	}
	REP(i,1,n+1){
		cout << G[i].size() << endl;
	}
}
int32_t main(){

	FASTIO;
	solve();
    return 0;

}

Measured memory_bytes: 14512
#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 pcnt(int x) {
  return __builtin_popcount(x);
}

int f(int x) {
  if (x == 0) return 0;
  return f(x % pcnt(x)) + 1;
}

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

  vector<int> x(n);
  rep(i, n) x[i] = s[i] - '0';
  int pc = 0;
  rep(i, n) pc += x[i];
  vector<int> ans(n);
  // x[i]が0の場合と1の場合を確かめる
  rep(b, 2) {
    int npc = pc;
    if (b == 0)
      npc++;
    else
      npc--;
    if (npc <= 0) continue;
    int r0 = 0;
    rep(i, n) {
      r0 = (r0 * 2) % npc;
      r0 += x[i];
    }
    int k = 1;
    for (int i = n - 1; i >= 0; --i) {
      if (x[i] == b) {
        int r = r0;
        if (b == 0)
          r = (r + k) % npc;
        else
          r = (r - k + npc) % npc;
        ans[i] = f(r) + 1;
      }
      k = (k * 2) % npc;
    }
  }

  rep(i, n) cout << ans[i] << endl;

  return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a > c && b < c) || (a < c && b > c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t ans = 1;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        ans = boost::math::lcm(ans, t);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        List<String> a = new ArrayList<>();
        for(int i = 0;i < h;i++){
            a.add(sc.next());
        }
        for(int i = 0;i < w+2;i++){
            System.out.print("#");
        }
        System.out.println();

        for(String str : a){
            System.out.printf("#%s#\n",str);
        }

        for(int i = 0;i < w+2;i++){
            System.out.print("#");
        }
        System.out.println();
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD =998244353;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

ll dp[200010];
ll tdp[200010];

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> L(K);
    vector<ll> R(K);

    REP(i, K){
        cin >> L[i] >> R[i];
    }

    REP(i, 200010){
        dp[i] = 0;
        tdp[i] = 0;
    }

    dp[1] = 1;
    tdp[1] = 1;

    for(ll i=2; i<=N; i++){
        tdp[i] = tdp[i-1] % MOD; 
        REP(j, K){
            ll l = L[j];
            ll r = R[j];

            dp[i] += ((tdp[max(0LL, i-l)] % MOD) - (tdp[max(0LL,i-r-1)] % MOD) + MOD) % MOD; 
            tdp[i] += ((tdp[max(0LL, i-l)] % MOD) - (tdp[max(0LL,i-r-1)] % MOD) + MOD) % MOD; 
            dp[i] = dp[i] % MOD; 
            tdp[i] = tdp[i] % MOD;
        }
    }
    // for(ll i=1; i<=N; i++){
    //     cout << dp[i] << " " << tdp[i] << endl;
    // }
    cout << dp[N] % MOD << endl;
    return 0;
}

Measured memory_bytes: 6748
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    cin >> N >> K;

    double ans = 0;
    FOR(i, 1, N + 1) {
        int n = i, cnt = 0;
        while (n < K) {
            n *= 2;
            cnt++;
        }
        ans += pow(0.5, cnt) / N;
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, t;
vector<int> a;
int p, ng;
int sum;
int ans;
bool flg;

signed main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> t; a.push_back(t);
        if (t > 0) p += t;
        else if (t < 0) ng += t;
        else flg = true;
    }
    if (p == 0 && !flg) {
        sort(a.begin(), a.end(), greater<int>());
        cout << -ng + 2*a.front() << endl;

        sum = a.front();
        for (int i=1;i<n;i++) {
            cout << sum << " " << a[i] << endl;
            sum -= a[i];
        }
    }
    else if (ng == 0 && !flg) {
        sort(a.begin(), a.end());
        cout << p - 2*a.front() << endl;

        sum = a.front();
        for (int i=1;i<n-1;i++) {
            cout << sum << " " << a[i] << endl;
            sum -= a[i];
        }
        cout << a[n-1] << " " << sum << endl;
    }
    else {
        cout << p - ng << endl;

        sort(a.begin(), a.end());
        sum = a.back(); a.pop_back();
        for (int i=n-2;i>=0;i--) {
            if (a[i] > 0) {
                cout << a[0] << " " << a[i] << endl;
                a[0] -= a[i];
                a.pop_back();
            }
            else break;
        }
        for (auto& it: a) {
            cout << sum << " " << it << endl;
            sum -= it;
        }
    }
}


Measured memory_bytes: 2804
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 200000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 

    fast;
ll h,n;
cin>>h>>n;

ll a[n],b[n];

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

ll dp[n+1][h+1];
memset(dp,0,sizeof(dp));

for(ll i=1;i<=h;i++)
    dp[0][i]=inf;

for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=h;j++)
    {
       if(a[i-1]>=j)
       dp[i][j]=min(dp[i-1][j],b[i-1]);

        else
        {
            dp[i][j]=min(dp[i-1][j],dp[i][j-a[i-1]]+b[i-1]);
        }

    }
}

cout<<dp[n][h]<<endl;
  
}

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

typedef long long ll;

ll A, B, K;

int main()
{
    cin >> A >> B >> K;
    ll tk = min(A, K);
    A -= tk; K -= tk;
    tk = min(B, K);
    B -= tk; K -= tk;
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int p,q,a,n;

int mypow(int a,int b){
	if(b==0)return 1;
	return a*mypow(a,b-1);
}

int gcd(int a,int b){
	if(b<a){
		int c=b;
		b=a;
		a=c;
	}
	if(a==0)return b;
	return gcd(b%a,a);
}

//int cnt;

int buf[10];
int sss;

int f(int p,int q,int aa,int nn,int m){
//cout<<p<<" "<<q<<" "<<aa<<" "<<nn<<" "<<m<<endl;
//cnt++;
	if(p==1&&nn==n-1&&q*aa<=a&&q>=m){
//int k;
//for(k=sss;k<n;k++)cout<<buf[k]<<" ";
//cout<<endl;
		return 1;
	}
	if(nn==n-1)return 0;
	int i,res=0;
	for(i=m;mypow(i,n-nn)*aa<=a;i++){
		buf[nn]=i;
		if(p*i-q<0)continue;
		int g=gcd(p*i-q,q*i);
		res+=f((p*i-q)/g,(q*i)/g,aa*i,nn+1,i);
	}
	return res;
}

int main() {
	int res;
	while(cin>>p>>q>>a>>n,p){
//cnt=0;
		if(p>n*q){
			cout<<0<<endl;
			continue;
		}
		res=0;
		int i;
		int g=gcd(p,q);
		for(i=0;i<n;i++){
//sss=i;
			res+=f(p/g,q/g,1,i,1);
		}
//cout<<" "<<cnt<<endl;
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;
int p = 1e9 + 7;

int32_t main()
{	
	IOS;
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i*i <= n; i++)
	{
		if(n % i == 0)
		{
			int k = n/i - 1;
			if(k)
				if(n % k == n / k)
					ans += k;
		}	
	}
	cout << ans;
	return 0;
} 


Measured memory_bytes: 256