akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	int n;
	cin >>n;
	vector<double> v(n);
	for (int i = 0; i < n; i++) {
		cin >>v[i];
	}

	sort(v.begin(),v.end());
	double ans=v[0];
	for (int i = 1; i < n; i++) {
		ans=(ans+v[i])/2;

	}

	cout <<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 != 0) {
			cnt++;
		}
	}
	double ans;
	ans = (double)cnt / (double)N;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
     
         
        using namespace std;
         
        #define N  1000000000;
    #define ll         long long
        vector<ll>adj[100005];
        std::vector<ll> vis;
        ll dfs(ll node)
        {
           
           ll ans=0;
           for(auto j:adj[node])
           {
            if(vis[j]==0)
            {
                vis[j]=1;
                ans^=(1+dfs(j));
            }
           }
           return ans;
         }
         int main()
        
       
        {
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int TESTS=1;
           // cin>>TESTS;
             while(TESTS--)
            {
              ll n;
              cin>>n;
              for(ll i=0;i<n-1;i++)
              {
                ll a,b;
                cin>>a>>b;
                adj[a].push_back(b);
                adj[b].push_back(a);
              }
              vis=vector<ll>(n+2,0);
              vis[1]=1;
              if(dfs(1))
                cout<<"Alice"<<endl;
            else
                cout<<"Bob"<<endl;
            }
            return 0;
        }

Measured memory_bytes: 9600
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

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

    vector<int> v;
    REP(i, 3) {
        int ai;
        cin >> ai;
        v.push_back(ai);
    }

    sort(ALL(v));
    
    cout << (v[0] + v[1] == v[2] ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"time"
)

var D int
var cs []int
var ss [][]int

func main() {
	D = ReadInt()
	cs = ReadInts(26)
	ss = make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	// naives
	answers := []int{}
	last := make([]int, 26)
	for d := 1; d <= D; d++ {
		maxT, maxScore := -1, math.MinInt32
		for i := 0; i < 26; i++ {
			s := ss[d-1][i] - cs[i]*(d-last[i])
			if s > maxScore {
				maxT, maxScore = i, s
			}
		}
		last[maxT] = d
		answers = append(answers, maxT+1)
	}

	rand.Seed(12345681)

	lastAnswers := Dup(answers)
	lastScore, _ := scores(lastAnswers)

	start := time.Now()
	timeout := 1800 * time.Millisecond
	for time.Now().Sub(start) < timeout {
		d, q := rand.Intn(D)+1, rand.Intn(26)+1
		newAnswers := Dup(lastAnswers)
		newAnswers[d-1] = q
		newScore, _ := scores(newAnswers)
		if newScore >= lastScore {
			lastAnswers, lastScore = newAnswers, newScore
		}
	}

	for _, v := range lastAnswers {
		fmt.Println(v)
	}
}

func Dup(xs []int) []int {
	return append([]int{}, xs...)
}

func scores(answers []int) (int, []int) {
	scores := []int{}
	last := make([]int, 26)
	score := 0
	for d := 1; d <= D; d++ {
		t := answers[d-1] - 1
		score += ss[d-1][t]
		last[t] = d
		for i := 0; i < 26; i++ {
			score -= cs[i] * (d - last[i])
		}
		scores = append(scores, score)
	}
	return score, scores
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6608
h, w = list(map(int, input().split()))
a = [list(map(lambda x: int(x) & 1, input().split())) for i in range(h)]
ans = []
for i in range(h):
    for j in range(w-1):
        if a[i][j] & 1 == 1:
            ans.append(' '.join([str(i+1), str(j+1), str(i+1), str(j+2)]))
            a[i][j+1] += 1
for i in range(h-1):
    if a[i][-1] & 1 == 1:
        ans.append(' '.join([str(i+1), str(w), str(i+2), str(w)]))
        a[i+1][-1] += 1
print(len(ans))
for s in ans:
    print(s)

Measured memory_bytes: 16432
N = int(input())
H = list(map(int, input().split()))
ans = 0
count = 0
for i in range(1,N):

    if H[i-1] >= H[i]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0

ans = max(ans,count)

print(ans)

Measured memory_bytes: 14252
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    vector<string> str(k);
    rep(i, n){
        str[i % k].push_back(t[i]);
    }
    ll ans = 0;
    rep(i, k){
        vl dp(3, 0);
        for(auto &c:str[i]){
            vl ndp(3,0);
            if(c == 'r'){
                ndp[0] = max(dp[1], dp[2]);
                ndp[1] = max(dp[0], dp[2]);
                ndp[2] = max(dp[0], dp[1]) + p;
            }else if(c == 's'){
                ndp[0] = max(dp[1], dp[2]) + r;
                ndp[1] = max(dp[0], dp[2]);
                ndp[2] = max(dp[0], dp[1]);
            }else{
                ndp[0] = max(dp[1], dp[2]);
                ndp[1] = max(dp[0], dp[2]) + s;
                ndp[2] = max(dp[0], dp[1]);
            }
            dp = ndp;
        }
        ans += max(dp[0], max(dp[1], dp[2]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::*;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: i64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        S: Chars,
    }

    let R = S.iter().filter(|&&s| s == 'R').count();
    let G = S.iter().filter(|&&s| s == 'G').count();
    let B = S.iter().filter(|&&s| s == 'B').count();

    let mut ans = R * G * B;

    for i in 0..N {
        for k in i+1..N {
            let j2 = i + k;
            if j2 % 2 == 1 {
                continue;
            }

            let mut V = HashSet::new();
            V.insert(S[i]);
            V.insert(S[k]);
            V.insert(S[j2 / 2]);

            if V.len() == 3 {
                ans -= 1;
            }
        }
    }

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


Measured memory_bytes: 2200
#include<cstdio>

int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);

    d = a/b;
    r = a%b;
    f = double(a)/double(b);

    printf("%d %d %.5lf\n", d,r,f);
    return 0;
}



Measured memory_bytes: 2736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int a,b;
char grid[100][100];
int main(void){
    cin>>a>>b;
    cout<<"100 100\n";
    --a;
    --b;
    for(int i=-1;++i-2500;){
        if(a<=0||(i/50)&1)cout<<"##";
        else{
            cout<<".#";
            --a;
        }
        if(i%50==49)cout<<"\n";
    }
    for(int i=-1;++i-2500;){
        if(b<=0||~(i/50)&1)cout<<"..";
        else{
            cout<<".#";
            --b;
        }
        if(i%50==49)cout<<"\n";
    }
}

Measured memory_bytes: 256
# include "stdio.h"

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    if((a==5&&b==5&&c==7)||(a==7&&b==5&&c==5)||(a==5&&b==7&&c==5)){
       printf("YES\n");
    }else{
       printf("NO\n");
    }


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;

int main() {
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        printf("%.3lf %.3lf\n",round((b*f-c*e)/(b*d-a*e)*1000)/1000+EPS,round((c*d-a*f)/(b*d-a*e)*1000)/1000+EPS);
    }
    return 0;
}



Measured memory_bytes: 3332
s = int(input())

def f(n):
    if n % 2 == 0:
        return n//2
    else:
        return 3*n+1

if s in [1,2,4]:
    print(4)
else:
    count = 1
    while s != 4:
        s = f(s)
        count += 1
    print(count+3)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S; cin >> S;
    ll cnt = 0;
    rep(i, S.size()){
        if (S[i] - '0' == 1){cnt++;}
    }
    cout << cnt << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

typedef long long ll;


int main()
{
    ash;
    int n;
    cin>>n;
    int l=n/100;
    int r=n%100;
    if(l>=1&&l<12){
        if(r>=1&&r<=12)
            cout<<"AMBIGUOUS\n";
        else
            cout<<"MMYY\n";
    }
    else{
        if(r>=1&&r<=12)
            cout<<"YYMM\n";
        else
            cout<<"NA\n";
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    string s; cin >> s;
    sort(s.begin(), s.end());
    puts(s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes":"No");
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N],ans[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	long long sum=0,tot=0;
	for(int i=2;i<=n;i+=2)
		sum+=a[i]; 
	for(int i=1;i<=n;i++)
		tot+=a[i];
	tot/=2;
	for(int i=1;i<=n;i+=2)
	{
		if(i!=1)
			sum=sum+a[i-2]-a[i-1];
		ans[i]=(tot-sum)*2;
	} 
	sum=0;
	for(int i=3;i<=n;i+=2)
		sum+=a[i];
	for(int i=2;i<=n;i+=2)
	{
		if(i!=2)
			sum=sum+a[i-2]-a[i-1];
		ans[i]=(tot-sum)*2;
	} 
	for(int i=1;i<=n;i++)
		printf("%lld ",ans[i]);
	return 0;
}


Measured memory_bytes: 2048
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    int n;
    typedef tuple<int, int> t;
    vector<t> v;
    int inp;

    cin >> n;
    FOR(i, 1, n) {
        cin >> inp;
        v.push_back(make_tuple(inp, i));
    }

    sort(ALL(v));

    REP(i, n) {
        if (i != 0) {
            cout << " ";
        }
        cout << get<1>(v.at(i));
    }
    cout << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "4";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int k;
    cin >> k;
    
    while (k--) {
        cout << "ACL";
    }

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


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


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

  int a,b,n;
  cin>>a>>b>>n;
  if(n<b)
  {
    int ans=(n*a)/b-a*(n/b);
    cout<<ans;
  }
  else
  {
    n-=n%b;
    n--;    
    int ans=(n*a)/b-a*(n/b);
    cout<<ans;
  }
  

}

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

int main(){
  int a,b;
  string s;
  cin >> a >> b >> s;
  bool ans=true;
  for(int i=0;i<s.size();i++){
    if(i==a){
      if(s[i]!='-'){
        ans=false;
      }
    }else{
      if (s[i]<'0'||s[i]>'9'){
        ans=false;
      }
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

typedef enum {false, true} bool;


int main(void)
{
    int N;
    bool flag, ans;
    int a[3], ai;
    int a_num[3];
    char c;
    int i, j;
    int ctr;
    int temp;
    
    
    ans = true;
    
    ctr = 0;
    
    
    scanf("%d%c", &N, &c);
    
    
    for(i=0; i<N; i++)
    {
        scanf("%d%c", &ai, &c);
        
        
        flag = false;
        
        for(j=0; j<ctr; j++)
        {
            if(ai == a[j])
            {
                flag = true;
                
                a_num[j]++;
                
                break;
            }
        }
        
        if(!flag)
        {
            if(ctr < 3)
            {
                a[ctr] = ai;
                a_num[ctr++] = 1;
            }
            else
            {
                ans = false;
            
                break;
            }
        }
    }
    
    
    if(ans)
    {
        ans = false;
        
        
        switch(ctr)
        {
            case 1:
                if(a[0] == 0)
                    ans = true;
                
                break;
                
            case 2:
                if(a[0] == 0 && a_num[0]*2 == a_num[1])
                {
                    ans = true;
                }
                else if(a[1] == 0 && a_num[1]*2 == a_num[0])
                {
                    ans = true;
                }
                
                break;
                
            case 3:
                temp = a[0] ^ a[2];
                
                if(temp == a[1])
                {
                    if(a_num[0] == a_num[1] && a_num[1] == a_num[2])
                        ans = true;
                }
        }
    }
    
    
    if(ans)
        printf("Yes\n");
    else
        printf("No\n");
    
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC045A
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());



            Console.WriteLine((a + b) * h / 2);
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();

    sc.close();

    int count = K;

    for (int i = 1; i < N; i++) {
      count = count * (K - 1);
    }

    System.out.println(count);

  }

}

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

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

	int c,a,n;
	for(int i=0; i<Q; i++){
		cin >>c>>a>>n;
		int ans=0;

		int tmp=n;
		for(int i=0; i<tmp; i++){
			if(a>0&&c>0){
				ans++;
				n--;
				a--;
				c--;
			}
		}

		tmp=a;
		for(int i=0; i<tmp; i++){
			if(c>1){ 
				ans++;
				a--;
				c=c-2;
			}
		}
		ans=ans+c/3;

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define per(i,a,b) for (int i=a;i>=b;i--)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=a;i<b;i++)
#define maxn 10000005
int n;
#define mod 998244353
void add(int&x,int y){
	x=(x+y)%mod;
}
int pw2[maxn],fac[maxn],inv[maxn];
int power(int a,int b,int p){
	int s=1,w=a;while (b){
		if (b&1)s=1ll*s*w%p;
		w=1ll*w*w%p;b>>=1;
	}
	return s;
}
int C(int a,int b){
	return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main(){
	scanf("%d",&n);int res=0;
	pw2[0]=1;rep(i,1,n)pw2[i]=2*pw2[i-1]%mod;
	fac[0]=1;rep(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=power(fac[n],mod-2,mod);
	per(i,n,1)inv[i-1]=1ll*inv[i]*i%mod;
	rep(i,n/2+1,n)
		add(res,2ll*C(n,i)*pw2[n-i]%mod);
	res = (power(3,n,mod)-res+mod)%mod;
	printf("%d\n",res);
	return 0;
}

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

typedef pair<int64_t,int64_t> ii;
ii a[200005];
int64_t n,k,res=0,Count=1,b[200005],tree[200005];

void Update(int idx)
{
    while(idx<=Count)
    {
        tree[idx]++;
        idx+=idx&-idx;
    }
}

int64_t Query(int idx)
{
    int64_t rs=0;
    while(idx>0)
    {
        rs+=tree[idx];
        idx-=idx&-idx;
    }
    return rs;
}

int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].first;
        a[i].first+=a[i-1].first-k;
        a[i].second=i;
    }
    sort(a,a+n+1);
    b[a[0].second]=1;
    for(int i=1;i<=n;i++)
        if(a[i].first!=a[i-1].first)
            b[a[i].second]=++Count;
        else
            b[a[i].second]=Count;
    Update(b[0]);
    for(int i=1;i<=n;i++)
    {
        res+=Query(b[i]);
        Update(b[i]);
    }
    cout<<res;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#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-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<6-a-b<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;

  for(int i = 1;i <= 9;i++){
    if(n % i == 0 && n/i <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
a, b = input().split()
a = int(a)
b = int(b)
ans = 0
for i in range(1, a + 1):
    c = 0
    if i == a:
        c = b + 1
    else:
        c = 13
    for j in range(1, c):
        if i == j:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <cstdlib>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N], B[N], C[N-1];

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

    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N-1; i++){
        cin >> C[i];
    }
    int ret = 0;

    for(int i = 0; i < N; i++){
        ret += B[A[i]-1];
        if(i > 0 && A[i-1] +1 == A[i]){
            ret += C[A[i-1]-1];
        }
    }
    cout << ret << endl;
    return 0;
}

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

int main(){

	int E, Y;
	cin >> E >> Y;

	// 和暦から西暦へ変換するとき
	if(E == 1) cout << 1867 + Y << endl ;
	else if(E == 2) cout << 1911 + Y << endl ;
	else if(E == 3) cout << 1925 + Y << endl ;
	else if(E == 4) cout << 1988 + Y << endl ;

	// 西暦から和暦へ変換するとき
	if(1868 <= Y && Y <= 1911) cout << "M" << Y - 1867 << endl;
	else if(1912 <= Y && Y <= 1925) cout << "T" << Y - 1911 << endl ;
	else if(1926 <= Y && Y <= 1988) cout << "S" << Y - 1925 << endl ;
	else if(1989 <= Y && Y <= 2016) cout << "H" << Y - 1988 << endl ;


	return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n,ans(0);
    char t('0');
    cin >> n >> t;
    rep(i,n-1){
        char c; cin >> c;
        if(c!=t){
            ans++;
            t = c;
        }
    }

    cout << ans+1 << endl;

    return 0;
}

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

int main() {

int n, m;
cin >> n >> m;
int a, p = 0, c = 0;
string s;
int ar[n + 1], pe[n + 1];
for(int i = 0; i < n +1; ++i) ar[i] = 0, pe[i] = 0;
for(int i = 0; i < m; ++i){
	cin >> a >> s;
	if(s == "WA"){
		if(ar[a] != 1) pe[a]++;
	} 
	else if(s == "AC"){

		ar[a] = 1;
	}
}
for(int i = 0; i < n + 1; ++i){
	if(ar[i] > 0) c+=ar[i], p+=pe[i];
}
cout << c << ' ' << p;
return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
#define IO if(fopen("input.txt", "r")){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);} std::ios::sync_with_stdio(false);
using namespace std;


signed main()
{

    IO
    int t = 1;
    // cin >> t;
    while (t--) {


        int n;
        cin >> n;
        int ans = 0, cnt = 0;
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            if (a == b) cnt++;
            else cnt = 0;

            if (cnt >= 3) {
                ans = 1;
            }
        }

        if (ans == 1) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }

    }


    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from itertools import accumulate
import copy


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline()[:-1] for _ in range(line)]


H, W, K = zz()
C = []
for h in range(H):
    tmp = S()
    value = []
    for _tmp in tmp[:-1]:
        if (_tmp == '#'):
            value.append(1)
        else:
            value.append(0)
    C.append(value)

C = np.array(C)
ans = 0
for h in itertools.product([0, 1], repeat=H):
    for w in itertools.product([0, 1], repeat=W):
        tmp_C = copy.copy(C)

        for i, _h in enumerate(h):
            if (_h == 1):
                tmp_C[i, :] = 0
        for i, _w in enumerate(w):
            if (_w == 1):
                tmp_C[:, i] = 0
        if (np.sum(tmp_C) == K):
            ans += 1
print(ans)


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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007

//container-use 

typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< ll,ll > pll;
typedef vector<pair<ll,ll > > vpl;
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define rep(i,a,b) for (int i = a; i <= b; i++)

//main function here
ll power(ll x,ll y)
{
    ll p=mod;
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
     if (y & 1)
      res = (res*x) % p;
     y = y>>1;
     x = (x*x) % p;
  }
    return res;
}
#define sizes 1000010
#define PI 3.14159265


ll fact[sizes];
ll inv[sizes];
ll invfact[sizes];
ll ncr(ll n,ll i)
{
  return (((fact[n]*invfact[i])%mod)*invfact[n-i])%mod;
}
void factorial()
{
  fact[0]=1;
  for (ll i = 1; i <= sizes-5; i++)
  fact[i]=(fact[i-1]*i)%mod;
}
void invfactorial()
{
    inv[0] = inv[1] = invfact[0]=1;
    for (ll i = 2; i <= sizes-5; i++)
        inv[i] = (inv[mod % i] * (mod - mod / i) )% mod;
    for (ll i = 1; i <=sizes -5; i++)
        invfact[i]=(invfact[i-1]*inv[i])%mod;
}
ll def(ll n,ll r)
{
    ll a=n-r,res=1;
    for(ll i=a+1;i<=n;i++)
    {
        res=(res*i)%mod;
    }
    return (res*invfact[r])%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n,a,b;
    cin>>n>>a>>b;
    ll res=power(2,n)-1;
    factorial();
    invfactorial();
    // cout<<def(3,1)<<"\n";
    cout<<((res-def(n,a)-def(n,b))%mod + mod)%mod;
  return 0;
 }

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long


using namespace std;
const int N = 500077;
int n, m, k, l, r, d;
int a[N];
int b[N];


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> l >> r >> d;
    int col = r / d - l / d;
    if (l % d == 0){
        col++;
    }
    cout << col << endl;


}


Measured memory_bytes: 3612
function main(input) {
  var n = input[0]-0;
  var a = 0;
  for(var i=1;i<=n;i++){
    if(i%2==1) a++;
  }
  console.log(a/n);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 11468
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,len=0,to[100010],num=0,sum=0,ans=0;
pii a[100010];
vector <pii> v[100010];
vector <LL> fliu,flid;
bool has[100010];

int main()
{
	cin>>n>>k;
	rep(i,n) scanf("%lld%lld",&a[i].se,&a[i].fi);
	sort(a,a+n);
	rep(i,n)
	{
		if(!has[a[i].se])
		{
			has[a[i].se]=true;
			to[a[i].se]=len++;
		}
		v[to[a[i].se]].pb({a[i].fi,i});
	}
	rep(i,len)
	{
		sort(v[i].begin(),v[i].end());
		rep(j,v[i].size())
		{
			if(v[i][j].se>=n-k&&j<v[i].size()-1) flid.pb(v[i][j].fi);
			if(v[i][j].se<n-k&&j==v[i].size()-1) fliu.pb(v[i][j].fi);
			if(v[i][j].se>=n-k&&j==v[i].size()-1) num++;
			if(v[i][j].se>=n-k) sum+=v[i][j].fi;
		}
	}
	ans=max(ans,sum+sqr(num));
	sort(fliu.begin(),fliu.end());
	sort(flid.begin(),flid.end());
	for(int i=fliu.size()-1,j=0;i>=0&&j<flid.size();i--,j++)
	{
		num++;
		sum+=fliu[i]-flid[j];
		ans=max(ans,sum+sqr(num));
	}
	cout<<ans<<endl;
	rt0;
}


Measured memory_bytes: 8828
// Last Change: 11/09/2019 22:27:02.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const ll MOD = 998244353;

ll powerfulPow(ll x, ll n) {
  if (n == 0) {
    return 1;
  }
  if (n % 2 == 0) {
    return powerfulPow((x * x) % MOD, n / 2) % MOD;
  } else {
    return (x * powerfulPow(x, n - 1)) % MOD;
  }
}

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

  if (D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  if (dists[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  for (ll i = 1; i < N; ++i) {
    if (dists[i] > 0 and dists[i - 1] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll res = 1;
  ll last = N;
  for (last = N; last >= 1; --last) {
    if (dists[last - 1] != 0) {
      break;
    }
  }

  for (ll i = 1; i < last; ++i) {
    res = (res * (powerfulPow(dists[i - 1], dists[i]) % MOD)) % MOD;
    res %= MOD;
  }

  cout << res % MOD << endl;

  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pii > VPI;
typedef vector<pll > VPL;
const int mod = 1000000007;

ll A;

ll cal(ll v){
    ll t = A;
    while(t >= v){
        if(t % v == 0) t /= v;
        else t %= v;
    }
    return t;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //cin >> n;
    //REP(i, 2, n){
      //  if(cal(i) == 1) printf("%d\n", i);
    //}
    cin >> A;
    ll B = A - 1;
    ll ans = 0, tB = B;
    for(ll k = 2; k * k <= A; ++k) if(A % k == 0){
        if(cal(k) == 1) ans++;//, printf("%lld\n", k);
    }
    ll res = 1;
    for(ll k = 2; k * k <= B; ++k) if(tB % k == 0){
        int num = 0;
        while(tB % k == 0){
            num++;
            tB /= k;
        }
        res *= (num + 1);
    }
    if(tB > 1) res *= 2LL;
    cout << ans + res << endl;
    return 0;
}


Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
struct Segment{
	Point p1,p2;
};
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
Point project(Segment s,Point p){
	Vector base=s.p1-s.p2;
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r;
}
Point reflect(Segment s,Point p){
	return p+(project(s,p)-p)*2;
}
main(){
	int x1,y1,x2,y2;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	Point p1(x1,y1),p2(x2,y2);
	Segment s;
	s.p1=p1;s.p2=p2;
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d%d",&x1,&y1);
		Point p=reflect(s,Point(x1,y1));
		printf("%.10lf %.10lf\n",p.x,p.y);
	}	
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 85;

int n, a[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int money = 1000, stocks = 0;
    for(int i = 0; i < n; i++)
    {
        if(i < n - 1 && a[i] < a[i + 1])
        {
            stocks += money / a[i];
            money %= a[i];
        }
        else
        {
            money += stocks * a[i];
            stocks = 0;
        }
    }
    cout << money << "\n";
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
li = []
ans = 0
count = 1
for i in range(N):
    s = list(str(input()))
    s.sort()
    li += [s]
li.sort()
li += ["a"]
for j in range(N):
    if li[j]==li[j+1]:
        count += 1
    else:
        ans += (count*(count-1))//2
        count = 1
print(ans)

Measured memory_bytes: 24652
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

string solve(int n, const vector<char>& ss){
    if(any_of(begin(ss), end(ss), [](char s){return s == 'Y';})){
        return "Four";
    }else{
        return "Three";
    }
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<char> ss(n);
    cin >> ss;

    cout << solve(n, ss) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

bool solve(int n, int m, string s, vector<set<int> > const & g) {
    vector<int> a(n), b(n);
    REP (i, n) for (int j : g[i]) {
        (s[j] == 'A' ? a : b)[i] += 1;
    }

    vector<bool> removed(n);
    function<void (int)> go = [&](int i) {
        if (a[i] and b[i]) return;
        if (removed[i]) return;
        removed[i] = true;
        for (int j : g[i]) if (not removed[j]) {
            (s[i] == 'A' ? a : b)[j] -= 1;
            if (not a[j] or not b[j]) {
                go(j);
            }
        }
    };
    REP (i, n) {
        go(i);
    }

    return count(ALL(removed), false);
}

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<set<int> > g(n);
    REP (i, m) {
        int a, b; cin >> a >> b;
        -- a; -- b;
        g[a].insert(b);
        g[b].insert(a);
    }
    cout << (solve(n, m, s, g) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 33156
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  ll n=s.size();
  ll ans=n*(n-1)/2;
  map<char,ll>mp;
  rep(i,n){
    mp[s[i]]++;
  }
  for(auto p:mp){
    ans-=p.second*(p.second-1)/2;
  }
  ans++;
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 720
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    X=list(map(int,input().split()))
    ans=0
    for i in range(n-1):
        ans+=min(a*(X[i+1]-X[i]),b)
    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 14224
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

#define MAX 1000000005
 
typedef long long ll;
typedef pair<int, int> P;

int main(int, char**)
{
    string s, t;
    cin >> s >> t;

    if (s == t.substr(0, s.size())) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3600
n,k = map(int,input().split())
ans = 0
ans2 = 0
for i in range(1,n+1):
    if i % k == 0:
        ans += 1
    if i % k == k//2 and k%2 == 0:
        ans2 += 1
print(ans**3 + ans2**3)


Measured memory_bytes: 3068
# coding=utf-8

if __name__ == '__main__':

    N = int(input())
    otsdm = 0

    for i in range(N):
        x = list(input().split())

        if x[1] == 'JPY':
            otsdm = otsdm + float(x[0])
        else:
            otsdm = otsdm + float(x[0]) * 380000

    print(otsdm)

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

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

using namespace std;

typedef long long ll;

#define pf(n) printf("%d\n",n)
#define sf(n) scanf("%d",&n)
#define in(n) for(int i=0;i<n;i++)
#define vi vector<int>
#define vs vector<string>
#define sort(a) sort(a.begin(),a.end())

int main()
{
    int n;
    sf(n);
    int m;
    sf(m);
    vi l(m);
    vi r(m);
    in(m)
    {
        sf(l[i]);
        sf(r[i]);
    }
    sort(l);
    sort(r);
    if(l[m-1]<=r[0])
        pf(abs(l[m-1]-r[0])+1);
    else pf(0);
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int a, b, max = -1000;

	scanf("%d %d", &a, &b);

	if (a + b >= max) max = a + b;
	if (a - b >= max) max = a - b;
	if (a * b >= max) max = a * b;

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

	return 0;
}

Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  set<int> s;
  while (q--) {
    if (in()) {
      cout << s.count(in()) << endl;
    } else {
      s.emplace(in());
      cout << s.size() << endl;
    }
  }
}



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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ll n;
    cin >> n;
    ll minNum = 10000000000000000;
    VLL array(5);
    rep(i,5){
        cin >> array[i];
        minNum = min(minNum,array[i]);
    }
    cout << 4 + (ll)ceil(n/(double)minNum) << endl;

    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else {
    cout << "a == b" << endl;
  }
  return 0;
}



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

#define MAXN 3000

using namespace std;

double coin[MAXN];
double acumH[MAXN];
double acumT[MAXN];
double dp[MAXN][MAXN];
bool already[MAXN][MAXN];
int n;

double Solve(int heads, int x = 0){
    if(!already[heads][x]) {
        already[heads][x] = true;
        if (heads == n - x)
            dp[heads][x] = acumH[x];
        else if(heads == 0)
            dp[heads][x] = acumT[x];
        else if(x < n - 1){
            if(heads > 0)
                dp[heads][x] += Solve(heads - 1, x + 1) * coin[x];
            dp[heads][x] += Solve(heads, x + 1) * (1 - coin[x]);
        }
    }
    return dp[heads][x];
}

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

    cout << setprecision(10) << fixed;
    cin >> n;

    for(int i = 0; i < n; ++i)
        cin >> coin[i];

    acumH[n - 1] = coin[n - 1];
    acumT[n - 1] = 1 - coin[n - 1];
    for(int i = n - 2; i >= 0; i--){
        acumH[i] = coin[i] * acumH[i + 1];
        acumT[i] = (1 - coin[i]) * acumT[i + 1];
    }

    double ans = 0;
    for(int i = 0; i <= n / 2; ++i)
        ans += Solve(n - i);

    cout << ans << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 78464
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 個数の入力
		int n = sc.nextInt();
      	int[] w = new int[n];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	}
}

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

using namespace std;

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    vector<vector<int>> tree(n + 1);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
    }
    queue<pair<int, int>> qa;
    qa.emplace(make_pair(v, 0));
    vector<int> dis_a(n + 1, -1);
    dis_a[v] = 0;
    while (!qa.empty()) {
        auto front = qa.front();
        qa.pop();
        for (auto e: tree[front.first]) {
            if (dis_a[e] < 0) {
                dis_a[e] = front.second + 1;
                qa.emplace(make_pair(e, front.second + 1));
            }
        }
    }

    queue<pair<int, int>> qb;
    qb.emplace(make_pair(u, 0));
    vector<int> dis_t(n + 1, -1);
    dis_t[u] = 0;
    while (!qb.empty()) {
        auto front = qb.front();
        qb.pop();
        for (auto e: tree[front.first]) {
            if (dis_t[e] < 0) {
                dis_t[e] = front.second + 1;
                qb.emplace(make_pair(e, front.second + 1));
            }
        }
    }

    int ans = -1;
    for (int i = 1; i <= n; i++) {
        if (dis_a[i] > dis_t[i] && dis_t[i] >= 0) {
            ans = max(ans, dis_a[i]);
        }
    }

    if (ans == 0) {
        cout << 1 << endl;
    } else {
        cout << ans - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6784