akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll M;
    cin >> M;
    ll sum = 0;
    ll order = 0;
    ll d,c;
    for (ll i = 0; i < M; i++) {
        cin >> d >> c;
        sum += d*c;
        order += c;
    }
    cout << order - 1 + (sum-1) / 9 << endl;
}

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

int main() {
  int n,ans,naka = 0,oshiri = 0,atama = 0,shiriatama = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    for(int j = 0;j < s.size()-2;j++){
      if(s.at(j) == 'A' && s.at(j+1) == 'B'){
        naka++;
      }
    }
    if(s.at(0) == 'B' && s.at(s.size()-1) == 'A'){
      shiriatama++;
    }
    else if(s.at(0) == 'B'){
      atama++;
    }
    else if(s.at(s.size()-1) == 'A'){
      oshiri++;
    }
  }
  if(atama < oshiri){
    ans = atama + shiriatama + naka;
  }
  else if(atama > oshiri){
    ans = oshiri + shiriatama + naka;
  }
  else if(shiriatama != 0){
    if(oshiri == 0 && atama == 0){
      ans = naka + shiriatama-1;
    }
    else{
      ans  = oshiri + naka + shiriatama;
    }
  }
  else{
    ans = oshiri + naka;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if (s.equals("RRR")) {
      System.out.println("3");
    } else if (s.equals("RRS") || s.equals("SRR")) {
      System.out.println("2");
    } else if (s.equals("RSS") || s.equals("SRS") || s.equals("SSR") || s.equals("RSR")) {
      System.out.println("1");
    } else {
      System.out.println("0");
    }
  }
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N;
	int D;
	cin >> D >> N;
	if (D == 0) {
		if (N == 100) {
			cout << 101;
			return 0;
		}
		cout << N;
	}
	else if(D ==1) {
		if (N == 100) {
			cout << 10100;
			return 0;
		}
		cout << N*100;
	}
	else if (D == 2) {
		if (N == 100) {
			cout << 1010000;
			return 0;
		}
		cout << N*10000;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N, K;
    int ans = 0;
    cin >> N >> K;
    rep(i, N){
        int h;
        cin >> h;
        if(h>=K) ans++;
    }
    cout << ans << endl;
    return 0;

}


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

using namespace std;
#define int long long
#define endl '\n'



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        if (s[0] == 'A') c1++;
        if (s[0] == 'W') c2++;
        if (s[0] == 'T') c3++;
        if (s[0] == 'R') c4++;
    }
    cout << "AC x " << c1 << endl;
    cout << "WA x " << c2 << endl;
    cout << "TLE x " << c3 << endl;
    cout << "RE x " << c4 << endl;
    return 0;
}


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

#define MIN 10
#define ll long long

int digits(ll int num){    /*桁数を返す*/
    ll int dig = 1;
    int i = 0;
    if(num == 1)return 1;

    while(dig <= num){
        dig *= 10;
        i++;
    }
    return i;
}

int main(){
    ll int N,A,B;
    ll int i;
    cin >> N;

    for(i=1;i*i<=N;i++){  /*N=A*Bを満たすAを探索*/
        if(N % i == 0)A = i;
    }

    cout << digits(N / A) << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
tr=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    tr[x].append(y)
    tr[y].append(x)
from collections import deque
seen=[-1]*n
todo=deque([0])
while todo:
    v=todo.popleft()
    seen[v]=1
    for nv in tr[v]:
        if seen[nv]==-1:
            todo.append(nv)
v0=v
seen=[-1]*n
todo=deque([v])
seen[v]=0
while todo:
    v=todo.popleft()
    for nv in tr[v]:
        if seen[nv]==-1:
            todo.append(nv)
            seen[nv]=seen[v]+1
c=seen[v]
c+=1
if c%3==2:
    print('Second')
else:
    print('First')


Measured memory_bytes: 50260
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;cin>>n;
    priority_queue<long long int>pq;
    for(long long int j=0;j<n;j++){long long int num;cin>>num;pq.push(num);};
    long long int a=0,b=0,i=0;
    while(pq.size()>0)
    {
        if(i%2==0)
        a+=pq.top();
        else
        b+=pq.top();
        pq.pop();
        i++;
    }
    cout<<abs(a-b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, a, b := io.NextInt(), io.NextInt(), io.NextInt()
	p := io.NextInts(n)
	sort.Ints(p)
	i := sort.Search(n, func(i int) bool { return p[i] > a })
	j := sort.Search(n, func(j int) bool { return p[j] > b })
	first := i
	second := j - i
	third := n - j
	ans := Min(first, second, third)
	io.Println(ans)
}

// Min returns minimum value of inputs
func Min(a ...int) (min int) {
	for i, ai := range a {
		if i == 0 || ai < min {
			min = ai
		}
	}
	return min
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1784
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define rank rank228
#define y1 y1228
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
using ll = long long;
using ld = long double;
// const int MAXMEM = 200 * 1000 * 1024;
// char _memory[MAXMEM];
// size_t _ptr = 0;
// void* operator new(size_t _x) { _ptr += _x; return _memory + _ptr - _x; }
// void operator delete (void*) noexcept {}
const string FILENAME = "input";




int n, k, s;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  //	read(FILENAME);     
    cin >> n >> k >> s;
    if (k == 0) {
        for (int i = 0; i < n; i++) {
            cout << (s + 1 == 1000000001 ? 1: s + 1) << ' ';
        }
        cout << '\n';
        return 0;
    }
    for (int i = 0; i < k; i++) {
        cout << s << ' ';
    }
    for (int i = 0; i < n - k; i++) {
        cout << (s + 1 == 1000000001 ? 1: s + 1) << ' ';
    }
    cout << '\n';
    return 0;
}            	


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt(),R = sc.nextInt();
		if(N >= 10) pw.print(R);
		else pw.print(100*(10-N)+R);
		pw.close();
	}
	
	static  class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n, m, x;
    std::cin>>n>>m>>x;
    std::vector<int> a(m);
    for(auto i = a.begin();i != a.end();i++){
        std::cin>>*i;
    }

    int left = 0;
    int right = 0;
    for(auto i = a.begin(); i != a.end();i++){
        if(*i < x){
            ++left;
        }
        if(*i > x){
            ++right;
        }
    }
    std::cout<<std::min(left, right)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    //N even
    int n = sc.nextInt();
    //M odds
    int m = sc.nextInt();
    //ans N only
    int ansN = 0;
    //ans M only
    int ansM = 0;
    
    ansN = n*(n-1)/2;
    ansM = m*(m-1)/2;      

    System.out.println(ansN + ansM);
    
  }
}

Measured memory_bytes: 21844
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin>>n;
string s=to_string(n);
int l=s.size();
if(s[l-1]=='2'||s[l-1]=='4'||s[l-1]=='5'||s[l-1]=='7'||s[l-1]=='9')
{
    cout<<"hon"<<endl;
}
else if(s[l-1]=='0'||s[l-1]=='1'||s[l-1]=='6'||s[l-1]=='8')
{
    cout<<"pon"<<endl;
}
else
    cout<<"bon"<<endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    char copy;
    string s,t;
    int count=0;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    
    for(int i=0;i<min(s.size(),t.size());i++){
        if(s[i]<t[i]){
            cout<<"Yes"<<endl;
            return 0;
        }
        else if(s[i]>t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(t.size()==min(s.size(),t.size())){    
    cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vl a(n); REP(i, n) cin >> a[i];

	ll c = 1;
	ll ans = a[0] - 1;
	FOR(i, 1, n) if(a[i] > c) {
		if (a[i] == c + 1) {
			c++;
		} else {
			ans += (a[i] - 1) / (c + 1);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
turu, kame = (0, 0)

x , y = map(int, input().split())

flag = False
for i in range(x + 1):
    turu = i
    kame = x - i
    
    if turu * 2 + kame * 4 == y:
        flag = True
        
if flag:
    print('Yes')
else:
    print('No')

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
   int n,m;
   cin >>n >> m;
   vector<int> v(n);
   ll sum=0;
   for(int i=0;i<m;i++)
   {
       cin >> v[i];
       sum+=v[i];
   }
   cout << max((ll)-1,n-sum) << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[10];
  cin >> s;
  sort(s, s+ 4);
  bool ans = (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]);
  ans ? cout << "Yes": cout << "No";
  return 0;
}

Measured memory_bytes: 256
fac = [0] * 700000
finv = [0] * 700000
inv = [0] * 700000
mod = 1000000007

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, 700000):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod

x, y = map(int, input().split())

if (x + y) % 3 == 0:
    k = (2 * x - y) // 3
    l = (2 * y - x) // 3
    if k >= 0 and l >= 0:
        print(fac[k + l] * (finv[k] * finv[l] % mod) % mod)
    else:
        print(0)
else:
    print(0)


Measured memory_bytes: 86244
import java.io.*;
import java.util.*;
class Main{
    public static void main(String []args){
        Scanner in = new Scanner(System.in);
        int w = in.nextInt();
        int h = in.nextInt();
        int n = in.nextInt();
        int t[][] = new int[w][h];
        while(n-->0){
            int x = in.nextInt();
            int y = in.nextInt();

            int a = in.nextInt();
            switch(a){
                case 1: for(int i = 0;i< x;i++)
                    for(int j = 0; j< h; j++)t[i][j] = 1;
                    break;
                case 2:for(int i = x;i<w;i++)
                    for(int j = 0; j<h;j++)t[i][j] = 1;
                    break;
                    case 3:for(int i = 0; i < w;i++)
                    for(int j = 0 ;j<y;j++)t[i][j]  = 1;
                    break;
                case 4:for(int i = 0;i<w;i++)
                    for(int j = y;j<h;j++)t[i][j] = 1;
            }
        }
        int ret = 0;
        for(int i = 0;i<w;i++){
            for(int j = 0; j<h;j++){
                if(t[i][j] ==0)
                    ret++;
            }
        }
        System.out.println(ret);
    }
}

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

int main() {
int a,b,c,t;
cin >> a >> b >> c;
if (a > b) {
t = a;
a = b;
b = t;
} 
if (b > c) {
t = c;
c = b;
b = t;
}
if (a > b) {
t = a;
a = b;
b = t;
} 
cout << a <<" "<< b <<" "<< c<< endl;

return 0;
}


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

string s;
int k, n, dp[302][302][302];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> k;
	n = s.size();
	s = 'N' + s;
	for(int i = 1; i <= n; ++i) {
		dp[0][i][i] = 1;
		if(i < n) dp[0][i][i + 1] = 1 + (int)(s[i] == s[i + 1]);
	}
	for(int i = 2; i < n; ++i) {
		for(int j = 1; j + i <= n; ++j) {
			dp[0][j][j + i] = max(dp[0][j + 1][j + i], dp[0][j][j + i - 1]);
			if(s[j] == s[j + i]) dp[0][j][j + i] = dp[0][j + 1][j + i - 1] + 2;
		}
	}
	for(int r = 1; r <= k; ++r) {
		for(int i = 1; i <= n; ++i) {
			dp[r][i][i] = 1;
			if(i < n) dp[r][i][i + 1] = 2;
		}
		for(int i = 2; i < n; ++i) {
			for(int j = 1; j + i <= n; ++j) {
				if(s[j] == s[j + i]) dp[r][j][j + i] = dp[r][j + 1][j + i - 1] + 2;
				dp[r][j][j + i] = max(max(dp[r][j + 1][j + i], dp[r][j][j + i]), max(dp[r][j][j + i - 1], dp[r - 1][j + 1][j + i - 1] + 2));
			}
		}
	}
	cout << dp[k][1][n] << endl;
	return 0;
}

Measured memory_bytes: 107520
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a[200001],ans,t=1;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]==t)
		{
			ans++;
			t++;
		}
	}
	if(ans==0) printf("-1");
	else printf("%d",n-ans);
	return 0;
}

Measured memory_bytes: 1024
use std::io::BufRead;

fn main() {
    let s = std::io::stdin();
    let mut buf = s.lock();
    let mut s = String::new();
    let (n, m) = {
        buf.read_line(&mut s).unwrap();
        let mut it = s.trim().split_whitespace();
        let n: usize = it.next().unwrap().parse().unwrap();
        let m: usize = it.next().unwrap().parse().unwrap();
        (n, m)
    };
    let mut a = vec![(false, false); n];
    for _ in 0..m {
        s.clear();
        buf.read_line(&mut s).unwrap();
        let mut it = s.trim().split_whitespace();
        let x: usize = it.next().unwrap().parse().unwrap();
        let y: usize = it.next().unwrap().parse().unwrap();
        if x == 1 {
            a[y - 1].0 = true;
        }
        if y == n {
            a[x - 1].1 = true;
        }
    }
    for (a, b) in a {
        if a && b {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}


Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import fractions
    a, b, c, d = map(int, input().split())
    e = c * d // fractions.gcd(c, d)
    def main(x):
        ckosu=x//c
        dkosu=x//d
        ekosu=x//e
        return ckosu+dkosu-ekosu
    print(b-a+1-((main(b)-main(a-1))))
resolve()

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

int main() {
    int w, i;
    int b[] = {125, 140, 160};

    while (cin >> w) {
        if (w == -1) return 0;
        int diff = 4280 - 1150;
        w -= 10;
        for (i = 0; w > 10 && i < 2; w -= 10, i++) {
            diff -= 10 * b[i];
        }
        if (w > 0) diff -= w * b[i];
        cout << diff << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


const double PI = acos(-1);

int main(){
    ll x,y;
    cin>>x>>y;
    ll n = 100;
    for(ll i = 0; i<n; i++){
        for(ll j = 0; j<n; j++){
            if((2*i + 4*j) == y){
                if(i+j == x){
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");
    return 0;
}


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

int main(){
	char c,str[1000][1000];
	int i,j,flag=0;;
	
	for(i=0;;i++){
		for(j=0;;j++){
			scanf("%c",&c);
			if(c==' ')break;
			else if( c>=97 && c<=122)str[i][j]=c-32;
			else str[i][j]=c;
			
			if(c=='\n'){
				flag=1;
				break;
			}
		}
		if(flag==1)break;
	}
	for(j=0;j<=i;j++){
		printf("%s",str[j]);
		if(j<i)printf(" ");
	}
	
	return 0;
}

Measured memory_bytes: 996
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    long long X;

    cin >> X;

    for(long long i=-200; i<=200; ++i){
        for(long long j=-200; j<=200; ++j){
            long long calc = (i*i*i*i*i) - (j*j*j*j*j);
            if(calc == X){
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
 int n;
 cin >> n;
 vector <long double> p(n);
 for(int i = 0;i < n;i++){
 	cin >> p[i];
 }
 vector <vector <long double>> dp(n + 1,vector <long double>(n + 1,0));
 dp[1][1] = p[0];
 dp[1][0] = 1 - p[0];
 for(int i = 2;i <= n;i++){
 	 dp[i][0] = dp[i - 1][0]*(1 - p[i - 1]);
     for(int j = 1;j <= i;j++){
         dp[i][j] = dp[i - 1][j]*(1 - p[i - 1]) + dp[i-1][j-1]*p[i - 1];
         //cout << i << " " << j << " " << dp[i][j] << endl;
     }
 }
 long double ans = 0;
 for(int i = n/2 + 1;i <= n;i++){
     ans += dp[n][i];
 }
 cout << setprecision(10) << ans << endl;
 return 0;
}

Measured memory_bytes: 141056
#include<stdio.h>

int main()
{

  int i,j,n,a[100],flag=0,sw,u,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

  scanf("%d",&a[i]);

  }

  flag = 1;
  i=0;
  while(flag){
    flag = 0;

    for (j = n - 1; j >= i+1; j--) {
      if (a[j - 1] > a[j]) { 
	sw = a[j];        
	a[j] = a[j - 1];
	a[j - 1]= sw;
	flag = 1;
	count++;
      }

    }
    i++;
  }

  for(u=0;u<n-1;u++){
    printf("%d ",a[u]);
 }
  printf("%d",a[u]);
  printf("\n");
  printf("%d",count);
  printf("\n");
  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
int n,A[2000];
int solve(int i,int m){
  int res;
  if(m==0)
    return 1;
  if(i>=n)
    return 0;
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}
int main(){
  int q,m,i,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    a=solve(0,m);
    if(a==1)
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}




Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if (s=="keyence"){
		cout<<"YES"<<endl;
		return 0;
	}
	for (int i=0;i<s.size();i++)
		for (int j=1;j+i<=s.size();j++){
			string ss=s.substr(0,i)+s.substr(i+j);
			//cout<<i<<" "<<j<<" "<<ss<<endl;
			if (ss=="keyence"){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // long K = long.Parse(Console.ReadLine());
            // int[] ABC = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            // int Y = int.Parse(Console.ReadLine());
            // string A = Console.ReadLine();
            // string B = Console.ReadLine();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(int.Parse);
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // for(int i = 0; i<A_num.Length;i++){
            //     A_num[i] = 0;
            // }
            Console.WriteLine(((a+b)*h)/2);
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String a = scanner.nextLine();
            if (a.equals("0"))
                break;
            int sum = 0;
            for (char b : a.toCharArray()) {
                sum += Integer.parseInt(String.valueOf(b));
            }
            System.out.println(sum);
        }
    }

}



Measured memory_bytes: 26668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N=5000;
int n,k,q,b[N+10],c[N+10],d[N+10],ans=1e9;
bool vis[N+10];
struct data {
    int x;
    int loc;
}a[N+10];
bool cmp(data p,data q) {
    return p.x<q.x;
}
void work() {
    int num=0;
    for (int i=1;i<=n;) {
        int j=i;
        while (j<=n&&vis[j]==0) j++;
        int cnt=0;
        for (int kv=i;kv<j;kv++) c[++cnt]=b[kv];
        sort(c+1,c+cnt+1);
        for (int kv=1;kv<=cnt-k+1;kv++) d[++num]=c[kv];
        while (j<=n&&vis[j]==1) j++;
        i=j;
    }
    sort(d+1,d+num+1);
    if (num<q) return;
    ans=min(ans,d[q]-d[1]);
}
int main() {
    scanf("%d%d%d",&n,&k,&q);
    for (int i=1;i<=n;i++) {
        scanf("%d",&a[i].x);
        b[i]=a[i].x;
        a[i].loc=i;
    }
    sort(a+1,a+n+1,cmp);
    for (int i=1;i<=n;i++) {
        work();
        vis[a[i].loc]=1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const double eps = 1e-10;
const int mod =1e9+7;
const int maxn = 100000 + 100;
int a[maxn];
int poww(int a,int b){
    long long ans=1,base=a;
    while(b!=0){
        if(b&1!=0)(ans*=base)%=mod;
        (base*=base)%=mod;
        b>>=1;}
    return ans;
}
int main() {
#ifdef ac
    //freopen("in.txt" , "r" , stdin);
//    freopen("out.txt" , "w" , stdout);
#endif
    int n;
    cin >> n;
    for(int i=1;i<=n;++i) {
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    if(n&1) {
        int flag=0;
        for(int i=1;i<=n;++i) {
            if(!(i&1)) flag+=2;
            if(a[i]!=flag) {
                cout << 0<< endl;
                return 0;
            }
        }
    }
    else {
        int flag=-1;
        for(int i=1;i<=n;++i) {
            if(i&1)flag+=2;
            if(a[i]!=flag) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    int t=n/2;
    long long ans = poww(2,t);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] odd = new int[100001];
		int[] even = new int[100001];
		for(int i = 0; i < n; i++){
		    v[i] = sc.nextInt();
		    if(i%2 == 0){
		        odd[v[i]]++;
		    }else{
		        even[v[i]]++;
		    }
		}

		// 計算
		int result = 0;
		int oddFirstId = -1;
		int oddFirst = 0;
		int oddSecondId = -1;
		int oddSecond = 0;
		int evenFirstId = -1;
		int evenFirst = 0;
		int evenSecondId = -1;
		int evenSecond = 0;
		for(int i = 0; i < 100001; i++){
		    if(oddFirst < odd[i]){
		        oddSecondId = oddFirstId;
		        oddSecond = oddFirst;
		        oddFirstId = i;
		        oddFirst = odd[i];
		    }else if(oddSecond < odd[i]){
		        oddSecondId = i;
		        oddSecond = odd[i];
		    }
		    if(evenFirst < even[i]){
		        evenSecondId = evenFirstId;
		        evenSecond = evenFirst;
		        evenFirstId = i;
		        evenFirst = even[i];
		    }else if(evenSecond < even[i]){
		        evenSecondId = i;
		        evenSecond = even[i];
		    }
		}
		if(oddFirstId != evenFirstId){
		    result = n - (oddFirst + evenFirst);
		}else if(oddFirst + evenSecond < oddSecond + evenFirst){
		    result = n - (oddSecond + evenFirst);
		}else{
		    result = n - (oddFirst + evenSecond);
		}
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 59136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int n;
    int a[200010];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    qsort(a, n, sizeof(a[0]), asc);
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] == a[i + 1])
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 1788
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
MOD = 10 ** 9 + 7

N, T = MI()
A = LMI()

# m[i] := i以降で最大の値
m = [0] * N
for j, a in enumerate(reversed(A)):
    if j == 0:
        m[N - 1] = a
        continue
    i = N - j - 1
    m[i] = max(a, m[i + 1])

M = 0
M_cnt = 0
for i, a in enumerate(A):
    if i == N - 1:
        continue
    diff = m[i + 1] - a
    if diff > M:
        M = diff
        M_cnt = 1
    elif diff == M:
        M_cnt += 1
print(M_cnt)


Measured memory_bytes: 62704
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            var s = 0;
            var e = S.Length - 1;
            var ans = 0L;
            for (var i = 0; i < S.Length; --i)
            {
                if (S[s] == S[e])
                {
                    ++s;
                    --e;
                    if (e <= s)
                    {
                        WriteLine(ans);
                        return;
                    }
                    continue;
                }
                if (S[s] != 'x' && S[e] != 'x')
                {
                    WriteLine(-1);
                    return;
                }
                ++ans;
                if (S[s] == 'x')
                    ++s;
                if (S[e] == 'x')
                    --e;
            }
            //Out.Flush();
        }
    }
}


Measured memory_bytes: 13280
#最初に置いておくもの
import sys
sys.setrecursionlimit(500000) 
input=sys.stdin.readline


N=int(input())
A = list(map(int, input().split()))
inf=float('inf')
dp=[inf]*N

def chmin(a,b):
    return min(a,b)

def rec(n):
    if n==0:
        return 0
    if dp[n] < inf:
        return dp[n]
    
    res=rec(n-1) + abs(A[n] - A[n-1])
    if n>1:
        res=chmin(res,rec(n-2) + abs(A[n] - A[n-2]))
    dp[n]=res
    return res

print(rec(N-1))

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back
#define fst first
#define snd second

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void solve() {

}

int main() {
  string s;
  cin >> s;
  rep(i,3) cout << s[i]; puts("");
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
#define INF 1e18

void solve()
{
    ll N,M,S,T;
    vll to[100001];
    ll dp[100001][3];
    cin >> N >> M;
    for1(i,M) {
        ll u,v;
        cin >> u >> v;
        --u; --v;
        to[u].push_back(v);
        //to[v].push_back(u);
    }
    cin >> S >> T;
    --S; --T;
    for1(i,N) {
        for1(j,3) {
            dp[i][j] = INF;
        }
    }
    dp[S][0] = 1;

/*
    for1(i,N) {
        for1(j,3) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    cout << "----" << endl;
*/
    bool loop = false;
    do {
        loop = false;
        for1(i,N) {
            for (auto t: to[i]) {
                //cout << i << " --> " << t << endl;
                if (dp[t][1] > dp[i][0]) {
                    dp[t][1] = dp[i][0];
                    loop = true;
                }
                if (dp[t][2] > dp[i][1]) {
                    dp[t][2] = dp[i][1];
                    loop = true;
                }
                if (dp[t][0] > dp[i][2] + 1) {
                    dp[t][0] = dp[i][2] + 1;
                    loop = true;
                }
            }
        }

    } while (loop);

    if (dp[T][0] != INF) {
        cout << dp[T][0] - 1 << endl;
    } else {
        cout << -1 << endl;
    }
}

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


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string s;
	cin >> s;
	string arfa = "abcdefghijklmnopqrstuvwxyz";
	if (s.size() < 26) {
		map<char, int>c;
		for (int i = 0; i < s.size(); i++) {
			c[s[i]]++;
		}
		for (int i = 0; i < 26; i++) {
			if (c[arfa[i]] == 0) {
				s = s + arfa[i];
				cout << s;
				return 0;
			}
		}
	}
	else{
		string k = "";
		k = k + s[25];
		for (int i = 24; i >= 0; i--) {
			for (int j = 0; j < k.size(); j++) {
				if (k[j] - s[i] > 0) {
					string f;
					for (int d = 0; d < i; d++) {
						f = f + s[d];
					}
					f = f + k[j];
					cout << f;
					return 0;
				}
			}
			k = k + s[i];
		}
	}
	cout << -1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi; 
typedef pair<int,int> pi;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

vector<ll> dp, h;

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

	dp.assign(n, 10000000000);
	h.assign(n, 0);
	
	for(ll i = 0; i < n; i++){
		cin >> h[i];
	}
	
	dp[0] = 0;
	
	for(ll i = 0; i < n; i++){
		
		for(ll i2 = i+1; i2 <= i+k; i2++) {
						
			if(i2 == n) break;
			dp[i2] = min( dp[i2] , dp[i] + ( abs( h[i2] - h[i] ) ) );
		}
		
	}
	
	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
#include<stdio.h>
using namespace std;

typedef long long ll;

long long Mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

#define INF 1e19;

struct SegmentTree {
   ll n;  // 最下段のノード数
   vector<ll> node;
   ll SIJK;  // 最弱なやつ(INFとか-1とか)
 
  public:
   SegmentTree(ll v) {
     SIJK = (1ll << 50) - 1;  // INFは最弱なので
 
     ll sz = v;
     n = 1;
     while (n < sz) n *= 2;  // n…最下段の横幅
     node.resize(2 * n - 1, SIJK);
 
     // 最下段以外を更新していく
     for (ll i = n - 2; i >= 0; i--) {
       node[i] = compare(node[i * 2 + 1], node[i * 2 + 2]);
     }
   }
 
   // 結合法則を満たすやつならなんでもいいよー。aかbを返す。
   ll compare(ll a, ll b) {
     return min(a, b);
   }
 
   // i番目の要素をvalに変更する
   void update(ll i, ll val) {
     // まず最下段(2n-1)を変更する
     i += n - 1;
     node[i] = compare(val,node[i]);
 
     // 上に行きながら更新していく
     while (i > 0) {
       i = (i - 1) / 2;  // 親へ
       node[i] = compare(node[2 * i + 1], node[2 * i + 2]);
     }
   }
 
   // [a,b) 中の結果を返す。[l,r)は対称区間の左端と右端。
   ll find(ll a,ll b, ll now = 0, ll l = 0, ll r = -1) {
     // 初期化
     if (r < 0) r = n;
 
     // 俺は関係ないとき -> 答えの邪魔にならない値を返す
     if (r <= a || b <= l) return SIJK;
 
     // 要求区間の中にノードがすっぽり入ってる → 計算候補として返す
     if (a <= l && r <= b) return node[now];
 
     // ノードの一部分だけ要求区間に入ってる → 子を再帰的に探索する
     ll vl = find(a, b, 2 * now + 1, l, (l + r) / 2);  // 子(左)
     ll vr = find(a, b, 2 * now + 2, (l + r) / 2, r);  // 子(右)
     return compare(vl, vr);
   }
 };


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

    vector<ll> Sx={abs(x[0]-A)};
    vector<ll> Sy={abs(x[0]-B)};
    for (ll i=1;i<Q;i++){
        Sx.push_back(abs(x[i]-x[i-1]));
        Sy.push_back(abs(x[i]-x[i-1]));
    }

    for (ll i=1;i<Q;i++){
        Sx[i]+=Sx[i-1];
        Sy[i]+=Sy[i-1];
    }

    SegmentTree rmqxlow(N+1),rmqxhigh(N+1),rmqylow(N+1),rmqyhigh(N+1);

    ll dpx=Sx[0];
    ll dpy=Sy[0];
    ll test1=Sx[Q-1];
    ll test2=Sy[Q-1];
    rmqxlow.update(A,-A);
    rmqxhigh.update(A,A);
    rmqylow.update(B,-B);
    rmqyhigh.update(B,B);
    for (ll i=2;i<Q+1;i++){
        ll testx1=rmqxlow.find(0,x[i-1])+x[i-1]+Sy[i-2];
        ll testx2=rmqxhigh.find(x[i-1],N+1)-x[i-1]+Sy[i-2];
        dpx=min(testx1,testx2);

        ll testy1=rmqylow.find(0,x[i-1])+x[i-1]+Sx[i-2];
        ll testy2=rmqyhigh.find(x[i-1],N+1)-x[i-1]+Sx[i-2];
        dpy=min(testy1,testy2);

        rmqxlow.update(x[i-2],dpy-Sy[i-1]-x[i-2]);
        rmqxhigh.update(x[i-2],dpy-Sy[i-1]+x[i-2]);
        rmqylow.update(x[i-2],dpx-Sx[i-1]-x[i-2]);
        rmqyhigh.update(x[i-2],dpx-Sx[i-1]+x[i-2]);
        test1=min(test1,dpx+Sx[Q-1]-Sx[i-1]);
        test2=min(test2,dpy+Sy[Q-1]-Sy[i-1]);
    }

    cout<<min(test1,test2)<<endl;

}

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

int main(){
    int n, val, max, min;
    long long sum;
    
    cin >> n;
    cin >> val;
    max = val;
    min = val;
    sum = val;
    for(int i=0;i < n-1;i++){
        cin >> val;
        if(val > max){
            max = val;
        }
        else if(val < min){
            min = val;
        }
        sum = sum + val;
    }
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl

const long long MOD = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll as[n];
    rep(i, n){
        cin >> as[i];
    }
    ll lmas[n+1];
    ll rmas[n+1];
    lmas[0] = 0;
    for(ll i = 0; i < n; i++){
        lmas[i+1] = max(as[i], lmas[i]);
    }
    rmas[n] = 0;
    for(ll i = n-1; i >= 0; i--){
        rmas[i] = max(as[i], rmas[i+1]);
    }

    rep(i, n){
        cout << max(lmas[i], rmas[i+1]) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6272
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,k,x,y;
int ans = 4e18;
vector<pair<int,int>>vecx,vecy;
int a[100];
int b[100];
int knt[100];
int cnt[100][100];
int sum[100];

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> k;
	for(int i = 1;i <= n;i++)
	{
		cin >> x >> y;
		vecx.pb(mp(x,i));
		vecy.pb(mp(y,i));
	}
	sort(vecx.begin(),vecx.end());
	sort(vecy.begin(),vecy.end());
	for(int i = 0;i < sz(vecx);i++) a[vecx[i].second] = i + 1;
	for(int i = 0;i < sz(vecy);i++) b[vecy[i].second] = i + 1;
	for(int i = 1;i <= n;i++)
	{
		cnt[a[i]][b[i]]++;
		cnt[a[i]][b[i]] += cnt[a[i]][b[i] - 1];
	}
	for(int i = 1;i <= n;i++)
	{
		for(int j = 1;j <= n;j++) knt[j] = 0;
		for(int j = i;j <= n;j++)
		{
			for(int jj = 1;jj <= n;jj++) {knt[jj] += cnt[j][jj];}
			memset(sum,0,sizeof(sum));
			for(int jj = 1;jj <= n;jj++) sum[jj] = knt[jj] + sum[jj - 1];
			for(int x = 1;x <= n;x++)
			{
				for(int y = x;y <= n;y++)
				{
					if(sum[y] - sum[x - 1] >= k) ans = min(ans,(vecx[j - 1].first - vecx[i - 1].first) * (vecy[y - 1].first - vecy[x - 1].first));
				}
			}
		}
	}
	rc(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MAX_P=100010;
const ll MOD=1e+9+7;
ll fact[MAX_P];

void make_fact(ll n){
  fact[0]=fact[1]=1;
  for(ll i=2;i<=n;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}
int main(){
  int n;cin>>n;
  make_fact(n+1);
  ll a[100010];rep(i,n+1) cin>>a[i];
  bool f[100010];
  fill(f,0);
  int back,front;
  ll chain;
  rep(i,n+1){
    if(!f[a[i]]){
      f[a[i]]=true;
    }
    else{
      chain=a[i];
      back=n-i;
      break;
    }
  }
  rep(i,n+1){
    if(a[i]==chain){
      front=i;
      break;
    }
  }
  rep1(i,n+1){
    ll res=mod_comb(n+1,i,MOD)-mod_comb((ll)(back+front),i-1,MOD);
    if(res<0) res+=MOD;
    prin(res);
  }


    




    
  

  return 0;
}


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

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    int a = 1;
    char c = s[0];
    for(int i = 1; i < s.size(); i++){
        if(c != s[i]) a++;
        c = s[i];
    }
    if(a == s.size()) puts("yes");
    else puts("no");
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
double a,b,x;
# define M_PI           3.14159265358979323846
int main(){
    scanf("%lf%lf%lf",&a,&b,&x);
    x/=a;
    if (x<0.5*a*b){
        printf("%.8f",atan(b/(x*2/b))/M_PI*180);
    }
    else{
        printf("%.8f",atan(((b-(x/a))*2)/a)/M_PI*180);
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i*i<=n;i++){
        ans=i*i;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int N, W, w[100], v[100];
long long dp[101][100001];

int main(){
	cin >> N >> W;
	for(int i = 0; i < N; ++i) cin >> w[i] >> v[i];
	
	for(int i = N; i >= 0; --i){
		for(int j = 0; j <= W; ++j){
			if(i >= N || j <= 0) dp[i][j] = 0;
			else if(j < w[i]) dp[i][j] = dp[i+1][j];
			else dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
		}
	}
	cout << dp[0][W] << endl;
}

Measured memory_bytes: 79104
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a:i32 = v[0];
	let b:i32 = v[1];
	let c:i32 = v[2];
	let d:i32 = v[3];
	println!("{}", max(a*b, c*d));
}

Measured memory_bytes: 4352