akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define ll   long long 
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
#define fmd          1000000007
#define md         998244353 
#define M           400011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll c;

ll dp[M];
class SegTree{
public:
    int sz;
    vector<ll> v;
    SegTree(int s){
        sz=s;
        v=vector<ll> (4*sz+10,-1e18);
    }
    void up(ll n,ll s,ll e,ll i,ll val){
        if(s==e){
            v[n]=max(v[n],val);return ;
        }
        ll m=(s+e)/2;
        if(i>=s&&i<=m)up(2*n,s,m,i,val);
        else up(2*n+1,m+1,e,i,val);
        v[n]=max(v[2*n],v[2*n+1]);
    }
    ll query(ll n,ll s,ll e,ll l,ll r){
        if(s>e||l>e||s>r)return -1e18;
        if(s>=l&&e<=r)return v[n];
        ll m=(s+e)/2;
        return max(query(2*n,s,m,l,r),query(2*n+1,m+1,e,l,r));
    }
};



int solve(){
    ll n,i,j,k,m,x,y,z;
    ll p;
    cin>>n;
    vector<pair<ll,ll > > v;
    map<ll,ll> mp;
    for(i=0;i<n;++i){
        cin>>x>>y;
        mp[x];mp[x+y-1];
        v.pb({x,x+y-1});
    }
    sort(all(v));
    for(auto x:mp)mp[x.F]=++c;
    for(i=0;i<n;++i){
        v[i].F=mp[v[i].F];
        v[i].S=mp[v[i].S];
    }
    SegTree s(c);
    dp[c+1]=1;
    dp[v.back().F]=2;
    s.up(1,1,c,v.back().F,c+1);

    for(i=n-2;i>=0;--i){
        x=s.query(1,1,c,v[i].F,v[i].S);
        // trace(i,x);
        if(v[i].S<v[i+1].F){
            x=v[i+1].F;
        }
        dp[v[i].F]+=dp[x];
        dp[v[i].F]+=dp[v[i+1].F];
        dp[v[i].F]%=md;
        s.up(1,1,c,v[i].F,x);
    }
    cout<<dp[v[0].F]%md<<"\n";



	die();

}
 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif

     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int t;
    t=1;;
    // prec();
    // cin>>t;
 
    while(t--){

        solve();
    }
 
 
 
 


#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 44908
import math
a,b,x = map(int, input().split())

if x < a*a*b/2:
    h = b
    v = 2*x/(a*b)
else:
    h = 2*(a*a*b-x)/(a*a)
    v = a
angle = math.degrees(math.atan(h/v))
print(angle)

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

int main() {
    int N;
    cin >> N;
    set<int> st;
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (st.find(A) == st.end()) st.insert(A);
        else st.erase(A);
    }
    cout << st.size() << endl;
}

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

int main()
{
    string s, t;
    int count = 0;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
            count++;
    }
    cout << count;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3916
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
using namespace std;
struct aa{int l, r;}a[N];
struct tt{int l, r, f, mx;}t[N*2];
int n, m, ans, x, y, l, l1;
inline bool cmp(aa a, aa b){return a.l<b.l;}
inline void maketree(int L, int R){
	t[l].l=t[l].r=t[l].f=0; t[l].mx=R;
	if(L<R){
		int mid=(L+R)>>1, l1=l;
		l++; t[l1].l=l; maketree(L, mid);
		l++; t[l1].r=l; maketree(mid+1, R);
	}
}
inline void pushdown(int i){
	if(t[i].f){
		t[t[i].l].f+=t[i].f; t[t[i].l].mx+=t[i].f;
		t[t[i].r].f+=t[i].f; t[t[i].r].mx+=t[i].f;
		t[i].f=0;
	}
}
inline void ins(int i, int a, int b, int L, int R){
	if(a<=L&&R<=b){t[i].f++; t[i].mx++; return;}
	pushdown(i);
	int mid=(L+R)>>1;
	if(a<=mid)ins(t[i].l, a, b, L, mid);
	if(mid<b)ins(t[i].r, a, b, mid+1, R);
	t[i].mx=max(t[t[i].l].mx, t[t[i].r].mx);
}
int main(){
	scanf("%d%d", &n, &m); ans=max(0, n-m); l=0;
	for(int i=1; i<=n; i++){scanf("%d%d", &x, &y); if(x+2<=y){a[++l].l=x+1; a[l].r=y-1;}}
	sort(a+1, a+1+l, cmp); l1=l;
	l=1; maketree(1, m);
	for(int i=1; i<=l1; i++){
		ins(1, 1, a[i].r, 1, m);
		x=t[1].mx; ans=max(ans, x-a[i].l+1-m);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int h, w;

vint dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int bfs(vvstr maze, vvint d) {
    queue<P> que;
    que.push(P(0, 0));
    d[0][0] = 1;
    while (que.size()) {
        P p = que.front();
        que.pop();
        if (p.fi == h-1 && p.se == w-1) break;
        rep(i, 4) {
            int nx = p.fi + dx[i], ny = p.se + dy[i];

            if (0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && maze[nx][ny] == ".") {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.fi][p.se] + 1;
            }
        }
    }
    return d[h-1][w-1];
}

int main() {
    cin >> h >> w;
    vvstr maze(h, vstr(w));
    vvint d(h, vint(w, INF));
    int road = 0;
    string s;
    rep(i, h) {
        cin >> s;
        rep(j, w) {
            maze[i][j] = s[j];
            if (s[j] == '.') road++;
        }
    }

    int res = bfs(maze, d);
    int ans;
    if (res == INF) ans = -1;
    else ans = road - res;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


# refered to
# rank : http://at274.hatenablog.com/entry/2018/02/02/173000
# size : abc120 kaisetsu
class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1] * (n+1)
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # Returns the number of sets to which x belongs
    def size(self, x):
        return -1*self.par[self.find(x)]
    
    def size_list(self):
        return [x*(-1) for x in self.par[1:] if x < 0]

    # Returns number if root
    def find(self, x):
        if(self.par[x] < 1):
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    # Are the parents of x and y the same?
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # find root 
        x = self.find(x)
        y = self.find(y)

        # Already x connect to y
        if(x == y):
            return False

        # Reconnect
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # update x size
        self.par[x] += self.par[y]
        # set parent number of y to x
        self.par[y] = x

        return True 
    
    def root_nodes(self):
        return len([i for i in self.par[1:] if i <= -1])
    
    

def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):
    """graph.input.linkedlist
        input: u[]:start, v[]:end
        output:g[][]
    """
    uf = UnionFind(N)

    g = [[] for i in range(N+1)]
    for i in range(M):
        g[A[i]].append(B[i])
        g[B[i]].append(A[i])
    
    g_b = [[] for i in range(N+1)]
    for i in range(K):
        g_b[C[i]].append(D[i])
        g_b[D[i]].append(C[i])
    

    for i in range(M):
        uf.union(A[i], B[i])

    ans = []
    for i in range(1, N+1):
        ans.append(uf.size(i)-1 - len(g[i]) - len([x for x in g_b[i] if uf.same_check(i, x) == True]))
        
    print(' '.join(map(str, ans)))
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (K)  # type: "List[int]"
    D = [int()] * (K)  # type: "List[int]"
    for i in range(K):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(N, M, K, A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 55384
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;


int main(void){
    // Here your code !
    int n,s[1000];
    double m,A;
    while(1){
    cin>>n;
    if(n==0) break;
    m=0;
    A=0;
    for(int i=0;i<n;i++){

     
       cin>>s[i];
       m=m+s[i];
       
    }
    m=m/n;
    
    for(int i=0;i<n;i++){

       A=A+pow((s[i]-m),2);
       
    }
    A=A/n;
    A=sqrt(A);
    printf("%f\n",A);
    
}

}

Measured memory_bytes: 1188
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define F first
#define S second
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define fo(i, n)   for (int i = 1; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define fast  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define E cout << '\n'
const int N = 1e5 + 5;
int dp[N], a[N];
signed main(){
   fast;
   int n, k;
   cin >> n >> k;
   for(int i = 1; i <= n; ++i)
        cin >> a[i], dp[i] = 1e18;
   if(n == 1)
        return cout << 0,0;
   dp[1] = 0;

   for(int i = 2; i <= n; ++i) {
      int K = k;
      for(int j = i - 1; j > 0 && K--; --j)
        dp[i] = min(dp[j] + abs(a[i] - a[j]), dp[i]);
   }
   cout << dp[n];
   return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B;

  cin >> A >> B;

  for (int p = 0; p <= 10000; p++) {
    if (A == p * 8 / 100 && B == p * 10 / 100) {
      printf("%d\n", p);
      return 0;
    }
  }

  puts("-1");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <fstream>
using namespace std;
int main()
{
    // // 以降 cin の入力元が 'input.txt' になる
    // std::ifstream in("tests/sample-3.in");
    // std::cin.rdbuf(in.rdbuf());

    // ここにプログラムを記載
    int N;
    cin >> N;
    int d, i;
    set<int> setd;
    for (i = 0; i < N; i++)
    {
        cin >> d;
        setd.insert(d);
    }
    cout << setd.size() << endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

class RMQ {
    int n;
    vector<int> dat;
    
public:
    RMQ(int _n) {init(_n);}
    RMQ(){}
    
    void init(int _n) {
        n=1;
        while (n<_n) n*=2;
        dat.resize(2*n-1, INT_MAX);
    }
    
    void update(int k, int a) {
        k += n-1;
        dat[k] = a;
        while (k>0) {
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    
    int size() {
        return n;
    }
    
    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INT_MAX;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a, b, k*2+1, l, (l+r)/2);
            int vr = query(a, b, k*2+2, (l+r)/2, r);
            return min(vl, vr);
        }
    }
 
    int query(int l, int r)
    {
        return query(l, r, 0, 0, n);
    }
};

int main()
{
    ios::sync_with_stdio(false);

    int N, T;
    cin >> N >> T;
    
    RMQ R(N);
    rep(i, N) {
        int A;
        cin >> A;
        R.update(i, A);
    }

    int max_val = -1, max_cnt = 0;

    REP(i, 1, N) {
        int n = R.query(i, i+1) - R.query(0, i); 
        if (n <= 0) continue;
        if (n == max_val) {
            max_cnt++;
        } else if (n > max_val) {
            max_val = n;
            max_cnt = 1;
        }
    }

    cout << max_cnt << endl;
}


Measured memory_bytes: 1280
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    A.append(CA[1:])

buys = []
for i in range(2**N):
    buy = []
    for j in range(N):
        if ((i>>j) & 1):
            buy.append(j)
    buys.append(buy)

ans = 10**9
flag = 1
for books in buys:
    cost = 0
    power = [0] * M
    for book in books:
        cost += C[book]
        for i in range(M):
            power[i] += A[book][i]

    if min(power) >= X:
        ans = min(ans, cost)
        flag = 0

print(-1 if flag else ans)

Measured memory_bytes: 9436
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < ll(n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	long double a, b;
	cin >> a >> b;
	cout << (ll)(a * b + 0.001) << endl;
}

Measured memory_bytes: 3736
def main():
    N = int(input())
    S = [0] * N
    T = [0] * N
    for i in range(N):
        S[i], T[i] = input().split()
    X = input()
    idx = S.index(X)
    ans = sum(map(int, T[idx+1:]))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p;
    string s;
    cin>>n>>p>>s;
    map<ll,ll> counts;
    ll res = 0;
    if (p==2||p==5) {
        rep(i,n) {
            ll now = s[i]-'0';
            if (now%p==0) {
                res += i+1;
            }
        }
    }
    else {
        ll rem = 0;
        ll rem10 = 1;
        for(int i=s.size()-1;i>=0;i--) {
            ll now = s[i] - '0';
            rem = (rem + rem10 * now) % p;
            counts[rem]++;
            rem10 = rem10 * 10 % p;
        }
        for(auto x:counts) {
            if (x.first==0) {
                res += x.second * (x.second+1)/2;    
            }
            else {
                res += x.second * (x.second-1)/2;
            }
            
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
 
void fio() 
{
    std::ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
void inputread()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
const ll m = 1e9+7;

int32_t main()
{
    fio();
    ll n,k,s=0,i;
    cin >> n >> k;
    vector<ll> a(n+1,0),sf(n+1), sl(n+1);

    for(i=0;i<=n;i++)
    {
        a[i]=i;
    }

    for(i=1;i<=n;i++)
    {
        sf[i]=sf[i-1]+a[i];
    }
    sl[n]=a[n];
    for(i=n-1;i>=0;i--)
    {
        sl[i] = sl[i+1]+a[i];
    }

    reverse(sl.begin(),sl.end());

    for(i=k;i<=n+1;i++)
    {
        s = s + sl[i-1] - sf[i-1] +1;
        s%=m;
        // cout << sl[i-1]  << " " << sf[i-1] << "\n";
    }
    cout << s;

    return 0;
}

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

int main(){
  int n,weight;

  cin >> n >> weight;

  int v[n],w[n];

  int dp[n+1][weight+1];

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

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

  for(int i=1; i<n+1; i++){
    for(int j=0; j<weight+1; j++){
      if(j<w[i-1]){
        dp[i][j] = dp[i-1][j];
      }

      else{
        dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i-1]] + v[i-1]);
      }
    }
  }

  cout << dp[n][weight] << endl;

  return 0;
}

Measured memory_bytes: 7020
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			
			long[] s = new long[N+1+1];
			int Q = scan.nextInt();
			String S = scan.next();
			char []c = new char[N];
			c = S.toCharArray();
			int []l = new int[Q];
			int []r = new int[Q];
			for(int i = 0;i<Q;i++) {
				l[i] = scan.nextInt();
				r[i] = scan.nextInt();
			}
			
			for(int i = 0;i<N;i++) {
				if(i>=1) {
				if(c[i]=='C'&&c[i-1]=='A') {
					s[i+1] = s[i]+1;
				}else {
					s[i+1] = s[i];
				}
				
			}
				//System.out.println(s[i+1]);
			}
				
			for(int i = 0;i<Q;i++) {	
				long a = s[r[i]]-s[l[i]];
				System.out.println(a);
			}
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 97616
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    int i;
    int score;
    int map[100] = {};
    int p = 0;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> score;
        if(score < 3200){
            map[score / 400] = 1;
        }else{
            p++;
        }
    }
    int c = 0;
    for(i = 0; i < 8; i++){
        c+=map[i];
    }
    int cmax = c;
    int cmin = c;
    cmax = cmax + p;
    if(cmin == 0)cmin = 1;
    if(cmax == 0)cmax = 1;
    cout << cmin << " " << cmax << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int d;
int c[26],s[365][26],last[26],t[365];

int main() {
  cin >> d;
  for(int i=0;i<26;i++) {
    cin >> c[i];
  }
  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  int score=0;
  for(int i=0;i<d;i++) {
    for(int j=1;j<26;j++) {
      if(s[i][t[i]]<s[i][j]) t[i]=j;
    }
    score+=s[i][t[i]];
    last[t[i]]=i+1;
    for(int j=0;j<26;j++) {
      score-=c[j]*(i+1-last[j]);
    }
  }
  int cnt=1000000;
  while(cnt--) {
    int day=rand()%d;
    int v=rand()%26;
    if(t[day]==v) continue;
    int dscore=0;
    int check[2]={v,t[day]};
    int pscore=0;
    int cscore=0;
    for(int i=0;i<2;i++) last[check[i]]=0;
    for(int i=0;i<d;i++) {
      pscore+=s[i][t[i]];
      last[t[i]]=i+1;
      for(int j=0;j<2;j++) {
        int id=check[j];
        pscore-=c[id]*(i+1-last[id]);
      }
    }
    for(int i=0;i<2;i++) last[check[i]]=0;
    for(int i=0;i<d;i++) {
      if(day==i) {
        cscore+=s[i][v];
        last[v]=i+1;
      }
      else {
        cscore+=s[i][t[i]];
        last[t[i]]=i+1;
      }
      for(int j=0;j<2;j++) {
        int id=check[j];
        cscore-=c[id]*(i+1-last[id]);
      }
    }
    if(pscore<cscore) {
      t[day]=v;
    }
  }
  for(int i=0;i<d;i++) {
    cout << t[i]+1 << endl;
  }
}

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

int main() {
    ll n;
    cin>>n;
    if(n%2){
        cout<<0<<endl;
        return 0;
    }
    
    ll ans = 0;
    ll k = n/10;
    ll l=n/10;
    while(n){
        ans += n/10;
        n /= 10;
    }
    while(k){
        ans += k/5;
        k /= 5;
    }
    while(l){
        ans  -= l/10;
        l /= 10;
    }
   
    cout << ans << endl;
    
    return 0;
}



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

using namespace std;

int a[12][12];

int main(int argc, char *argv[])
{
    int n, m, x;

    cin >> n >> m >> x;

    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0x7FFFFFFF;
    for (int s = 0; s < (1 << n); s++) {
        int cost = 0;
        vector<int> d(m);
        for (int i = 0; i < n; i++) {
            if ((s >> i) & 1) {
                cost += c[i];
                for (int j = 0; j < m; j++) {
                    d[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (d[j] < x) {
                ok = false;
            }
        }
        if (ok) {
            ans = min(ans, cost);
        }
    }
    if (ans == 0x7FFFFFFF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
   string s ;
   cin >> s ;
   size_t n = s.length() ;
   bool flag = true ;
   if(n % 2 != 0 ){
       cout << "No" << endl;
       return 0 ;
   }else{
       
       rep(i , n /2){
           if(s[2*i] != 'h' || s[2*i + 1] != 'i'){
               flag = false ;

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

 


Measured memory_bytes: 256
#include <stdio.h>
#define N_max 10000

int main(int argc, char const *argv[]) {
  int N;
  long A[N_max];
  //入力
  scanf("%d", &N );
  for (size_t i = 0; i < N; i++) {
    scanf("%ld", &A[i] );
  }
  //前処理(並び替え)
  long B[N_max] = {0};
  int b = 0;
  for (size_t i = 0; i < N; i++) {
    if ( (A[i]%2) == 0) {
      B[b] = A[i];
      A[b] = B[b];
      b ++;
    }
  }
  //計算
  int ans = 0;
  int loopmax = b;
  int no;
  while ( (A[0]%2) != 1 ) {
    no = 0;
    for (size_t i = 0; i < loopmax; i++) {
      if ( (A[i]%2) == 0 ) {
        A[i] = A[i]/2;
        if ( (A[i]%2) == 0 ) {
          B[no] = A[i];
          no ++;
        }
        ans ++;
      }
    }
    for (size_t i = 0; i < no; i++) {
      A[i] = B[i];
    }
    loopmax = no;
  }
//出力
printf("%d\n", ans );
  return 0;
}


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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      int[] ajacent;
      String[] vInfo;
      int id,degree;

      for(int i=0; i<n; i++) {
        vInfo  = br.readLine().split(" ");
        id     = Integer.parseInt(vInfo[0]);
        degree = Integer.parseInt(vInfo[1]);
        ajacent = new int[degree];
        for(int j=0; j<degree; j++) {
          ajacent[j] = graph.convIdToIndex( Integer.parseInt(vInfo[j+2]) );
        }
        graph.setVertex(id, ajacent);
      }

      graph.vertexSearch();

      graph.dispReport();
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }

  class Graph {

    Vertex[] vertices;
    Queue<Vertex> queue;
    int time;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      queue = new ArrayDeque<>(size);
      time = 0;
    }

    public void setVertex(int id) {
      vertices[convIdToIndex(id)] = new Vertex(id);
    }
    public void setVertex(int id, int[] ajacent) {
      setVertex(id);
      setAjacent(id, ajacent);
    }
    public void setAjacent(int id, int[] ajacent) {
      vertices[convIdToIndex(id)].ajacent = ajacent;
    }
    public void vertexSearch() {
      breadthFirstSearch(0);
    }
    public void dispReport() {
      StringBuilder buf = new StringBuilder();

      for (Vertex v : vertices) {
          buf.append(v.id).append(" ")
             .append(v.distance).append("\n");
      }

      System.out.print(buf);
    }
    public int convIdToIndex(int id) {
      return id-1;
    }

    private void breadthFirstSearch(int index) {
      vertices[index].state = Vertex.GRAY;
      vertices[index].distance = 0;
      queue.offer(vertices[index]);

      Vertex v;
      while(queue.size() != 0) {
        v = queue.poll();
        for (int ajcIndex : v.ajacent) {
          if(vertices[ajcIndex].state == Vertex.WHITE) {
            vertices[ajcIndex].state = Vertex.GRAY;
            vertices[ajcIndex].distance = v.distance + 1;
            queue.offer(vertices[ajcIndex]);
          }
        }
        v.state = Vertex.BLACK;
      }
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int index;
      int state;
      int[] ajacent;
      int findTime;
      int doneTime;
      int distance;

      public Vertex(int id) {
        this.id = id;
        index = id-1;
        state = WHITE;
        distance = -1;
      }
    }
  }
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli cnt;
bool flag;
lli k;
void func(lli n,string now){
	if(DEBUG)cout<<"n="<<n<<" now="<<now<<endl;
	if(n==now.size()){
		cnt++;
		if(cnt==k){
			cout<<now<<endl;
			flag=true;
			return;
		}
		return;
	}
	if(flag)return;

	lli c = now.at(now.size()-1) -'0';
	if(c!=0)func(n,now+to_string((c-1)));
	func(n,now+to_string(c));
	if(c!=9)func(n,now+to_string(c+1));
}

signed main(){

	cin>>k;

	REP(i,1,20){
		REP(j,1,10){
			if(flag)return 0;
			func(i,to_string(j));
		}
		if(flag)return 0;
	}

	return 0;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r.begin()); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v){ return accumulate(v.begin(), v.end()); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Field {
  Field(int w, int h) : w(w), h(h) {}
  bool invalid(int x, int y){ return x < 0 || w <= x || y < 0 || h <= y; }
  const int w, h;
};

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int masks[] = {0700, 0070, 0007, 0444, 0222, 0111, 0124, 0421};
  string s;
  while (cin >> s, s != "0"){
    vector<string> f;
    f.push_back(s);
    cin >> s;
    f.push_back(s);
    cin >> s;
    f.push_back(s);
    int black = 0;
    int white = 0;
    for (int y = 0; y < 3; y++){
      for (int x = 0; x < 3; x++){
        char c = f[y][x];
        if (c == 'w'){
          white |= 1 << (y * 3 + x);
        }
        else if (c == 'b'){
          black |= 1 << (y * 3 + x);
        }
      }
    }
    bool na = false;
    for (int i = 0; i < 8; i++){
      if ((white & masks[i]) == masks[i]){
        puts("w");
        break;
      }
      if ((black & masks[i]) == masks[i]){
        puts("b");
        break;
      }
      if (i == 7) na = true;
    }
    if (na) puts("NA");
  }
  return (0);
}

Measured memory_bytes: 1176
#include<stdio.h>
int main()
{
	int N,A[2][101],sum[101],max;
	int i,j,k;
	
	//// Scan
	scanf("%d",&N);
	for (i=1;i<=N;i++){scanf("%d",&A[0][i]);}
	for (i=1;i<=N;i++){scanf("%d",&A[1][i]);}
	
	
	
	
	/// the initial sum is the "L" shaped path:
	sum[1]=A[0][1];
	for (i=1;i<=N;i++){sum[1]+=A[1][i];}
	max=sum[1];
	
	
	//// the other sums are modification of the previous one:
	for (j=2;j<=N;j++){sum[j]=sum[j-1]+A[0][j]-A[1][j-1];
		if(max<sum[j]) max=sum[j]; else ;
	}
	
	
	//////// answer
	printf("%d",max);
	
	return 0;
}



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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i <= n - 3; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int N = int.Parse(ReadLine());
         for(int i = 1; i <= N; i++){
             WriteLine(func(i));
         }
      }

      static int func(int n){
          int cnt = 0;
          for(int x = 1; x < 100; x++){
              for(int y = 1; y < 100; y++){
                  for(int z = 1; z < 100; z++){
                      if(x*x+y*y+z*z+x*y+y*z+z*x == n) cnt++;
                      else if(x*x+y*y+z*z+x*y+y*z+z*x > n) break;
                  }
              }
          }
          return cnt;
      }
   }
}

Measured memory_bytes: 27376
/*
ID: torchwr1
LANG: C++
TASK: money
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	//freopen("asd.in", "r", stdin);
	//freopen("asd.out", "w", stdout);
	long long n, ans = 0;
	cin >> n;
	long long base = 1;
	for (int i = 1; i <= n; ++i) {
		if (n >= base * 9) {
			n -= base * 9;
			ans += 9;
		}
		else {
			ans += n / base;
			break;
		}
		base *= 10;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        StringBuilder sb = new StringBuilder();

        for(int i = 0; i < line.length() ; i++){
            char now = line.charAt(i);
            if(Character.isUpperCase(now))      sb.append(Character.toLowerCase(now));
            else if(Character.isLowerCase(now)) sb.append(Character.toUpperCase(now));
            else                                sb.append(now);
        }

        System.out.println(sb);

    }
}

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

int n;
double t,a;
double h[100005];

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

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

    double tmp=abs(a-(t-h[0]*0.006));
    int cc=0;

    for(int i=1;i<n;i++){
        if(abs(a-(t-h[i]*0.006))<tmp){
            tmp=abs(a-(t-h[i]*0.006));
            cc=i;
        }
    }

    cout << cc+1;

    return 0;
}


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

using namespace std;

#define ll long long

ll solve(ll n, ll k, ll d) {
    n = abs(n);
    ll ans = 0;
    if (n / d < k) {
        ll rest_moves = k - (n / d);
        if (rest_moves % 2 == 0) {
            ans = n % d;
        }
        else {
            ans = d - n % d;
        }
    }
    else {
        ans = n - d * k;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x, k, d;
    scanf("%lld %lld %lld", &x, &k, &d);
    printf("%lld\n", solve(x, k, d));
    return 0;
}


Measured memory_bytes: 3852
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias route = Tuple!(long, "From", long, "To");
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a, b, c, d;
    auto tmp = lread();
    a = tmp / 1000;
    tmp %= 1000;
    b = tmp / 100;
    tmp %= 100;
    c = tmp / 10;
    tmp %= 10;
    d = tmp;
    if (a + b + c + d == 7)
    {
        writeln(a, "+", b, "+", c, "+", d, "=7");
        return;
    }
    if (a + b + c - d == 7)
    {
        writeln(a, "+", b, "+", c, "-", d, "=7");
        return;
    }
    if (a + b - c + d == 7)
    {
        writeln(a, "+", b, "-", c, "+", d, "=7");
        return;
    }
    if (a + b - c - d == 7)
    {
        writeln(a, "+", b, "-", c, "-", d, "=7");
        return;
    }
    if (a - b + c + d == 7)
    {
        writeln(a, "-", b, "+", c, "+", d, "=7");
        return;
    }
    if (a - b + c - d == 7)
    {
        writeln(a, "-", b, "+", c, "-", d, "=7");
        return;
    }
    if (a - b - c + d == 7)
    {
        writeln(a, "-", b, "-", c, "+", d, "=7");
        return;
    }
    if (a - b - c - d == 7)
    {
        writeln(a, "-", b, "-", c, "-", d, "=7");
        return;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#define ll long long 
#include<algorithm> 
ll dp[3050][3050];
int v[3050],n;
bool vis[3050][3050];
ll dfs(int l,int r){
	if (l>r)return 0;
	if (vis[l][r])return dp[l][r];
	vis[l][r]=1;
	return dp[l][r]=std::max(v[r]-dfs(l,r-1),v[l]-dfs(l+1,r));
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&v[i]);
	printf("%lld",dfs(1,n));
}

Measured memory_bytes: 80384
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 1) {
    cout << (m == 1 ? 1 : m - 2) << endl;
    return 0;
  }
  cout << (n - 2) * (m - 2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,x,ans,dp[3010][3010];
P p[5010];
signed main(){
	cin>>n>>x;
	rep(i,n)cin>>p[i].fi>>p[i].se;
	sort(p,p+n);
	rep(i,3010){
		rep(j,3010){
			dp[i][j]=-INF;
		}
		
	}
	dp[0][0]=0;
	rep(i,n){
		if(i){
			for(int j=0;j<x;j++){
				dp[i][j]=max(dp[i][j],dp[i-1][j]);
				if(j+p[i-1].fi<=x)dp[i][j+p[i-1].fi]=max(dp[i][j+p[i-1].fi],dp[i-1][j]+p[i-1].se);
			}
		}
		int Max=0;
		rep(j,x)Max=max(Max,dp[i][j]);
		ans=max(ans,Max+p[i].se);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 71936
x,n = map(int,input().split())
L = list(map(int,input().split()))
ans = 10**10
li = []
for i in range(-200,201):
    if i not in L:
        ans = min(ans,abs(x-i))
        li.append((ans,i))
li.sort()
print(li[0][1])

Measured memory_bytes: 9188
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Integer[] list = new Integer[3];
        for(int i = 0;i < 3;i ++) list[i] = scanner.nextInt();
        Arrays.sort(list, Collections.reverseOrder());
        int a = list[0] * 10;
        int b = list[1];
        int c = list[2];
        System.out.println(a + b + c);
    }
}


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

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

    if (a >= b)
    {
        cout << "delicious" << endl;
    }
    else if (b - a > x)
    {
        cout << "dangerous" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int INF = 1000000007;
		int n = sc.nextInt();
		int m = sc.nextInt();
		long ele = sc.nextLong();

		int node, path;
		node = n;
		path = m;

		long dist[][] = new long[n][n];
		int z, x;
		long c;
		long graph[][] = new long[node][node];

		for (int i = 0; i < node; i++) {
			for (int j = 0; j < node; j++) {
				graph[i][j] = INF;
			}
		}
		for (int i = 0; i < path; i++) {
			z = sc.nextInt();
			x = sc.nextInt();
			c = sc.nextLong();
			z--;
			x--;
			graph[z][x] = c;// ここを消すと有向グラフに
			graph[x][z] = c;// graph[from][to]=distance
		}

		floydWarshall(graph, dist);



		long graph2[][] = new long[node][node];
		long dist2[][] = new long[node][node];
		for (int i = 0; i < node; i++) {
			Arrays.fill(graph2[i], INF);
		}
		for (int i = 0; i < node - 1; i++) {
			for (int o = i + 1; o < node; o++) {
				if (dist[i][o] <= ele) {
					graph2[i][o] = 1;
					graph2[o][i] = 1;
				}
			}
		}
		floydWarshall(graph2, dist2);
		int q = sc.nextInt();
		for (int i = 1; i <= q; i++) {

			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			if (dist2[a][b] >= INF-1) {
				System.out.println(-1);
			} else {

				System.out.println(dist2[a][b]-1);
			}
		}
	}

	public static void floydWarshall(long graph[][], long dist[][]) {

		int V = graph[0].length;
		int i, j, k;

		for (i = 0; i < V; i++) {
			for (j = 0; j < V; j++) {
				dist[i][j] = graph[i][j];
			}
		}
		for (k = 0; k < V; k++) {

			for (i = 0; i < V; i++) {

				for (j = 0; j < V; j++) {

					if (dist[i][k] + dist[k][j] < dist[i][j]) {
						dist[i][j] = dist[i][k] + dist[k][j];
					}
				}
			}
		}

	}

}

Measured memory_bytes: 92784
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

    vector<ll> H(N);
    vector<vector<ll>> L(N);

    rep(i,N){
        cin >> H[i];
    }

    ll a,b;
    rep(i,M){
        cin >> a >> b;
        a--;
        b--;
        L[a].push_back(b);
        L[b].push_back(a);
    }

    vector<ll> ans(N);
    rep(i,N){
        rep(j,L[i].size()){
            if(H[i] <= H[L[i][j]]) ans[i] = 1;
        }
    }

    ll count = 0;
    rep(i,N){
        if(ans[i] == 0) count++;
    }

    cout << count << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 10652
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int x = sc.nextInt();
        int[] as = new int[N];

        for (int i=0; i<N; i++) {
            as[i] = sc.nextInt();
        }
        Arrays.sort(as);
        int sum = 0;

        for (int i=0; i<N; i++) {
            x -= as[i];
            if (x < 0) {
                break;
            }
            sum++;
        }
        if (x > 0) {
            sum--;
        }

        System.out.println(sum);
    }
}



Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>

using namespace std;

typedef long long ll;

int main()
{

  int m1,m2,d1,d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;

  if(m1==m2)
    cout << 0 << endl;
  else
    cout << 1 << endl;


  return 0;
}



Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n,a,b ;
	cin >> n >> a >> b ;
	if((b-a-1)&1) cout << "Alice" << endl ;
	else cout << "Borys" << endl ;
}


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

int W, H, N;
int X1[1000], X2[1000], Y1[1000], Y2[1000];
vector<int> xs, ys;
int TW, TH;
int T[2010][2010];

void f(int x, int y, int m) {
  if (T[x][y] != 0) return;
  T[x][y] = m;
  if (x > 0)    f(x-1, y, m);
  if (x < TW-1) f(x+1, y, m);
  if (y > 0)    f(x, y-1, m);
  if (y < TH-1) f(x, y+1, m);
}

int main() {
  while (cin >> W >> H) {
    if (W == 0 && H == 0) break;
    cin >> N;
    xs.clear(), ys.clear();
    for (int i=0; i<N; i++) {
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
      xs.push_back(X1[i]), xs.push_back(X2[i]);
      ys.push_back(Y1[i]), ys.push_back(Y2[i]);
    }
    xs.push_back(0), xs.push_back(W);
    ys.push_back(0), ys.push_back(H);
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    TW = xs.size()-1, TH = ys.size()-1;
    for (int i=0; i<=TW; i++) {
      for (int j=0; j<=TH; j++) {
        T[i][j] = 0;
      }
    }
    for (int i=0; i<N; i++) {
      int xz1 = lower_bound(xs.begin(), xs.end(), X1[i]) - xs.begin(),
          xz2 = lower_bound(xs.begin(), xs.end(), X2[i]) - xs.begin(),
          yz1 = lower_bound(ys.begin(), ys.end(), Y1[i]) - ys.begin(),
          yz2 = lower_bound(ys.begin(), ys.end(), Y2[i]) - ys.begin();
      for (int x=xz1; x<xz2; x++) {
        for (int y=yz1; y<yz2; y++) {
          T[x][y] = -1;
        }
      }
    }
    int m = 0;
    for (int y=0; y<TH; y++) {
      for (int x=0; x<TW; x++) {
        if (T[x][y] == 0) f(x, y, ++m);
      }
    }
    cout << m << "\n";
  }
  return 0;
}

Measured memory_bytes: 11004
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    string s, t;
    cin >> s;
    int ans = 0;
    while (cin >> t)
    {
        for (char &c : t)
        {
            c |= 0x20;
        }
        if (s == t)
            ans++;
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 3164
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

strs=[]
for i in range(N):
    strs.append(one_str())

count = 0
head_B=0
tail_A=0
dual_num=0
for s in strs:
    count +=s.count("AB")
    head_B += 0 if s[0]!="B" else 1
    tail_A += 0 if s[-1]!="A" else 1 
    
    if s[0]=="B" and s[-1]=="A":
        dual_num+=1
    

if N==1:
    print(count)
elif dual_num==head_B==tail_A and head_B>=1:
    print(min(head_B, tail_A) -1 +count)
else:
    print( min(head_B, tail_A)+count)

Measured memory_bytes: 44632