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

vector<int> zAlgorithm(string S){
    int size = S.size();
    vector<int> A(size,0);
    A[0] = S.size();
    int i = 1, j = 0;
    while(i < size){
        while(i + j < size && S[j] == S[i+j])
            j++;
        A[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(i + k < size && k + A[k] < j)
            A[i + k] = A[k], k++;
        i += k, j -= k;
    }
    return A;
}

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;

    for (int i = 0; i < N;i++){
        auto str = zAlgorithm(S.substr(i));
        for (int j = 0; j < N - i;j++)
            ans = max(ans, min(str[j], j));
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
  ll n,h;
  cin >> n >> h;
  vector<ll> a(n),b(n);
  ll ma=0;
  for(ll i=0;i<n;++i){
    cin >> a[i] >> b[i];
    ma=max(ma,a[i]);
  }
  sort(b.rbegin(),b.rend());
  int j=0;
  int kazu=b.size();
  ll ans=0;
  while(h>0){
    if(kazu>0 && ma<b[j]){
      h=h-b[j];
      j++;
      kazu--;
      ans++;
    }else{
      h=h-ma;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int A[505][505];

int main(){
  int H,W,h,w; cin>>H>>W>>h>>w;
  if(H%h==0&&W%w==0){
    cout<<"No\n";
    return 0;
  }
  ll a=(1e9-1)/(h*w-1);
  rep(i,H) rep(j,W){
    if(i%h==h-1&&j%w==w-1) A[i][j]=-(a*(h*w-1)+1);
    else A[i][j]=a;
  }

  cout<<"Yes\n";
  rep(i,H){
    rep(j,W) cout<<A[i][j]<<" ";
    cout<<endl;
  }
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> v(N);
  for(auto &e : v) cin >> e;
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += v[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){

    unsigned int N,M,t,sum=0;
    cin>>N>>M;
    for(int i=1;i<=M;i++){
        cin>>t;
        sum+=t;
    }
    if(sum>N){
        cout<<"-1";
    }
    else{
        cout<<N-sum;
    }



}


Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

const INF: u64 = 1 << 60;

fn warshall_floyd(mut edges: Vec<Vec<u64>>) -> Vec<Vec<u64>> {
    for k in 0..edges.len() {
        for i in 0..edges.len() {
            for j in 0..edges.len() {
                edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j]);
            }
        }
    }
    edges
}

struct Permutation {
    n: usize,
    idx: usize,
}
impl Permutation {
    fn new(n: usize) -> Permutation {
        Permutation { n: n, idx: 0 }
    }
}
impl Iterator for Permutation {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Vec<usize>> {
        let mut r = vec![0; self.n];
        let mut idx = self.idx;
        for k in 1..self.n {
            r[k] = idx % (k + 1);
            idx /= k + 1;
        }
        if idx > 0 {
            return None;
        }
        r.reverse();
        let mut b = vec![true; self.n];
        b[r[0]] = false;
        for k in 1..self.n {
            let mut count = 0;
            for j in 0..self.n {
                if b[j] {
                    if count == r[k] {
                        r[k] = j;
                        b[j] = false;
                        break;
                    }
                    count += 1;
                }
            }
        }
        self.idx += 1;
        return Some(r);
    }
}

fn calc_cost(edges: &Vec<Vec<u64>>, r: &Vec<usize>) -> u64 {
    let mut cost = 0;
    for i in 0..r.len() - 1 {
        cost += edges[r[i]][r[i + 1]];
    }
    cost
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (N, M, R) = (v[0], v[1], v[2]);
    let r: Vec<usize> = read_vec();
    let mut r = r.iter().map(|&r| r - 1).collect::<Vec<_>>();

    let mut edges = vec![vec![INF; N]; N];
    for i in 0..M {
        let mut v: Vec<usize> = read_vec();
        let (a, b, c) = (v[0] - 1, v[1] - 1, v[2]);
        edges[a][b] = c as u64;
        edges[b][a] = c as u64;
    }
    for k in 0..N {
        for i in 0..N {
            for j in 0..N {
                edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j]);
            }
        }
    }
    let mut ans = INF;
    for ord in Permutation::new(R) {
        let mut ac = 0;
        for i in 1..R {
            let a = r[ord[i - 1]];
            let b = r[ord[i]];
            ac += edges[a][b];
        }
        ans = min(ans, ac);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){

int a,b,c,d,e,t;

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

if(a<0){
t=(0-a)*c+d+b*e;
}
else if(a>0){
t=(b-a)*e;
}

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

return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
constexpr double EPS = 1e-10;
using number = long long;

int main() {
    int n; cin >> n;
    vi a(n + 1, -1);
    rep(i, n) cin >> a[i];
    int ans = 0;
    int tmp = 1;
    rep(i, n) {
        if (a[i] == a[i + 1]) {
            tmp++;
        }
        else {
            ans += tmp / 2;
            tmp = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;


int main(){
    char d1[5] = {'.',',','!','?',' '};
    int n;
    while(cin >> n) {
        rep(i,n){
            string ar;
            cin >> ar;
            int cnt = 0;
            rep(j,ar.size()){
                if(ar[j + 1] != '0' && ar[j] != '0') {
                    cnt++;
                }else{
                    char c;
                    if(ar[j] == '0') continue;
                    else if(ar[j] == '1') c = d1[cnt % 5];
                    else if(ar[j] == '2') c = 'a' + (cnt % 3);
                    else if(ar[j] == '3') c = 'd' + (cnt % 3);
                    else if(ar[j] == '4') c = 'g' + (cnt % 3);
                    else if(ar[j] == '5') c = 'j' + (cnt % 3);
                    else if(ar[j] == '6') c = 'm' + (cnt % 3);
                    else if(ar[j] == '7') c = 'p' + (cnt % 4);
                    else if(ar[j] == '8') c = 't' + (cnt % 3);
                    else if(ar[j] == '9') c = 'w' + (cnt % 4);
                    cout << c;
                    cnt = 0;
                }
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding space */

int main(){
  int n; cin >> n;
  bool flag = 1;
  int tt = 0, xx = 0, yy = 0;
  rep(i,n){
    int t,x,y; cin >> t >> x >> y;
    int temp = (t - tt) - abs(x - xx) - abs(y - yy);
    if(temp < 0 || temp % 2)
      flag = 0;
    tt = t, xx = x, yy = y;
  }
  cout << (flag?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmin(a,b) a = min(a,b);

int dp[1005][10005];
const int INF = 1001001001;

int main() {
    int h, n;
    cin >> h >> n;
    rep(i,n+1)rep(j,h+1) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        rep(j,h+1) {    
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j], dp[i+1][max(j-a,0)]+b);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 42748
n  = int(input())

pro = n%10

if(pro == 2 or pro == 4 or pro == 5 or pro == 7 or pro == 9):
	print("hon")
elif(pro == 0 or pro == 1 or pro == 6 or pro == 8):
	print("pon")
else:
	print("bon")

Measured memory_bytes: 9188
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int n, t;
	cin >> n;
	t = n;
	int f = 0;
	while (t!=0) {
		f += t % 10;
		t = t / 10;
	}

	if (n%f == 0) {
		Yes;
	}
	else {
		No;
	}
	
	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	int a, b; cin >>a >> b;
	long int c = pow(100, a);
	if (a == 0 && b == 100) {
		cout << c * b + 1 << endl;
	}
	else if (a == 1 && b == 100) {
		cout << c * b + 100 << endl;
	}
	else if (a == 2 && b == 100) {
		cout << c * b + 10000 << endl;
	}
	else
		cout << c * b << endl;
	

}

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a,b,c;
	int k;
	
	cin>>a>>b>>c;
	cin>>k;
	
	while (b<=a) b*=2,k--;
	while (c<=b) c*=2,k--;
	
	if (k>=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

vector<pair<char, int> > data;
char pre, c;
int cnt, ans;


main(){
  while(1){
    data.clear();
    if(scanf("%c", &pre) == EOF) break;
    cnt = 1;
    while(1){
      scanf("%c", &c);
      if(c == '\n'){
        data.push_back(pair<char, int>(pre, cnt));
        break;
      }
      if(c != pre){
        data.push_back(pair<char, int>(pre, cnt));
        cnt = 0;
      }
      pre = c;
      cnt++;
    }
    ans = 0;
    for(int i=2;i<data.size();i++){
      if(data[i-2].first == 'J' && data[i-1].first == 'O' && data[i].first == 'I'){
        if(data[i-2].second >= data[i-1].second && data[i-1].second <= data[i].second){
          ans = max(ans, data[i-1].second);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll N;
ll Prime[5640];
ll a[5640];

bool isPrime(int a){
  rep(i,2,a){
    if (a % i == 0)return false;
  }
  return true;
}

// bool Sum(ll sum, ll lim, ll self){
//   if (lim == 5 && isPrime(sum))return false;
//   rep(i,self + 1,+lim){
//     Sum(sum + a[i], lim+1, i)
//   }
// }

int main()
{
  cin >> N;

  Prime[0] = 2;
  ll cnt = 1;
  rep(i,3,55555){
    if(isPrime(i) && i % 5 == 1){
      Prime[cnt] = i;
      cnt++;
    }
  }

  rep(i,0,N){
    cout << Prime[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    map<string, ll> M;
    for(int i = 0; i < N; i++){
        string S; cin >> S; M[S]++;
    }
    vector<string> S = {"AC", "WA", "TLE", "RE"};
    for(auto s : S){
        cout << s << " x " << M[s] << endl;
    }

}

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

namespace ABC087B_Coins
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int x = int.Parse(Console.ReadLine());
            int count = 0;

            for(int i = 0; i <= a; i++)
            {
                for(int j = 0; j <= b; j++)
                {
                    for(int k = 0; k <= c; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == x)
                        {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
 
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b){cout<<a<<endl;}
  else{cout<<a-1<<endl;
}
return 0;
}                  


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

public class Main {

	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		int[] t = new int[n];
		
		int sum = 	0;
		
		for(int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			sum+=t[i];
		}
		
		int m = sc.nextInt();
		
		int[] p = new int[m];
		int[] x = new int[m];
		
		for(int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			x[i] = sc.nextInt();
			
			out.println(sum - t[p[i] - 1] + x[i]);
		}
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

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: 23252
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int d;
	cin>>d;
	int c[26];
	rep(i,26)cin>>c[i];
	int lastd[26]={};
	int s[d][26];
	rep(i,d){
		rep(j,26)cin>>s[i][j];
	}

	int t[d];
	rep(i,d){
		cin>>t[i];
		t[i]--;

	}

	ll ans=0;
	rep(i,d){
		ans+=s[i][t[i]];
		lastd[t[i]]=i+1;
		rep(j,26){
			ans-=c[j]*(i+1-lastd[j]);
		}
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 3628
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)
i, j, k = 0, 0, 0
ans = 0
while i + j + k < x + y:
    cd = []
    if i < a and i < x:
        cd.append((p[i], 1, i))
    if j < b and j < y:
        cd.append((q[j], 2, j))
    if k < c:
        cd.append((r[k], 3, k))
    cd.sort()
    v, t, cur = cd[-1]
    ans += v
    if t == 1:
        i += 1
    elif t == 2:
        j += 1
    else:
        k += 1
print(ans)

Measured memory_bytes: 105444
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMax(Node a){
  while(a->right!=NIL)a=a->right;
  return a;

}

Node treeMini(Node a){
  while(a->left!=NIL){
      a=a->left;
  }
  return a;

}



Node treeSearch(Node a, int b){
  while(a!=NIL&&b!=a->key){
    if(b<a->key)a=a->left;
    else a=a->right;
  }
  return a;
}

Node treeSuccess(Node a){
  Node b;
  if(a->right!=NIL)return treeMini(a->right);

  b=a->parent;
  while(b!=NIL && a==b->right){
    a=b;
    a=b->parent;
  }
  return a;
}

void treeDel(Node a){
  Node b;
  Node c; 
  if(a->left==NIL||a->right==NIL)b=a;
  else b=treeSuccess(a);

  if(b->left!=NIL)c=b->left;
  else c=b->right;

  if(c!=NIL)c->parent=b->parent;

  if(b->parent!=NIL)root=c;
  else if(b==b->parent->left)b->parent->left=c;
  else b->parent->right=c;

  if(b!=a)a->key=b->key;
  
}

void insert(int a){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = a;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inorder(Node a){
  if(a==NIL)return;
  inorder(a->left);
  printf(" %d",a->key);
  inorder(a->right);
}
void preorder(Node a){
  if(a==NIL)return;
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}


int main(){
  int n, i, a;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &a);
      Node t = treeSearch(root, a);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &a);
      insert(a);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &a);
      treeDel(treeSearch(root, a));
    }
  }

  return 0;
}


Measured memory_bytes: 20484
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
const int INF = 1e9 + 5;
#define pb push_back
#define eb emplace_back
#define vll vector<long long int>
#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll, ll>
#define vpair vector<pii>
#define vbool vector<bool>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define sec second
#define fir first
#define br '\n'
#define permute next_permutation
#define pqua priority_queue<ll>
#define pqud priority_queue<ll, vector<ll>, greater<ll> >
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define maxi *max_element
#define pi acos(-1)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(10)

vector<long long int> sieve(long long int n){
 	vector<long long int> primes;
 	bool isPrime[n+1] = {false};
 	isPrime[1] = isPrime[0] = false;
 	for(long long int i = 2;i<=n;i++)
 	{
 		isPrime[i] = true;
 	}
 	for(long long int i = 2;i*i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			for(long long int j = i*i;j<=n;j+=i)
 			{
 				isPrime[j] = false;
 			}
 		}
 	}
 	for(long long int i = 2;i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			primes.push_back(i);
 		}
 	}
 	return primes;
}

void print_vector2(vector<vector<ll> >v) {
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v) {
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b) {
    return __gcd(a, b);
}

// v.back()
// v.erase(v.begin(), v.brgin + k)
// v.insert(at which place v.bigin() + 1 implines at i = 1, no. of times, value)
// v.insert(position, copy.begin(), copy.end())
// v1.swap(v2)
// v.clear() to clear v.empty() to check empty
// map assending order and set descending order 
// stringstream ss(str) Used for breaking words

int main(){
    FastIO;
    PRECISION;

    ll n;
    cin>>n;
    vll a(n);
    scan(a, n);
    ll h = a[0];
    ll ans = 0;
    loop(i, 0, n){
    	if(a[i] < h){
    		ans = ans - a[i] + h;
    	}
    	else if(a[i] > h){
    		h = a[i];
    	}
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 4764
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S.length()%2==1){cout<<NO<<endl;return;}
    else{
        REP(i, S.length()/2){
            int idx = i*2;
            if(S[idx]=='h' && S[idx+1]=='i'){}
            else{cout<<NO<<endl;return;}
        }
    }
    cout<<"Yes"<<endl;
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    char a[101]={0};
    char b[101]={0};
    char c[101]={0};
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);

    long sum=0;
    long i;
    for(i=0; i<n; i++) {
        if(a[i]==b[i] && a[i]==c[i]) {
            sum += 0;
        }
        else if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i]) {
            sum += 1;
        }
        else {
            sum += 2;
        }
    }
    printf("%ld\n", sum);
 
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c && b == c)
    {
        cout << 1;
    }
    else if (a == b || a == c || b == c)
    {
        cout << 2;
    }
    else
    {
        cout << 3;
    }
    
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
	int v;
	color[u]=GRAY;
	d[u]=++tt;
	for(v=0;v<n;v++){
		if(M[u][v]==0) continue;
		if(color[v]==WHITE){
			dfs_visit(v);
		}
	}
	color[u]=BLACK;
	f[u]=++tt;
}

void dfs(){
	int u;
	
	for(u=0;u<n;u++) color[u] = WHITE;
	tt=0;
	
	for(u=0;u<n;u++){
		if(color[u]==WHITE)dfs_visit(u);
	}
	
	for(u=0;u<n;u++){
		printf("%d %d %d\n",u+1,d[u],f[u]);
	}
}

int main() {
	int u,v,k,i,j;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			M[i][j]=0;
		}
	}
	
	for(i=0;i<n;i++){
		scanf("%d%d",&u,&k);
		u--;
		for(j=0;j<k;j++){
			scanf("%d",&v);
			v--;
			M[u][v]=1;
		}
	}
	
	dfs();
	
	return 0;
}

Measured memory_bytes: 2760
#!/usr/bin/env python3

x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ans += a[0] - 1;
    ll now = 2;
    for(i = 1;i < n;++i){
        if(a[i] == now) ++now;
        else ans += (a[i] - 1)/now;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4028
c = list(map(int, input().split()))
n, d = c[0], c[1]

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for l in range(n):
    a = x[l]*x[l] + y[l]*y[l]
    if a <= d*d:
        count += 1
print(count)


Measured memory_bytes: 116708
#include<bits/stdc++.h>
#define pb push_back
#define gc getchar 
using namespace std;
const int N=105;
typedef long long ll;
typedef double db;

int n,a[N],op[N];

char cp;
template<class T>inline void rd(T &x)
{
	cp=gc();x=0;int f=0;
	for(;!isdigit(cp);cp=gc()) if(cp=='-') f=1;
	for(;isdigit(cp);cp=gc()) x=x*10+(cp^48);
	if(f) x=-x;
}

int main(){
	int i,j,k,x,y;
    rd(n);
    for(i=1;i<=n;++i) rd(a[i]);
    for(i=n;i;--i){
    	for(j=i;j;--j)
    	 if(a[j]==j) break;
		if(!j) {puts("-1");return 0;}
		op[i]=j;
		for(;j<i;++j) a[j]=a[j+1];
	}
	for(i=1;i<=n;++i) printf("%d\n",op[i]);
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    cnt = 0
    # aが1からn-1まで動くと考える
    for a in range(1, n):
        # a*bがn-1以下であると考える
        cnt += (n-1) // a
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9020
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func dfs(s []string, a int, b int, c int) []string {
	if a < 0 || b < 0 || c < 0 {
		return nil
	}
	if len(s) == 0 {
		return []string{}
	}

	if "AB" == s[0] {
		if x := dfs(s[1:], a+1, b-1, c); x != nil {
			return append(x, "A")
		}
		if x := dfs(s[1:], a-1, b+1, c); x != nil {
			return append(x, "B")
		}
	} else if "AC" == s[0] {
		if x := dfs(s[1:], a+1, b, c-1); x != nil {
			return append(x, "A")
		}
		if x := dfs(s[1:], a-1, b, c+1); x != nil {
			return append(x, "C")
		}
	} else if "BC" == s[0] {
		if x := dfs(s[1:], a, b+1, c-1); x != nil {
			return append(x, "B")
		}
		if x := dfs(s[1:], a, b-1, c+1); x != nil {
			return append(x, "C")
		}
	}
	return nil
}

func main() {
	buf := make([]byte, 1024*1024)
	scanner.Buffer(buf, bufio.MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	a := readInt()
	b := readInt()
	c := readInt()

	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = readString()
	}

	ans := dfs(s, a, b, c)

	if len(ans) > 0 {
		fmt.Fprintln(w, "Yes")
	} else {
		fmt.Fprintln(w, "No")
		return
	}

	for i := len(ans) - 1; i > -1; i-- {
		fmt.Fprintln(w, ans[i])
	}
}

Measured memory_bytes: 36592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <cctype>
using namespace std;

int toInt(string s){
  istringstream iss(s);
  int a;
  iss >> a;
  return a;
}

int main(){
  int a;
  string s;
  
  cin >> a;
  string op;
  while(cin >> s){
    if(s == "=") break;
    if(!isdigit(s[0])){
      op = s;
    }
    else{
      if(op == "+"){
	int b = toInt(s);
	a += b;
      }
      else if(op == "-"){
	int b = toInt(s);
	a -= b;
      }
      else if(op == "*"){
	int b = toInt(s);
	a *= b;
      }
      else if(op == "/"){
	int b = toInt(s);
	a /= b;
      }
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,minus=0,minabs=1000000007; cin>>n;
    long long sum=0;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0) minus++;
        minabs=min(minabs,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(minus%2==0) cout<<sum<<endl;
    else cout<<sum-2*minabs<<endl;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s.at(i);
  for (int i = 0; i < h; i++) cout << s.at(i) << endl << s.at(i) << endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
C = III()
C.sort()

ans = 0
for i in range(N):
    ans += pow(4,N-1,mod)*C[i]*(N-i+1)
    ans %= mod

print(ans)

Measured memory_bytes: 80992
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] hp = new int[N];
    long sum = 0;
    for(int i=0; i<N; i++){
      int tmp = sc.nextInt();
      hp[i] = tmp;
    }
    Arrays.sort(hp);
    for(int i=0; i<N -K; i++){
      sum += hp[i];
    }
    System.out.println(sum);
  }
}



Measured memory_bytes: 65412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string S_input;
string S = "AKIHABARA";
int size_S = S.size();
vector<string> v;

int create(string s_ch, int i);

int main() {


    cin >> S_input;
    
    create("", 0);

    auto result = find(v.begin(), v.end(), S_input);
    if (result == v.end()) {
        cout << "NO" << endl;
    } 
    else {
        cout << "YES" << endl;
    }

}


int create(string s_ch, int i) {
    
    if (i == size_S) {
        v.push_back(s_ch);
        return 0;
    }
    
    if (S[i] == 'A') {
        create(s_ch, i+1);
        s_ch += S[i];
        create(s_ch, i+1);
    }
    else {
        s_ch += S[i];
        create(s_ch, i+1);
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};


signed main() {
	int i, j, n, sum = 0, cnt = 0;
	string s, s1, s2;
	bool flag = false;
	vector<int>list(26,0);
	int m,f,r;




	while (cin >> m >> f >> r) {
		if (m == -1 && f == -1 && r == -1) break;

		if (m == -1 || f == -1) {
			cout << "F" << endl;
		}
		else if (m + f >= 80) {
			cout << "A" << endl;
		}
		else if (m + f >= 65 &&  m + f < 80) {
			cout << "B" << endl;
		}
		else if (m + f >= 50 && m + f < 65) {
			cout << "C" << endl;
		}
		else if (m + f >= 30 && m + f < 50) {
			if (r >= 50) {
				cout << "C" << endl;
			}
			else {
				cout << "D" << endl;
			}
		}
		else if ( m + f < 30) {
			cout << "F" << endl;
		}

	}











	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main()
{
    int n,i,j,k,sum,tmp,x,y,z;
    int h,c,d,e;
    cin>>n>>h;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }
    sort(a,a+n);
    sort(b,b+n);
    for(i=n-1,sum=0;i>=0;i--){
        if(b[i]<a[n-1]){
            break;
        }
        if(h<=0){
            break;
        }
        h-=b[i];
        sum++;
    }
    if(h>0){
        //cout<<"sum="<<sum<<endl;
        tmp=h/a[n-1];
        if(h%a[n-1]!=0)
            tmp++;
        sum+=tmp;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int n, money = 100000;
	cin >> n;

	for (int i = 0; i < n; i++) {
		money *= 1.05;
		if (money % 1000 == 0) {
			continue;
		}
		money += 1000 - money % 1000;
	}

	cout << money << endl;

	return 0;
}

Measured memory_bytes: 2988
### constant

N = 1000
G = 3
GG = G * G

BTNS = ["ABC", "DEF", "GHI"]
DXYS = [[1, 0], [0, 1], [-1, 0], [0, -1]]

### main

nbrs = Array.new(GG){Array.new(GG){false}}

for y0 in (0...G)
  for x0 in (0...G)
    c0 = BTNS[y0][x0].ord - 'A'.ord

    DXYS.each do |dx, dy|
      x = x0 + dx
      y = y0 + dy
      if x >= 0 && x < G && y >= 0 && y < G
        c1 = BTNS[y][x].ord - 'A'.ord
        nbrs[c0][c1] = nbrs[c1][c0] = true
      end
    end
  end
end

while line = gets
  str = line.strip

  cf = true
  prvc = str[0].ord - 'A'.ord

  for i in (1...str.length)
    c = str[i].ord - 'A'.ord
    if ! nbrs[prvc][c]
      cf = false
      break
    end
    prvc = c
  end

  puts str if cf
end

Measured memory_bytes: 6120
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#define inf 20021225
#define ll long long
#define N 2100
using namespace std;
int read()
{
	int f=1,s=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9')	s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int a[N][N],p[N][N],e[N][N],hp[N][N],lp[N][N],n,m; char ch[N];
int main()
{
	n=read(),m=read(); int Q=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++)
		{
			a[i][j]=ch[j]-'0';
			p[i][j]=p[i-1][j]+p[i][j-1]-p[i-1][j-1]+a[i][j];
			e[i][j]=e[i-1][j]+e[i][j-1]-e[i-1][j-1]+(a[i][j]&a[i-1][j])+(a[i][j-1]&a[i][j]);
			hp[i][j]=hp[i][j-1]+(a[i][j]&a[i-1][j]);
			lp[i][j]=lp[i-1][j]+(a[i][j]&a[i][j-1]);
		}
	}
	while(Q--)
	{
		int h1=read(),l1=read(),h2=read(),l2=read();
		int poi=p[h2][l2]-p[h2][l1-1]-p[h1-1][l2]+p[h1-1][l1-1];
		//printf("%d %d %d %d\n",p[h2][l2],p[h2][l1-1],p[h1-1][l2],p[h1-1][l1-1]);
		int ed=e[h2][l2]-e[h2][l1-1]-e[h1-1][l2]+e[h1-1][l1-1];
		//printf("%d ",ed);
		ed -= hp[h1][l2]-hp[h1][l1-1];
		ed -= lp[h2][l1]-lp[h1-1][l1];
		//printf("%d %d %d %d\n",hp[h1][l2],hp[h1][l1-1],lp[h2][l1],lp[h1-1][l1]);
		printf("%d\n",poi-ed);
	}
	return 0;
}

Measured memory_bytes: 87680
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lc (o<<1)
#define rc (o<<1|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
int p[N],vis[N],q[N];
ll a[N],ans[N],s,k;
int n,m,len,x;

int main(){
	read(n);
	rep(i,1,n){
		read(a[i]);
		a[i]-=s,s+=a[i];
		p[i]=i;
	}
	read(m),read(k);
	rep(i,1,m){
		read(x);
		swap(p[x],p[x+1]);
	}
	rep(i,1,n){
		if(vis[i]) continue; len=0;
		for(int j=i;!vis[j];j=p[j]) q[len++]=j,vis[j]=1;
		REP(j,len) ans[q[j]]=a[q[(j+k)%len]];
	}
	rep(i,1,n){
		ans[i]+=ans[i-1];
		printf("%lld.0\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 12416
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,m = map(int,input().split())

if n==1 and m==1:
    ans = 1
elif n==1 or m==1:
    ans = n*m-2
elif n==2 or m==2:
    ans = 0
else:
    ans = (n-2)*(m-2)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    int n,r;
    cin>>n>>r;
    if(n<10)cout<<r+100*(10-n)<<endl;
    else cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
const int inf = (int) 1e9+7;
map<int,int> m;
int main(){
	fastIO;         
	int n;
	cin>>n; 
	for(int i=2;i<=n;i++){
		int x=i;
		for(int j=2;j<=sqrt(i);j++){
			if(x%j==0){
				while(x%j==0){
					m[j]++;
					x/=j;		
				}
			}
		}
		if(x>1)m[x]++;
	}
	long long ans=1;
	for(auto i : m){
		//cout<<i.first<<'\n';
		ans =(ans*(i.second+1)) % inf;
		//cout<<ans<<'\n';	
	}                    
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int d,m1=0,m2=0,m3=0,i;
    for(i=0;i<10;i++){
        scanf("%d",&d);
        if(d>m1){
            m3=m2;
            m2=m1;
            m1=d;
        }else if(d>m2){
            m3=m2;
            m2=d;
        }else if(d>m3){
            m3=d;
        }
    }
    printf("%d\n",m1);
    printf("%d\n",m2);
    printf("%d\n",m3);
    return 0;
}

Measured memory_bytes: 1028
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005];
ll sum = 0;

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	ll ans = 1e18;
	for(int i = 1; i < 200; i++) {
		sum = 0;
		for(int j = 0; j < N; j++) {
			sum += pow(arr[j] - i, 2);
		}
		ans = min(sum, ans);
	}
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int res=0;
string s;
vector<int> V;

int main()
{
    cin>>s;
    string ss="";
    V.push_back(0);
    for(int i=0;i<s.size();i++)
        if(s[i]!='x')
        {
            ss+=s[i];
            V.push_back(i+1);
        }
    V.push_back(s.size()+1);
    if(ss=="")
    {
        cout<<0;
        return 0;
    }
    for(int i=0;i<ss.size();i++)
        if(ss[i]!=ss[ss.size()-i-1])
        {
            cout<<-1;
            return 0;
        }
    for(int i=1;i<=(V.size()-1)/2;i++)
    {
        int l=V[i]-V[i-1];
        int r=V[V.size()-i]-V[V.size()-i-1];
        res+=max(l,r)-min(l,r);
    }
    cout<<res;
}


Measured memory_bytes: 1148
def find_max_profit(prices:list) -> int:
    maxp = -10000000000
    minp = prices[0]
    for i in range(1,len(prices)):
        if prices[i] - minp > maxp:
            maxp = prices[i] - minp
        if prices[i] < minp:
            minp = prices[i]
    return maxp            
    
if __name__ == '__main__':
    n = int(input())
    prices = []
    for i in range(n):
        prices.append(int(input()))
    print(find_max_profit(prices))

    


Measured memory_bytes: 13592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static int linearSearch(int x, int[] arr) {
        int i = 0;
        while (arr[i] != Integer.MIN_VALUE) {
            if (arr[i] == x) return arr[i];
            i++;
        }
        return Integer.MIN_VALUE;
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(in.readLine());
            if (n <= 0) {
                System.out.println(0);
                System.exit(0);
            }

            String[] line = in.readLine().split(" ");
            int[] S = new int[n + 1];
            S[n] = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                S[i] = Integer.parseInt(line[i]);
            }

            int q = Integer.parseInt(in.readLine());
            line = in.readLine().split(" ");
            int C = 0;
            for (int i = 0; i < q; i++) {
                int t = Integer.parseInt(line[i]);
                int ret = linearSearch(t, S);
                if (ret != Integer.MIN_VALUE) C++;
            }

            System.out.println(C);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 26992
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
L_1 = set([l[1] for l in L if l[0]==1])
L_2 = set([l[0] for l in L if l[1]==N])
print("POSSIBLE" if L_1&L_2 else "IMPOSSIBLE")

Measured memory_bytes: 53848
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        a: usize,
        b: usize,
    }
    if a * 500 >= b {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352