akhauriyash/Code-Regression huggingface dataset:
import numpy as np

A, B, H, M = map(int, input().split())

Htheta = ((H%12)*60 + M)*0.5
Mtheta = M*6

degdef = abs(Htheta - Mtheta)* np.pi / 180
ans = np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(degdef))
print(ans)

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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
var inputArray = new string[3];
			inputArray = Console.ReadLine().Split(' ');

			// 不正な入力は処理しない
			if (inputArray.Length != 3) {
				Console.WriteLine("invalid input");
				return;
			}

			// 入力値セット
			var N = long.Parse(inputArray[0]);
			var A = long.Parse(inputArray[1]);
			var B = long.Parse(inputArray[2]);

			var shou = N / (A + B);
			var amari = N % (A + B);

			var answer = shou * A + Math.Min(A, amari);
			Console.WriteLine(answer);
		}
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

string s;

vector<int> sgt[4*N];

vector<int> merge(vector<int> a,vector<int> b)
{
    vector<int> c(26,0);
    for(int i=0;i<26;++i)
    {
        c[i]=a[i]|b[i];
    }
    return c;
}

void build(ll st,ll en,ll pos)
{
    if(st==en)
    {
        sgt[pos].resize(26,0);
        sgt[pos][s[st]-'a']=1;
        return;
    }
    ll mid=(st+en)/2;
    build(st,mid,2*pos+1);
    build(mid+1,en,2*pos+2);
    sgt[pos]=merge(sgt[2*pos+1],sgt[2*pos+2]);
}

void update(ll st,ll en,ll pos,ll idx,char v)
{
    if(st==en)
    {
        sgt[pos][s[st]-'a']=0;
        sgt[pos][v-'a']=1;
        return ;
    }
    ll mid=(st+en)/2;
    if(idx>=st&&idx<=mid){
        update(st,mid,2*pos+1,idx,v);
    }
    else{
        update(mid+1,en,2*pos+2,idx,v);
    }
    sgt[pos]=merge(sgt[2*pos+1],sgt[2*pos+2]);
}

vector<int> range(ll st,ll en,ll pos,ll l,ll r)
{
    if(st>r||en<l)
    {
        vector<int> lol(26,0);
        return lol;
    }
    if(st>=l&&en<=r){return sgt[pos];}
    ll mid=(st+en)/2;
    return merge(range(st,mid,2*pos+1,l,r),range(mid+1,en,2*pos+2,l,r));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin>>n;
	cin>>s;

	build(0,n-1,0);

	ll q;
	cin>>q;
	while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            int idx;
            char c;
            cin>>idx>>c;
            --idx;
            update(0,n-1,0,idx,c);
            s[idx]=c;
        }
        else
        {
            ll l,r;
            cin>>l>>r;
            --l;--r;
            vector<int> ar=range(0,n-1,0,l,r);
            int ans=0;
            for(int i=0;i<26;++i){
                if(ar[i]){++ans;}
            }
            cout<<ans<<endl;
        }
    }

	return(0);
}


Measured memory_bytes: 157084
def main():
    N = int(input())
    H = list(map(int, input().split()))

    judge = 'Yes'

    #H[0] = H[0] - 1

    for i in range(1,N):
        if H[i-1] > H[i] :
            H[i-1] = H[i-1] - 1
        elif H[i-1] == H[i] and H[i-2] != H[i-1]:
            H[i-1] = H[i-1] - 1

        '''
        if i == N-1:
            if H[i-1] > H[i]:
                H[i] = H[i] - 1
        '''

    for i in range(1,N):
        if H[i-1] > H[i]:
            judge = 'No'
        if N == 1:
            judge = 'Yes'

    #print(H)
    print(judge)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 14400
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))
dp = np.zeros(n)

for i in range(1, n):
    s = min(k, i)
    dp[i] = np.min(dp[i-s:i] + np.abs(h[i] - h[i-s:i]))

#    for j in range(i-s, i):
#        t.append(dp[j] + abs(h[i] - h[j]))

print(int(dp[-1]))


Measured memory_bytes: 22836
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(1==i%2){
            if('R'==s[i]){
                cout<<"No";
                return 0;
            }
        }else{
            if('L'==s[i]){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<set>  
#include<map>  
#include<stack>  
#include<cstdio>  
#include<queue>  
#include<cmath>  
#include<vector>  
#include<climits>  
#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=((x<<3)+(x<<1))+c-'0';c=getchar();} 
    return f*x; 
}
#define MAXN 2200000
struct edge{
    int v,w;
    edge(){}
    edge(int V,int W){v=V,w=W;}
};
int n,m;
struct node{
    int u,k;
    node(){}    
    node(int U,int K){u=U,k=K;}
    friend bool operator < (node a,node b){return a.u==b.u?a.k<b.k:a.u<b.u;}
};
struct node1{
    int u,v,k;
    node1(){}   
    node1(int U,int V,int K){u=U,v=V,k=K;}
};
vector<node> Make_zx;
vector<node1> Make_xx;
vector<edge> G[MAXN+5];
int dis[MAXN+5];
bool vis[MAXN+5];
queue<int>Q;
int SPFA(int S,int T){
    memset(vis,0,sizeof(vis));
    memset(dis,0x3f,sizeof(dis));
    dis[S]=0,vis[S]=1,Q.push(S);
    while(!Q.empty()){
        int u=Q.front(),v,w,siz=G[u].size();
        Q.pop();
        vis[u]=0;
        for(int i=0;i<siz;i++){
            v=G[u][i].v,w=G[u][i].w;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                if(!vis[v]){
                    vis[v]=1;
                    Q.push(v);
                }
            }
        }
    }
    return dis[T]==INF?-1:dis[T]/2;
}
int main(){
	while(~scanf("%d%d",&n,&m))
	{
	    for(int i=1;i<=m;i++){
	        int p=read()-1,q=read()-1,c=read()-1;
	        Make_zx.push_back(node(p,c));
	        Make_zx.push_back(node(q,c));
	        Make_xx.push_back(node1(p,q,c));
	        Make_xx.push_back(node1(q,p,c));
	    }
	    sort(Make_zx.begin(),Make_zx.end());
	    for(int i=0;i<int(Make_zx.size());i++){
	        G[n+i].push_back(edge(Make_zx[i].u,1));
	        G[Make_zx[i].u].push_back(edge(n+i,1));
	    }
	    for(int i=0;i<int(Make_xx.size());i++){
	        int l1=lower_bound(Make_zx.begin(),Make_zx.end(),node(Make_xx[i].u,Make_xx[i].k))-Make_zx.begin(),
	        l2=lower_bound(Make_zx.begin(),Make_zx.end(),node(Make_xx[i].v,Make_xx[i].k))-Make_zx.begin();
	        G[l1+n].push_back(edge(l2+n,0));
	    }
	    printf("%d\n",SPFA(0,n-1));
	}
}

Measured memory_bytes: 96124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)output(a[i],i!=n-1?',':10);}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

int a[10];
int n,m;
string anss;
ll ansv;
void dfs(int num, int cost, ll sm, string s) {
  // cout << num << " " << cost << " " << sm << " " << s << endl;
  if (num == n) {
    if (cost <= m) {
      if (chmin(ansv, sm)) {
        anss = s;
      }
    }
    return;
  }
  REP(i,10) {
    dfs(num+1, cost+a[i], sm*10+i, s+string(1,i+'0'));
  }
}

int main() {
  while(cin>>n>>m) {
    REP(i,10) input(a[i]);
    ansv = 1LL<<60;
    dfs(0, 0, 0, "");
    // cout << ansv << endl;
    if (ansv == 1LL<<60)
      puts("NA");
    else
      cout << anss << endl;
    
  }
}


Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<stdbool.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
int dp[110] = { 0 };
bool flag[110] = { false };
int board[510][510] = { 0 };

bool prime[100010] = { false };
int c[100010];
void eratos(int b) {
	int i = 2;
	while (i <= sqrt(b)) {
		int j = 2;
		while (j <= sqrt(i) && !prime[i]) {
			if (i%j == 0) {
				prime[i] = true;
				break;
			}
			else j++;
		}
		int z = 2;
		while (!prime[i]) {
			if (i*z <= b) {
				prime[i*z] = true;
				z++;
			}
			else break;
		}
		i++;
	}
}
int main(void) {
	int q, l, r, ans = 0, rmax = 0;
	prime[1] = true;
	/*cin >> l >> r;
	eratos(r);
	for (int i = l;i <= r;i++)if (!prime[i])cout << i << endl;*/
	cin >> q;
	eratos(100000);
	for (int i = 3;i <= 100000;i+=2) {
		if (!prime[i] && !prime[(i + 1) / 2])c[i]++;
	}
	for (int i = 3;i <= 100000;i++)c[i] += c[i-1];
	for (int i = 0;i < q;i++) {
		cin >> l >> r;
		cout << c[r]-c[l-1] << endl;
	}
	

	/*int n;
	cin >> n;
	vector<int>s(n);
	for (int i = 0;i < n;i++)cin >> s[i];
	dp[0] = 0;
	int num = 0;
	for (int i = 1;i <= n;i++) {
		dp[i] = dp[i - 1];
		for (int j = 0;j < n;j++) {
			if (((dp[i-1] + s[j]) % 10 != 0)&&!flag[j]) {
				if (dp[i] < dp[i - 1] + s[j]) {
					dp[i] = dp[i - 1] + s[j];
					num = j;
				}
			}
		}
		flag[num] = true;
	}
	cout << dp[n] << endl;*/
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
const int N = 1e5 + 10;
const int mod = 998244353;
int a[N];
typedef long long ll;

ll qk_mod(ll a, ll n) {
    ll ret = 1;
    while(n) {
        if(n&1) ret = ret*a%mod;
        a = a*a%mod, n >>= 1;
    }
    return ret;
}

int main() {
    int n; scanf("%d", &n);
    int mxd = 0, first;
    for(int i = 1; i <= n; ++ i) {  
        int x; scanf("%d", &x);
        if(i == 1) first = x;
        a[x] ++;
        mxd = std::max(mxd, x);
    }
    ll tot = 1;
    for(int i = 0; i < mxd; ++ i) {
        if(a[i] == 0) {
            tot = 0;
            break;
        }
        tot *= qk_mod(a[i], a[i+1]);
        tot %= mod;
    }
    if(a[0] != 1 || first != 0) tot = 0;
    std::cout << (tot+mod)%mod << std::endl;
    //int amo; std::cin >> amo;
}

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 200007

int N, M;
ll val[MAX_N][2];
int tp[MAX_N], cnt[4];
pr p[MAX_N];
bool st[MAX_N][2];
std::multiset<ll> s;

bool cmp(pr a, pr b) { return val[a.fi][a.se] < val[b.fi][b.se]; }

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N);
    Rep(i, N) {
        read(val[i][0]), read(val[i][1]);
        p[++M] = pr(i, 0);
        p[++M] = pr(i, 1);
    }
    std::sort(p + 1, p + M + 1, cmp);
    ll res = 0;
    Rep(i, N) {
        res += val[p[i].fi][p[i].se];
        st[p[i].fi][p[i].se] = true;
        s.insert(val[p[i].fi][p[i].se]);
    }
    Rep(i, N) {
        if (st[i][0] && st[i][1]) cnt[tp[i] = 0]++;
        else if (st[i][0] && !st[i][1]) cnt[tp[i] = 1]++;
        else if (!st[i][0] && st[i][1]) cnt[tp[i] = 2]++;
        else cnt[tp[i] = 3]++;
    }
    if (!cnt[1] || !cnt[2] || cnt[3]) return printf("%lld\n", res), 0;
    ll tmp = res;
    res = 1e16;
    rep(i, N + 1, M) {
        int k = p[i].fi;
        if (cnt[tp[k]] > 1) {
            s.erase(s.find(val[k][p[i].se ^ 1]));
            chmin(res, tmp + val[k][p[i].se] - *s.rbegin());
            s.insert(val[k][p[i].se ^ 1]);
        } else chmin(res, tmp + val[k][p[i].se] - *s.rbegin());
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i,T x=1){
        for(i++;i<=n;i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i-= i&-i) {
            x += d[i];
        }
        return x;
    }
    // 下の2個の操作を使う時は上の2個の操作が使えない事に注意
    T getmax(int i){ // get max(d[i]) for i = 0,1,...,i-1,i
        T x = 0;
        for(i++;i;i-=i&-i) {
            x = max(x, d[i]);
        }
        return x;
    }
    void setmax(int i, int v){ // set d[i] = max(d[i], v)
        for(i++;i<=n;i+=i&-i){
            d[i] = max(d[i], v);
        }
    }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,k;
    cin >> n >> k;
    vector<int> a(n+1),b(n+1);
    rep(i,n)cin >> a[i];
    for(int i=0;i<k;i++){
        for(int i=0;i<n;i++){
            int left = max(0,i - a[i]);
            int right = min(n-1,i + a[i]);
            b[left]++;
            b[right+1]--;
        }
        for(int i=1;i<n;i++)b[i]+=b[i-1];
        a = b;
        b = vector<int>(n+1);
        bool end = 1;
        rep(i,n){
            if(a[i] != n)end = 0;
            break;
        }
        if(end)break;
    }
    rep(i,n){
        cout << a[i];
        if(i != n-1)cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 5576
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        int b = in.nextInt();
        int x,y;
        for(int i=0;i<10000;i++){
            x = (int)(i*0.08);
            y = (int)(i*0.1);
            if(x==a && y==b) {out.println(i);return;}
        }
        out.println(-1);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23124
#include<stdio.h>
//#include<string.h>
int main()
{
  char s[4];
  int i,j,check[4],dem=0;
  scanf("%s", &s);
  check[0]=0;
  check[1]=0;
  check[2]=0;
  check[3]=0;
  for (i=0; i<=3; i++)
    {
      if (check[i]==0) 
        {
          dem++;
          check[i]=1;
        }
	     for (j=i+1; j<4; j++)
          {
            if (s[j]==s[i] && check[j]==0) check[j]=1;
          }
    }
      //printf("%d\n", dem);
      if (dem!=2) printf("No");
      else
        {
          int f1=1;
          for (i=1; i<4; i++)
            {
              if (s[i]==s[0]) f1++;
            }
            //printf("%d", f1);
          if (f1==2) printf("Yes");
           else printf("No");
        }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x >= r && x <= w - r && y >= r && y <= h - r)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}



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


int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(a<b &&b<c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<math.h>
#include <iostream>
using namespace std;
#define  LL long long

const int maxn = 1e5+55;

LL a[maxn],b[maxn];
LL x[maxn],v[maxn];
LL sum[maxn];
int main()
{
	LL n,c;
	cin>>n>>c;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>v[i];

	for(LL i=1;i<=n;i++)
		a[i]=a[i-1]+v[i]-(x[i]-x[i-1]);
	x[n+1]=c;

	for(LL i=n;i>=1;i--)
		b[i]=b[i+1]+v[i]-(x[i+1]-x[i]);
	a[0]=b[n+1]=-1231231222231323;

	for(LL i=1;i<=n;i++)
		a[i]=max(a[i-1],a[i]);

	for(LL i=n;i>=1;i--)
		b[i]=max(b[i],b[i+1]);

	LL ans=0;
	for(LL i=1;i<=n;i++){
		ans=max(ans,-x[i]+a[i]+b[i+1]); //顺时针，再折回
		ans=max(ans,a[i]);//顺时针，不折回
		ans=max(ans,b[i]);//逆时针，不折回
		ans=max(ans,-(c-x[i])+b[i]+a[i-1]);//逆时针 再折回
	}
	cout<<ans<<endl;




}


Measured memory_bytes: 3328
#include<stdio.h>

int main(void){
    int a,b;
    int result_sum=0;
    int result_sub=0;
    int result_mul=0;
    int result;
    scanf("%d %d",&a,&b);
    result_sum = a+b;
    result_sub = a-b;
    result_mul = a*b;

    if(result_sum >= result_sub){
        result = result_sum;
    }
    else{
        result = result_sub;
    }
    if(result_mul >= result){
        result = result_mul;
    }

    printf("%d",result);

}



Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include "set"
#include "map"
#include "unordered_map"
#include <string>
#include <iomanip>
#include <numeric>
#include "cmath"

using namespace std;
#define double long double
#define int long long
#define all(a) a.begin(), a.end()


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n;
	cin >> n;

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

	vector<vector<int> > dp(n, vector<int>(2, -1));


	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (a[i] % 2 == 0) {
				dp[i][0] = max(dp[i][0], a[i] / 2);
			}
			else {
				dp[i][1] = max(dp[i][1], a[i] / 2);
			}
		}
		else {
			if (a[i] % 2 == 0) {
				int temp = -1;
				int pemt = -1;
				if (dp[i - 1][0] != -1) {
					temp = max(temp, dp[i - 1][0] + a[i] / 2);
					if (a[i]/2>0)
					pemt = max(pemt, dp[i - 1][0] + a[i] / 2 - 1);
				}
				if (dp[i - 1][1] != -1) {
					temp = max(temp, dp[i - 1][1] + a[i] / 2);
					if (a[i]>0)
					pemt = max(pemt, dp[i - 1][1] + a[i] / 2);
				}

				dp[i][0] = max(dp[i][0], temp);
				dp[i][1] = max(dp[i][1], pemt);
			}
			else {
				int temp = -1, pemt = -1;
				if (dp[i - 1][0] != -1) {
					pemt = max(pemt, dp[i - 1][0] + a[i] / 2);
				}
				if (dp[i - 1][1] != -1) {
					temp = max(temp, dp[i - 1][1] + a[i] / 2 + 1);
				}
				dp[i][0] = max(dp[i][0], temp);
				dp[i][1] = max(dp[i][1], pemt);
			}

		}
	}

	cout << max(dp[n - 1][0], dp[n - 1][1]);
}

Measured memory_bytes: 9448
n = int(input())
x = []

for i in range(n):
    x.append(int(input()))

minv = x[0]
maxv = - 10**9

for i in range(1, n):
    maxv = max(maxv, x[i]-minv)
    minv = min(minv, x[i])

print(maxv)


Measured memory_bytes: 13592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

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


Measured memory_bytes: 3588
N,C=map(int,input().split())
L=[list(map(int,input().split())) for _ in range(N)]
cal_list=[]
dis_list=[]
cal_list.append(0)
dis_list.append(0)
for i in range(N):
    dis_list.append(L[i][0])
    cal_list.append(L[i][1])
    
dis_list.append(C)
#時計回りの時
time_around=[0 for _ in range(N+1)]
time_around_rev=[0 for _ in range(N+1)]
time_around_temp=0
for i in range(1,N+1):
    time_around[i]=time_around[i-1]+(cal_list[i]-(dis_list[i]-dis_list[i-1]))
    if time_around_temp<time_around[i]-dis_list[i]:
        time_around_rev[i]=time_around[i]-dis_list[i]
        time_around_temp=time_around[i]-dis_list[i]
        
    else:
        time_around_rev[i]=time_around_temp
#反時計回りの時
time_rev_around=[0 for _ in range(N+1)]
time_rev_around_rev=[0 for _ in range(N+1)]
time_rev_around_temp=0
for i in range(1,N+1):
    time_rev_around[i]=time_rev_around[i-1]+(cal_list[N-i+1]-(dis_list[N-i+2]-dis_list[N-i+1]))
    if time_rev_around_temp< time_rev_around[i]-(C-dis_list[N-i+1]):
        time_rev_around_rev[i]=time_rev_around[i]-(C-dis_list[N-i+1])
        time_rev_around_temp=time_rev_around_rev[i]
    else:
        time_rev_around_rev[i]=time_rev_around_temp
        
#結果を示す
result=0
for i in range(1,N+1):
    result=max((time_around[i]+time_rev_around_rev[N-i]),(time_rev_around[i]+time_around_rev[N-i]),result)
    
print(result)

Measured memory_bytes: 43924
N,K = list(map(int,input().split()))

n = [0]*N
ans = 0
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for k in range(d):
        n[A[k]-1] += 1
    
for i in range(N):
    if n[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define rep(i,n) for(int i=0;i<n;i++)

typedef long long ll;
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, ans=0;
    cin >> n;
    rep(i,n+1){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout << ans;
    return 0;
}

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


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

	int time=0;
	int ans=1;
	for(int i=0; i<n; i++){
		int res=0;
		int num=i+1;
		while(num>0){
			if(num%2==0){
				res++;
				num /= 2;
			}else{
				break;
			}
		}
		if(res>time){
			ans=i+1;
			time=res;
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;

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

	ll n,d;
	cin>>n>>d;
	d*=d;
	int count=0;
	for(int i=0;i<n;i++){
		ll val,x,y;
		cin>>x>>y;
		val=x*x+y*y;
		if(val<=d)
			count++;
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3168
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"]

    def __init__(
        self,
        height: int,
        width: int,
        start: Tuple[int, int],
        goal: Tuple[int, int],
        grid: List[str],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        # Values of start and goal must be 0-origin.
        self.height = height + 4
        self.width = width + 4
        self.start = self._flatten_coordinate(*start)
        self.goal = self._flatten_coordinate(*goal)
        self.road = road
        self.wall = wall
        self.grid = self._flatten_grid(grid)

    def _flatten_dxy(self, x: int, y: int) -> int:
        return self.width * x + y

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self._flatten_dxy(h + 2, w + 2)

    def _flatten_grid(self, grid: List[str]) -> str:
        flat_grid = self.wall * self.width * 2
        for row in grid:
            flat_grid += self.wall * 2 + row + self.wall * 2
        flat_grid += self.wall * self.width * 2
        return flat_grid

    def bfs(self) -> int:
        w = self.width
        move_to_warp = {
            -w: (-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -w - 1),
            w: (w + 1, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2),
            -1: (-w - 2, -2, w - 2, w - 1, 2 * w - 2),
            1: (-w + 1, -2 * w + 2, -w + 2, 2, w + 2),
        }

        unsearched = 1 << 30
        dist = [unsearched] * (self.height * self.width)
        dist[self.start] = 0
        queue = deque([self.start])
        while queue:
            x = queue.popleft()
            cur_dist = dist[x]
            if x == self.goal:
                break

            for move, warp in move_to_warp.items():
                nx = x + move
                if self.grid[nx] == self.road:
                    if dist[nx] > cur_dist:
                        dist[nx] = cur_dist
                        queue.appendleft(nx)
                else:
                    for dx in warp:
                        nx = x + dx
                        if self.grid[nx] == self.wall:
                            continue
                        if dist[nx] > cur_dist + 1:
                            dist[nx] = cur_dist + 1
                            queue.append(nx)

        return dist[self.goal] if dist[self.goal] != unsearched else -1

    def debug(self):
        print(f"<DEBUG>\nstart={self.start}, goal={self.goal}", file=sys.stderr)
        for row in zip(*[iter(self.grid)] * self.width):
            print(*row, file=sys.stderr)


def main():
    H, W, CH, CW, DH, DW, *S = open(0).read().split()
    start, goal = (int(CH) - 1, int(CW) - 1), (int(DH) - 1, int(DW) - 1)
    maze = WarpableMaze(int(H), int(W), start, goal, S)
    # maze.debug()
    print(maze.bfs())


if __name__ == "__main__":
    main()


Measured memory_bytes: 220656
#include <iostream>

using namespace std;

#define x first
#define y second 

typedef pair<int, int> P;

int main() {
    int d; cin >> d;
    while (d--) {
        int x, y, w, h;
        cin >> x >> y >> w >> h;

        int north, south, west, east;
        north = y+h;
        south = y;
        west = x;
        east = x+w;

        int n; cin >> n;
        P cat[n];
        for (int i = 0; i < n; i++) {
            cin >> cat[i].x >> cat[i].y;
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (west <= cat[i].x && cat[i].x <= east && south <= cat[i].y && cat[i].y <= north) {
                count++;
            }
        }

        cout << count << endl;
    }
    return 0;
}
        

Measured memory_bytes: 0
s1 = [1,3,5,7,8,10,12]
s2 = [4,6,9,11]
s3=[2]
x,y = map(int,input().split())
if x in s1 and y in s1:
    print("Yes")
elif x in s2 and y in s2:
    print("Yes")
elif x in s3 and y in s3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)
        if n == 0 {
                fmt.Println(0)
                return
        }

        s := ""
        for n != 0 {
                k := 0
                n, k = n/(-2), n%(-2)
                if k < 0 {
                        n += 1
                        k += 2
                }
                s = string(k+'0') + s
        }
        fmt.Println(s)
}


Measured memory_bytes: 512
from itertools import combinations

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

cnt = [0] * n
for i, j in combinations(range(n), 2):
    i, j = i + 1, j + 1
    dist = min(abs(j - i), abs(i - x) + abs(j - y) + 1,
               abs(i - y) + abs(j - x) + 1)
    cnt[dist] += 1

for i in range(1, n):
    print(cnt[i])


Measured memory_bytes: 46940
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
puts_yesno n==m

Measured memory_bytes: 1788
import sys
import heapq

H,W = map(int,input().split())
maze = [list(input()) for i in range(H)]

def removeWalls(wallPointH,wallPointW):
  if maze[wallPointH][wallPointW]=="#":
    changeTo = "."
  elif maze[wallPointH][wallPointW]=="1":
    changeTo = "0"
  if maze[wallPointH][wallPointW]=="#" or maze[wallPointH][wallPointW]=="1":
    maze[wallPointH][wallPointW]=changeTo
    if wallPointH+1 <= H-1:
      removeWalls(wallPointH+1,wallPointW)
    if wallPointW+1 <= W-1:
      removeWalls(wallPointH,wallPointW+1)

if maze[0][0]=="#":
  flag=1
else:
  flag=0
      
que = [[flag,0,0]]
heapq.heapify(que)
count = 0
      
while que:
  qu = heapq.heappop(que)
  if qu[0]==1:
    heapq.heappush(que, qu)
    count += 1
    for q in que:#いったん"#"の撤去作業を行う
      q[0]=0
      removeWalls(q[1],q[2])
  else:#queの中身にまだ進める場所があるなら
    nowH = qu[1]
    nowW = qu[2]
    if nowH==H-1 and nowW==W-1:#ゴールの場合
      print(count)
      sys.exit()
    else:#それ以外の場合
      #右近傍と下近傍、それぞれマップの中ならqueに格納。
      if nowH+1 <= H-1:
        if maze[nowH+1][nowW]=="#":
          maze[nowH+1][nowW]="1"
          heapq.heappush(que, [1,nowH+1,nowW])
        elif maze[nowH+1][nowW]==".":
          maze[nowH+1][nowW]="0"
          heapq.heappush(que, [0,nowH+1,nowW])
      if nowW+1 <= W-1:
        if maze[nowH][nowW+1]=="#":
          maze[nowH][nowW+1]="1"
          heapq.heappush(que, [1,nowH,nowW+1])
        elif maze[nowH][nowW+1]==".":
          maze[nowH][nowW+1]="0"
          heapq.heappush(que, [0,nowH,nowW+1])
        



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
bool cmp(long long int x,long long int y)
{
   return x>y;
}
int main(void)
{
   long long int t,n,ans=0;
   vector<long long int> v,v1,v2;
   vector< pair <long long int,long long int> >p,p1,p2;
   set<long long int> st;
   priority_queue<long long int> pq;
   priority_queue< long long int,vector<long long int>,greater<long long int> > lpq;
   priority_queue< pair<long long int,long long int>,vector< pair<long long int,long long int> >,greater< pair <long long int,long long int> > > plpq;
      cin>>n;
      for(long long int i=1;i<=n;i++)
      {
         if(i%3!=0 && i%5!=0)
            ans=ans+i;
      }
      cout<<ans<<endl;
   return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b;
    cin >> a >> b;
    if (a >= 6 && a <= 12) b /= 2;
    if (a <= 5) b = 0;
    cout << b << endl; 
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f[200000];
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt, a[210000], b[210000];
LL solve() {
	LL x = INF;
	function<bool(LL)> dfs = [&](LL cur) {
		bool ret = 1;
		for (int i = 0; i < g[cur].size(); i++) {
			LL v, cost;
			tie(v, cost) = tie(g[cur][i].to, g[cur][i].cost);
			if (a[v] == INF) {
				a[v] = -a[cur];
				b[v] = cost - b[cur];
				ret &= dfs(v);
			}
			else if (x == INF) {
				if (a[cur] + a[v] != 0) {
					LL num = a[v] + a[cur], den = cost - b[cur] - b[v];
					if (den%num != 0)ret = false;
					x = den / num;
				}
			}
			if (x != INF) {
				if ((a[cur] + a[v])*x + b[v] + b[cur] == cost) {}
				else ret = false;
			}
			else {
				if (a[v] + a[cur] == 0 && b[v] + b[cur] == cost) {}
				else ret = false;
			}	
		}
		return ret;
	};
	a[0] = 1, b[0] = 0;
	if (!dfs(0))return 0;
	if (x != INF) {
		rep(i, n) {
			if (a[i] * x + b[i] <= 0)return 0;
		}
		return 1;
	}

	LL l = 0, r = INF;
	rep(i, n) {
		if (a[i] == 1) {
			l = max(l, -b[i]);
		}
		else {
			r = min(r, b[i]);
		}
	}
	return max(0LL, r - l - 1);
}
int main() {
	cin >> n >> m;
	g.resize(n);
	rep(i, m) {
		LL x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		g[x].push_back(Edge{ y, z });
		g[y].push_back(Edge{ x,z });
	}
	rep(i, n)a[i] = INF;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 18816
#include<iostream>
using namespace std;
long long int n,m,nd;
int main()
{
    cin>>n>>m;
    nd=2*n;
    if(nd>m)cout<<m/2<<endl;
    else
    {
        m-=nd;
        m/=4;
        cout<<n+m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> cnt(n);
    for(int i=1;i <= n; i++){
        for(int j=i+1; j <= n; j++){
            cnt[min(j-i, abs(x-i) + 1 + abs(y-j))]++;
        }
    }
    for(int i=1;i < n; i++){
        cout << cnt[i] << endl;
    }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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==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;
  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");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807
#define array(N, t) (t*)calloc(N, sizeof(t))

int main() {
  int K;
  scanf("%d", &K);

  int mod_K = 7 % K;

  for (int i = 1; i <= K; i += 1) {
    if (mod_K == 0) {
      printf("%d\n", i);
      return 0;
    }
    mod_K = ((mod_K * 10) + 7) % K;
  }

  printf("-1\n");
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	char a;
	cin>>a;
	if(a>='a')cout<<'a'<<endl;
	else cout<<"A"<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

//なんて工夫のない提出

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


	int N = getint();
	ll K = 0;
	while ((ct = *ci++) >= '0') K = K * 10 + ct - '0';

	int sei[200000], fu[200000];
	int seik = 0, fuk = 0;
	int zero = 0;
	rep(i, N) {
		int a = getint();
		if (a > 0) sei[seik++] = a;
		else if (a < 0) fu[fuk++] = -a;
		else zero++;
	}
	pakuri_sort(seik, sei);
	pakuri_sort(fuk, fu);
	ll k0 = ll(seik) * fuk + ll(zero) * (zero - 1) / 2 + ll(zero) * (N - zero);

	ll L = -1000000000000000001, R = 1000000000000000000;
	while (L + 1 < R) {
		ll M = (L + R) / 2;
		ll k = 0;
		if (M >= 0) {
			k += k0;
			int i = 1;
			while (i < seik) {
				if (ll(sei[i]) * sei[i - 1] > M) break;
				k += i;
				i++;
			}
			int j = i - 1;
			while (i < seik) {
				while (j >= 1 && ll(sei[i]) * sei[j - 1] > M) j--;
				k += j;
				i++;
			}
			i = 1;
			while (i < fuk) {
				if (ll(fu[i]) * fu[i - 1] > M) break;
				k += i;
				i++;
			}
			j = i - 1;
			while (i < fuk) {
				while (j >= 1 && ll(fu[i]) * fu[j - 1] > M) j--;
				k += j;
				i++;
			}
		}
		else {
			int j = 0;
			rep(i, seik) {
				while (j < fuk && ll(sei[i]) * fu[fuk - j - 1] >= -M) j++;
				k += j;
			}
		}
		if (k >= K) R = M;
		else L = M;
	}

	printf("%lld\n", R);

	Would you please return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

bool CheckValue(int value, int p[], int n) {
	for (int i = 0; i < n; i++)
	{
		if (value == p[i]) return false;
	}
	return true;
}

int main()
{
	int x, n;
	int* p;
	cin >> x >> n;
	if (n == 0) {
		cout << x << endl;
		return 0;
	}

	p = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}

	int a = 0;
	int ans = 0;
	while (1) {
		if (CheckValue(x - a, p, n)) {
			ans = x - a;
			break;
		}
		if (CheckValue(x + a, p, n)) {
			ans = x + a;
			break;
		}
		a++;
	}
	cout << ans << endl;

	delete[] p;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define ull unsigned lint
#define db long double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gc getchar()
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int a[110];
inline int gabs(int x) { return x<0?-x:x; }
int main()
{
	int n=inn(),s=0,ans=0;rep(i,1,n) a[i]=inn();
	rep(i,1,n) s+=a[i];
	rep(i,1,n) if(ans==0||gabs(a[i]*n-s)<gabs(a[ans]*n-s)) ans=i;
	return !printf("%d\n",ans-1);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int L = sc.nextInt();
      int R = sc.nextInt();
      int d = sc.nextInt();
      
      // 算出
      int countL = (L-1) / d;
      int countR = R / d;
      int result = countR - countL;
      
      // 出力
      System.out.println(result);
    }
    
}

Measured memory_bytes: 35636