akhauriyash/Code-Regression huggingface dataset:
N = int(input())
T, A = [int(x) for x in input().split()]
Hs = [int(x) for x in input().split()]

ans = 0
diff = -1
for i, H in enumerate(Hs):
    t = T - H * 0.006
    d = abs(A - t)
    if diff < 0 or d < diff:
        diff = d
        ans = i + 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;



int main()
{
	int seq[100000];
	int n;
	cin >> n;
	int i = 0;
	for(i; i < n; i++)
	{
		cin >> seq[i];
	}
	
	int q;
	cin >> q;
	

	int num = 0;
	int key = 0;
	for(i = 0; i < q; i++)
	{
		cin >> key;
		if(*lower_bound(seq, seq+n, key) == key) num ++;
	}
	
	cout << num << endl;
//	system("pause");
	return 0;
}




Measured memory_bytes: 3384
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            x.add(s.nextInt());
            y.add(s.nextInt());
        }

        double sumed = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                int side = Math.abs(x.get(i) - x.get(j));
                int vertical = Math.abs(y.get(i) - y.get(j));
                sumed += Math.sqrt(Math.pow((double) side, 2) + Math.pow((double) vertical, 2));
            }
        }
        int mpy = N*(N-1);
        double mpy2 = (N - 1) * 2;
        System.out.print((sumed * mpy2) / mpy);
    }
}


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


int z_algo(string S){
    vector<int> vt(S.length(),0);
    int L=0,R=0;
    for(int i=1;i<S.length();i++){
        if(i>R){
            L=i;R=i;
            while(R<S.length()&&S[R-L]==S[R]){
                
                //cout<<R<<""<<L<<" "<<S<<vt[R]<<" "<<vt[L]<<endl;
                R++;
            }
            vt[i]=R-L;
            //cout<<vt[i]<<endl;
            R--;
        }else{
            int k=i-L;
            if(vt[k]<R-i+1){
                vt[i]=vt[k];
            }else{
                L=i;
                while(R<S.length()&&S[R-L]==S[R]){
                    R++;
                }
                vt[i]=R-L;
                R--;
            }
        }
    }
    int ans=0;
    for(int i=0;i<S.length();i++){
        if(vt[i]<=i){
            ans=max(ans,vt[i]);
        }
    }
    return ans;
}

int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int res=0;
    for(int i=0;i<N-1;i++){
        int ans=z_algo(S.substr(i));
        res=max(res,ans);
    }
    cout<<res<<endl;

}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long bis = 1;
		if (b - a < 2 || 1 + k - 1 < a) {
			bis += k;
		} else {
			bis = a;
			int turn = (int)a - 1;
			if ((k - turn) % 2 == 0) {
				bis += (k - turn) / 2 * (b - a);
			} else {
				bis += (k - turn) / 2 * (b - a) + 1;
			}
		}
		System.out.println(bis);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

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

    vector<int> A(N);
    REP(i, N)
    {
        cin >> A.at(i);
    }

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

    int s = 0;
    REP(i, N - 1)
    {
        s += A.at(i);
    }

    if (s > A.at(N - 1))
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int n[5];
	int ans = 0;

	for (int i = 1; i <= 5; i++) {

		cin >> n[i];

		if (n[i] == 0) {

			ans = i;
			break;

		}
	}

	cout << ans;


	return 0;
}

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

template <class T>
struct Matrix {
  vector<vector<T>> A;
  Matrix() {}
  Matrix(size_t m, size_t n) : A(m, vector<T>(n, 0)) {}
  Matrix(size_t n) : A(n, vector<T>(n, 0)) {}
  size_t height() const { return (A.size()); }
  size_t width() const { return (A[0].size()); }
  inline const vector<T> &operator[](int k) const {
    return (A.at(k));
  }
  inline vector<T> &operator[](int k) { return (A.at(k)); }
  static Matrix E(size_t n) {
    Matrix mat(n);
    for(int i = 0; i < n; ++i) mat[i][i] = 1;
    return (mat);
  }
  Matrix &operator+=(const Matrix &B) {
    size_t m = height(), n = width();
    assert(m == B.height() && n == B.width());
    for(int i = 0; i < m; ++i)
      for(int j = 0; j < n; ++j) (*this)[i][j] += B[i][j];
    return (*this);
  }
  Matrix &operator-=(const Matrix &B) {
    size_t m = height(), n = width();
    assert(m == B.height() && n == B.width());
    for(int i = 0; i < m; ++i)
      for(int j = 0; j < n; ++j) (*this)[i][j] -= B[i][j];
    return (*this);
  }
  Matrix &operator*=(const Matrix &B) {
    size_t m = height(), n = B.width(), p = width();
    assert(p == B.height());
    vector<vector<T>> C(m, vector<T>(n, 0));
    for(int i = 0; i < m; ++i)
      for(int k = 0; k < p; ++k) {
        T tmp = (*this)[i][k];
        for(int j = 0; j < n; ++j) C[i][j] += tmp * B[k][j];
      }
    A.swap(C);
    return (*this);
  }
  Matrix &operator^=(long long k) {
    Matrix B = Matrix::E(height());
    while(k) {
      if(k & 1) B *= *this;
      *this *= *this;
      k >>= 1;
    }
    A.swap(B.A);
    return (*this);
  }

  Matrix operator+(const Matrix &B) const {
    return (Matrix(*this) += B);
  }
  Matrix operator-(const Matrix &B) const {
    return (Matrix(*this) -= B);
  }
  Matrix operator*(const Matrix &B) const {
    return (Matrix(*this) *= B);
  }
  Matrix operator^(const long long k) const {
    return (Matrix(*this) ^= k);
  }
  friend ostream &operator<<(ostream &os, Matrix &p) {
    size_t m = p.height(), n = p.width();
    for(int i = 0; i < m; i++) {
      os << "[";
      for(int j = 0; j < n; j++) {
        os << p[i][j] << (j + 1 == n ? "]\n" : ",");
      }
    }
    return (os);
  }
};

long long n, m;
Matrix<long long> mat, tmp;

int main() {
  cin >> n >> m;
  mat = Matrix<long long>(n, m);
  tmp = Matrix<long long>(m, 1);

  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j) cin >> mat[i][j];
  for(int i = 0; i < m; ++i) cin >> tmp[i][0];
  mat *= tmp;
  for(int i = 0; i < n; ++i) cout << mat[i][0] << endl;
  return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL N;

LL calc(LL v) {
    LL res = 0;
    LL cur = v;
    while (cur < N) {
        res += (N / 2) / cur;
        cur *= v;
    }
    return res + (v == 2 ? N / 2 : 0);
}

int main(void) {
    cin >> N;

    if (N % 2) {
        cout << 0 << endl;
        return 0;
    }

    // DEBUG(calc(2))
    // DEBUG(calc(5))
    cout << min(calc(2), calc(5)) << endl;
}


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

int n,m;
int a[1001],b[1001],c[1000],d[1000],e[1000],f[1000];
int U[4000][4000], L[4000][4000];
typedef pair<int,int> P;
vector<vector<bool>>vis;
typedef long long ll ;


int id(vector<ll>h,ll a){
    return lower_bound(h.begin(),h.end(),a)-h.begin();
}

int main(){

    cin>>n>>m;
    vector<ll> h,w;
    ref(i,n){
        cin>>a[i]>>b[i]>>c[i];
        h.push_back(a[i]);
        h.push_back(b[i]);
        w.push_back(c[i]);
    }
    ref(i,m) {
        cin>>d[i]>>e[i]>>f[i];
        h.push_back(d[i]);
        w.push_back(f[i]);
        w.push_back(e[i]);
    }
    h.push_back(INF);
    h.push_back(-INF);
    w.push_back(INF);
    w.push_back(-INF);
    h.push_back(0);
    w.push_back(0);
    sort(h.begin(),h.end());
	sort(w.begin(),w.end());
	h.erase(unique(h.begin(),h.end()),h.end());
	w.erase(unique(w.begin(),w.end()),w.end());



	vis=vector<vector<bool>>(h.size(),vector<bool>(w.size(),false));


	ref(i,n){
		L[id(h,a[i])][id(w,c[i])]++;
		L[id(h,b[i])][id(w,c[i])]--;
	}
	ref(i,m){
		U[id(h,d[i])][id(w,e[i])]++;
		U[id(h,d[i])][id(w,f[i])]--;
	}
	for(int i=1;i<h.size();i++){
		for(int j=1;j<w.size();j++){
			L[i][j]+=L[i-1][j];
			U[i][j]+=U[i][j-1];
		}
	}


	queue<P>q;
	q.push({id(h,0),id(w,0)});
	ll ans=0;
	while(!q.empty()){
        P p=q.front();
        q.pop();
        int x=p.first,y=p.second;
        if(!x||!y||x==h.size()-1||y==w.size()-1){
            cout<<"INF";
            return 0;
        }
        if(!vis[x][y]){
            vis[x][y]=1;
            ans+=(h[x+1]-h[x])*(w[y+1]-w[y]);
			if(!U[x][y])q.push({x-1,y});
			if(!L[x][y])q.push({x,y-1});
			if(!U[x+1][y])q.push({x+1,y});
			if(!L[x][y+1])q.push({x,y+1});
        }


	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 98764
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

x = 0
for i in range(n):
    x += bb[aa[i] - 1]
    if i > 0 and aa[i - 1] == aa[i] - 1:
        x += cc[aa[i - 1] - 1]
print(x)

Measured memory_bytes: 3060
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, t[100], m, p[100], x[100],i; int sum = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &t[i]);
    sum += t[i];
  }
  scanf("%d", &m);
  for(i = 0; i < m; i++){
    scanf("%d %d", &p[i], &x[i]);
    printf("%d\n", sum - t[p[i] - 1] + x[i]);
  }

  return 0;
}
  
  


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        PriorityQueue<Integer> q = new PriorityQueue<Integer>();
        int cnt = 0;
        for (int i=0;i<N;i++) {
            int P = sc.nextInt();
            q.add(P);
            if (q.peek()==P) cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 67344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> l(n);
    REP(i, n) cin >> l[i];

    vector<ll> cnt(2001);
    REP(i, n) cnt[l[i]]++;
    FOR(i, 1, 2001) cnt[i] += cnt[i-1];

    dump(cnt);

    ll ret = 0;
    REP(i, n) FOR(j, i+1, n) {
        ll lb = abs(l[i]-l[j]), ub = l[i]+l[j];
        ll tmp = cnt[ub-1] - cnt[lb];
        if(lb < l[i] && l[i] < ub) tmp--;
        if(lb < l[j] && l[j] < ub) tmp--;
        dump(i, j, lb, ub, tmp);
        ret += tmp;
    }
    cout << ret/3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int A, B, K;
  	cin >> A >> B >> K;
  	int count = 0;
  	vector<int> ans;
  	for(int i = 1; i <= 100; i++){
    	if(A%i == 0 && B%i == 0) ans.push_back(i);
    }
  	reverse(ans.begin(), ans.end());
  	cout << ans[K-1] << endl;
}

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

int main(){
  	
  	int n,m,memo = 0;
  	cin >> n;
  	int d[n];
  	
  	rep(i,0,n){
      cin >> d[i];
    }
  	cin >> m;
  	int t[m];
  
  	rep(i,0,m){
      cin >> t[i];
    }
  
  	sort(d,d+n);
  	sort(t,t+m);
  
  	rep(j,0,m){
      while(1){
        if(t[j] == d[memo]){
          memo++;
          break;
        }
        else{
          memo++;
          if(memo >= n){
            cout << "NO" << endl;
            return 0;
          }
        }
      }
    }
  
  	cout << "YES" << endl;
  	return 0;
}

Measured memory_bytes: 1792
import sys

if __name__ == "__main__":
    args = sys.stdin.read().split()
    N, A = int(args[0]), list(map(int, args[1:]))  # N = len(A)

    cnt = 0
    while True:
        if any(map(lambda x: x % 2 == 1, A)):    
            break

        cnt += 1
        A = list(map(lambda x: x / 2, A))

    print(cnt)



Measured memory_bytes: 2940
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      k: usize,
      hs: [usize; n]
    }
    let mut hs = hs;
    hs.sort();
    let mut ans = hs[n-1] - hs[0];
    for i in (k-1)..n {
        let h = hs[i] - hs[i+1-k];
        ans = min(h, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n, m, q = [int(i) for i in input().split()]
imos = [[0 for r in range(n+1)] for l in range(n+1)]
for i in range(m):
    l, r = [int(i) - 1 for i in input().split()]
    imos[0][r] += 1
    imos[l+1][r] -= 1
#imos法
for l in range(n):
    for r in range(1, n):
        imos[l][r] += imos[l][r-1]
for r in range(n):
    for l in range(1, n):
        imos[l][r] += imos[l-1][r]
for i in range(q):
    l, r = [int(i) - 1 for i in input().split()]
    print(imos[l][r])

Measured memory_bytes: 9716
#include <stdio.h>
int main (void){
    int a=0,b,c,d,e,i;
    for(i=0;i<4;i++){
        scanf("%d",&b);
        a=a+b;
    }
    c=a/60;
    d=c*60;
    e=a-d;
    printf("%d\n%d\n",c,e);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
// #define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;
 
int n, m;
int a[88][88];
int b[88][88];
int dp[80][80][12800];
 
int sol (int x, int y, int cur) {
  if (x == n - 1 && y == m - 1) return min (cur + abs (a[x][y] - b[x][y]), abs(cur - abs(a[x][y] - b[x][y])));
  if (x < 0 || x >= n || y < 0 || y >= m) return 100000;
  int &ret = dp[x][y][cur];
  if (ret != -1) return ret;
  int cost1 = cur + abs(a[x][y] - b[x][y]);
  int cost2 = abs(cur - abs(a[x][y] - b[x][y]));
  ret = sol (x + 1, y, cost1);
  ret = min (ret, sol (x + 1, y, cost2));
  ret = min (ret, sol (x, y + 1, cost1));
  ret = min (ret, sol (x, y + 1, cost2));
  return ret;
}
 
signed main () {
  // boost();
  memset(dp, -1, sizeof dp);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &b[i][j]);
    }
  }
  printf("%d", sol (0, 0, 0));
  return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a;
    if(n % 2){
        rep(i, n){
            int x;
            cin >> x;
            if( (i+1) % 2 ) a.insert(a.begin(), x);
            else a.push_back(x);
        }
    }else{
        rep(i, n){
            int x;
            cin >> x;
            if( (i+1) % 2 ) a.push_back(x);
            else a.insert(a.begin(), x);
        }
    }

    rep(i, n){
        cout << a[i] << " ";
    }

    return 0;
}

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

using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<ll> x(n),y(n),h(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
    }
    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            int flag=0;
            ll H;
            for(int i=0;i<n;i++){
                if(!flag && h[i]!=0){
                    flag=1;
                    H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
                }
            }
            for(int i=0;i<n;i++){
                if(h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),0LL)){
                    break;
                }
                if(i+1==n){
                    cout<<cx<<" "<<cy<<" "<<H<<endl;
                    return 0;
                }
            }
            
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
  ll n ,i;
  cin>>n;
  ll a[n],sum=0,ans=0;  
  for(i=0;i<n;i++)
    cin>>a[i];
for(i=n-1;i>=0;i--)
{
  ans+=(sum*a[i]);
  sum+=a[i];
  ans%=mod;
  sum%=mod;
}
  
  cout<<ans<<endl;
  
  
  return 0;
}

Measured memory_bytes: 5152
#include <iostream>//cout
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>//swap
using namespace std;
static const int MAX = 200000;
#define rep(i,n) for(int i=0;i<n;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
int main() {
  long long int N, W;
  long long int x, a, b, c;
  int ans = 0;
  cin >> a >> b >> c >> x;
  for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
	for (int k = 0; k <= c; k++) {
	  if (i*500 + j*100 + k*50 == x)
	    ans++;
	}
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
a = list(map(int, input().split()))

money = 0
now = 0
for i in range(n):
    money += abs(a[i] - now)
    now = a[i]
money += abs(now)

for i in range(n):
    before_p = a[i - 1] if i != 0 else 0
    next_p = a[i + 1] if i != n - 1 else 0


    loss = abs(a[i] - before_p) + abs(next_p - a[i])
    add = abs(next_p - before_p)
    ans = money - loss + add
    print(ans)


Measured memory_bytes: 14176
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>

using namespace std;

int main(){
    int N;
    cin>>N;
    int A[100000];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N);
    int maxA=A[N-1];
    int ans=-1;
    for(int i=0;i<N-1;i++){
        if(maxA%2==0){
            int mid=maxA/2;
            if(abs(A[i]-mid) < abs(ans-mid)){
                ans=A[i];
            }
        }else{
            int mid_L=maxA/2;
            int mid_H=mid_L+1;
            int dist_now=min(abs(A[i]-mid_L),abs(A[i]-mid_H));
            int dist_tmp=min(abs(ans-mid_L),abs(ans-mid_H));
            if(dist_now<dist_tmp) ans=A[i];
        }
    }
    cout<<maxA<<' '<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import sys
readline=sys.stdin.readline
read=sys.stdin.read

n,c=map(int,readline().split())
m=2*10**5
stc=[list(map(int,l.split())) for l in read().splitlines()]
cht=[[0]*(m+1) for _ in range(c)]
for e in stc:
  cht[e[2]-1][2*e[0]-1:2*e[1]]=[1 for _ in range(2*e[1]-2*e[0]+1)]
mnr=0
for i in range(1,m+1):
  mnr=max(mnr,sum(cht[ch][i] for ch in range(c)))
print(mnr)


Measured memory_bytes: 74832
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(a) (int)a.size()
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef db T;
const db eps = 1e-9 , pi = acosl(-1.);
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
  T x,y; P(){} P(T x,T y):x(x),y(y){}
  P operator - (const P&b) const {return P(x-b.x,y-b.y);}
  P operator + (const P&b) const {return P(x+b.x,y+b.y);}
  T operator * (const P&b) const {return x*b.x+y*b.y;}
  T operator / (const P&b) const {return x*b.y-y*b.x;}
  P operator * (const T&k) const {return P(x*k,y*k);}
  P operator / (const T&k) const {return P(x/k,y/k);}
};
T norm(P a){return a*a;}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}
P reflect(P p,P a,P b){return proj(p,a,b)*2-p;}
T cross(P o,P a,P b){return (a-o)/(b-o);}
int crossOp(P o,P a,P b){return sgn(cross(o,a,b));}
bool onPS(P p,P s,P t){return sgn((t-s)/(p-s))==0&&sgn((p-s)*(p-t))<=0;}
struct L{ P s,t;L(){} L(P s,P t):s(s),t(t){}};
bool isSSr(const L&a,const L&b){ // seg x seg restrict
  T c1=(a.t-a.s)/(b.s-a.s) , c2=(a.t-a.s)/(b.t-a.s),
    c3=(b.t-b.s)/(a.s-b.s) , c4=(b.t-b.s)/(a.t-b.s);
  return sgn(c1) * sgn(c2) < 0 && sgn(c3) * sgn(c4) < 0;
}
bool isSS(L a,L b){ // seg x seg , replace x->y to accelerate
  T c1=(a.t-a.s)/(b.s-a.s),c2=(a.t-a.s)/(b.t-a.s);
  T c3=(b.t-b.s)/(a.s-b.s),c4=(b.t-b.s)/(a.t-b.s);
  return sgn(c1) * sgn(c2) <= 0 && sgn(c3) * sgn(c4) <= 0 &&
    sgn(max(a.s.x,a.t.x) - min(b.s.x,b.t.x)) >= 0 &&
    sgn(max(b.s.x,b.t.x) - min(a.s.x,a.t.x)) >= 0 &&
    sgn(max(a.s.y,a.t.y) - min(b.s.y,b.t.y)) >= 0 &&
    sgn(max(b.s.y,b.t.y) - min(a.s.y,a.t.y)) >= 0;
}

P a, b, c, d;

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	int q;
	cin >> q;
	cout << setiosflags(ios::fixed);
	cout << setprecision(10);
	while(q--) {
		cin >> a.x >> a.y >> b.x >> b.y;
		cin >> c.x >> c.y >> d.x >> d.y;
		L x = L(a, b), y = L(c, d);
		cout << isSS(x, y) << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=2e5+5;
int n,k,i,j,p,rev,a[N];
char s[N];
void trans(int x) { if (x) putchar('A'); else putchar('B'); }
int main()
{
	//freopen("reflector.in","r",stdin);
	//freopen("reflector.out","w",stdout);
	scanf("%d%d%s",&n,&k,s+1);
	rep(i,1,n) if (s[i]=='A') a[i]=1; else a[i]=0;
	for (j=0,p=1;j<k && p<=n;j++) {
		if (a[p]^rev) {a[p]^=1; continue;}
		rev^=1; p++;
	}
	if (j>=k) {
		rep(i,p,n) trans(a[i]^rev);
		rep(i,n+1,n+p-1) trans((n+p-i)&1);
	}
	else {
		if (n&1) {
			trans((k-j+1)&1);
			rep(i,2,n) trans(i&1);
		}
		else rep(i,1,n) trans((i+1)&1);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int A, B;

int main(void){
	
	scanf("%d %d", &A, &B);
	if(A + B >= 10) printf("error\n");
	else printf("%d\n", A + B);
	
    return 0;
}

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

using ll = long long;

int main() {
   int n;
   cin >> n;
   map<ll, ll> mp;
   for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      mp[a]++;
      mp[a-1]++;
      mp[a+1]++;
   }

   ll ans = 0;
   for (auto x : mp) {
      ans = max(ans, x.second);
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
 
int main(void){
  int n, m, input, sum = 0;
  vector<int> A, q;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> input;
    A.push_back(input);
  }
  cin >> m;
  for(int i=0; i<m; i++){
    cin >> input;
    q.push_back(input);
  }
  vector<int> ans(m, 0);

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

  for(int i=0; i<(1<<n); i++){
    sum = 0;
    for(int j=0; j<n; j++){
      if(i & (1<<j)){
        sum += A[j];
      }
    }
    for(int j=0; j<m; j++){
      if(sum == q[j]){
        ans[j] = 1;
      }
    }
  }
  for(int i=0; i<ans.size(); i++){
    if(ans[i] == 1){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }

  return 0;
}


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

int main() {
    int n;
    int h[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];

    int ans = 0;
    while (true) {
        if (*max_element(h, h + n) == 0) break;

        int i = 0;
        while (i < n) {
            if (h[i] == 0) i++;
            else {
                ans++;
                while (i < n && h[i] > 0) {
                    h[i]--;
                    i++;
                }
            }
        }
    }

    cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int k;
    cin >> k;
    int a = 0;
    for (int i = 0; i <= k; ++i) {
        a = (10 * a + 7) % k;
        if (a == 0){
            cout << 1 + i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s,t;cin>>s>>t;
    int n=s.size();
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3792
#include<algorithm>
#include<string>
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int H, W;
    cin >> H >> W;
    char a[110][110];
    for(int i = 1;i <= H;i++){
        for(int j = 1;j <= W;j++){
            cin >> a[i][j];
        }
    }
    
    for(int i = 1;i <= H;i++){
        bool C = false;
        for(int j = 1;j <= W;j++){
            bool A = true;
            for(int l = 1;l <= W;l++){
                if(a[i][l] == '#')A = false;
            }
            if(A == false){
                bool B = true;
                for(int l = 1;l <= H;l++){
                    if(a[l][j] == '#')B = false;
                }
                if(B == true);
                else{ cout << a[i][j];C = true;}
            }
        }
        if(C == true)cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int A,B=0,C=0;
  cin >> A;
  vector<long long int>P(A+1),G(P);
  for(int i=0;i<A+1;i++)cin >> P[i];
  for(int i=0;i<A;i++)cin >> G[i];
  for(int i=0;i<A;i++){
      if(P[i]+P[i+1]>=G[i]){
          if(P[i]<=G[i]){
          B+=G[i];
          P[i+1]=P[i+1]+P[i]-G[i];
          }else B+=G[i];
      }
      else{
          B+=P[i]+P[i+1];
          P[i+1]=0;
      }
  }
  cout << B << endl;
}


Measured memory_bytes: 1792
n = int(input())
a = [input().split() for l in range(n)]
b = 0
t = [0]
x = [0]
y = [0]
for i in range(n):
    t.append(a[i][0])
    x.append(a[i][1])
    y.append(a[i][2])

for k in range(n):
    o = int(t[k+1])-int(t[k])
    p = int(x[k+1])-int(x[k])
    q = int(y[k+1])-int(y[k])
    if (o >= p+q) and ((o - (p+q))%2 == 0):
        b += 1
    else:
        b = b

if b == n:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 34604
#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 treeSearch(Node u, int k){
  if(u==NIL || u->key==k) return u;
  else if(u->key > k) return treeSearch(u->left,k);
  else if(u->key < k) return treeSearch(u->right,k);
  //else return u;

}

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

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


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

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

Measured memory_bytes: 19360
/*

“I shall be telling this with a sigh    
Somewhere ages and ages hence:     
Two roads diverged in a wood, and I—    
I took the one less traveled by,   
And that has made all the difference.” 

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int             long long int
#define ld              long double
#define lop(i, a, b)    for (int i = a; i < b; i++)
#define rlop(i, b, a)   for (int i = b-1; i >= a; i--)
#define F               first
#define S               second
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpi             vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define spi             set <pii>
#define endl            "\n" 
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define mset(a, b, c)   lop (i, 0, c) a[i] = b
#define print1(a, n)    lop (i, 0, n) cout << a[i] << " "; cout << endl

inline int pow(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;

void solve()
{
     int m,d,cnt=0;
     cin>>m>>d;

     lop(i,1,m+1)
     {
          lop(j,1,d+1)
          {
               if(d>10)
               {
                    int x=j%10;
                    int y=j/10;
                    if(x>=2 && y>=2 && x*y==i) 
                         cnt++;
               }
          }
     }
     cout<<cnt;
     
}

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

// #ifndef ONLINE_JUDGE
//      freopen("input.txt",  "r",  stdin);
//      freopen("output.txt", "w", stdout);
// #endif

     solve();

     return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    s = to_string(a) + to_string(b);
    int k = stoi(s);
    for (int i=0; i<=pow(k,0.5); i++){
        if (pow(i,2) == k){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
package main

// Solution for https://atcoder.jp/contests/abc068/tasks/abc068_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	m := n
	for i := 2; i <= n; i <<= 1 {
		m = i
	}
	con.Println(m)
	return nil
}


Measured memory_bytes: 640
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

ll gcd(ll a, ll b) 
{ 
    if (!a) 
       return b; 
    return gcd(b%a,a); 
}

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll a, b, c, d;
	re(a,b,c,d);
	ll c1 = (a%c == 0) ? b/c - a/c + 1 : b/c - (a/c + 1) + 1;
	ll c2 = (a%d == 0) ? b/d - a/d + 1 : b/d - (a/d + 1) + 1;
	ll x1 = gcd(c,d);
	ll x2 = (c*d)/x1;
	ll c3 = (a%x2 == 0) ? b/x2 - a/x2 + 1 : b/x2 - (a/x2 + 1) + 1;
	cout<< b-a - (c1+c2- c3) + 1;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,k,a[N];
int check(int x){
    int ans=0;
    rep(i,1,n) ans+=(a[i]-1)/x;
    return ans<=k;
}
signed main(){
    FastIO;
    cin>>n>>k;
    rep(i,1,n) cin>>a[i];
    int l=1,r=1e9,ans=1e9;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4432
N = int(input())
alist = [int(x) for x in input().split()]
positive =  max(alist)+min(alist) >=0
if positive:
	argmaxabs = alist.index(max(alist))
else:
	argmaxabs = alist.index(min(alist))
print(2*N-2)
for i in range(1,N+1):
	if not argmaxabs+1 == i:
		print(str(argmaxabs+1)+" "+str(i))
if positive:
	for i in range(1,N):
		print(str(i)+" "+str(i+1))
else:
	for i in range(N,1,-1):
		print(str(i)+" "+str(i-1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,M;
string S;

signed main(){
  int N;cin>>N;
  int tmp=1;
  while(tmp<=N){
    tmp*=2;
  }
  print(tmp/2);


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    ll s;
    cin >> s;
    
    if(s == 1e18){
        cout << 0 << " " << 0 << " " << (ll)1e9 << " " << 1 << " " 
    <<  0 << " " << (ll)1e9 <<endl;
    }
    else{
        cout << 0 << " " << 0 << " " << (ll)1e9 << " " << 1 << " " 
    <<  (ll)1e9 - s % ((ll)1e9) << " " <<s / ((ll)(1e9)) + 1 <<endl;
    }

    return 0;
}

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

public class Main
{

  final static int[] WEIGHT =
  { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final int num = Integer.parseInt(input.readLine());

      System.out.println(solver(num));
    }

  }

  private static String solver(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    StringBuilder ret = new StringBuilder();

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        ret.append(WEIGHT[count]);
        ret.append(" ");
      }
      count++;
    }
    return ret.toString().trim();
  }

}

Measured memory_bytes: 24424
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$ans = 0;
foreach ($a as $key => $value) {
    if ((1 + $key) % 2 !== 0 and $value % 2 !== 0) {
        ++$ans;
    }
}
echo $ans.PHP_EOL;

Measured memory_bytes: 16224
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

// template<typename T>
// void print(T &arr){
//     ll sz = sizeof(arr)/sizeof(arr[0]);
//     for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
//     cout << arr[sz-1] << endl;
// }


int main(){
    // std::ifstream in("antigreedy0.in");
    // std::cin.rdbuf(in.rdbuf());
    
    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N);
    vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(N+1,vector<ll>(330,0)));   
    // vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(N+1,vector<ll>(30,0)));   
    rep(i,N)cin >> w[i] >> v[i];
    ll base = w[0];
    rep(i,N)w[i] -= base;
    rep(i,N){
        rep(j,N){
            if(i < j)continue;
            rep(k,330){
                dp[(i+1)%2][j][k] = max(dp[(i+1)%2][j][k],dp[i%2][j][k]);
                if(w[i] <= k && (j+1)*base + k <= W){
                    dp[(i+1)%2][j+1][k] = max(dp[(i+1)%2][j+1][k],dp[i%2][j][k-w[i]] + v[i]);
                }
            }
        }
        // print(i);
        // print(dp[(i+1)%2]);
    }

    ll res = 0;
    rep(j,N+1){
        res = max(res, dp[N%2][j][max(0LL,min(W - (j)*base, 300LL))]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
char s[MAXN];
int L,suf[MAXN];
void Solve() {
    scanf("%s",s + 1);
    L = strlen(s + 1);
    int64 ans = 0;
    for(int i = L - 1; i >= 1 ; --i) {
	if(s[i] == 'B' && s[i + 1] == 'C') suf[i] = suf[i + 2] + 1;
	else if(s[i] == 'A') {
	    suf[i] = suf[i + 1];
	    ans += suf[i];
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}



Measured memory_bytes: 1280
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val x = (n.toDouble() / 1.08).toInt()

    when (n) {
        (x * 1.08).toInt() -> println(x)
        ((x + 1) * 1.08).toInt() -> println(x+1)
        else -> println(":(")
    }
}

Measured memory_bytes: 33788
#include<bits/stdc++.h>
 using namespace std;
 
 const long double PI = (acos(-1));
 
 int main(){
 	int A,B,H,M;
 	long double ans=0;
 	long double rad=0;
 	long double theta_m=0;
 	long double theta_h=0;
 	//入力受け取り
 	cin >> A >> B >> H >> M;
 	//分針、時針を円の割り合になおす
 	theta_m = (long double)M/60.0;
 	theta_h = (long double)H/12.0 + ((long double)M/60.0/12.0);
 	//内角の大きさを求めラジアンになおす
 	rad=(theta_h-theta_m)*2*PI;
 	//第二余弦定理に適用する
 	ans=A*A+B*B-2*A*B*cos(rad);
 	//ansは2乗の状態なのでruteを求める
 	ans=sqrt(ans);
 	cout << fixed << setprecision(20);
 	cout << ans << "\n";
 }

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
int main (){
string a,b,c,x,y,z;
cin>>a>>b>>c;
 if ((a[0]>='a' && a[0]<='z')&&(b[0]>='a' && b[0]<='z')&&(c[0]>='a' && c[0]<='z'))

 x=a[0]-32;
 cout<< x;
 y=b[0]-32;
 cout<<y;
  z=c[0]-32;
 cout<<z;

return 0;
}


Measured memory_bytes: 256
x = int(input())
#print(x)

kyu = 0

if x < 400:
  kyu = 0
elif 400 <= x and x <= 599:
  kyu = 8
elif 600 <= x and x <= 799:
  kyu = 7
elif 800 <= x and x <= 999:
  kyu = 6
elif 1000 <= x and x <= 1199:
  kyu = 5
elif 1200 <= x and x <= 1399:
  kyu = 4
elif 1400 <= x and x <= 1599:
  kyu = 3
elif 1600 <= x and x <= 1799:
  kyu = 2
elif 1800 <= x and x <= 1999:
  kyu = 1
else:
  kyu = 0

print(kyu)

Measured memory_bytes: 9200