akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

var nodes []Node
var tree [][]int

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	q := getNextInt(scanner)

	tree = make([][]int, n)

	for i := 0; i < n; i++ {
		tree[i] = make([]int, 0)
	}

	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}

	nodes = make([]Node, n)
	for i := 0; i < q; i++ {
		p := getNextInt(scanner) - 1
		x := getNextInt(scanner)
		nodes[p].x += x
	}

	dfs(0, 0, 0)

	for i := 0; i < n; i++ {
		fmt.Fprint(writer, nodes[i].x)
		if i < n-1 {
			fmt.Fprint(writer, " ")
		} else {
			fmt.Fprintln(writer, "")

		}
	}

	writer.Flush()
}

func dfs(c, p, inc int) {
	for i := 0; i < len(tree[c]); i++ {
		if tree[c][i] == p {
			continue
		}
		dfs(tree[c][i], c, inc+nodes[c].x)
	}
	nodes[c].x += inc
}

type Node struct {
	x int
}


Measured memory_bytes: 48256
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if (i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);
//const li MOD = 100055128505716009;
//const li P = 3e4 + 11;

const int N = 1e5 + 7;

int n;
vector<pt> a;

bool read() {
	if (!(cin >> n))
		return false;

	a.resize(n);
	forn(i, n) {
		cin >> a[i].first;
		a[i].y = i;
	}

	sort(all(a));

	return true;
}

void solve() {
	for (auto it : a) {
		cout << it.y + 1 << ' ';
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	ios::sync_with_stdio(0);
	cin.tie(0);

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while (read()) {
#else
	if (read()) {
#endif

		solve();

#ifdef _DEBUG
		cout << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	}

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

int  main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i, s.size())
	{
		if (s[i] + n <= 90)
		{
			char c = s[i] + n;
			cout << c;
		}
		else
		{
			char c = (s[i]+n) - 26;
			cout << c;
		}
	}
	cout << endl;
	return (0);
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(n), a(m), b(m);
    rep(i, n) v[i] = i + 1;
    rep(i, m) cin >> a[i] >> b[i];

    int ans = 0;
    do
    {
        if (v[0] != 1)
        {
            break;
        }

        int ok = true;
        rep(i, n - 1)
        {
            bool pass = false;
            rep(j, m)
            {
                bool A = (v[i] == a[j] && v[i + 1] == b[j]);
                bool B = (v[i] == b[j] && v[i + 1] == a[j]);
                if (A || B)
                {
                    pass = true;
                }
            }
            if (!pass)
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            ans++;
        }

    } while (next_permutation(all(v)));
    cout << ans << endl;

    return 0;
}

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

template<class T> inline bool chmin(T& a, T b){
	if (a > b){
		a = b;
		return true;
	}
	return false;
}

const long long INF = 1LL << 60;
long long dp[100010];
int main()
{
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) cin >> h[i];
	for (auto &x : dp) x = INF;
	dp[0] = 0;
	for (int i = 1; i < n; i++){
		chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
		if (i > 1) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout << dp[n-1] << endl;

}



Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n, W;
    const int INF = 1e9;
    cin>>n>>W;
    vector<pair<int, int> > item(n);
    for(int i =0; i<n; i++)
        cin>>item[i].first>>item[i].second;

    ll sum_value = 0;
    for(int i =0; i<n ;i++)
        sum_value +=item[i].second;


    vector<ll> dp(sum_value+1, INF);



    // previously dp[i] = maximum value that can be obtained with a knapsack of size i
    //            dp[i] = minimum weight that can be put for a knapsack with value i

    dp[0] = 0;
    for(int i =0; i< n; i++)
    {
        for(int j = sum_value; j>= item[i].second ; j--)
        {  
            dp[j] = min(dp[j] , item[i].first + dp[j-item[i].second]);
        }
    }

    int ans = -1;
    for(int i = 0; i<=sum_value; i++)
    {
        if(dp[i]<=W)
            ans = i;

    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][] a = new long[n][2];
        for(int i = 0; i < n; i++) {
            a[i][0] = (long)(i + 1);
            a[i][1] = sc.nextLong();
        }
        Arrays.sort(a, (o1, o2) -> (int)(o2[1] - o1[1]));
        long[][] dp = new long[n + 1][n + 1];
        dp[1][0] = a[0][1] * (a[0][0] - 1);
        dp[0][1] = a[0][1] * (n - a[0][0]);
        for(int k = 2; k <= n; k++) {
            for(int i = 0; i <= k; i++) {
                // dp[i][k - i]の更新
                // k人目が(i - pi)のパターン
                if(i > 0) dp[i][k - i] = dp[i - 1][k - i] + (a[k - 1][1] * (a[k - 1][0] - i));

                // k人目が(pi - i)のパターン
                if(k > i) dp[i][k - i] = Math.max(dp[i][k - i], dp[i][k - i - 1] + (a[k - 1][1] * (n - k + i + 1 - a[k - 1][0])));
            }
        }
        long ans = 0;
        for(int i = 0; i <= n; i++) {
            ans = Math.max(ans, dp[i][n - i]);
        }
        System.out.println(ans);
    }
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	static class Scanner {

		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> h(100000);
  rep(i,0,n) cin>>h[i];
  Q ab(100000);
  rep(i,0,m) cin>>ab[i].first>>ab[i].second;

  vector<bool> v(100000);
  rep(i,0,n) v[i]=true;

  rep(i,0,m){
    int a=ab[i].first,b=ab[i].second;
    if(h[a-1]<h[b-1]) v[a-1]=false;
    else if(h[a-1]>h[b-1]) v[b-1]=false;
    else{
      v[a-1]=false,v[b-1]=false;
    }
  }
  int cnt=0;
  rep(i,0,n){
    if(v[i]) cnt++;
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 5360
import Control.Applicative ((<$>), (<*>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  solve <$> getl (readi B.readInt) <*> getl (readi B.readInt) <*> getl (readi B.readInt) >>= print

solve :: Int -> Int -> Int -> Int
solve x a b = (x - a) `mod` b

fibs :: [Int]
fibs = 1:1:zipWith (+) (tail fibs) fibs

getl :: (ByteString -> a) -> IO a
getl f = f <$> B.getLine

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n


Measured memory_bytes: 380
N = gets.to_i
# 異なる場合0
s = gets.chomp.split('').map{|c| c == 'o' ? 0 : 1}

# 羊が0
pat01 = [[0, 0], [0, 1], [1, 0], [1, 1]]

pat01.each do |pat|
    (2..N).each do |i|
        pat[i] = pat[i - 2] ^ pat[i - 1] ^ s[i - 1]
    end
    if pat[0] == pat[N] && pat[1] ^ pat[N - 1] ^ s[0] ^ pat[0] == 0
        puts pat[0...N].map{|bit| bit == 0 ? 'S' :  'W'}.join
        exit
    end
end

puts -1

Measured memory_bytes: 16324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll ans = 0;
map<vll, bool> mp;
void solve(ll n, ll m, ll q, vll &a, vll &b, vll &c, vll &d, vll &v) {
	ll subans = 0;
	for (ll i = 0; i < q; i++) {
		if (v[b[i]] - v[a[i]] == c[i]) subans += d[i];
	}
	ans = max(ans, subans);

	for (ll i = 0; i < n - 1; i++) {
		if (v[i] < v[i + 1]) {
			v[i]++;
			if (!mp[v]) {
				solve(n, m, q, a, b, c, d, v);
				mp[v] = true;
			}
			v[i]--;
		}
	}
	if (v[n - 1] < m) {
		v[n - 1]++;
		if (!mp[v]) {
			solve(n, m, q, a, b, c, d, v);
			mp[v] = true;
		}
		v[n - 1]--;
	}
}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m, q;
	cin >> n >> m >> q;
	vll a(q), b(q), c(q), d(q);
	for (ll i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}

	vll v(n);
	for (ll i = 0; i < n; i++) v[i] = 1;

	solve(n, m, q, a, b, c, d, v);
	cout << ans << endl;
}


Measured memory_bytes: 19472
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) // present in container?
#define vpresent(c,x) (find(all(c),x) != (c).end()) // present in vector?
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr)
#define endl '\n'
using namespace std;

void solve(){   
	int a, b; cin >> a >> b;
	cout << a*b << endl;
}
 
signed main(){
	fastio;
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


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

template <class T>
using V = vector<T>;

template <class T>
using VV = V<V<T>>;

int main() {
    int N;
    cin >> N;
    V<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    V<int> DP(N, -1);
    DP[0] = 0;

    for (int i = 0; i < N; ++i) {
        if (i + 1 < N) {
            // i ->i + 1への遷移
            if (DP[i + 1] == -1)
                DP[i + 1] = DP[i] + abs(h[i + 1] - h[i]);
            else
                DP[i + 1] = min(DP[i + 1], DP[i] + abs(h[i + 1] - h[i]));
        }
        if (i + 2 < N) {
            //i -> i + 2への遷移
            if (DP[i + 2] == -1)
                DP[i + 2] = DP[i] + abs(h[i + 2] - h[i]);
            else
                DP[i + 2] = min(DP[i + 2], DP[i] + abs(h[i + 2] - h[i]));
        }
    }
    cout << DP[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 4000
#include <iostream>
int main() {
    int W,a,b;
    int a_max,a_min,b_max,b_min,ans = 0;
    std::cin >>W >>a >>b;

    if(W<1 || a<1 || b<1){
        return  -1;
    }
    a_max = a+W;
    a_min = a;
    b_max = b+W;
    b_min = b;
    if(2 <= b_max && b_max < a_min){
        ans = a_min - b_max;
    } else if(2 <= a_max && a_max < b_min){
        ans = b_min - a_max;
    } else {
        ans = 0;
    }
    printf("%d\n",ans);

    return 0;
}


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

int main() {
    while (1) {
        long long int n = 0;
        long long int result = 0;
        
        cin >> n;
        if (n == -1) {
            break;
        }
        
        long long int temp = 0;
        
        for (long long int i = 0; n != 0; i++) {
            temp = n;
            
            n &= 3;
        
            for (long long int j = 0; j < i; j++) {
                n *= 10;
            }
            
            result += n;
        
            n = temp;
            
            n = n >> 2;
        }
        
        cout << result << endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

#define MP(a, b) make_pair(a, b)

pair<int, int> p[100000];

int main()
{
	int N ,M;
	cin >> N >> M;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		p[i] = MP(b, a);
	}
	sort(p, p+M);
	int res = 0;
	int be = -1;
	rep(i, M) {
		int b = p[i].first;
		int a = p[i].second;
		if (be >= a) continue;
		be = b - 1;
		res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << "{";
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i] << ",}"[i == vec.size() - 1];
  }
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << "{" << p.first << " " << p.second << "}";
}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string s; cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int A,B,X;
    scanf("%d%d%d",&X,&A,&B);
    if(1<=X && X<=1000000000 && 1<=A && A<=1000000000 && 1<=B && B<=1000000000)
    {
        if(B<=A) printf("delicious");
        else if (B>A+X) printf("dangerous");
        else printf("safe");
    }

return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,d;
    cin>>n>>d;
    d*=d;
    int ans = 0;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d){
            ans++;
        }
    }
    cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int[] ar = new int[n];
    for (int i = 0; i < n; i++) {
      ar[i] = scan.nextInt();
    }

    int count = 1;
    boolean e = false;
    for (int i = 0; i < ar.length; i++) {
        if(ar[i] == count){
            e = true;
            count++;
        }
    }

    System.out.println(e?ar.length-count+1:-1);
  }
}

Measured memory_bytes: 65600
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        System.out.println(a*b + " " + (2*a+2*b));

    }
}



Measured memory_bytes: 26144
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(final String[] args){
    
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int check = 0;
        for(int a = 0; a < 1000 ; a++){
            for(int b = -1000 ; b < a ; b++){
                if(check == 0){
                    if(a*a*a*a*a - b*b*b*b*b == x){
                        check++;
                        System.out.println(a + " " + b);
                    }
                }
            }
        }



        


    }
}

Measured memory_bytes: 38796
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 1<<18, rt = 1<<10;
int n, m, a[maxn], b[maxn], c[maxn];
int ans = 0;
void dec(int col) {
	int t = a[col], p = 0;
	a[col]--;
	for(int i = 1<<18; i>>=1;)
		if(p + i < n && b[p + i] < t) p += i;
	p += b[p] < t;
	ans -= abs(b[p] - p);
	b[p]--;
	ans += abs(b[p] - p);
}
void inc(int col) {
	int t = a[col], p = 0;
	a[col]++;
	for(int i = 1<<18; i>>=1;)
		if(p + i < n && b[p + i] <= t) p += i;
	ans -= abs(b[p] - p);
	b[p]++;
	ans += abs(b[p] - p);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
		a[c[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		b[i - 1] = a[i] = i - a[i];
	}
	sort(b, b + n);
	for(int i = 0; i < n; i++) ans += abs(b[i]-i);
	for(int p, x; m--;) {
		cin >> p >> x;
		inc(c[p]);
		c[p] = x;
		dec(c[p]);
		cout << ans/2 << '\n';
	 }
}


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

/*-------------------Define Start-------------------*/
typedef bool BL;                        // 布尔类型
typedef char SB;                        // 有符号1字节,8位
typedef unsigned char UB;                // 无符号1字节,8位
typedef short SW;                        // 有符号短整型,16位
typedef unsigned short UW;                // 无符号短整型,16位
typedef long SDW;                        // 有符号整型,32位
typedef unsigned long UDW;               // 无符号整型,32位
typedef long long SLL;                    // 有符号长整型,64位
typedef unsigned long long ULL;            // 无符号长整型,64位
typedef char CH;                        // 单个字符
typedef float R32;                        // 单精度浮点数
typedef double R64;                        // 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;                //常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;                //用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;    //用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 1e6 + 7;
SLL r1, c1, r2, c2;
SLL ans;

SLL fac[maxN * 2];
void init_fact() {
    fac[0] = 1;
    For(i, 1, 2 * maxN - 1) {
        fac[i] = (i * fac[i - 1]) % mod;
    }
}

void input(){
    cin >> r1 >> c1 >> r2 >> c2;
    init_fact();
}

//ax + by = gcd(a, b) = d
// 扩展欧几里德算法
/**
 *    a*x + b*y = 1
 *    如果ab互质，有解
 *    x就是a关于b的逆元
 *    y就是b关于a的逆元
 *     
 *    证明： 
 *        a*x % b + b*y % b = 1 % b
 *        a*x % b = 1 % b
 *        a*x = 1 (mod b)
 */
inline void ex_gcd(SLL a, SLL b, SLL &x, SLL &y, SLL &d){
    if(!b) {
        d = a, x = 1, y = 0;
    }
    else{
        ex_gcd(b, a % b, y, x, d);
        y -= x * (a / b);
    }
}

// 求a关于p的逆元，如果不存在，返回-1 
// a与p互质，逆元才存在 
inline SLL inv_mod(SLL a, SLL p = mod){
    SLL d, x, y;
    ex_gcd(a, p, x, y, d);
    return d == 1 ? (x % p + p) % p : -1;
}

inline SLL comb_mod(SLL m, SLL n) {
    SLL ret;

    if(m > n) {
        swap(m, n);
    } 
    
    ret = (fac[n] * inv_mod(fac[m], mod)) % mod;
    ret = (ret * inv_mod(fac[n - m], mod)) % mod;
    
    return ret;
}

void solve(){
    For(i, r1, r2) {
        ans = (ans + comb_mod(i + 1, c2 + i + 1) - comb_mod(i + 1, c1 + i) + mod) % mod;
    }
}

void output(){
    cout << ans << endl;
}

int main() {
    input();
    solve();
    output();
    return 0;
}

Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    unsigned long long b[87];
    b[0] = 2;
    b[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        b[i] = b[i - 1] + b[i - 2];
    }
    printf("%lld\n", b[n]);
}


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

using namespace std;

int lcs(string x,string y){
    int m = x.size();
    int n = y.size();
    int lcs_lst[m+1][n+1];
    x = ' '+x;
    y = ' '+y;
    for(int i=0;i<=m;i++) lcs_lst[i][0] = 0;
    for(int i=1;i<=n;i++) lcs_lst[0][i] = 0;

    int ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(x[i] == y[j])
                lcs_lst[i][j] = lcs_lst[i-1][j-1]+1;
            else{
                lcs_lst[i][j] = max(lcs_lst[i][j-1],lcs_lst[i-1][j]);
            }
            ans = max(ans,lcs_lst[i][j]);

        }
    }

    return ans;
}

int main(){
    int n; cin >> n;
    string a,b;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        cout << lcs(a,b) << endl;
    }
}



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

int main() {
  int N,M=-1;
  cin>>N;

  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    
    int j=0,tmp=A;
    while(true){
      if(tmp%2==0){
        j+=1;
        tmp/=2;
      }else{
        break;
      }
    }
    if(j<M || M==-1){
      M=j;
    }
  }
  cout<<M<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  a = int(input())
  A.append(a)
  
A2 = sorted(A)
mx1 = A2[-1]
mx2 = A2[-2]
ind = A.index(mx1)

for i in range(N):
  if i != ind:
    print(mx1)
  else:
    print(mx2)


Measured memory_bytes: 19000
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll h, n;
	cin >> h >> n;
	vector<P> vs(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
	}
	const ll INF = 1e15;
	vector<ll> dp(h + 1, INF);
	dp[0] = 0;
	rep(i, h + 1) {
		rep(j, n) {
			auto p = i - vs[j].first;
			p = max(0LL, p);
			dp[i] = min(dp[i], dp[p] + vs[j].second);
		}
	}
	cout << dp[h] << endl;
	return 0;
}


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

int X, Y;

int main(){
  cin >> X >> Y;
  cout << X + (Y/2) << endl;
}


Measured memory_bytes: 3600
a = [list(map(int,input().split()))for _ in range(3)]
n = int(input())
for i in range(n):
    b= int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:a[j][k ] = 0
ans = "No"
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:ans = "Yes"
    if a[0][i] == a[1][i] == a[2][i] == 0:ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == 0:ans = "Yes"
if a[0][2] == a[1][1] == a[2][0] == 0:ans = "Yes"
print(ans)

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

int main(){
  int a,i,j,d,b,c,k,e=0;
  cin>>a>>b>>c>>d;
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        e+=(500*i+100*j+50*k==d);
      }
    }
  }
  cout<<e<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll H, W;
    cin >> H >> W;
    bool a[H][W];
    REP(i, H){
    	string s;
    	cin >> s;
    	REP(j, W){
    		a[i][j] = (s[j] == '#');
    	}
    }

    bool red[H][W], blue[H][W];
    REP(i, H){
    	REP(j, W){
    		if(j==0||a[i][j]) red[i][j] = 1;
    		else if(i>0 && i<H-1 && j>0 && j<W-1 && i%2) red[i][j] = 1;
    		else red[i][j] = 0;
    	}
    }
    REP(i, H){
    	REP(j, W){
    		if(j==W-1||a[i][j]) blue[i][j] = 1;
    		else if(i>0 && i<H-1 && j>0 && j<W-1 && !(i%2)) blue[i][j] = 1;
    		else blue[i][j] = 0;
    	}
    }

    REP(i, H){
    	REP(j, W){
    		cout << (red[i][j] ? '#' : '.');
    	}
    	cout << endl;
    }
    cout << endl;
    REP(i, H){
    	REP(j, W){
    		cout << (blue[i][j] ? '#' : '.');
    	}
    	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int a[15][15];
int main(int argc, char const *argv[])
{
	int n,d;
	cin>>n>>d;
	for(int i = 1;i <= n; ++i)
	{
		for(int k = 1;k <= d; ++k)
		{
			scanf("%d",&a[i][k]);
		}
	}
	int ans = 0;
	for(int i = 1;i <= n; ++i)
	{
		for(int j = i + 1;j <= n; ++j)
		{
			int sum = 0;
			for(int k = 1;k <= d; ++k)
			{
				sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			int k = sqrt(sum);
			if(k * k == sum)
			{
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
  string p, s;

  cin >> p >> s;

  p = p + p;

  bool flag = false;

  for(int i=0;i<(int)p.size() - (int)s.size()+1;i++){
    string t=p.substr(i,s.size());

    if( t == s ){
      flag = true;
      break;
    }
  }

  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

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

    long long int check = 1e18;
    bool flag = true;
    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] != 0) check /= a[i];
        if(a[i] == 0) flag = false;
    }

    if(flag == false){
        cout << 0 << endl;
        return 0;
    }
    
    if(check == 0){
        cout << -1 << endl;
        return 0;
    }

    long long int ans = 1;
    for(int i=0; i<n; i++){
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
using System;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int b;
            
            b = int.Parse(Console.ReadLine());

            if (b%1000==0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1000 - b % 1000);
            }
        }
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

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

  int n=s.size();
  int k=t.size();
  int id=-1;
  for(int i=n-k; i>-1; i--){
    bool ok=true;
    rep(j,k){
      if(s[i+j]!='?' && s[i+j]!=t[j]) ok=false;
    }
    if(ok){
      id = i;
      rep(j,k){
        s[i+j] = t[j];
      }
      break;
    }
  }
  if(id==-1){
    prt("UNRESTORABLE");
    return 0;
  }
  rep(i,n){
    if(s[i]=='?') cout << 'a';
    else {cout << s[i];}
  }
  cout << "\n";

}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin>>a[i];
    if(N==1){
        cout<<1<<endl;
        return 0;
    }

    int cnt=0, pos=0, mode=-1;
    while(pos<N-1){
        if(mode==-1){
            if(a[pos]<a[pos+1])mode=1;
            else if(a[pos]==a[pos+1])pos++;
            else mode=0;
        }
        else if(mode==1){
            if(a[pos]>a[pos+1]){
                cnt++;
                mode=-1;
            }
            pos++;
        }else if(mode==0){
            if(a[pos]<a[pos+1]){
                cnt++;
                mode=-1;
            }
            pos++;
        }
        if(pos==N-1)cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <functional>
#include <queue>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

const int mod = 998244353;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) { int z = 1;
  for (; y; y >>= 1, x = Mul(x, x)) { if (y & 1) z = Mul(z, x); } return z; }
inline int Inv(int x) { return Pow(x, mod - 2); }
inline int Fix(li x) { x %= mod; if (x < 0) x += mod; return (int)x; }
inline int Fix(int x) { x %= mod; if (x < 0) x += mod; return x; }

// ----------------------------------------

const int maxn = 2e5;

struct Data {
  int n0, n1;
  li cost;

  void operator += (const Data &b) {
    cost += b.cost + (li)n1 * b.n0;
    n0 += b.n0;
    n1 += b.n1;
  }

  Data operator + (const Data &b) const {
    Data ans = *this;
    ans += b;
    return ans;
  }

  bool operator < (const Data &b) const {
    return (li)n1 * b.n0 < (li)n0 * b.n1;
  }
};

int n;
int num[maxn];
int par[maxn];
Data dat[maxn];
int fa[maxn];

priority_queue< pair<Data, int>,
                vector< pair<Data, int> >,
                greater< pair<Data, int> > > que;

int Find(int x) {
  return x == par[x] ? x : par[x] = Find(par[x]);
}

void Unite(int x, int y) {
  par[Find(x)] = Find(y);
}

int main(void) {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d", fa + i);
    --fa[i];
  }
  for (int i = 0; i < n; ++i) {
    par[i] = i;
    scanf("%d", num + i);
    if (num[i] == 0) {
      dat[i] = {1, 0, 0};
    } else {
      dat[i] = {0, 1, 0};
    }
    if (i > 0) {
      que.push({dat[i], i});
    }
  }
  while (!que.empty()) {
    int i = que.top().second;
    Data d = que.top().first;
    que.pop();
    if (par[i] != i) continue;
    int j = Find(fa[i]);
    Unite(i, j);
    dat[j] += d;
    if (j != 0) {
      que.push({dat[j], j});
    }
  }
  li ans = dat[0].cost;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 13424
#include<cstring>
#include<iostream>
using namespace std;
char s[1005];
char ans[1005];
int main()
{
    while(cin.getline(s,1000))
    {
        int len=(int)strlen(s);
        for(int i=0;i<26;i++)
        {
            for(int j=0;j<len;j++)
            {
                if(s[j]>='a'&&s[j]<='z')
                    ans[j]=(char)((s[j]-'a'-i+26)%26+'a');
                else
                    ans[j]=s[j];
            }
            ans[len]='\0';
            char *str,*str2,*str3;
            str=strstr(ans,"the");
            str2=strstr(ans,"this");
            str3=strstr(ans,"that");
            if(str==0&&str2==0&&str3==0)continue;
            cout<<ans<<endl;
            break;
        }
    }
}

Measured memory_bytes: 1128
H,W=map(int,input().split())

sq=[list(input()) for i in range(H)]

pos=[[0,0,0]]
g=True

while pos!=[]:
    y,x,depth=pos.pop(0)

    if y==H-1 and x==W-1:
        g=False
        break
    
    if x-1>=0:
        if sq[y][x-1]==".":
            pos.append([y,x-1,depth+1])
            sq[y][x-1]="!"
    if x+1<=W-1:
        if sq[y][x+1]==".":
            pos.append([y,x+1,depth+1])
            sq[y][x+1]="!"
    if y-1>=0:
        if sq[y-1][x]==".":
            pos.append([y-1,x,depth+1])
            sq[y-1][x]="!"
    if y+1<=H-1:
        if sq[y+1][x]==".":
            pos.append([y+1,x,depth+1])

if g==True:
    print(-1)
else:
    temp=0
    for k in range(H):
        for m in range(W):
            if sq[k][m]=="#":
                temp+=1


    print(H*W-temp-depth-1)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<tuple<int,int,int>> p[4], v;
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < 2; ++j) {
			int x, y;
			cin >> x >> y;
			tuple<int,int,int> t = make_tuple(x, y, i);
			if(y == 0) {
				p[0].push_back(t);
			} else if(x == R) {
				p[1].push_back(t);
			} else if(y == C) {
				p[2].push_back(t);
			} else if(x == 0) {
				p[3].push_back(t);
			}
		}
	}
	for(int i = 0; i < 4; ++i) {
		if(i < 2) {
			sort(ALL(p[i]));
		} else {
			sort(ALL(p[i]), greater<tuple<int,int,int>>());
		}
		v.insert(v.end(), ALL(p[i]));
	}
	map<int,int> mp;
	for(int i = 0; i < v.size(); ++i) {
		// cout << get<0>(v[i]) << "," << get<1>(v[i]) << "," << get<2>(v[i]) << endl;
		mp[get<2>(v[i])] = i;
	}
	N = v.size();
	stack<int> S, T;
	for(int i = 0; i < N; ++i) {
		// cout << i << endl;
		int u = get<2>(v[i]);
		int b = mp[u];
		if(i == b) {
			if(!T.empty() && T.top() == i) {
				S.pop();
				T.pop();
			}
			continue;
		}
		if(!T.empty() && b > T.top()) {
			// cout << u << "<," << b << "," << T.top() << endl;
			cout << "NO" << endl;
			return 0;
		}
		S.push(i);
		T.push(b);
	}

	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 18876
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int k;
	char s[106];
	cin>>k>>s;
	if(strlen(s)>k)
	{
		s[k]='.';
		s[k+1]='.';
		s[k+2]='.';
		s[k+3]='\0';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3592
def fft(f, n, w, p, g):
    d = n // 2
    v = w
    while d >= 1:
        u = 1
        for i in range(d):
            for j in range(i, n, 2*d):
                f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
            u = u * v % p
        v = v * v % p
        d //= 2
def ifft(f, n, invw, p, g):
    d = 1
    while d < n:
        v = pow(invw, n // (2 * d), p)
        u = 1
        for i in range(d):
            for j in range(i, n, 2*d):
                f[j+d] *= u
                f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
            u = u * v % p
        d *= 2
def convolve(a, b):
    p, g = 998244353, 3
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)
    fft(a, n, w, p, g), fft(b, n, w, p, g)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a, n, invw, p, g)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


Measured memory_bytes: 203056
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, x;
    cin >> n >> x;
    ll ans = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans += max(0, a[i]-x);
        a[i] = min(a[i], x);
    }
    for(int i = 1; i < n; i++){
        if(a[i]+a[i-1] > x){
            int take = a[i]+a[i-1]-x;
            ans += take;
            a[i] -= take;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10, mod = 1e9 +  7;
inline int read() {
	int x = 0, f = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, a[MAXN], b[MAXN], f[5001][5001], fac[10001], ifac[10001];
int add(int x, int y) {
	if(x + y < 0) return x + y + mod;
	return x + y > mod ? x + y - mod : x + y ;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fastpow(int a, int p) {
	int base = 1;
	while(p) {
		if(p & 1) base = mul(base, a);
		a = mul(a, a); p >>= 1;
	}
	return base;
}
void init() {
	fac[0] = 1;
	for(int i = 1; i <= 8000; i++) fac[i] = mul(i, fac[i - 1]);
	ifac[8000] = fastpow(fac[8000], mod - 2);
	for(int i = 8000; i; i--) ifac[i - 1] = mul(i, ifac[i]);
}
int id(int x) {
	return 2001 + x;
}
int C(int N, int M) {
	return 1ll * fac[N] * ifac[N - M] % mod * ifac[M] % mod;
}
main() {
//	freopen("a.in", "r", stdin);
	init();
	N = read();
	for(int i = 1; i <= N; i++) a[i] = read(), b[i] = read(), f[id(-a[i])][id(-b[i])]++;
    for(int i = 1; i <= 4221; i++)
    	for(int j = 1; j <= 4221; j++)
    			f[i][j] = add(f[i][j], add(f[i - 1][j], f[i][j - 1]));
    		//	printf("%d %d %d\n", i, j, f[i][j]);
    int sum = 0;
    for(int i = 1; i <= N; i++) 
		sum = add(sum, add(f[id(a[i])][id(b[i])], -C(a[i] + b[i] + a[i] + b[i], a[i] + a[i])));
		//这里会到8000.。。 
    sum = 1ll * sum * 500000004ll % mod;
    cout << sum % mod;
    return 0;
}
/*
8
2000 2000
1999 1998
1 1
1 1
2 1
1 3
2 1
3 3
*/

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

using namespace std;
#define forr(i, n) for(ll i = n-1; i >= 0; i--)
#define forn(i, n) for(ll i = 0; i < n; i++)
#define forab(i, a, n) for(ll i = a; i < n; i++)
#define forabr(i, a, b) for(ll i = a; i >= b; i--)
#define endl '\n'
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(7); cout.setf(ios::fixed);
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

typedef long long ll;
typedef string S;

const ll mod = 1e9 + 7;
const ll Inf = LONG_LONG_MAX;
const double long PI = 3.1415926535;

ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll max(ll a, ll b){if(a > b)return a;return b;}
ll gcd (ll a, ll b) {while (b) {a %= b;swap (a, b);}return a;}
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }

int a, b, c, d;

int main(){
    fast_io;
    cin >> a >> b >> c >> d;
    a = ceil((a+.0)/d);
    c = ceil((c+.0)/b);
    if(a >= c)
        cout << "Yes";
    else
        cout << "No";
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int l,r;
	int ANS=0;
  for(int i=0;i<N;i++){
    cin >> l >> r;
    ANS+=r-l+1;
  }
  cout << ANS << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int H,W;
    int i,j;
    
    while(1){
        scanf("%d %d", &H, &W);\
        if(H == 0&& W ==0){
            break;
        }
        for(i =0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
int main(void)
{
    int n,m,i,j,l,W[50],B[50],R[50],a,e,d,p,f,g,h,k,flg;
	char s[50][50];
	a=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",&s[i]);
	}
	for(i=0;i<n;i++){
	    W[i]=0; R[i]=0; B[i]=0;
	}
	for(i=0;i<n;i++){
	    for(j=0;j<m;j++){
		    if(s[i][j]=='W'){
			    W[i]++;
			}
			if(s[i][j]=='B'){
			    B[i]++;
			}
			if(s[i][j]=='R'){
			    R[i]++;
			}
		}
	}
	p=100000; d=0;
	for(i=0;i<n-2;i++){
	    e=d+R[i]+B[i];
		d+=R[i]+B[i];
		f=0;
		for(j=i+1;j<n-1;j++){
			f+=W[j]+R[j];
			h=f+e;
			flg=0;
			g=0;
			for(l=j+1;l<n;l++){
				g+=W[l]+B[l];
				k=h+g;
				flg=1;
			}
			if(flg==1&&p>k) p=k;
			else if(flg==0&&p>h) p=h;
		}
	}
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll res1 = max(a * c, a * d);
	ll res2 = max(b * c, b * d);
	cout << max(res1, res2) << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,h,sum,a[111];
  while(1){
    cin >> n >> m >> h;
    if(n==0&&m==0&&h==0)break;
    sum=0;
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    if(a[m-1]==0) {cout<<"0"<<endl;continue;}
    sum=sum*100*(100-h)/100;
    cout<<sum/a[m-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1){
			System.out.println("Hello World");
		}else{
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a+b);
		}
		

	}
}

Measured memory_bytes: 20820