akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
    while(x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *y;
    Node *x;

    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }

    free(y);
}

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

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    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 *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

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

int main() {
    int n, i, x;
    string com;

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            cin >> x;
            Node *t = find(root, x);
            if (t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if (com == "insert") {
            cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if (com == "delete") {
            cin >> x;
            treeDelete(find(root, x));
        }
    }

    return 0;
}


Measured memory_bytes: 21888
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
int main(){
	int N; cin >> N;
	vector<pair<int, int> > AB(N);

	for(int i = 0; i < N; ++i) cin >> AB[i].second >> AB[i].first;

	sort(AB.begin(), AB.end());

	ll sum = 0;
	for(int i = 0; i < N; ++i){
		sum += AB[i].second;
		if(sum > AB[i].first) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1792
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, m: usize);
    let ceil2 = |x: usize| if x % 2 == 1 { x / 2 + 1 } else { x / 2 };
    for i in 0..ceil2(m) {
        println!("{} {}", i + 1, n - i);
    }
    let c = ceil2(n);
    for i in 0..(m / 2) {
        println!("{} {}", c - i - 1, c + i + 1);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2136
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<bits/stdc++.h>
using namespace std;

/*define*/
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//typedef pair<int, int> P;
static const int max_n = 10000, max_m = 102;
static const int  INF = 1000000000;
int ci;

int main(){
    string a; cin >> a;
    rep(i, 8){
        int c = a[0] - '0';
        string ans;
        ans.push_back(a[0]);
        rep(j, 3){
            if((i>>j)&1){
                ans.push_back('+');
                ans.push_back(a[j+1]);
                c += a[j+1] -'0';
            }else{
                ans.push_back('-');
                ans.push_back(a[j+1]);
                c -= a[j+1] -'0';
            }
        }
        if(c==7){
            cout << ans << "=7";
            cin >> ci;
            break;
        }
    }
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll N;
ll A[200001],B[200001];
ll dp[4011][4011];
ll fac[8011],finv[8011];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  else return (fac[n]*finv[r]%mod)*finv[n-r]%mod;
}

int main(){
  fac[0]=1;
  rep(i,8000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,8001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N;
  rep(i,N){
    cin>>A[i]>>B[i];
    dp[2000-A[i]][2000-B[i]]++;
  }
  rep(i,4001)rep(j,4001){
    (dp[i+1][j]+=dp[i][j])%=mod;
    (dp[i][j+1]+=dp[i][j])%=mod;
  }
  ll res=0,sub=0;
  rep(i,N){
    (res+=dp[A[i]+2000][B[i]+2000])%=mod;
    (sub+=comb(2*(A[i]+B[i]),2*A[i]))%=mod;
  }
  cout<<(res-sub+mod)*mod_pow(2,mod-2)%mod<<endl;
  return 0;
}


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

int main() {
   int n,m;
   cin>>n>>m;
   vector<int> a(m,0);
   for(int i=0;i<n;i++){
   	int k;
    cin>>k;
     for(int j=0;j<k;j++){
     	int b;
        cin>>b;
        a[b-1]++;
     }
   }
  int ans=0;
	for(int i=0;i<m;i++){
    	if(a[i]==n) ans++;
    }  
  cout<<ans;
}


Measured memory_bytes: 3652
s = input()
n = int(input())
for _ in range(n):
    li = input().split()
    op = li[0]
    a, b = map(int, li[1:3])
    if op == "replace":
        p = li[3]
        s = s[:a] + p + s[b+1:]
    elif op == "reverse":
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif op == "print":
        print(s[a:b+1])


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

int main()
{
    int N, D;
    cin >> N >> D;
    float answer;
    if (N % (2 * D + 1) == 0) {
        answer = N / (2 * D + 1);
    } else {
        answer = static_cast<int>(N / (2 * D + 1)) + 1;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
std::vector<int> a,b;
int N,M;

int loboa(int n){
  int l=0,r=N;
  while(r-l>1){
    int m=(l+r)/2;
    if(a[m]>=n)l=m;
    else r=m;
  }
  return l;
}
int lobob(int n){
  int l=0,r=M;
  while(r-l>1){
    int m=(l+r)/2;
    if(b[m]>=n)l=m;
    else r=m;
  }
  return l;
}

signed main() {
  cin>>N>>M;
  //std::vector<int> a(N),b(M);
  a.resize(N);b.resize(M);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<M;i++)cin>>b[i];
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  for(int i=1;i<N;i++)if(a[i]==a[i-1]){cout<<0<<endl;return 0;}
  for(int i=1;i<M;i++)if(b[i]==b[i-1]){cout<<0<<endl;return 0;}
  int ans=1;
  for(int i=N*M;i>0;i--){
    int A=loboa(i);
    int B=lobob(i);
    if(a[A]<i||b[B]<i){cout<<0<<endl;return 0;}
    if(a[A]==i&&b[B]==i)continue;
    if(a[A]==i)ans*=B+1;
    if(b[B]==i)ans*=A+1;
    if(a[A]!=i&&b[B]!=i){
      if((A+1)*(B+1)-N*M+i>0)ans*=(A+1)*(B+1)-N*M+i;
      else {cout<<0<<endl;return 0;}
    }
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
typedef modint<MOD> m;
#pragma endregion

int main() {
  cin >> A >> B >> C;
  if(A == B && B != C){
    cout << "Yes";
  }else if(B == C && A != B){
    cout << "Yes";
  }else if(A == C && A != B){
    cout << "Yes";
  }else{
    cout << "No";
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(void){
  int n;
  cin>>n;
  int l[n];
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    l[t-1]=i+1;
  }
  set<int>s;
  s.insert(0);
  s.insert(n+1);
  int a;
  for(int i=0;i<n;i++){
    decltype(s)::iterator it=s.lower_bound(l[i]);
    int x=*it--;
    int y=*it;
    a+=(x-l[i])*(l[i]-y)*(i+1);
    s.insert(l[i]);
  }
  cout<<a<<'\n';
}

Measured memory_bytes: 11136
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int N  = 57;
// int a[N], b[N], c[N], d[N];
struct T{
    int a, b, c, d;
};

T a[N];
int n, m, q; 
set<vector<int>> ct;
int ans = 0;
int get(vector<int>& d) {
    int ret = 0;
    for (int i = 1; i <= q; ++i) {
        if (d[a[i].b - 1] - d[a[i].a - 1] == a[i].c) {
            ret += a[i].d;
        }
    }
    return ret;
}

auto mutate(vector<int> c) -> void {
    if (ct.count(c)) return;
    ct.emplace(c);
    ans = max(ans, get(c));
    for (int i = 0; i < n; ++i) {
        if (c[i] == m) continue;
        if (i < n - 1 && c[i] + 1 > c[i + 1]) continue;
        ++c[i];
        if (!ct.count(c)) mutate(c);
        --c[i];
    }

}


auto main() -> int {
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> q;
    for (int i = 1; i <= q; ++i) {
        cin >> a[i].a >> a[i].b >> a[i].c >> a[i].d;
    }
    vector<int> ini(n, 1);
    mutate(ini);
    cout << ans << "\n";
	return 0;
}


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

int main() {
    ll N;
    cin >> N;

    vector<int> a(N);
    int x = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        x = x ^ a[i];
    }

    for (int i = 0; i < N; i++) {
        int output = x ^ a[i];
        printf("%d ", output);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 4044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BFrog2 solver = new BFrog2();
        solver.solve(1, in, out);
        out.close();
    }

    static class BFrog2 {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int k = in.scanInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.scanInt();
            }
            long dp[] = new long[n];
            Arrays.fill(dp, Long.MAX_VALUE / 2);


            dp[0] = 0;
            for (int i = 1; i < n; i++) {

                for (int j = 1; j <= k; j++) {
                    if (i - j >= 0) dp[i] = Math.min(dp[i - j] + Math.abs(arr[i] - arr[i - j]), dp[i]);
                }
            }
            out.println(dp[n - 1]);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    ll a, b, x;
    cin >> a >> b >> x;

    // 処理
    ll ans = 0;
    if (a > 0) {
        ans = b / x - (a - 1) / x;
    } else {
        ans = b / x + 1;
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL long long

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const LL N=5005;
LL n,sum[N][3],ans;
//R==0,G==1,B==2
char s[N];

int main()
{
	n=read();
	scanf("%s",s+1);
	for(LL i=1;i<=n;++i)
	{
		sum[i][0]=sum[i-1][0];
		sum[i][1]=sum[i-1][1];
		sum[i][2]=sum[i-1][2];
		if(s[i]=='R')
			sum[i][0]++;
		else if(s[i]=='G')
			sum[i][1]++;
		else
			sum[i][2]++;
	}
	for(LL i=1;i<=n;++i)
		for(LL j=i+1;j<=n;++j)
			if(s[i]!=s[j])
			{
				LL l=j-i;
				if(s[i]=='R'&&s[j]=='B'||s[j]=='R'&&s[i]=='B')
				{
					ans+=sum[i-1][1];
					if(i-l>=1&&s[i-l]=='G')
						ans--;
				}
				if(s[i]=='R'&&s[j]=='G'||s[j]=='R'&&s[i]=='G')
				{
					ans+=sum[i-1][2];
					if(i-l>=1&&s[i-l]=='B')
						ans--;
				}
				if(s[i]=='G'&&s[j]=='B'||s[j]=='G'&&s[i]=='B')
				{
					ans+=sum[i-1][0];
					if(i-l>=1&&s[i-l]=='R')
						ans--;
				}
			}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3804
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let mut a: Vec<i32> = readnc();
    a.sort();
    if a[0] == 5 && a[1] == 5 && a[2] == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

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

	ll ans = 0;

	for (int i = 0; i < n; ++i) {
		if (i > 0 && s[i] == 'L' && s[i - 1] == 'L')
			++ans;
		if (i < n - 1 && s[i] == 'R' && s[i + 1] == 'R')
			ans++;
	}
	ans += 2 * k;
	ans = min((ll)n - 1, ans);

	cout << ans << endl;

	return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	static int h, w, memo[][];
	static char field[][];
	static int INF = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		h = fs.nextInt(); w = fs.nextInt();
		field = new char[h][w];
		for(int i=0;i<h;i++) {
			String s = fs.next();
			for(int j=0;j<s.length();j++) {
				field[i][j]=s.charAt(j);
			}
		}
		//startだけ決めて、一番遠いところをゴールにする
		int ans = 0;
		memo = new int[h][w];
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				for(int k=0;k<h;k++) {
					Arrays.fill(memo[k], INF);					
				}
				if(field[i][j]=='#')continue;
				dfs(i,j, 0);
				ans = Math.max(ans, check());
			}
		}
		System.out.println(ans);
	}
	
	static int check() {
		int res = 0;
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(memo[i][j]==INF)continue;
				res = Math.max(res, memo[i][j]);
			}
		}
		return res;
	}
	
	static void dfs(int x, int y, int d) {
		if(memo[x][y]<=d)return;
		memo[x][y]= Math.min(memo[x][y], d);
		for(int i=0;i<4;i++) {
			int dx = DX[i]; int dy = DY[i];
			int nx = x + dx , ny = y + dy;
			if(0<=nx&&nx<h&&0<=ny&&ny<w) {
				if(memo[nx][ny]==1)continue;
				if(field[nx][ny]=='#')continue;
				dfs(nx, ny, d+1);
			}
		}
	}
}

//高速なScanner
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: 24660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin>>vec[i];
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int a=0, b=0;
  for(int i=0; i<N; i++){
    if(i%2==0){
      a+=vec[i];
    }
    else{
      b+=vec[i];
    }
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b;
  cin >> a >> b;
  if (a%b==0) cout << -1 << endl;
  else cout << a << endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll g(ll x) {
  ll ans = 0;
  if (x % 2 == 0) ans = x;
  ans +=  ((x+1) / 2) % 2;

  return ans;
}

int main() {
  ll a, b;
  cin >> a >> b;

  ll ans;
  if (a == 0) {
    ans = b;
  } else {
    // cout << g(a - 1) << endl;
    // cout << g(b) << endl;
    ans = g(a - 1) ^ g(b);
  }

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


Measured memory_bytes: 256
b = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[b-1])

Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  input_lines = line.split(" ")
});

reader.on('close', () => {
    var new_input_lines = [];
    for(var i=0;i<input_lines.length;i++){
        new_input_lines[i] = parseInt(input_lines[i]);
    }
    var N = new_input_lines[0]
    var A = new_input_lines[1]
    var B = new_input_lines[2]
    
    if (A * N > B) {
      console.log(B)
    }else{
      console.log(N * A)
    }
});

Measured memory_bytes: 30936
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <int64_t MOD>
class Modint {
  using Self = Modint<MOD>;

  int64_t m_value;

 public:
  Modint(int64_t value) : m_value((value % MOD + MOD) % MOD) {}
  Self pow(int64_t e) const {
    if (e == 0) {
      return (Self)1;
    } else if (e % 2 == 0) {
      return ((*this) * (*this)).pow(e / 2);
    } else {
      return (*this).pow(e - 1) * (*this);
    }
  }
  Self inv() const { return pow(MOD - 2); }
  Self& operator=(const Self& rh) {
    m_value = rh.m_value;
    return *this;
  }
  Self operator-() const { return Self(-m_value); }
  Self operator+(const Self& other) const {
    return Self(m_value + other.m_value);
  }
  Self operator-(const Self& other) const {
    return Self(m_value - other.m_value);
  }
  Self operator*(const Self& other) const {
    return Self(m_value * other.m_value);
  }
  Self operator/(const Self& other) const { return (*this) * other.inv(); }
  Self& operator+=(const Self& rh) { return (*this) = (*this) + rh; }
  Self& operator-=(const Self& rh) { return (*this) = (*this) - rh; }
  Self& operator*=(const Self& rh) { return (*this) = (*this) * rh; }
  int64_t value() const { return m_value; }
};

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

  vector<int> pos(26, 1);
  for (char c : s) {
    pos[c - 'a']++;
  }

  using Mint = Modint<1'000'000'007>;
  Mint result = 1;
  for (int p : pos) {
    result *= p;
  }
  result -= 1;
  cout << result.value() << endl;

  return 0;
}

Measured memory_bytes: 3704
#include<stdio.h>
int A[20];

int alg(int,int,int);

int main(){
  int n,q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(alg(0,m,n))printf("yes\n");
    else printf("no\n");
  }
}


int alg(int i,int m,int n){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  res=alg(i+1,m,n)||alg(i+1,m-A[i],n);
  return res;
}



Measured memory_bytes: 2076
#include<iostream>
using namespace std;
int main(){
  int a=0,b=0;
  
  cin>>a>>b;
  
  if(a+b==15){
    cout<<"+"<<endl;
  }else if(a*b==15){
    cout<<"*"<<endl;
  }else{
    cout<<"x"<<endl;
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
//#define push push_back
//#define pop pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
// ll mod(ll a, ll b)
// {
// 	if(a%b<0)
// 	{
// 		return a%b + b;
// 	}
// 	return a%b;
// }
 
 
// ll mod_exp(ll a, ll b, ll c)
// {
// 	ll res=1;
// 	a=a%c;
// 	while(b>0)
// 	{
// 		if(b%2==1)
// 		{
// 			res=(res*a)%c;
// 		}
// 		b/=2;
// 		a=(a*a)%c;
// 	}
// 	return res;
// }
// ll mymod(ll a,ll b)
// {
//     return ((a%b)+b)%b;
// }
// bool prime[200001];
// void SieveOfEratosthenes() 
// { 
//     memset(prime, true, sizeof(prime)); 
//     prime[1]=false;
//     for (int p=2; p*p<=200000; p++) 
//     { 
//         if (prime[p] == true) 
//         { 
//             for (int i=p*p; i<=200000; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
//     return;
// }
// ll powe[200005];
// void power()
// {
//     powe[0]=1;
//     REP(i,1,200005)
//     {
//         powe[i]=mymod(2*powe[i-1],num);
//     }
// }
// ll gcdExtended(ll,ll,ll *,ll *);
// ll modInverse(ll a, ll m) 
// { 
//     ll x, y; 
//     ll g = gcdExtended(a, m, &x, &y); 
//         ll res = (x%m + m) % m;
//         return res;
// } 
// ll gcdExtended(ll a, ll b, ll *x, ll *y) 
// { 
//     if (a == 0) 
//     { 
//         *x = 0, *y = 1; 
//         return b; 
//     } 
//     ll x1, y1; 
//     ll gcd = gcdExtended(b%a, a, &x1, &y1); 
//     *x = y1 - (b/a) * x1; 
//     *y = x1; 
//     return gcd; 
// } 
// ll facto[200005];
// void f()
// {
// 	facto[0]=1;
// 	REP(i,1,200005)
// 	{
// 		facto[i]=mymod((i*facto[i-1]),num);
// 	}
// }
string ans="";
void dfs(set<ll> adj[], ll a, bool def[], ll parent=-1)
{
    def[a]=true;
    for(auto x: adj[a])
    {
        if(parent!=-1 && x!=parent && def[x])
        {
            cout<<"Impossible\n";
            exit(0);
        }
        if(!def[x])
        {
            dfs(adj,x,def,a);
        }
    }
    ans+=(char)(a+97);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    REP(i,1,100000)
    {
        if((8*i)/100 == a && (10*i)/100 ==b)
        {
            cout<<i<<"\n";
            exit(0);
        }
    }
    cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		for(int i=1;i<n+1;i++){
			if(String.valueOf(i).length()%2!=0){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 28628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int main(){    
    int n ;
    cin >> n ;
    if (n >= 30)
    {
        cout << "Yes" << endl ;
    }else
    {
        cout << "No" << endl ;
    }
    
    
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

int main() {
	int h, w;
	int map[10][10];

	std::cin >> h >> w;

	for (size_t i = 0; i < 10; i++)
	{
		for (size_t j = 0; j < 10; j++)
		{
			std::cin >> map[i][j];
		}
	}

	for (size_t k = 0; k < 10; k++)
	{
		for (size_t i = 0; i < 10; i++)
		{
			for (size_t j = 0; j < 10; j++)
			{
				map[i][j] = std::min(map[i][j], map[i][k] + map[k][j]);
			}
		}
	}

	int ans = 0;

	for (size_t i = 0; i < h; i++)
	{
		for (size_t i = 0; i < w; i++)
		{
			int n;

			std::cin >> n;
			if (n == -1) continue;

			ans += map[n][1];
		}
	}

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

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

int main(){
	int n, q, l, r;
	string s;
	cin >> n >> q >> s;
	vector<int> ac(n);
	rep(i, n){
		if(i == 0){
			ac.at(0) = 0;
			continue;
		}
		ac.at(i) = ac.at(i-1);
		if(s[i] == 'C' && s[i-1] == 'A') ac.at(i)++;
	}
	rep(i, q){
		cin >> l >> r;
		l--; r--;
		cout << ac.at(r)-ac.at(l) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>

class A
{
public:
    A()
    {
        int n;
        std::cin >> n;

        std::vector<int> a(n);
        for(int i = 0; i < n; ++i)
        {
            std::cin >> a[i];
        }

        int cnt = bubbleSort(a, n);

        show(a);
        std::cout << cnt << std::endl;
    }

    const int bubbleSort(std::vector<int>& a,  const int n)
    {
        int cnt = 0;
        bool flag = true;

        while(flag)
        {
            flag = false;

            for(int i = n - 1; i >= 1; --i)
            {
                if(a[i] < a[i - 1])
                {
                    int v = a[i];
                    a[i] = a[i - 1];
                    a[i - 1] = v;

                    flag = true;
                    cnt++;
                }
            }
        }

        return cnt;
    }

    void show(const std::vector<int>& a)
    {
        for(int i = 0; i < a.size(); ++i)
        {
            std::cout << a[i] << (i + 1 == a.size() ? "\n" : " ");
        }
    }
};

int main(void)
{
    A a;
    return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
int main(){
    int n, i = 0;
    scanf("%d",&n);
    int a[n];
    int count = 0;
    for(; i < n; i++){
        scanf("%d",&a[i]);
        if(a[i] % 2 != 0){
            a[i] = -1;
        }
        else count ++;
    }
    int p = 0;
    for(i = 0 ; i < n; i++){
        if(a[i] != -1){
            if(a[i] % 3 == 0 || a[i] % 5 == 0)
                p++;
        }
    }
    if(p == count)
        puts("APPROVED");
    else puts("DENIED");
    return 0;
}

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

    vector<string>w(n);
    for (int i=0;i<n;i++) {
        cin>>w[i];
    }

    bool answer=true;

    for (int i=0;i<=n-2;i++) {
        if(w[i].back()!=w[i+1].front()){
            answer=false;
        }
    }

    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n;j++) {
            if(w[i]==w[j]){
                answer=false;
            }
        }
    }

    if(answer==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define Max 1000

int main() {
    vector<int> v[Max];
    int q, n;
    cin >> n >> q;
    int num, qst, x;
    for (int i = 0; i < q; i++) {
        cin >> qst >> num;
        if (qst == 0) {
            cin >> x;
            v[num].push_back(x);
        } else if (qst == 1) {
            for (int i = 0; i < v[num].size(); i++) {
                if (i) cout << " ";
                cout << v[num][i];
            }
            cout << endl;
        } else {
            v[num].clear();
        }
    }
    return 0;
}


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

typedef long long ll;

const int MAXN = 1e5 + 10;

vector<int> grafo[MAXN];
ll dp[MAXN],correction[MAXN],ansP[MAXN];
int N,M;

void dfs1(int v,int p){

	dp[v] = 1;
	vector<int> children;
	for(int u : grafo[v]){
		if(u == p) continue;
		dfs1(u,v);
		dp[v] = (dp[v] * (1 + dp[u])) % M;
		children.push_back(u);
	}

	vector<ll> prefV,sufV;
	ll pref = 1, suf = 1;
	for(int i = 0;i<(int)children.size();i++){
		int u = children[i];
		prefV.push_back(pref);
		pref = (pref * (1 + dp[u])) % M;
	}
	for(int i = (int)children.size() - 1;i>=0;i--){
		int u = children[i];
		sufV.push_back(suf);
		suf = (suf * (1 + dp[u])) % M;
	}
	reverse(sufV.begin(),sufV.end());
	for(int i = 0;i<(int)children.size();i++){
		int u = children[i];
		correction[u] = (prefV[i]*sufV[i]) % M;
	}

}

void dfs2(int v,int p){

	ansP[v] = (dp[v] * correction[v]) % M;

	for(int u : grafo[v]){
		if(u == p) continue;
		correction[u] = (correction[u] * (correction[v]) + 1) % M;
		dfs2(u,v);
	}

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<N;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}

	dfs1(1,-1);
	correction[1] = 1;
	dfs2(1,-1);

	for(int i = 1;i<=N;i++) printf("%lld\n",ansP[i]);

	return 0;

}

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

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

int main() {
    int N, K, C; cin >> N >> K >> C;
    string S; cin >> S;
    vector<bool> ok(N); for (int i = 0; i < N; i++) ok[i] = S[i] =='o';
    vector<bool> lef(N, false);
    int l = 0;
    for (int i = 0; i < N; i++) {
        if (ok[i]) {
            l++;
            lef[i] = true;
            i += C;
        }
    }
    vector<bool> rig(N, false);
    int r = 0;
    for (int i = N-1; 0 <= i; i--) {
        if (ok[i]) {
            r++;
            rig[i] = true;
            i -= C;
        }
    }
    if (l == K && r == K) {
        for (int i = 0; i < N; i++) if (lef[i] && rig[i]) cout << i + 1 << endl;
    }
}


Measured memory_bytes: 1796
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-16 19:45:23
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e4 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 998244353; // 1e9 + 9;

ll n , k , ans[MAXN] , fact[MAXN] , inv[MAXN] , pw2[MAXN] , cost[MAXN];

ll C(ll r , ll n){
    if(r < 0 || r > n || n < 0) return 0;
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

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

    fact[0] = inv[0] = pw2[0] = 1;
    for(int i = 1 ; i < MAXN ; i++) pw2[i] = pw2[i - 1] * 2 % MOD , fact[i] = fact[i - 1] * i % MOD , inv[i] = poww(fact[i] , MOD - 2 , MOD);
    cin >> k >> n;
    for(int i = 0 ; i <= k ; i++){
        for(int j = 0 ; j <= i ; j++){
            cost[i] += C(k - i - i + j - 1 , n + k - i - i - 3) * pw2[j] % MOD * C(j , i) % MOD;
            //cout << i << sep << j << sep << cost[i] << endl;
        }
        cost[i] %= MOD;
        //cout << i << sep << cost[i] << endl;
    }
    for(int i = 1 ; i <= k ; i++){
        for(int j = i ; j <= k ; j++){
            ll L = max(1ll , i + j - k) , R = i , x = max(0LL , R - L);
            //cout << i << sep << j << sep << L << sep << R << sep << x << endl;
            ans[i + j] += MOD - cost[x];
        }
    }
    //for(int i = 2 ; i <= n + n ; i++)   cout << i << sep << ans[i] << endl;
    for(int i = 2 ; i <= k + k ; i++)   cout << (ans[i] + C(k - 1 , n + k - 1)) % MOD << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 640
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] MP = new int[H+1];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }
        for(int i=0;i<=H;i++){
            MP[i] = Integer.MAX_VALUE;
        }
        MP[0]=0;
        for(int i=1;i<=H;i++){
            for(int j=0;j<N;j++){
                if(i-A[j]<=0){
                    MP[i] = Math.min(B[j], MP[i]);
                }else{
                    MP[i] = Math.min(B[j] + MP[i-A[j]], MP[i]);
                }
            }
        }
        System.out.println(MP[H]);
    }
}


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

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(reader.readLine());
		String data[] = reader.readLine().split(" ");
		int[] ints = new int[num];
		for(int i=0; i<num; i++){
			ints[i] = Integer.parseInt(data[i]);
		}
		int max=Integer.MIN_VALUE;
		int min=Integer.MAX_VALUE;
		long sum=0;
		
		for(int i : ints){
			if(max<i)
				max=i;
			if(min>i)
				min=i;
			sum+=i;
		}
		
		System.out.println(Integer.toString(min)+" "+Integer.toString(max)+" "+Long.toString(sum));
		
	}
}

Measured memory_bytes: 25536
# -*- coding: utf-8 -*-
import math
    
def abs(num):
    if num < 0:
        return -num
    else:
        return num

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    s_dict = {}
    for _ in range(n):
        s = input()
        s_dict[s] = 1

    print(len(s_dict))
    
# else:
    # do nothing

Measured memory_bytes: 35424
#include<bits/stdc++.h>
using namespace std ;
const int N= 3e5;
int Mod = 1e9+7 ;
long long cum [N];


int main(){
    string N;
    cin >> N;
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < N.length(); ++i) {
        if (N[i] == 'R') {
            tmp++;
            ans = tmp;
        } else {
            if (ans < tmp) {
              ans = tmp;
            }
            tmp = 0;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main() {
  string S, T;
  int c = 0;
  cin >> S >> T;
  S[0]==T[0]?c++:false;
  S[1]==T[1]?c++:false;
  S[2]==T[2]?c++:false;
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int a[] = {
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};


int main(int argc, char const *argv[]) {
    // code
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n = sc.nextLong();
        	long res =0;
        	for(int i=1;i<=n;i++) {
        		if(i%3!=0 && i%5!=0)
        			res=res+i;
        	}
        	System.out.println(res);
    }
}


Measured memory_bytes: 35760
<?php
	function swap(&$array, $i, $j){
		$tmp = $array[$i];
		$array[$i] = $array[$j];
		$array[$j] = $tmp;
	}

	function selectionSort(&$array){
		$count = 0;
		for($i = 0; $i < count($array) - 1; ++$i){
			$min = $array[$i];
			$index = $i;
			for($j = $i + 1; $j < count($array); ++$j){
				if($min > $array[$j]){
					$min = $array[$j];
					$index = $j;
				}
			}
			if($i != $index){
				swap($array, $i, $index);
				++$count;
			}
		}
		return $count;
	}
	function insertionSort(&$array){
		for($i = 1; $i < count($array); ++$i){
			$x = $array[$i];
			$j = $i - 1;
			while($j >= 0 && $array[$j] > $x){
				$array[$j + 1] = $array[$j];
				--$j;
			}
			$array[$j + 1] = $x;
		}
	}

	$n = intval(trim(fgets(STDIN)));
	$line = trim(fgets(STDIN));
	$numbers = explode(" ", $line);

	$count = selectionSort($numbers);

	for($i = 0; $i < count($numbers); ++$i){
		echo $numbers[$i];
		if($i != (count($numbers)-1))
			echo " ";
	}
	echo PHP_EOL;
	echo $count . PHP_EOL;
?>


Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,r;
    cin>>n>>r;
    r*=r;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=r) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int64_t a;

    std::cin>> a;

    std::vector< int > b( a );
    std::priority_queue< int64_t > c;
    std::priority_queue< int, std::vector<int64_t>, std::greater<int64_t> > d;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> b[i];

        d.push( abs( b[i] ) );

        if( b[i] < 0 )
        {
            c.push( b[i] );
        }
    }

    int64_t all = 0;
    
    if( c.size() % 2 != 0 )
    {
        all += d.top() * -1;
        d.pop();
    }

    while( !d.empty() )
    {
        all += abs( d.top() );
        d.pop();
    }
    
    std::cout<< all <<"\n";
}


Measured memory_bytes: 2544
n = int(input())
prices = [int(input()) for _ in range(n)]
max_profit = prices[1] - prices[0]
min_price = prices[0]
for price in prices[1:]:
    max_profit = max(max_profit, price - min_price)
    min_price = min(min_price, price)

print(max_profit)


Measured memory_bytes: 15100