akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextLong();
        long y = sc.NextLong();

        long answer = 0;
        answer += Math.Max(0, (4 - x) * 100000);
        answer += Math.Max(0, (4 - y) * 100000);
        if (x == 1 && y == 1)
        {
            answer += 400000;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

void solve() {
    int x, n;
    cin >> x >> n;
    vector<int> p(101, 0);
    rep(i, n) {
        int t;
        cin >> t;
        p[t]++;
    }

    vector<int> cand;
    for (int i = 1; i <= 100; i++) {
        if (p[i] == 0) {
            cand.push_back(i);
        }
    }
    cand.push_back(0);
    cand.push_back(101);
    sort(cand.begin(), cand.end());

    int ans = 0;
    int diff = 10000;
    rep(i, cand.size()) {
        if (diff > abs(x - cand[i])) {
            ans = cand[i];
            diff = abs(x - cand[i]);
        }
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 3628
a = input()

flag1 = False
flag2 = False
k = int(a[:2])
l = int(a[2:])
if k is not 0 and k < 13:
    flag1 = True
if l is not 0 and l < 13:
    flag2 = True

if flag1 and flag2:
    print('AMBIGUOUS')
elif flag1:
    print('MMYY')
elif flag2:
    print('YYMM')
else:
    print('NA')



Measured memory_bytes: 3060
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define repl(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef unsigned long long ull;
//typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const ll N=(ll)(1e6+1);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
ll inv(int x){return binpow(x, MOD - 2);}
ll divide(ll x, ll y){return mul(x, inv(y));}
ll fact[N];
void precalc(){fact[0] = 1;for(ll i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
ll C(ll n, ll k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================
VI adj[200005];
int vis[200005];
int tot=0;
void dfs(int node)
{
    tot++;
    vis[node]=1;
    for (auto x : adj[node])
    {
        if (vis[x]==0)
        {
            dfs(x);
        }
    }
}

int main() {
//#ifdef _DEBUG
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
IOS;
int n,m;
cin>>n>>m;
int maxa=0;
while (m--)
{
    int u,v;
    cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
}
rep(i,1,n+1)
{
    if (vis[i]==0)
    {   dfs(i);
        maxa=max(tot,maxa);
        tot=0;
    }
}
cout<<maxa<<endl;
}


Measured memory_bytes: 21544
#include <stdio.h>

int main(void) {
    int n;
 
    scanf("%d", &n);
    while (n--){
        int y, m, d;
        int cntdays = 0;
 
        scanf("%d %d %d", &y, &m, &d);
        
        for(d=d;d!=1;d++){
            if(y%3 == 0 && d<20)
                cntdays++;
            else if(m%2 == 1 && d<20)
                cntdays++;
            else if (d<19)
                cntdays++;
            else{
                d = 0;
                cntdays++;
                m++;
            }
        }
        
        for(m=m;m!=1;m++){
        	if(m>10){
        	    m=0;
        	    y++;
        	}
        	else if(y%3 == 0)
        	    cntdays+=20;
         	else if(m%2 == 1)
        	    cntdays+=20;
        	else
        	    cntdays+=19;
        }
        
        for(y=y;y!=1000;y++){
        	if(y%3 == 0)
        	    cntdays += 200;
        	else
        	    cntdays += 195;
        }
    
    printf("%d\n", cntdays);
    
    }
    
return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, r;
    string m;
    while (true) {
        cin >> a >> m >> b;
        if (m == "?") {
            break;
        } else if (m == "+") {
            r = a + b;
        } else if (m == "-") {
            r = a - b;
        } else if (m == "*") {
            r = a * b;
        } else if (m == "/") {
            r = a / b;
        }
        cout << r << endl;
    }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;
ll n ;
vector<ll> c(0);
vector<ll> mem;
vector<vector<ll>> place(200001,vector<ll>(0));

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

tuple<ll,ll,ll,ll,ll,ll> bamboocomb(ll x, vector<ll> length_list, ll number_of_bamboo){
    ll fa = 0,fb = 0,fc = 0;
    ll noca = -1, nocb = -1, nocc = -1;
    bitset<16> bx(x);
    for(ll i=0;i<number_of_bamboo;i++){
        if(bx.test(2*i)){
            if(bx.test(2*i+1)){
                fc += length_list.at(i);
                nocc++;
            }else{
                fa += length_list.at(i);
                noca++;
            }
        }else{
            if(bx.test(2*i+1)){
                fb += length_list.at(i);
                nocb++;
            }
        }
    }
    return make_tuple(fa,fb,fc,noca,nocb,nocc);
}

int main(){
    ll n,a,b,c; cin >> n >> a >> b >> c;
    vector<ll> l(n);
    rep(i,n) cin >> l.at(i);

    //採用しない->00,aの竹に採用->01,bの竹に採用->10,cの竹に採用->11

    ll ans = INF;

    for(ll i=0;i<(1<<(2*n));i++){
        tuple<ll,ll,ll,ll,ll,ll> candidate = bamboocomb(i,l,n);
        if(get<0>(candidate) * get<1>(candidate) * get<2>(candidate) == 0) continue;
        ans = min(ans,10*get<3>(candidate)+abs(get<0>(candidate) - a) + 10*get<4>(candidate)+abs(get<1>(candidate) - b) + 10*get<5>(candidate) + abs(get<2>(candidate) - c));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	ll N,A,B; cin >> N >> A >> B;
	vector<ll> X;
	REP(i,N){
		ll x; cin >> x;
		X.PB(x);
	}
	
	ll ans = 0;
	FOR(i,1,N){
		ans += min(A * (X[i] - X[i-1]),B);
	}
	
	PRINTLLD(ans);
	
	
	return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX*2];
  ll cnt[MAX*2]={};
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
  }
  
  ll s=0;
  for(i=0; i<N; i++) {
    s+=cnt[i]*(cnt[i]-1)/2;
  }
  
  for(i=0; i<N; i++) {
    ll t=cnt[a[i]];
    pt(s-t*(t-1)/2+(t-1)*(t-2)/2);
    
    
  }
  
  
  
  
}




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


const int N=1e5+1;

int dist[N];
vector<int>graph[N];
bool visited[N];
int v,e;
vector<int>temp;

void topologicalsort(){
 int indeg[v+1];
 memset(indeg,0,sizeof(indeg));

for(int i=1;i<=v;i++)dist[i]=INT_MIN;

for(int i=1;i<=v;i++){
    for(int j=0;j<graph[i].size();j++){
        indeg[ graph[i][j] ]++;
    }
 }

 queue<int>q;
 for(int i=1;i<=v;i++){
    if(indeg[i]== 0){
        q.push(i);
        dist[i]=0;
    }
 }

 while(!q.empty()){
   int t=q.front();
   visited[t]=true;
   q.pop();
   temp.push_back(t);
   for(int i=0;i<graph[t].size();i++){
      if(!visited [graph[t][i]]){
        indeg[graph[t][i]]--;
        if(indeg[graph[t][i]]==0){
            q.push(graph[t][i]);
        }
      }
    }
 }
}

int main(){

cin>>v>>e;

for(int i=0;i<e;i++){
    int x,y;
    cin>>x>>y;
    graph[x].push_back(y);
}




topologicalsort();

for(int i=0;i<temp.size();i++){
  for(int j=0;j<graph[temp[i]].size();j++){
    if(dist[graph[temp[i]][j]] < dist[temp[i]] +1 ){
         dist[graph[temp[i]][j]]=dist[temp[i]] +1 ;
    }
  }
}

int mx=INT_MIN;
for(int i=1;i<=v;i++){
mx=max(dist[i],mx);
}

cout<<mx<<endl;

return 0;
}


Measured memory_bytes: 7292
from itertools import accumulate
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

cnt0 = [0] * m
cnt1 = [0] * m
for i in range(n-1):
    cnt0[a[i+1]] += (a[i+1] - a[i]) % m - 1
    if (a[i] + 1) % m <= a[i+1]:
        cnt1[(a[i]+1) % m] += 1
        cnt1[a[i+1]] -= 1
    else:
        cnt1[(a[i]+1) % m] += 1
        cnt1[0] += 1
        cnt1[a[i+1]] -= 1
cnt1 = list(accumulate(cnt1))
diff = list(accumulate([0] + [cnt0[i] - cnt1[i] for i in range(m-1)]))
ans = min(diff)
for i in range(n-1):
    ans += min((a[i+1] - a[i]) % m, a[i+1] + 1)
print(ans)



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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  */

const int inf = 1LL<<60;

int n;
V<int> es[151010];
double dp[151010];
double ans[151010];

void dfs(int v, int p){
  double sum = 0;
  int k = 0;
  for(auto to : es[v]){
    if(to == p) continue;
    dfs(to, v);
    sum += dp[to]+1.0;
    k++;
  }

  if(k) dp[v] += sum/k;
}

double dfs2(int v, int p, double d_p){
  double sum = 0;
  for(auto to : es[v]){
    if(to == p){
      sum += d_p + 1.0;
    }else{
      sum += dp[to] + 1.0;
    }
  }

  int k = sz(es[v]);
  ans[v] = sum/k;

  for(auto to : es[v]){
    if(to == p) continue;
    dfs2(to, v, (sum-dp[to]-1.0)/max(1LL, k-1));
  }
}

signed main() {
  cin >> n;
  rep(i, 0, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }

  dfs(0, -1);
  dfs2(0, -1, 0);
  rep(i, 0, n){
    printf("%.12f\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
signed main() {
    for(int i = 0; i < 5; i++) {
        int A;
        cin >> A;
        if(A == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;


const double EPS = 1e-7;
const double PI = acos(-1.0);

struct PT {
  ll x, y;
  int id;
  PT() {}
  PT(ll x_, ll y_): x(x_), y(y_), id(-1) {}
  ll len2() const {
    return x * x + y * y;
  }
  double len() const {
    return sqrt(len2());
  }
  PT operator - (const PT &b) const {
    return PT(x - b.x, y - b.y);
  }
  ll operator * (const PT &b) const {
    return x * b.x + y * b.y;
  }
  ll operator % (const PT &b) const {
    return x * b.y - y * b.x;
  }
  bool operator < (const PT &b) const {
    return tie(x, y) < tie(b.x, b.y);
  }
};

const int MAXN = 123;
PT in[MAXN];
double ans[MAXN];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    in[i].x = x;
    in[i].y = y;
    in[i].id = i;
  }
  sort(in, in + N);
  vector<PT> st;
  for (int i = 0; i < N; i++) {
    while (SZ(st) >= 2 && (st[SZ(st) - 1] - st[SZ(st) - 2]) % (in[i] - st[SZ(st) - 1]) < 0)
      st.pop_back();
    st.PB(in[i]);
  }
  for (int i = N - 2; i >= 0; i--) {
    while (SZ(st) >= 2 && (st[SZ(st) - 1] - st[SZ(st) - 2]) % (in[i] - st[SZ(st) - 1]) < 0)
      st.pop_back();
    st.PB(in[i]);
  }
  for (int i = 0; i < N; i++)
    ans[i] = 0;
  st.PB(st[1]);
  for (int i = 1; i < SZ(st) - 1; i++) {
    PT A = st[i - 1] - st[i];
    PT B = st[i + 1] - st[i];
    double tmp = A * B / (A.len() * B.len());
    //double ang = PI - acos(clamp(tmp, -1.0, 1.0)); // C++ 17 required
    double ang = PI - acos(min(max(tmp, -1.0), 1.0));
    ans[st[i].id] = ang / (2 * PI);
  }
  for (int i = 0; i < N; i++)
    printf("%.10f\n", ans[i]);
  double sum = 0;
  for (int i = 0; i < N; i++)
    sum += ans[i];
  //assert(fabs(sum - 1.0) < EPS);
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll mod(ll val, ll m) {
    ll res = val % m;
    if (res < 0) res += m;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >>K;
    vint L(N), R(N);
    rep(i, N) cin >> L[i] >> R[i];
    vll dp1(N + 1), dp2(N + 1);
    dp1[0] = 1;
    dp2[1] = 1;
    ll p = 998244353;

    REP(i, 1, N) {
        rep(k, K) {
            int E = i - L[k];
            int S = max(0, i - R[k]);
            if (S < 0 || E < 0) continue;

            dp1[i] += dp2[E + 1] - dp2[S];
            dp1[i] = mod(dp1[i], p);
        }
        dp2[i + 1] = dp2[i] + dp1[i];
        dp2[i + 1] %= p;
    }


    cout << dp1[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
int a[200010];

int main (int argc, char const* argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i] -= i;
	}
	sort(a, a+n);
	int med = a[(n - 1) >> 1];
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		ans += abs(a[i] - med);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
a,b,c,d=map(int,input().split());x=range(c+d);D=[[0]*6011for _ in[0]*6011];D[a][b]=1
for i in x:
 for j in x:D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%998244353
print(D[c][d])

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

int main()
{
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for (int i = 0; i < K; i++)
  {
    sum+=vec.at(i);
  }
  cout << sum;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here

    int N,count=-1,x;
    cin >> N;
    vector<int> num(N);
    for(int i=1;i<N;i++){
        cin >> x; 
        num.at(x-1)++;
    }
    
    for(int i=0;i<N;i++){
        cout << num.at(i) << endl;
    }

}

Measured memory_bytes: 4048
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
}

Measured memory_bytes: 28880
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {
	int a = -1;
	int b = -1;

	cin >> a >> b;

	while (a != -1) {
		for (int i = 1; i <= 7; i++) {
			if (a + b < pow(10, i)) {
				cout << i << endl;
				break;
			}
		}

		a = -1;
		cin >> a >> b;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    while(t--){
    
        double arr[5];
        int brr[5];
        for(int i=0;i<5;i++){
            cin>>arr[i];
        }
        for(int i=0;i<5;i++){
            brr[i]=ceil(arr[i]/10)*10-arr[i];
        }
        sort(brr,brr+5);
        for(int i=0;i<10;i++){
            for(int j=0;j<5;j++){
                if(i==brr[j]){
                    sum=ceil((sum+arr[j])/10)*10;
                }
            }
        }
        cout<<sum-brr[4];
    }
}
    

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

public class Main {

	class Point {
		long x, y;

		public Point(long x, long y) {
			super();
			this.x = x;
			this.y = y;
		}
		
	}
	
	long vm(Point a, Point b, Point c) {
		return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
	}
	
	void solve() {
		int mod = 998244353;
		int n = in.nextInt();
		Point[] a=  new Point[n];
		for (int i = 0; i < n; i++) {
			a[i] = new Point(in.nextLong(), in.nextLong());
		}
		long[] pow2 = new long[n + 1];
		pow2[0] = 1;
		for (int i = 0; i < n; i++) {
			pow2[i + 1] = pow2[i] * 2 % mod;
		}
		long result = pow2[n] - 1;
		for (int i = 0; i < n; i++) {
			result--;
			for (int j = i + 1; j < n; j++) {
				int cnt = 0;
				for (int k = j + 1; k < n; k++) {
					if (vm(a[i], a[j], a[k]) == 0) {
						cnt++;
					}
				}
				result -= pow2[cnt];
			}
		}
		out.println((result % mod + mod) % mod);
		
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)

int main(){
    int N;
    cin >> N;
    vector<int> x(N+1);
    rep(i,N) cin >> x[i];
    x[N] = 2020;
    
    int M;
    cin >> M;
    int a;
    rep(i,M){
        cin >> a;
        if(x[a] > x[a-1] + 1) x[a-1] = min(x[a-1] + 1, 2019);
    }
    
    rep(i,N) cout << x[i] << endl;
    
    
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli; 

int main()
{
   // ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    lli n,temp1,temp2,t,x,y,m,k,b,temp,q,d,p;
    t=1;
    
    while(t--)
    {
	cin>>n;
	/*for(int i =13;i>=2;i--)
	{
		if(n==pow(26,i))
		{
			cout<<"y";
			for(int j=0;j<i-1;j++)
			{
				cout<<"z";
			}
			cout<<endl;
			return 0;
		}
		
	}*/
//	cout<<n<<endl;
	lli hash[14]={0};
	lli ans=0;
	
	for(int i =13;i>=0;i--)
	{
		ans=0;
		for(int j=0;j<i;j++)
		{
			ans+=26*pow(26,j);
		}
		//cout<<"For i = "<<i<<endl;
		//cout<<"ans is "<<ans<<endl;
	
		if( n>ans)
		{
				lli mn=1e9;
			for(int k=1;k<=26;k++)
			{
				if(n- k*pow(26,i) <=ans)
				{
					mn=k;
					break;
				}
			}
		//	cout<<"MN is "<<mn<<endl<<"ans is "<<ans<<endl;
			hash[i]=mn;
			n=n-  pow(26,i)* mn;
		}
		//cout<<"N is "<<n<<endl;
	}
	/*for(int i =13;i>=0;i--)
	{
		cout<<hash[i]<<" ";
	}
	cout<<endl;*/
	for(int i =13;i>=0;i--)
	{
		if(hash[i]!=0)
		{
			cout<<char('a'+hash[i]-1);
		}
	}
	cout<<endl;
	}
	
}

	
	



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

vector<vector<int>> g;
vector<int> f,d;
vector<bool> seen;
int tim = 1;

void dfs(int now){
  seen[now] = true;
  d[now] = tim;
  tim++;
  
  for(int next: g[now]){
    if(seen[next]){
      continue;
    }
    dfs(next);
  }
  f[now] = tim;
  tim++;
}

int main(){
  int n;
  cin >> n;
  g = vector<vector<int>>(n);
  f = d = vector<int>(n);
  seen = vector<bool>(n,false);

  for (int i = 0; i < n; i++)
  {
    int u,k;
    cin >> u >> k;
    for (int j = 0; j < k; j++)
    {
      int v;
      cin >> v;
      g[i].push_back(v-1);
    }
  }

  for (int i = 0; i < n; i++)
  {
    if(!seen[i]) dfs(i);
  }
  for (int i = 0; i < n; i++)
  {
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }  
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> cnt(n+1,vector<int> (3,0));
  int lens = s.size();
  int cr = 0;
  int cg = 0;
  int cb = 0;
  if( s[0] == 'R' ) cr = 1;
  if( s[0] == 'G' ) cg = 1;
  if( s[0] == 'B' ) cb = 1;

  for (int i = 1; i < lens; i++ ) {
      cnt[i][0] = cr;
      cnt[i][1] = cg;
      cnt[i][2] = cb;
      if( s[i] == 'R' ) cr++;
      if( s[i] == 'G' ) cg++;
      if( s[i] == 'B' ) cb++;
  }
  ll ret = 0;
  for (int i = 3 ; i < lens ; i++ ){
    if( s[i] == 'R' ){
      for(int j = i-1 ; j > 0 ; j-- ) if( s[j] != s[i] ) {
        if( s[j] == 'G' ){
          ret += cnt[j][2];//cnt of B
          if( j - i + j >= 0 && s[j - i + j] == 'B' ) ret--;
        }
        if( s[j] == 'B' ){
          ret += cnt[j][1];//cnt of G
          if( j - i + j >= 0 && s[j - i + j] == 'G' ) ret--;
        }
      }
    }
    if( s[i] == 'G' ){
      for(int j = i-1 ; j > 0 ; j-- ) if( s[j] != s[i] ) {
        if( s[j] == 'R' ){
          ret += cnt[j][2];//cnt of B
          if( j - i + j >= 0 && s[j - i + j] == 'B' ) ret--;
        }
        if( s[j] == 'B' ){
          ret += cnt[j][0];//cnt of R
          if( j - i + j >= 0 && s[j - i + j] == 'R' ) ret--;
        }
      }
    }
    if( s[i] == 'B' ){
      for(int j = i-1 ; j > 0 ; j-- ) if( s[j] != s[i] ) {
        if( s[j] == 'R' ){
          ret += cnt[j][1];//cnt of G 
          if( j - i + j >= 0 && s[j - i + j] == 'G' ) ret--; // G R B
        }
        if( s[j] == 'G' ){
          ret += cnt[j][0];//cnt of R
          if( j - i + j >= 0 && s[j - i + j] == 'R' ) ret--; // R G B
        }
      }
    }

  }
  cout << ret << endl;

  return 0;

}



Measured memory_bytes: 3352
#include <cstdio>
using namespace std;
int n, a, b, c;
int main() {
	scanf("%d", &n);
	while (n --> 0) {
		scanf("%d%d%d", &a, &b, &c);
		if (a < b + c || ((a & 1) != (b + c & 1))) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}
int main() {
    int N;
    cin >> N;
    vi p = vi(N);

    rep(i,N){
        cin >> p[i];
    }
    int ans =0;

    REP(i,1,N-1){
        if(p[i-1] == p[i+1]){
            if (p[i-1] < p[i]){
                ans++;
            }
        }else if (p[i-1]>p[i+1]){
            if(p[i-1]>=p[i] && p[i]>p[i+1]){
                ans++;
            }
        }else if (p[i-1]<p[i+1]){
            if(p[i+1]>=p[i] && p[i]>p[i-1]){
                ans++;
            }
        }
    }


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

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

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  vector<int> acc(N);
  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    acc[p - 1] += x;
  }
  function<void(int, int)> dfs = [&](int pre, int u) {
    for (int v : G[u])
      if (pre != v) {
        acc[v] += acc[u];
        dfs(u, v);
      }
  };
  dfs(-1, 0);
  for (int i = 0; i < N; ++i) cout << acc[i] << (i == N - 1 ? "\n" : " ");
  return 0;
}

Measured memory_bytes: 29696
main :: IO ()
main = do
  brgcst <- getLine
  if brgcst == "0 0 0 0 0 0"
    then return ()
    else do
      let ls = map read . words $ brgcst
      print $ solve ls
      main

solve :: [Int] -> Int
solve [b,r,g,c,s,t] = b * (15 * 6 - 2 * 5) +
                      r * (15 * 4 - 2 * 3) +
                      g * 7 + c * 2 + s * 3 -
                      (t - b * 5 - r * 3) * 3 + 100

Measured memory_bytes: 4028
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 998244353;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
ll n, k, dp[MAX];
void speed_solve(){
    cin >> n >> k;
    ll x[k], y[k];
    rep(i,k) {
        cin >> x[i] >> y[i];
    }
    ll dp[n + 5];
    init(dp, 0);
    dp[n] = 1;
    bace(i, n - 1, 1) {
        rep(j,k) {
            ll cnt = sub(dp[min(i + x[j], n + 1)], dp[min(i + y[j], n + 1) + 1]);
            dp[i] = add(dp[i], cnt);
        }
        dp[i] = add(dp[i], dp[i + 1]);
    }
    ll ans = sub(dp[1], dp[2]);
    cout << ans ;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 5184
n = int(input())
a = []
for _ in range(n):
    a.append(list(map(int,input().split())))

d = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]

d = sorted(d, key = lambda x: x[1])
#print(d)

b = [-100000000000000000]
c = [0]


for i in range(n):
    for j in range(len(b)):
        if d[i][0] >= b[j]:
            b = [d[i][1]]
            c = [c[j] + 1]
            break

    
    #print(b)
    #print(c)

print(max(c))
        
    


Measured memory_bytes: 44592
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n) for(int i=n;i>=0;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	lli n,m;
	string s,t;
	cin>>n>>m;
	cin>>s>>t;
	lli pr=n*m;
	lli gcd=__gcd(n,m);
	lli len=pr/gcd;
	string ans="";
//	FOR0(len) ans.pb('-');
	lli k=len/n;
	lli in=0;
	int np=0;
	int p1=len/m,p2=len/n;
	int in1=0,in2=0;
	while(in1<n&&in2<m){
		if(s[in1]!=t[in2]){
			np=1;break;
		}
		in1+=p1;
		in2+=p2;
	}
//	FOR0(n) {
//		ans[((i)*k)]=s[i];
//	}
//	k=len/m;
//	FOR0(m){
//		if(ans[(i*k)]!='-'&&ans[i*k]!=t[i]){
//			np=1;break;
//		}
//		else{
//			ans[i*k]=t[i];
//		}
//	}
	if(np==1){
		cout<<-1<<endl;return 0;
	}
//	FOR0(len){
//		if(ans[i]=='-') ans[i]='a';
//	}
	cout<<len<<endl;
	return 0;
}


Measured memory_bytes: 640
import math 
MOD = int(1e9)

s = int(input())
if s==1000000000000000000:
    ans = [0,0,MOD,0,0,MOD]
    print(*ans)
    exit()

ans = [0,0,MOD,1]
x,y = 0,0
y = s//MOD + 1
x = MOD - s%MOD
ans.append(x)
ans.append(y)
print(*ans)


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

int main() {
    int N;
    scanf("%d", &N);
    vector<int> ans;
    if (N == 0) ans.push_back(0);
    while (N != 0) {
        if (N % 2 == 0) ans.push_back(0);
        else {
            ans.push_back(1);
            N--;
        }
        N /= -2;
    }
    for (int i = ans.size() - 1; i >= 0; i--) {
        printf("%d", ans[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var s, t string
  var flag bool

  fmt.Scan(&s, &t)

  flag = true

  for i := 0; i < 3; i++ {
    if s[i] != t[2-i] {
      flag = false
      break
    }
  }

  if flag {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}

Measured memory_bytes: 512
h,w = map(int, input().split())
g = []
for i in range(h):
  c = input()
  if '#' not in c:
    continue
  g.append(c)
h = len(g)
memo = []
for i in range(w):
  f = 1
  for j in range(h):
    if g[j][i] == '#':
      f = 0
  if f:
    memo.append(i)
for j in range(h):
  print(''.join([g[j][i] for i in range(w) if i not in memo]))

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

using namespace std;

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

	int n;
	cin >> n;

	vector<double> probability(n);

	for (double& p : probability)
		cin >> p;

	for (auto p : probability)
		cerr << p << " ";
	cerr << endl;

	vector< vector<double> > dp(n + 1, vector<double>(n + 1, 0.0));

	dp[0][0] = 1.0;


	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			if (i - 1 >= 0)
				dp[i][j] += probability[i + j - 1] * dp[i - 1][j];
			if (j - 1 >= 0)
			{
				dp[i][j] += (1.0f - probability[i + j - 1]) * dp[i][j - 1];
			}
		}
	}

	double ans = 0;

	for (int i = 0; i <= n; ++i)
	{
		if (i >= n - i)
			break;

		ans += dp[n - i][i];
	}

	cout << fixed << setprecision(9) << ans;

	return 0;
}

Measured memory_bytes: 70784
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>

using namespace std;
const int maxn = 500005;
int t, n, q, l, r;
int a[maxn], c[maxn];///a[]原数组,c[]树状数组
int ans[maxn];///询问的结果
vector<pair<int, int> > v[maxn];

///树状数组(区间求和)
int lowbit(int x) {
    return x & (-x);
}

void Add(int pos, int val)///单点修改
{
    for (int i = pos; i <= n; i += lowbit(i))
        c[i] += val;
}

int Sum(int pos)///从0位置到pos位置的区间和
{
    int ret = 0;
    for (int i = pos; i > 0; i -= lowbit(i))
        ret += c[i];
    return ret;
}

int main() {
    memset(c, 0, sizeof(c));
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        v[i].clear();
    for (int i = 1; i <= q; i++) {
        scanf("%d%d", &l, &r);
        v[r].push_back(make_pair(l, i));
    }
    unordered_map<int, int> lastpose;
    for (int i = 1; i <= n; i++) {
        if (lastpose[a[i]])
            Add(lastpose[a[i]], -1);
        Add(i, 1);
        lastpose[a[i]] = i;
        for (int j = 0; j < v[i].size(); j++) {
            int L = v[i][j].first;
            int R = i;
            int id = v[i][j].second;
            int sum = Sum(R) - Sum(L - 1);
            ans[id] = sum;
        }
    }
    for (int i = 1; i <= q; i++)
        printf("%d\n", ans[i]);

    return 0;
}

Measured memory_bytes: 50908
using System;
class MyMain
{
    static void Main()
    {
        string[] s = System.Console.ReadLine().Trim().Split(' ');
        long N = long.Parse(s[0]), A = long.Parse(s[1]), B = long.Parse(s[2]),x;
        if (A > B) x = 0;
        else if (N == 1 && A != B) x = 0;
        else if (N == 1 && A == B) x = 1;
        else x = (B - A)*(N - 2) + 1;
        System.Console.WriteLine(x);
        System.Console.ReadLine();
    }
}

Measured memory_bytes: 13140
#include <cstdio>
const int NIL = -1;
struct node {
	int parent;
	int left;
	int right;
};

node nodes[100000];

int depth(int i) {
	int count = 0;
	while (nodes[i].parent != NIL) {
		i = nodes[i].parent;
		count++;
	}
	return count;
}

void type(int i) {
	if (nodes[i].parent == NIL) {
		printf("root");
	} else if (nodes[i].left == NIL) {
		printf("leaf");
	} else {
		printf("internal node");
	}
}

int main()
{
	int n;
	for (int i = 0; i < 100000; ++i) {
		node &p = nodes[i];
		p.parent = NIL;
		p.left = NIL;
		p.right = NIL;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int v, m;
		scanf("%d %d", &v, &m);
		node &r = nodes[v];
		int prev = v;
		for (int j = 0; j < m; ++j) {
			int c;
			scanf("%d", &c);
			node &q = nodes[c];
			q.parent = v;
			if (j == 0) {
				r.left = c;
			} else {
				nodes[prev].right = c;
			}
			prev = c;
		}
	}

	for (int i = 0; i < n; ++i) {
		printf("node %d: parent = %d, depth = %d, ",
				i, nodes[i].parent, depth(i));
		type(i);
		int c = nodes[i].left;
		printf(", [");
		if (c != NIL) {
			int j = 0;
			while(c != NIL) {
				if (j > 0) { printf(", "); }
				printf("%d", c);
				j++;
				c = nodes[c].right;
			}
		}
		printf("]");
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2204
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int ans, s;

void dfs(int begin, int depth, int sum) {
  if(depth == 0){
    if(s == sum){
      ans++;
    }
    return;
  }
  for(int i = begin+1 ; i <= 9 ; i++){
    dfs(i, depth-1, sum+i);
  }
}

int main(){
  int n;
  while(cin >> n >> s){
    if(n == 0 && s == 0) break;
    ans = 0;
    for(int i = 0 ; i <= 9 ; i++){
      dfs(i, n-1, i);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>


int main() {
    std::string s;
    int sum(0);
    
    std::getline(std::cin,s);
    for(int i = 0,size=s.size(); i < size; ++i) sum += s[i] - '0';
    
    if(sum%9 == 0) puts("Yes");
    else puts("No");
    
    return 0;
}


Measured memory_bytes: 3312
using System;

namespace ITP1_5_D
{
    class Program
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            
            for (int i = 3; i <= x; i ++)
            {
                if (i % 3 == 0 || i % 10 == 3 || i % 100 / 10 == 3 || i % 1000 / 100 == 3 || i % 10000 / 1000 == 3)
                {
                    Console.Write(" " + i);
                }
                else continue;
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15948
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(r,n-r)
    if r == 0:
        return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans

n,k = map(int,input().split())
for i in range(1,k+1):
    if n-k+1  < i :
        print(0)
    else:
        print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod) % mod)

Measured memory_bytes: 3940
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	int N; while (cin >> N && N != 0)
	{
		vector<vector<int>> dat(N + 2, vector<int>(0));
		rep(i, N)
		{
			int M = 0; cin >> M;
			rep(j, M)
			{
				int tmp; cin >> tmp;
				dat[i].push_back(tmp);
			}
		}
		int K; cin >> K;
		vector<int> tar(K, 0);
		rep(i, K) { cin >> tar[i]; }
		vector<int> ans(N, 0);
		int cri = 0;
		rep(i, N) rep(j, (int)tar.size())
		{
			int tmp = count(all(dat[i]), tar[j]);
			if (tmp >= 1) { ans[i]++; }
			if (ans[i] == (int)tar.size()) { cri++; }
		}
		if (cri == 1){printf("%d\n", max_element(all(ans)) - ans.begin() + 1); }
		else { printf("-1\n"); }
	}

	return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a[3], k;
  cin>>a[0]>>a[1]>>a[2]>>k;
  sort(a, a + 3);
  int ans = a[0] + a[1];
  for (int i=0; i<k; i++) {
    a[2] *= 2;
  }
  ans += a[2];
  cout<<ans<<endl;
}

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

int main(void) {
    set<char> exist;
    string S;cin>>S;
    for (int i = 0; i < S.size(); i++) {
        char s = S[i];
        if (exist.find(s) != exist.end()) {
            cout << "no" << endl;
            return 0;
        }
        exist.insert(s);
    }
    cout << "yes" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int cnta = 0, cntb = 0, cntc = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'a') cnta++;
        if(s[i] == 'b') cntb++;
        if(s[i] == 'c') cntc++;
    }
    int cntmax = max(cnta, max(cntb, cntc));
    if(cntmax - cnta <= 1 && cntmax - cntb <= 1 && cntmax - cntc <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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



int main(){
    int N,X;
    cin >> N >> X;
    int allkona = 0;
    vector<int> kona(N);
    for(int i=0;i<N;i++){
        cin >> kona.at(i);
        allkona = allkona + kona.at(i);
    }
    sort(kona.begin(),kona.end());
    //reverse(kona.begin(),kona.end());

    int nokori = X - allkona;
    int count = N;
    
    count = count + nokori/kona.at(0);
    
    cout << count << endl;
    
}

Measured memory_bytes: 256
solve [_] = "Yes"
solve (a:b:c) | a < b = solve ((b-1):c)
              | a == b = solve (b:c)
              | otherwise = "No"

main = do
    n <- readLn :: IO Int
    hn <- map read . words <$> getLine :: IO [Int]
    putStrLn $ solve hn


Measured memory_bytes: 34532